Bug 403376

Summary: [Wayland] Cannot resize correctly a gtk CSD window by dragging its borders
Product: [Plasma] kwin Reporter: Patrick Silva <bugseforuns>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: damianatorrpm, kde, matejm98mthw, nate
Priority: NOR    
Version: 5.15.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.17.0
Sentry Crash Report:

Description Patrick Silva 2019-01-18 20:46:53 UTC
STEPS TO REPRODUCE
1. open some gtk csd window under Wayland (gnome disks, pitivi video editor, pulseeffects, etc)
2. while the window is not maximized, try to resize it manually by dragging some window border
3. 

OBSERVED RESULT
weird behaviors: Sometimes the window size increases instead decreases, sometimes the window size changes immediately after I start to drag the window border, window size does not track cursor movements correctly.

EXPECTED RESULT
the window is resized correctly.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.14.90
KDE Frameworks Version: 5.54.0
Qt Version: 5.12.0


ADDITIONAL INFORMATION
the same windows can be resized correctly under X11.
Comment 1 Damian Ivanov 2019-04-04 16:28:23 UTC
it does't work either by alt + right click kwin and gtk is broken
Comment 2 Matej Mrenica 2019-04-04 16:48:44 UTC
I have this problem too and I also reported it on gnome bugtracker but there hasn't been any activity in 8 months, see: https://gitlab.gnome.org/GNOME/gtk/issues/1163
Comment 3 Vlad Zahorodnii 2019-04-04 16:51:50 UTC
(In reply to mthw0 from comment #2)
> I have this problem too and I also reported it on gnome bugtracker but there
> hasn't been any activity in 8 months, see:
> https://gitlab.gnome.org/GNOME/gtk/issues/1163

This is clearly a bug on our side.
Comment 4 David Edmundson 2019-04-05 01:24:14 UTC
I remember this from a report a while ago.

When dragging, kwin has protection that it only sends one resize event at a time, then blocks till the app re-renders before sending the next so that it can track the correct pending topleft position. It made sense on X and wl_surface.

We sometimes send a configure event twice with the same size. Qt responds, GTK does not which is legitimate behaviour, then we deadlock till the timeout.

We don't need this request behaviour since we added proper configure ack handling.

If I do:

 bool ShellClient::isWaitingForMoveResizeSync() const {
   return false;
  }

everything still great and is faster too.
Comment 5 David Edmundson 2019-04-09 10:57:14 UTC
Git commit 985601e0a41a84ffab51bc942824bd48bc8a6290 by David Edmundson.
Committed on 09/04/2019 at 10:14.
Pushed by davidedmundson into branch 'master'.

[wayland] Queue XDG configure requests when resizing toplevel interactively

Summary:
When resizing a window particularly from the left side, we need to
co-ordinate moving the window with when we get the resized buffer.

The code in AbstractClient::handleMoveResize checks
isWaitingForResizSync to make sure we never send more than one resize
request at a time to keep that in sync.

This makes sense on X and wl_shell_surface, but not on XDGShell where we
can track which resize events have been handled by the client.

ShellClient already keeps a stack of our pending configure requests and
handles everything appropriately, we don't need to block.

This results in a smoother dragging experience and avoids a potential
deadlock currently seen when a client may not reply to a no-op configure
request.

Test Plan: Async ack handling is covered by existing unit tests

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20397

M  +8    -3    shell_client.cpp

https://commits.kde.org/kwin/985601e0a41a84ffab51bc942824bd48bc8a6290
Comment 6 David Edmundson 2019-05-10 15:35:15 UTC
Git commit bc83065cebd7ac855966da52edd1afcaf0fc2865 by David Edmundson.
Committed on 10/05/2019 at 15:34.
Pushed by davidedmundson into branch 'master'.

Handle XdgShell window geometry in configure request sizes

Summary:
The size passed to an XDG shell configure request should match the
window size of the given window, we don't want to include the size of
any shadows that may be drawn by the client.

Kwin has the same concept of geometry for both window management, input
and rendering.

In order to approach this in a way that does not risk any regressions
with kwin's current structure AbstractClient::geometry remains the
canonical source and we handle the window within that internally within
ShellClient treating the windowGeometry as a set of margins from this.

This is part of a much bigger task (T10867). This patch addresses
windows growing when starting a drag based resize.

Test Plan:
Unit test
gtk3-demo

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20937

M  +36   -0    autotests/integration/shell_client_test.cpp
M  +44   -4    shell_client.cpp
M  +5    -0    shell_client.h

https://commits.kde.org/kwin/bc83065cebd7ac855966da52edd1afcaf0fc2865
Comment 7 David Edmundson 2019-05-10 21:21:50 UTC
Matching kwayland commit missed the freeze :(

Reopening to remind me to merge into master after we branch and after my wayland patch gets accepted
Comment 8 Nate Graham 2019-05-17 13:23:00 UTC
Plasma 5.16 has branched, so this can probably go in again.
Comment 9 Nate Graham 2019-05-17 16:27:37 UTC
Re-landed in 5.17 with https://commits.kde.org/kwin/1b9eaa62c26c407022e8a64ec33b391860af0e5d