x11: use the full screen size for the screen frame, not _NET_WORKAREA - #217
x11: use the full screen size for the screen frame, not _NET_WORKAREA#217probonopd wants to merge 1 commit into
Conversation
The X11 backend used _NET_WORKAREA as the monitor/screen frame on single-monitor setups. But the window Y-flip in _OSFrameToXFrame is done against the full screen height, so when the work area is shorter than the screen (panels/struts reserving part of it) every window positioned at the top of the screen ends up shifted down by that difference. A screen frame in the AppKit/OpenStep model is the whole display; the usable area after panels and struts is a separate concept applications query on their own. Drop the _NET_WORKAREA override so the screen frame uses the full output size, consistent with the Y-flip, and remove the now unused _workAreas helper.
|
@rfm added this code few months ago, so he should have the say on whether we drop this again. Either way is fine with me. |
|
As I recall, the current code was written to make the tops of menus available so allow them to be moved and the first menu item selected reliably, and achieved that objective. Before the last lot of changes, the top part of our menus would be hidden behind the top bar controlled by many window managers. However, it's hardly surprising if there are bugs: it was a quick/simple fix. The problem I have here is with this sentence:
The current model is precisely because my understanding was that an OpenStep/AppKit display is the usable display, because apps expect to be able to draw anywhere on screen, and that when OpenStep was designed for display postscript, there were no window managers, no struts, and no difference between the physical screen and the usable screen. I'm happy to be educated otherwise, but what are the AppKit/gnustep-gui methods used by apps to to query panels and struts, and where can I see examples of Apple and GNUstep app source using those methods to position windows/menus? |
|
Hi @rfm, thanks for your quick response. Obviously my experience with GNUstep is not as deep as yours, but here are my thoughts: AppKit distinguishes between the physical display ( I agree the current work-area code was a reasonable quick fix to keep menus reachable below the WM's top bar. My concern is narrower: it is internally inconsistent. The screen frame ( That inconsistency bites either way:
I'd suggest we fix the consistency (whichever direction) rather than leave the flip and the frame disagreeing. The alternative direction (keep the work-area frame but flip against the same height) has the same side effect of moving top-positioned windows, while keeping For the Gershwin |
|
I wouldn't claim to be deeply experienced with the gui/backend as I don't write gui apps and hardly ever touch it, and I don't actually know why I'm not seeing any issues if _OSFrameToXFrame if getting things wrong, but I'm perfectly prepared to accept there is a bug there. I also don't understand why you want to draw at the top of the physical screen when the window manager is going to ensure that its own topbar, another window outside of GNUstep control, will hide anything you draw. My understanding is that there are at least three areas to consider: Now, what I did with _NET_WORKAREA was to try to conflate the physical area with the usable area, on the theory that if the GNUstep app can never display outside the usable area, then the usable area corresponds to the NSScreen rect as far as the GNUstep app is concerned. Maybe that's wrong, and the NSScreen rect should correspond to the physical display, but if so, the GUI drawing code needs to understand the distinction between the physical screen rectangle and the usable screen rectangle somehow, so that it doesn't try to position the main menu, menubar etc outside of the usable part of the display (which is what was previously happening). So unless I'm missing something, I think we can either: Drop the workarea adjustment so that the screen rectangle is the physical size as reported by X, but at the same time keep the workarea code to find the usable screen rectangle, pass the usable rectangle back to the GUI. Add a new internal method to find the usable rectangle, adjust the -visibleFrame method to incorporate the usable rectangle, and adjust the menu code to use the usable rectangle information to ensure that main menus/menubars are appropriately constrained to be within the usable area of the screen. or We can have the NSScreen rectangle report the usable (to the GNUstep app) area of the physical screen, and fix any errors in the OpenStep<->X coordinate mapping resulting from that. Does that make sense? |
|
I think this is a design/policy thing that Fred should decide on: I can see arguments either for both ways (I was lazy and chose the option that looked like least work). However, as far as I can see this PR on its own just breaks placement of menus and windows when used with the current main window managers: it would need to be coupled with all the changes to get menu placement and the -visibleFrame calculation correct. |
|
Hi @rfm, @fredkiefer, As I understand it, the underlying issue is that There seem to be two consistent ways to fix this: Option (a):
|
|
I think to do this we would need to:
The main menu in turn could ask NSScreen for visibleFrame, and position itself by its own height above it, because it knows that vusibleFrame has already taken it's height into account. When changing themes we would need to be careful to change main menu height first, then get NSScreen to update, then reposition menus if necessary. |
|
Some measurements on this, all with a single monitor. The work area is only applied when the server reports exactly one RandR Where the override does apply, the shift is real. With 40 rows reserved, a 60 Separately, _workAreas sets origin.y to zero instead of flipping it, so a #226 corrects both of those inside the current model. It does not settle |
The X11 backend used
_NET_WORKAREAas the monitor/screen frame on single-monitor setups. But the window Y-flip in_OSFrameToXFrameis done against the full screen height, so when the work area is shorter than the screen (because panels/struts reserve part of it) every window positioned at the top of the screen ends up shifted down by that difference.A concrete symptom: a full-width menu bar / top panel requested at y = 0 lands several pixels below the upper screen border. (I ran into this when I made an AppImage for Gershwin Desktop's Menu.app and ran this on a Ubuntu 22.04 KDE neon 6.0 Live ISO. With the patch applied, it works correctly.)
Suggested change: A screen frame in the AppKit/OpenStep model is the whole display; the usable area left after panels and struts is a separate concept applications query on their own. This drops the
_NET_WORKAREAoverride so the screen frame uses the full output size, consistent with the Y-flip in_OSFrameToXFrame, and removes the now-unused_workAreashelper.References:
cc @pkgdemon