After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 755051 - Windows revert to previous size after being resized using gtk_window_resize() on Wayland
Windows revert to previous size after being resized using gtk_window_resize()...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 759253 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-09-15 10:25 UTC by jdoe
Modified: 2015-12-16 18:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (610 bytes, application/gzip)
2015-09-15 10:25 UTC, jdoe
  Details
Proposed fix (1.23 KB, patch)
2015-10-27 17:14 UTC, Olivier Fourdan
accepted-commit_now Details | Review

Description jdoe 2015-09-15 10:25:15 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.
Comment 1 Olivier Fourdan 2015-10-26 10:12:56 UTC
Looks like a mutter issue to me, the spurious resize does not happen in weston.
Comment 2 Jasper St. Pierre (not reading bugmail) 2015-10-26 15:39:03 UTC
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.
Comment 3 Olivier Fourdan 2015-10-26 16:41:47 UTC
(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.
Comment 4 Jasper St. Pierre (not reading bugmail) 2015-10-26 16:44:23 UTC
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.
Comment 5 Olivier Fourdan 2015-10-27 12:49:50 UTC
(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().
Comment 6 Jasper St. Pierre (not reading bugmail) 2015-10-27 16:10:45 UTC
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.
Comment 7 Olivier Fourdan 2015-10-27 16:20:58 UTC
(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.
Comment 8 Olivier Fourdan 2015-10-27 17:13:30 UTC
Moving to gtk+
Comment 9 Olivier Fourdan 2015-10-27 17:14:01 UTC
Created attachment 314249 [details] [review]
Proposed fix
Comment 10 Jasper St. Pierre (not reading bugmail) 2015-10-27 17:17:52 UTC
Review of attachment 314249 [details] [review]:

Yeah. This check was broken.
Comment 11 Olivier Fourdan 2015-10-28 07:56:22 UTC
attachment 314249 [details] [review] pushed as commit 3058c3e wayland: configure clients that resize themselves
Comment 12 Jasper St. Pierre (not reading bugmail) 2015-12-16 18:22:55 UTC
*** Bug 759253 has been marked as a duplicate of this bug. ***