labwc/include
John Lindgren 3be8fe25f3 xdg: handle initially maximized xdg-shell views better
Currently, initially maximized (or fullscreen) xdg-shell views exhibit
one of two issues:

 - some (e.g. GTK and Qt apps) paint an initial frame un-maximized
   (before the "map" event) and only maximize in a later commit

 - others (e.g. foot) maximize immediately without flicker, but never
   store a valid natural size, so we end up using a fallback (640x480)

Under KWin, neither of these issues occur, so I looked into what labwc
is doing wrong. It seems that:

 - wlroots internally sends an initial configure event with a size of
   0x0 to all xdg-shell views. This requests the client to set its own
   preferred (a.k.a. natural) size.

 - For an initially maximized/fullscreen view, the initial configure
   event should contain the maximized/fullscreen size rather than 0x0.
   In labwc, this means we have to call wlr_xdg_toplevel_set_size()
   earlier, i.e. from the new_surface event. Tracing with WAYLAND_DEBUG
   shows that the initial configure event now has the correct geometry,
   matching KWin behavior. With this change, GTK and Qt apps no longer
   paint an incorrect un-maximized frame.

 - However, this means that all xdg-shell views now suffer from the same
   issue as foot, where we never receive a commit with the un-maximized
   (natural) geometry. The correct way to get the natural geometry seems
   to be to wait until we want to un-maximize, and send a configure
   event of 0x0 at that point.

Sending a configure event of 0x0 when un-maximizing is a bit annoying as
it breaks some assumptions in labwc code. In particular:

 - view->natural_geometry may now be unknown (0x0), requiring various
   wlr_box_empty() checks sprinkled around. I added these in all the
   obvious places, but there could be some code paths that I missed.

 - Positioning the newly un-maximized view within view_maximize() no
   longer works since we don't know the natural size. Instead we have to
   run the positioning logic from the surface commit handler. This
   results in some extra complexity, especially for interactive move.
   See the new do_late_positioning() function in xdg.c.

Some TODOs/FIXMEs (non-blocking in my opinion):

 - The view_wants_decorations() check is now duplicated in both the
   new_surface and map event handlers. I'm not sure if this is necessary
   but it seemed like the safest approach for now. More testing would be
   nice, particularly with various combinations of config and client SSD
   preferences.

 - Aside from the interactive move case, the "late positioning" logic
   always centers the view when un-maximizing, and does not invoke any
   of the smart placement logic. If we want to invoke smart placement
   here, I'd appreciate someone with more knowledge of that code to take
   a look and figure out how to do that correctly.
2024-07-19 22:48:39 +01:00
..
button Fix some header includes detected by clangd 2024-04-21 21:58:57 +02:00
common magnifier: fix flickering on simultaneous gamma changes 2024-06-29 23:36:41 +02:00
config config: add configuration for tablet tool motion sensitivity 2024-07-19 22:45:41 +01:00
input config: add configuration for tablet tool motion 2024-07-19 22:45:41 +01:00
menu menu: support pipe menus 2024-03-24 21:44:16 +00:00
action.h Fix some header includes detected by clangd 2024-04-21 21:58:57 +02:00
buffer.h includes: identifier consistency in include guards 2023-05-13 22:29:21 +01:00
debug.h includes: identifier consistency in include guards 2023-05-13 22:29:21 +01:00
decorations.h includes: identifier consistency in include guards 2023-05-13 22:29:21 +01:00
dnd.h chase (dnd): refactor to use wlroot's scene_drag_icon 2023-12-03 18:24:26 +00:00
edges.h snap: cache and ignore last-snapped edge when growing or shrinking 2024-04-10 23:30:28 +01:00
idle.h Add support for ext_idle_notify_v1.. 2023-07-09 08:26:33 +01:00
labwc.h xdg: handle initially maximized xdg-shell views better 2024-07-19 22:48:39 +01:00
layers.h xdg: support xdg-shell v3 with popup repositioning 2024-07-01 20:16:31 +01:00
magnifier.h magnifier: minor refactor 2024-05-16 11:33:53 +02:00
meson.build Make xwayland support optional 2020-12-30 10:29:21 +00:00
node.h session-lock: allow client to update cursor shape 2024-05-31 11:21:29 +09:00
osd.h osd: add window-switcher custom field (#1670) 2024-04-10 23:39:31 +01:00
output-state.h chase: output->pending 2024-07-17 21:28:59 +01:00
output-virtual.h Add optional headless fallback output 2024-03-08 13:54:13 +01:00
overlay.h overlay: allow to draw both/either of filled/outlined rectangle 2024-04-22 19:22:23 +01:00
placement.h view: honor automatic placement when adjusting floating geometry 2023-12-30 16:50:09 +00:00
regions.h overlay: add snap-to-edge overlay (PR #1652) 2024-04-05 04:35:31 +02:00
resistance.h includes: identifier consistency in include guards 2023-05-13 22:29:21 +01:00
resize-indicator.h Replace _ with - in source file names 2024-05-22 07:10:51 +01:00
resize-outlines.h Implement <resize><drawContents> 2024-06-15 21:17:01 +01:00
session-lock.h session-lock: restore focused view on unlock 2024-07-07 15:48:32 +09:00
snap-constraints.h snap: cache and ignore last-snapped edge when growing or shrinking 2024-04-10 23:30:28 +01:00
snap.h snap: cache and ignore last-snapped edge when growing or shrinking 2024-04-10 23:30:28 +01:00
ssd-internal.h ssd: show squared corners when the view is tiled 2024-06-27 22:29:11 +01:00
ssd.h Add All context for mouse events 2024-05-19 22:17:04 +01:00
theme.h Add screen magnifier 2024-05-16 00:07:23 +02:00
view-impl-common.h view: commonize sub-view logic in view_move_to_front/back() 2023-10-21 15:40:56 +01:00
view.h xdg: handle initially maximized xdg-shell views better 2024-07-19 22:48:39 +01:00
window-rules.h wayland: add support for security-context-v1 2024-05-29 22:28:06 +01:00
workspaces.h workspaces: react to Reconfigure 2024-04-22 05:44:52 +09:00
xwayland.h xwayland: set initial geometry in map_request handler 2024-07-19 22:40:43 +01:00