Last active
December 15, 2015 01:28
-
-
Save winny-/eb8680c674ef23a3b41a to your computer and use it in GitHub Desktop.
Fixes http://dwm.suckless.org/patches/dwm-6.1-warp.diff to (A) not warp if cursor is on selected window's border (B) when using topbar = 1, do not warp when cursor is touching top edge of screen (C) Cleans up duplicate XQueryPointer() code using getrootptr()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ruN dwm-6.1-orig/dwm.c dwm-6.1/dwm.c | |
--- dwm-6.1-orig/dwm.c 2015-11-08 16:39:37.000000000 -0600 | |
+++ dwm-6.1/dwm.c 2015-12-14 19:17:19.656091228 -0600 | |
@@ -227,6 +227,7 @@ | |
static void updatetitle(Client *c); | |
static void updatewmhints(Client *c); | |
static void view(const Arg *arg); | |
+static void warp(const Client *c); | |
static Client *wintoclient(Window w); | |
static Monitor *wintomon(Window w); | |
static int xerror(Display *dpy, XErrorEvent *ee); | |
@@ -840,6 +841,7 @@ | |
in gedit and anjuta */ | |
selmon = m; | |
focus(NULL); | |
+ warp(selmon->sel); | |
} | |
void | |
@@ -1384,6 +1386,8 @@ | |
} | |
XSync(dpy, False); | |
while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | |
+ if (m == selmon && (m->tagset[m->seltags] & m->sel->tags)) | |
+ warp(m->sel); | |
} | |
void | |
@@ -2040,6 +2044,28 @@ | |
arrange(selmon); | |
} | |
+void | |
+warp(const Client *c) | |
+{ | |
+ int x, y; | |
+ | |
+ if (!c) { | |
+ XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww/2, selmon->wy + selmon->wh/2); | |
+ return; | |
+ } | |
+ | |
+ if (!getrootptr(&x, &y) || | |
+ (x > c->x - c->bw && | |
+ y > c->y - c->bw && | |
+ x < c->x + c->w + c->bw*2 && | |
+ y < c->y + c->h + c->bw*2) || | |
+ (y > c->mon->by && y < c->mon->by + bh) || | |
+ (c->mon->topbar && !y)) | |
+ return; | |
+ | |
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); | |
+} | |
+ | |
Client * | |
wintoclient(Window w) | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment