Bug 505298

Summary: Alt+tab not locking mouse to full screen app when mouse is on secondary screen
Product: [Plasma] kwin Reporter: Jovan Pavlovic <jovan.pavlovic99>
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: kdedev, nate, strong.drum0546, tilrnz
Priority: NOR Keywords: multiscreen
Version First Reported In: 6.3.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Showcase Bug 1
Showcase of Bug 2
Bug with windowed game

Description Jovan Pavlovic 2025-06-07 07:09:45 UTC
SUMMARY

In multi monitor setup (in my case 2 monitors: monitor 1 (left) and monitor 2 (right)) 
when alt+tab to full screen app but cursor is on different screen (full screen game on monitor screen 1, mouse on monitor screen 2), mouse will not snap onto full screen app and will stay on screen 2 until mouse is fully moved to screen 1.

Sometimes when mouse is moved back to screen 1 it will not lock the mouse to that screen and its possible to move out of full screen window causing next click to exit out full screen mode.

Video showcase is added to attachments

STEPS TO REPRODUCE
1. Open some other application on monitor 2
2. Open full screen app on monitor 1
3. alt tab and hover mouse over monitor 2 application
4. alt tab back to full screen app
5 . left click (to exit full screen app)
## Continuation for extended bug that is bit more tricky to reproduce (continuing after step 4)
5. move mouse slightly to screen 1 (had more success if mouse is near the screens border)
6. click to lock into full screen app
7. move mouse out of screen 1
8. click again (to exit full screen app)

OBSERVED RESULT
Full screen app closes because mouse is on screen 2

EXPECTED RESULT
Mouse should be moved and forced to stay on screen 1

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0
Kernel Version: 6.14.9-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 32 × AMD Ryzen 9 7950X3D 16-Core Processor
Memory: 124.9 GiB of RAM
Graphics Processor 1: AMD Radeon RX 6900 XT
Graphics Processor 2: AMD Radeon Graphics

ADDITIONAL INFORMATION

kwin_wayland --version
kwin_watchdog: Watchdog: disabled, not running on a systemd environment or watchdog is not set up. No WATCHDOG_USEC.
kwin 6.3.5
QThreadStorage: entry 8 destroyed before end of thread 0x56400ddcee70
QThreadStorage: entry 1 destroyed before end of thread 0x56400ddcee70
QThreadStorage: entry 0 destroyed before end of thread 0x56400ddcee70

kscreen-console
START: Requesting Config
Received config. Took 3 milliseconds
Screen:
        maxSize: QSize(64000, 64000)
        minSize: QSize(0, 0)
        currentSize: QSize(3414, 960)

-----------------------------------------------------

Id:  1
Name:  "DP-1"
Type:  "DisplayPort"
Connected:  true
Enabled:  true
Priority:  2
Rotation:  KScreen::Output::None
Pos:  QPoint(1707,0)
MMSize:  QSize(597, 336)
FollowPreferredMode:  false
Size:  QSize(2560, 1440)
Scale:  1.5
Clones:  None
Mode:  "2"
Preferred Mode:  "1"
Preferred modes:  QList("1")
Modes: 
         "1"    "2560x1440@60"   QSize(2560, 1440)   59.951
         "10"    "1920x1080@60"   QSize(1920, 1080)   60
         "11"    "1920x1080@60"   QSize(1920, 1080)   60
         "12"    "1920x1080@60"   QSize(1920, 1080)   59.94
         "13"    "1600x1200@60"   QSize(1600, 1200)   59.951
         "14"    "1680x1050@60"   QSize(1680, 1050)   59.954
         "15"    "1600x900@60"   QSize(1600, 900)   60
         "16"    "1280x1024@75"   QSize(1280, 1024)   75.025
         "17"    "1280x1024@60"   QSize(1280, 1024)   60.02
         "18"    "1440x900@60"   QSize(1440, 900)   59.887
         "19"    "1280x800@60"   QSize(1280, 800)   59.81
         "2"    "2560x1440@165"   QSize(2560, 1440)   164.834
         "20"    "1280x720@60"   QSize(1280, 720)   60
         "21"    "1280x720@60"   QSize(1280, 720)   60
         "22"    "1280x720@60"   QSize(1280, 720)   59.94
         "23"    "1024x768@75"   QSize(1024, 768)   75.029
         "24"    "1024x768@60"   QSize(1024, 768)   60.004
         "25"    "800x600@75"   QSize(800, 600)   75
         "26"    "800x600@60"   QSize(800, 600)   60.317
         "27"    "720x480@60"   QSize(720, 480)   60
         "28"    "720x480@60"   QSize(720, 480)   60
         "29"    "720x480@60"   QSize(720, 480)   59.94
         "3"    "2560x1440@144"   QSize(2560, 1440)   143.973
         "30"    "720x480@60"   QSize(720, 480)   59.94
         "31"    "640x480@75"   QSize(640, 480)   75
         "32"    "640x480@60"   QSize(640, 480)   60
         "33"    "640x480@60"   QSize(640, 480)   59.94
         "34"    "640x480@60"   QSize(640, 480)   59.94
         "35"    "720x400@70"   QSize(720, 400)   70.082
         "36"    "1600x1200@60"   QSize(1600, 1200)   59.869
         "37"    "1280x1024@60"   QSize(1280, 1024)   59.895
         "38"    "1024x768@60"   QSize(1024, 768)   59.92
         "39"    "2560x1440@60"   QSize(2560, 1440)   59.961
         "4"    "2560x1440@120"   QSize(2560, 1440)   119.998
         "40"    "1920x1080@60"   QSize(1920, 1080)   59.963
         "41"    "1600x900@60"   QSize(1600, 900)   59.946
         "42"    "1368x768@60"   QSize(1368, 768)   59.882
         "43"    "1280x720@60"   QSize(1280, 720)   59.855
         "5"    "2560x1440@75"   QSize(2560, 1440)   74.971
         "6"    "1920x1200@60"   QSize(1920, 1200)   59.885
         "7"    "1920x1080@120"   QSize(1920, 1080)   120
         "8"    "1920x1080@120"   QSize(1920, 1080)   119.88
         "9"    "1920x1080@100"   QSize(1920, 1080)   100
