Restrict the mouse cursor to stay on primary screen - how?

How can I restrict the mouse cursor to stay on the primary screen?

In my setup I use a TV as screen, and I also connect my AVR directly from the PC because the TV and the AVR refuse to cooperate. The AVR tells the PC that it is a screen, and therefore the PC sees two screens and fuse them to one display. When I happen to push the mouse cursor to the AVR part of the display, the AVR “screen” becomes the active one, and Krunner and programs open there, invisible to me. That causes confusion, confusion leads to suffering, and suffering leads to the dark side …

I cannot disable the AVR “screen” in the system settings, because then the PC will not send the sound signal to the AVR.

I would like to restrict the mouse cursor to stay on the primary screen. What should I do to make that happen?

Platform: x86_64-Linux-qt6
OS version: Manjaro Linux 24.0.3
KDE Frameworks 6.3.0
Widgetset library: Qt 6.7.1

$ inxi -G
Graphics:
  Device-1: AMD Ellesmere [Radeon RX 470/480/570/570X/580/580X/590]
    driver: amdgpu v: kernel
  Display: wayland server: X.org v: 1.21.1.13 with: Xwayland v: 24.1.0
    compositor: kwin_wayland driver: X: loaded: modesetting dri: radeonsi
    gpu: amdgpu resolution: 1: 320x240 2: 1920x1080
  API: EGL v: 1.5 drivers: radeonsi,swrast
    platforms: wayland,x11,surfaceless,device
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.1.1-manjaro1.1
    renderer: AMD Radeon RX 590 Series (radeonsi polaris10 LLVM 17.0.6 DRM 3.57
    6.9.5-1-MANJARO)
  API: Vulkan v: 1.3.279 drivers: radv surfaces: xcb,xlib,wayland

I’m not sure what an “AVR” is, but generally - if you tell Plasma you have a screen, then the mouse can go there.

That being said - if you put enough “gap” between the screens, then the mouse will not be able to travel the gap. If you set it up correctly, you can trap the mouse on one screen so it cannot travel to the other. I’m not sure how this will interact across reboots - you might get the mouse stuck on the wrong screen, which will be a problem.

The Plasma System Settings Display Configuration will not let you do that - because this is really not a good idea normally - and will force you to have the screens attached, but you can use the command line tool kscreen-doctor to manipulate the screen configuration manually.

To do that, start by starting a terminal and running kscreen-doctor -o to show your current configuration. It may be a good idea to save the output to some text file so that you can refer to it later.

Then you can set the position of one screen so it is farther away from the other screen - for example, my setup looks somewhat like this:

Output: 1 eDP-1
        enabled
        connected
        priority 1
        Panel
        Modes:  0:1920x1200@60*!  …
        Geometry: 1200,720 1920x1200
…
Output: 2 DP-5
        enabled
        connected
        priority 2
        DisplayPort
        Modes:  0:1920x1200@60*!  …
        Geometry: 0,0 1200x1920

Looking at the Geometry field we can see that output 1 is to the right of output 2 (2 is 0,0 to 1200,1920 while 1 is positioned at X of 1200). I can then move my right screen (output 1) further to the right by running:

kscreen-doctor output.1.position.1500,720

Or put it back where it was by running:

kscreen-doctor output.1.position.1200,720

Note that you can’t move things to the left - because of how the coordinate map works, 0,0 is the left-most-top-most point on the screen.

I generally wouldn’t recommend playing with that unless you are very comfortable fixing things through the command line, but messing things up is an important part of learning. Good luck and ping if you need more help.

Thank you very much guss77, your suggestion works, and the setting stays active after a reboot.

I ran kscreen-doctor output.1.position.2000,300 in Konsole to create a gap between the screens, and it keeps my mouse cursor on the primary screen, just like I wished :grinning:

The Plasma System Settings Display Configuration complains “Gaps between displays are not supported. Make sure all displays are touching.” , but it does not reset the position to enforce it.

PS: AVR is Audio/Video Receiver