Bug 458929 - Cursor stays hidden when gdb break point is triggered using GLFW3
Summary: Cursor stays hidden when gdb break point is triggered using GLFW3
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: libinput (other bugs)
Version First Reported In: 5.25.4
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-09 15:02 UTC by Abdul
Modified: 2022-09-12 10:05 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Minimal project to reproduce the bug (4.89 KB, application/zip)
2022-09-09 15:02 UTC, Abdul
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Abdul 2022-09-09 15:02:45 UTC
Created attachment 151951 [details]
Minimal project to reproduce the bug

SUMMARY
When debugging a c/c++ project with gdb, if a break point is triggered in a specific way, cursor will stay hidden even if the window loses focus. This makes the user unable to use the mouse whenever a breakpoint is hit. Essentially making debugging apps in plasma DE a nightmare.

I believe this is a kwin issue because if I understand correctly, kwin doesn't let apps hide the cursor from all windows, just from the windows created from host app's process.
 
The function for hiding the cursor from GLFW is  
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); 

I tried producing a minimal example to reproduce the bug. It is a cmake project attached to this issue. It might need some tinkering to make it work on your setup, I'm using vs code, so I left the configuration files there in case it is useful for anyone.

STEPS TO REPRODUCE
1. Install GLFW3 and download attached project
2. Generate CMake project with "cmake -DCMAKE_BUILD_TYPE=Debug ."
3. Place breakpoint on line 18 (end bracket) on main.c
4. Start debugging and exit the app(Alt + F4 for me), without making the window lose focus
5. Break point is hit, app loses focus but cursor still doesn't show 

OBSERVED RESULT
Cursor is hidden even when focusing other apps

EXPECTED RESULT
Cursor should be visible (shouldn't it?)

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Archlinux
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5
Comment 1 Vlad Zahorodnii 2022-09-12 10:05:44 UTC
> 5. Break point is hit, app loses focus but cursor still doesn't show 

The attached demo hides the cursor and it appears like it creates a pointer constraint so the pointer can't escape the window. When you hit Alt+F4, kwin politely asks your demo to close the window, the demo receives that "polite" request and quits the while loop. Note that during that whole time, the pointer constraint is still active as "return 0" has not been executed so no surface has been destroyed and kwin continues to think that your demo is still running. Unfortunately, not really a bug.