Bug 485409 - Pointer escapes confinement when moving over surface above the one it is confined to
Summary: Pointer escapes confinement when moving over surface above the one it is conf...
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: input (show other bugs)
Version: git master
Platform: openSUSE Linux
: HI normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-12 02:46 UTC by Aaron Kirschen
Modified: 2024-05-04 11:34 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
c program which creates a window with surface that can constrain the pointer by pressing "l" or unconstrain by pressing "u". I edited this from a different bug report by Mark Bolhuis (bug id=449620) (3.93 KB, application/gzip)
2024-04-12 02:46 UTC, Aaron Kirschen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Kirschen 2024-04-12 02:46:57 UTC
Created attachment 168408 [details]
c program which creates a window with surface that can constrain the pointer by pressing "l" or unconstrain by pressing "u". I edited this from a different bug report by Mark Bolhuis (bug id=449620)

SUMMARY

The pointer can escape its confinement from a constrained window when moved over another window's surface that is above the one it is confined to. 


STEPS TO REPRODUCE

(With Wayland windows)
    1. Run the provided C program to create a window.
    2. Move another window partially over the window created by the program so that it overlaps the window and crosses over the edge of the window.
    3. Set the overlapping window to "Keep Above Others" using a KWin Window Rule, so that it remains above the window created by the program.
    4. Constrain the pointer to the window created by the program by pressing "l" when the pointer is on the surface.
    5. Move the pointer outside of the confined window surface by moving it over the "Keep Above Others" window’s surface.
       
OBSERVED RESULT

(With Wayland windows)
The pointer, though still constrained when it returns to the original window, can escape its confinement by passing over the window set to "Keep Above Others."


EXPECTED RESULT

The pointer should remain confined within the original window’s boundaries while it is constrained, regardless of its interaction with any overlapping window above it.

SOFTWARE/OS VERSIONS

Operating System: openSUSE Tumbleweed 20240410
KDE Plasma Version: 6.0.80
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.8.4-rc1-1-default (64-bit)
Graphics Platform: Wayland


ADDITIONAL INFORMATION

This issue presents differently depending on whether the surface the pointer is confined to is managed by Wayland or XWayland.

Behavior Summary:
    • In Wayland windows, the pointer can escape confinement by passing over another window above it which extends beyond the confined window’s boundary.
    • In XWayland windows, the pointer escapes confinement more readily; simply passing over any part of a window surface above it (whether it extends beyond the confined window’s boundary or not) breaks the confinement entirely. Moreover, the cursor shape change from the confined window is retained when the pointer is over other XWayland windows.

Wayland Window Confinement: 

If the surface the pointer is confined to is a Wayland window, the pointer remains confined to all visible edges of the window. However, it can escape this confinement by moving over any surface that is positioned above the confined surface and extends beyond its boundaries. 
This behavior can be demonstrated with the provided program that creates a Wayland window with pointer constraints by following the steps to reproduce.


XWayland Window Confinement: 

For a window managed by XWayland and confined using XGrabPointer, the behavior diverges significantly. Here, the pointer remains confined until it moves over a surface that is above it. 
Upon moving over this surface, regardless of whether it extends beyond the confined surface's boundaries or not, the pointer constraint is completely broken, allowing the pointer to freely cross the originally confined boundaries. 
When the pointer is over other XWayland windows, the cursor retains the shape it had during the confinement. However, this effect does not persist when the pointer moves over native Wayland windows, where the cursor shape reverts to normal.
I have not included steps to reproduce with XWayland windows, but I can make a sample program for that if it would help.

      
My use case is not very common: I'm trying to confine the pointer to a game which is in windowed mode that has an overlay window on top of it. The overlay is not injected into the game; it is running as a seperate process with its own window which passes through input to the game’s window. Both the game and the overlay are running through WINE and are XWayland windows. 
I think there may be other use cases such as watching a video in a window set to “Keep Above Others” above another window that the pointer is confined too.

The program I’ve included I got from a different bug report on KWin (id=449620 by Mark Bolhuis) and slightly edited it to only have constrain/unconstrain functionality. To constrain the pointer, press the “l” key. To unconstrain, press the “u” key.
Comment 1 Aaron Kirschen 2024-04-12 02:51:57 UTC
This maybe should have been filed as two separate bugs, one for Wayland windows and one for XWayland windows, but I was not certain.