EDID Info: 
        Device ID:  "xrandr-HP Inc.-OMEN 27q-CNC3232K8F"
        Name:  "OMEN 27q"
        Vendor:  "HP Inc."
        Serial:  "CNC3232K8F"
        EISA ID:  ""
        Hash:  "7997badb50a48267c23bcec31525ae70"
        Width:  60
        Height:  34
        Gamma:  2.2
        Red:  QQuaternion(scalar:1, vector:(0.68457, 0.308594, 0))
        Green:  QQuaternion(scalar:1, vector:(0.277344, 0.648438, 0))
        Blue:  QQuaternion(scalar:1, vector:(0.144531, 0.0595703, 0))
        White:  QQuaternion(scalar:1, vector:(0.313477, 0.329102, 0))

-----------------------------------------------------

Id:  2
Name:  "DP-2"
Type:  "DisplayPort"
Connected:  true
Enabled:  true
Priority:  1
Rotation:  KScreen::Output::None
Pos:  QPoint(0,0)
MMSize:  QSize(596, 335)
FollowPreferredMode:  false
Size:  QSize(2560, 1440)
Scale:  1.5
Clones:  None
Mode:  "46"
Preferred Mode:  "44"
Preferred modes:  QList("44")
Modes: 
         "44"    "2560x1440@60"   QSize(2560, 1440)   59.94
         "45"    "2560x1440@170"   QSize(2560, 1440)   169.831
         "46"    "2560x1440@165"   QSize(2560, 1440)   164.802
         "47"    "2560x1440@144"   QSize(2560, 1440)   143.856
         "48"    "2560x1440@120"   QSize(2560, 1440)   119.879
         "49"    "1920x1200@60"   QSize(1920, 1200)   59.94
         "50"    "1920x1080@144"   QSize(1920, 1080)   143.854
         "51"    "1920x1080@120"   QSize(1920, 1080)   120
         "52"    "1920x1080@120"   QSize(1920, 1080)   119.88
         "53"    "1920x1080@60"   QSize(1920, 1080)   60
         "54"    "1920x1080@60"   QSize(1920, 1080)   60
         "55"    "1920x1080@60"   QSize(1920, 1080)   59.94
         "56"    "1600x1200@60"   QSize(1600, 1200)   59.94
         "57"    "1680x1050@60"   QSize(1680, 1050)   59.954
         "58"    "1280x1024@75"   QSize(1280, 1024)   75.025
         "59"    "1280x1024@60"   QSize(1280, 1024)   60.02
         "60"    "1440x900@60"   QSize(1440, 900)   59.887
         "61"    "1280x800@60"   QSize(1280, 800)   59.94
         "62"    "1280x720@120"   QSize(1280, 720)   120
         "63"    "1280x720@120"   QSize(1280, 720)   119.88
         "64"    "1280x720@60"   QSize(1280, 720)   60
         "65"    "1280x720@60"   QSize(1280, 720)   59.94
         "66"    "1024x768@75"   QSize(1024, 768)   75.029
         "67"    "1024x768@70"   QSize(1024, 768)   70.069
         "68"    "1024x768@60"   QSize(1024, 768)   60.004
         "69"    "800x600@75"   QSize(800, 600)   75
         "70"    "800x600@72"   QSize(800, 600)   72.188
         "71"    "800x600@60"   QSize(800, 600)   60.317
         "72"    "800x600@56"   QSize(800, 600)   56.25
         "73"    "720x576@50"   QSize(720, 576)   50
         "74"    "720x576@50"   QSize(720, 576)   50
         "75"    "720x480@60"   QSize(720, 480)   60
         "76"    "720x480@60"   QSize(720, 480)   60
         "77"    "720x480@60"   QSize(720, 480)   59.94
         "78"    "720x480@60"   QSize(720, 480)   59.94
         "79"    "640x480@75"   QSize(640, 480)   75
         "80"    "640x480@73"   QSize(640, 480)   72.809
         "81"    "640x480@60"   QSize(640, 480)   60
         "82"    "640x480@60"   QSize(640, 480)   59.94
         "83"    "1600x1200@60"   QSize(1600, 1200)   59.869
         "84"    "1280x1024@60"   QSize(1280, 1024)   59.895
         "85"    "1024x768@60"   QSize(1024, 768)   59.92
         "86"    "1920x1200@60"   QSize(1920, 1200)   59.885
         "87"    "1280x800@60"   QSize(1280, 800)   59.81
         "88"    "2560x1440@60"   QSize(2560, 1440)   59.961
         "89"    "1920x1080@60"   QSize(1920, 1080)   59.963
         "90"    "1600x900@60"   QSize(1600, 900)   59.946
         "91"    "1368x768@60"   QSize(1368, 768)   59.882
         "92"    "1280x720@60"   QSize(1280, 720)   59.855
