GNOME Bugzilla – Bug 755051
Windows revert to previous size after being resized using gtk_window_resize() on Wayland
Last modified: 2015-12-16 18:22:55 UTC
Created attachment 311344 [details] test program After being resized using gtk_window_resize(), windows revert to its previous size upon losing focus. This doesn't happen when using X11 backend or manually resizing the window. Steps to reproduce: 1. Start the attached test program and any other application. 2. Resize the test program's window using gtk_window_resize() by clicking on the resize button. The test program's window should grow larger. 3. Give focus to the other application's window by clicking on it. 4. Observe the window of the test program shrink back to its previous size.
Looks like a mutter issue to me, the spurious resize does not happen in weston.
The code is correct, from what I can tell. Hints for anybody else wanting to debug this: when focusing and unfocusing a window, we configure the surface with last_sent_width / height. That's set here: https://git.gnome.org/browse/mutter/tree/src/wayland/meta-window-wayland.c#n159 When the client does gdk_window_resize, then that function should be called with META_MOVE_RESIZE_WAYLAND_RESIZE in flags (coming from meta_window_wayland_move_resize, then toplevel_surface_commit). Double-check that that path is being called, and that last_sent_width / height are being set correctly.
(In reply to Jasper St. Pierre from comment #2) > The code is correct, from what I can tell. Hints for anybody else wanting to > debug this: when focusing and unfocusing a window, we configure the surface > with last_sent_width / height. That's set here: > https://git.gnome.org/browse/mutter/tree/src/wayland/meta-window-wayland. > c#n159 > > When the client does gdk_window_resize, then that function should be called > with META_MOVE_RESIZE_WAYLAND_RESIZE in flags (coming from > meta_window_wayland_move_resize, then toplevel_surface_commit). > > Double-check that that path is being called, and that last_sent_width / > height are being set correctly. What I observed is this: meta_window_wayland_move_resize_internal() is called once when the window invokes gtk_window_resize() and also when the focus changes. In both cases, the flags contains flags=META_MOVE_RESIZE_WAYLAND_RESIZE. When the window resize itself with gtk_window_resize(), toplevel_surface_commit() at wayland/meta-wayland-surface.c:382 is called with a MetaWaylandPendingState which contains the new larger size as expected. But on later focus change, toplevel_surface_commit() gets called with a MetaWaylandPendingState which contains the old size, thus reverting to the old, original smaller size.
What happens in the middle is that mutter sends a configure event to the client for the smaller size. That second toplevel_surface_commit() simply has the client ack the smaller size. We send the configure event from surface_state_changed, which uses last_sent_width / height here: https://git.gnome.org/browse/mutter/tree/src/wayland/meta-window-wayland.c#n128 This is why I wanted you to pin down those values.
(In reply to Jasper St. Pierre from comment #4) > This is why I wanted you to pin down those values. last_sent_width/last_sent_height is set solely in meta_window_wayland_move_resize_internal() and this is not called when the client resizes its window, so the old values remain in effect and get reused in surface_state_changed().
Hm, really? When the client changes its size, we should get here with a new geometry: https://git.gnome.org/browse/mutter/tree/src/wayland/meta-wayland-surface.c#n408 Which should call down into move_resize_internal eventually.
(In reply to Jasper St. Pierre from comment #6) > Hm, really? Yes, really... > When the client changes its size, we should get here with a new > geometry: > https://git.gnome.org/browse/mutter/tree/src/wayland/meta-wayland-surface. > c#n408 > > Which should call down into move_resize_internal eventually. It *does* get to toplevel_surface_commit() but with the original, smaller size.
Moving to gtk+
Created attachment 314249 [details] [review] Proposed fix
Review of attachment 314249 [details] [review]: Yeah. This check was broken.
attachment 314249 [details] [review] pushed as commit 3058c3e wayland: configure clients that resize themselves
*** Bug 759253 has been marked as a duplicate of this bug. ***