Bug 449620 - Pointer constraints protocol not honored when switching from server side decorations to client side
Summary: Pointer constraints protocol not honored when switching from server side deco...
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kwin
Classification: Plasma
Component: input (show other bugs)
Version: 5.23.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2022-02-04 21:42 UTC by Mark Bolhuis
Modified: 2023-09-06 12:24 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
A small C file that demonstrates the bug (1.40 KB, application/gzip)
2022-02-04 23:29 UTC, Mark Bolhuis
Details
CORRECTION: Small C program that demonstrates the bug. (2.39 KB, application/gzip)
2022-02-04 23:47 UTC, Mark Bolhuis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Bolhuis 2022-02-04 21:42:34 UTC
SUMMARY
On a Wayland session a native Wayland client created with pointer constraints and server side decoration will no longer constrain the pointer if the client dynamically switches to client side decoration whilst the pointer is constrained.

STEPS TO REPRODUCE
1. Create a simple Wayland client that uses xdg-shell, pointer-constraints and xdg-decoration protocols.
2. Create an xdg_toplevel
3. Request SSD for the xdg_toplevel using zxdg_toplevel_decoration_v1_set_mode
4. Constrain the pointer to the wl_surface associated with the xdg_toplevel using zwp_pointer_constraints_v1_confine_pointer
5. Request CSD
6. Move the pointer outside the surface along the top edge

OBSERVED RESULT
The title bar is removed however the pointer is no longer contained by the top edge of the surface (where the title bar used to be), however the other 3 edges do still constrain the pointer.

EXPECTED RESULT
All four edges should still constrain the pointer.

LIST OF SCENARIOS
SSD -> Constrain Pointer -> CSD -> Bug
SSD -> CSD -> SSD -> Constrain Pointer -> CSD -> No Bug
SSD -> CSD -> Constrain Pointer -> Bug
SSD -> CSD -> SSD -> CSD -> Constrain Pointer -> No Bug

SOFTWARE/OS VERSIONS
Linux: ArchLinux 5.15.19-lts
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Wayland-Protocols Version: 1.25
NVIDIA Driver Version: 510.47.03
Comment 1 Mark Bolhuis 2022-02-04 23:29:32 UTC
Created attachment 146286 [details]
A small C  file that demonstrates the bug

This is a small C file that demonstrates the bug.
I have omitted error handling for brevity.
I have not included xkbcommon to keep the code simpler, so you'll need to chose some appropriate scan-codes for controlling both ssd/csd and constraining. 
You can edit the KEY_ definitions at the top of the file. 
The current codes are 'u', 'l', 'c', 's', for US-ANSI keyboards.
Comment 2 Mark Bolhuis 2022-02-04 23:47:17 UTC
Created attachment 146288 [details]
CORRECTION: Small C program that demonstrates the bug.

The previous attachment was archived incorrectly.
See this for the correct file.
Comment 3 David Edmundson 2023-09-06 10:39:06 UTC
This bug was reported against an outdated version of KWin. We have made many changes since the. 
If the issue persists in newer versions can you reopen the bug report updating the version number.
Comment 4 Mark Bolhuis 2023-09-06 12:24:19 UTC
(In reply to David Edmundson from comment #3)
> This bug was reported against an outdated version of KWin. We have made many
> changes since the. 
> If the issue persists in newer versions can you reopen the bug report
> updating the version number.

I've run some tests again on 5.27.7 and can confirm that the bug no longer appears.
I'm not sure what the problem was but I think it was something to do with Kwin preserving the entire frame size when toggling between SSD and CSD. IIRC on 5.23 the window was maintaining the same client area size, and the client area wasn't moved or resized until another configure cycle, but the frame bounds were moved, meaning that the pointer was being confined to a region that didn't match where the client area was.