1

I’m trying to find out how dwm decides the initial position of the mouse cursor, after it started. I looked in dwm.c for a while, but my knowledge of C and X11 doesn’t cut it.

What I want to do is to place the cursor in my primary monitor. Now it is created on the other one, causing it to be initially selected. When I first start a terminal or something else (using the keyboard), it opens in the wrong monitor. It’s a minor annoyance, but also a pretext to learn something :)

I’m not sure if dwm should be responsible for that, or xorg is maybe? Is dwm aware of the primary output set with xrandr?

Update

I tried to use XWarpPointer() in dwm.c, in main() just before run() is called. This way I managed to move the pointer to the center of the screen, but the wrong one :)

Update 2

As suggested in the comments, it could be something wrong in my xrandr setup. Here it is:

xrandr —output DP-0 —rotate left
xrandr —output DP-0 —left-of DP-4
xrandr —output DP-4 —pos 1080x160
xrandr —output DP-4 —primary

Edit: dwm initializes DP-0 first (where the status bar appears first). Though if I disconnect the mouse and reboot, dwm behaves correctly and the focus is on DP-4 (eventhough DP-0 is initialized first).

Update 3

As a test I started i3wm instead of dwm. The pointer is initialized in the center of the screen (DP-4) as expected and all is fine.

  • dwm will default to the primary screen (monitor), see dwm.suckless.org/multi-monitor – jasonwryan Dec 31 '18 at 23:37
  • @jasonwryan Yes, I recall reading this when I setup the second monitor, however looks like the mouse position overrides it (I tried disconnecting the mouse and it does default to the primary screen). – ghetto Jan 1 at 0:42
  • Mouse is a red herring; which screen is initialised first (where does dwm's status bar first appear)? – jasonwryan Jan 1 at 0:59
  • @jasonwryan Seems to appear first on the secondary screen – ghetto Jan 1 at 22:29
  • So, dwm/X thinks that is your primary: you can fix that with xrandr. – jasonwryan Jan 1 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.