Menu icon indicating copy to clipboard operation
Menu copied to clipboard

Handle multi-monitor setups better

Open probonopd opened this issue 5 years ago • 11 comments

Traditionally, the Mac has shown he menu bar only on the main display. Recent versions seem to show the same menu bar on all desktops.

probonopd avatar Jan 01 '21 20:01 probonopd

Possibly this could be achieved by setting

KWindowSystem::setOnDesktop(winId(), NET::OnAllDesktops);

Or not. The Dock has this but it also shows only on one desktop.

probonopd avatar Jan 23 '21 21:01 probonopd

Was just about to open an issue for this but i guess it's better to keep it in one place. Currently menu bar always displays on the first screen from the left to the right. Initially I tought it should only display on the main screen that's set by the user but displaying it on both screens would be really useful because of the context menus. 1613151826

Do we want to have it on both screens? I might look into this more as I use multimonitor very often.

PreyK avatar Feb 12 '21 17:02 PreyK

Also might be related: https://github.com/helloSystem/Menu/issues/52

PreyK avatar Feb 12 '21 18:02 PreyK

On the screenshot, it appears like the width for the menu bar is calculated for the smaller of your screens and then applied to the larger of the screens.

This is clearly a bug in Menu.

(We want to have the Menu on the main screen, and we want the user to be able to select what the main screen is. Optionally, we possibly want one Menu instance per screen, which seems to be possible in very new versions of macOS but never was the case in the Classic ones. Ideally we can do away with arandr and use a tool in our native toolkit, Qt, instead)

probonopd avatar Feb 12 '21 19:02 probonopd

Just looked into this, made some improvements:

The menu now opens on the main screen selected by the user. 1613250702

The menu automatically sets the correct width for the correct screen. (the bug in my previous screenshot no longer exists) 1613252073

https://github.com/helloSystem/Menu/issues/52 is also fixed 1613250892

Just opened a PR for this https://github.com/helloSystem/Menu/pull/55 What's still missing is a way to detect when the user changes the main screen but I haven't found a good way to do it in Qt. Orientation, position, and scaling changes should be automatic. Maybe there's a good way to do it via arandr but not sure yet if it stays because of https://github.com/helloSystem/Utilities/issues/41 Maybe in the future

PreyK avatar Feb 13 '21 21:02 PreyK

Thanks a ton @PreyK. The next ISO build should have the improvement.

Do we want to have it on both screens? I might look into this more as I use multimonitor very often.

If yes, then it should be optional, e.g., only have it on both screens if a certain environment variable is set.

probonopd avatar Feb 13 '21 22:02 probonopd

Sounds great @probonopd, can't wait to try it! Might take a look at the Dock too for some multimonitor improvements. Currently, It doesn't take the primary display into account. If it's the same-ish solution it should be pretty trivial but would improve the multi-monitor experience by a lot.

If yes, then it should be optional, e.g., only have it on both screens if a certain environment variable is set.

Possibly set from the screen settings application in like a checkbox? mock_sc

PreyK avatar Feb 14 '21 01:02 PreyK

Yes, this would be the natural place to put a checkbox. But before you spend time at the GUI please keep in mind that we want to replace that Gtk based legacy GUI with something native (Qt or PyQt) anyway. Hence I had suggested a simple environment variable for now - it should be easy to hook some GUI up later.

probonopd avatar Feb 14 '21 09:02 probonopd

@grahamperrin can you please re-test with the latest ISO and let us know whether we can close this ticket, thanks.

probonopd avatar Feb 14 '21 09:02 probonopd

@probonopd Of course, it was just a quick mockup

Also, I tested the new ISO and found some issues. The menu now draws on the correct display when it's set but it doesn't block window maximization when it's not on the first screen from left to right. (it works properly when using only one display or when the primary display is the first display on the left)

Video IMAGE ALT TEXT HERE

This happens because after we create the menu, we reserve an area for the menu through KWindowSystem from here: https://github.com/helloSystem/Menu/blob/cea947363a3f65e4d4ea2cf6b4d4f29ae53594a3/src/mainwindow.cpp#L143 It's essentially just saying to KWin that this is our place, not a usable place for app windows.

In theory, we'd just have to extend the above code to take the primary display dimensions into account. However, I haven't managed to make it work properly (the documentation on KWin is not the best IMO) because:

A) the reserved area gets stretched through the other display thus limiting the usable space when the main is our second display and their tops are not completely aligned

B) Can't quite grasp the documentation of how the reserved area gets defined, it kind of works but not really. https://api.kde.org/frameworks/kwindowsystem/html/classKWindowSystem.html#a669469a6738ccb8642a1c57c4ce08227 https://api.kde.org/frameworks/kwindowsystem/html/classKWindowSystem.html#af83b6d1db5390b191b5b9b0c061a1e03

We'd need to define the reserved area correctly

Or

Find a way to REALLY reserve a space for the menu because even though we reserve an area it doesn't have any effect when dragging windows. We shouldn't be able to drag windows under the menu (And I don't know why we can, we've already told KWin no) but currently, we can. If we find a fix for this we could possibly use it to block maximization also? Video IMAGE ALT TEXT HERE

PreyK avatar Feb 16 '21 15:02 PreyK

Thanks for your investigation @PreyK.

probonopd avatar Feb 16 '21 20:02 probonopd