EDID Info: 
        Device ID:  "xrandr-GIGA-BYTE TECHNOLOGY CO., LTD.-M27Q-21030B003556"
        Name:  "M27Q"
        Vendor:  "GIGA-BYTE TECHNOLOGY CO., LTD."
        Serial:  "21030B003556"
        EISA ID:  ""
        Hash:  "e6936a5014da6874870f25e52cfe452a"
        Width:  70
        Height:  39
        Gamma:  2.2
        Red:  QQuaternion(scalar:1, vector:(0.655273, 0.324219, 0))
        Green:  QQuaternion(scalar:1, vector:(0.208984, 0.713867, 0))
        Blue:  QQuaternion(scalar:1, vector:(0.146484, 0.0507813, 0))
        White:  QQuaternion(scalar:1, vector:(0.313477, 0.329102, 0))
Comment 1 Jovan Pavlovic 2025-06-07 07:21:22 UTC
Created attachment 182081 [details]
Showcase Bug 1

Example of mouse not moving to screen 1 when alt+tab
Comment 2 Jovan Pavlovic 2025-06-07 07:22:16 UTC
Created attachment 182082 [details]
Showcase of Bug 2

Showcase of mouse not locking to screen 1 after click and moving out to screen 2 afterwards
Comment 3 Lenzoid 2025-06-07 11:57:19 UTC
So in other words: You have to *click* into your fullscreen game for the mouse cursor to be trapped in there, alt-tabbing is not enough.

In the beginning that looked like a bug to me aswell. The behavior is different than on Windows but personally I wouldn't say this is a bug or a problem. Maybe there are reasons for why it behaves that way.
Comment 4 TraceyC 2025-06-08 19:47:59 UTC
Thanks for the bug report! Unfortunately it reports multiple distinct issues, which will make it not actionable. See https://community.kde.org/Get_Involved/Issue_Reporting#Multiple_issues_in_a_single_Bugzilla_ticket for more explanation.

Can I ask you to submit a new bug report for bug number 2? We can focus on the first issue in this report -  mouse focus when using alt-tab

For this bug, can you share a screen shot of the focus setting?
System Settings -> Window Management -> Window Behavior: Focus tab

The behavior in the screen recording looks like "Click to focus"
Do you get the behavior you want with "Focus follow mouse" or "Focus follows mouse (mouse precedence)"?


Thanks again!
Comment 5 Tino Lorenz 2025-06-09 08:47:14 UTC
To clarify, I think the important bit here is not the fullscreen part (1), but that the app captures the cursor.
I'm not sure what the use case would be for tabbing into / re-focusing such an app without re-capturing it, so I'd say this is defientely an issue.

1) In fact, I can reproduce the same behavior with a windowed game and it's just as annoying there.
Comment 6 Tino Lorenz 2025-06-09 09:20:16 UTC
Created attachment 182111 [details]
Bug with windowed game
Comment 7 Lenzoid 2025-06-10 17:52:09 UTC
Thanks for your additional comments. Did some more testing, this is what I want to highlight (considering only issue #1 from here on out).

- On single screen it works as expected (alt-tabbing into game captures mouse input correctly)
- On multiscreen the behavior is very different, alt-tab is basically not working as expected. Depending on the game you can have very weird issues and it can be quite annoying. 
- Tested with default settings at: System Settings -> Window Management -> Window Behavior: Focus tab
- Tested on Gnome, it works as expected there, even with two screens.
- Reproducible in git-master.

So I agree with Tino and moving this on to confirmed. A side note: there are gamers out there switching from Gnome to KDE, because of better VRR support among other reasons. I believe if SteamOS became a multi-screen system we could even justify a higher priority.  ;)