diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2025-02-09 02:12:11 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2025-02-09 10:41:37 -0800 |
commit | 606ca8f4504b9f85bf5510a68be2a7d88e365b91 (patch) | |
tree | ef49f0ec1046de1b777ebceb943ce995a1a772fa /src | |
parent | beac2ba833b912b819fae48ec268373ee994efbd (diff) |
key: warp pointer to middle of focused window when chasing
Now when holding down XK_m during focus changing operations the
pointer will follow the focus, which should be handy on
multihead.
Also simply pressing Mod1+XK_m without doing anything else will
chase the currently focused window, so you can bring the pointer
where you are immediately on demand using the keyboard.
Diffstat (limited to 'src')
-rw-r--r-- | src/key.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -492,6 +492,22 @@ void vwm_key_pressed(vwm_t *vwm, Window win, XKeyPressedEvent *keypress) break; } + /* if we're chasing focus with the pointer, center the pointer in the focused window */ + if (chase_it) { + /* We have to get the latest window attrs for this to always do the right thing, + * otherwise it's kind of racy as we've often _just_ changed window attrs, + * and want to query them to warp the pointer to the current configuration. + */ + XSync(VWM_XDISPLAY(vwm), False); + vwin = vwm_win_get_focused(vwm); + if (vwin) { + XWindowAttributes attrs; + + XGetWindowAttributes(VWM_XDISPLAY(vwm), vwin->xwindow->id, &attrs); + XWarpPointer(VWM_XDISPLAY(vwm), None, vwin->xwindow->id, 0, 0, 0, 0, attrs.width / 2, attrs.height / 2); + } + } + /* if what we're doing requests a grab, if not already grabbed, grab keyboard */ if (!key_is_grabbed && do_grab) { VWM_TRACE("saving focused_origin of %p", vwin); |