summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2021-05-14 20:37:57 -0400
committerJakob Kaivo <jkk@ung.org>2021-05-14 20:37:57 -0400
commit2bd0c9d971826d7b8247f4c3970a18429dfdd758 (patch)
treeea8a9678978b34f9153a8309fb6b183c098e80af
parent0cfec94c0284ddd0eeeb99667ce8e30ec99e15be (diff)
remove unnecessary event
-rw-r--r--xnext.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/xnext.c b/xnext.c
index d02230d..e6b6002 100644
--- a/xnext.c
+++ b/xnext.c
@@ -80,21 +80,15 @@ static Window *walk_tree(Display *dpy, Window win, Window *list, size_t *nwin)
return list;
}
-int switch_to(Display *dpy, Window root, Window prev, Window win)
+int switch_to(Display *dpy, Window prev, Window win)
{
- Atom ActiveWindowAtom = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
- XEvent xev = {
- .xclient.type = ClientMessage,
- .xclient.window = win,
- .xclient.message_type = ActiveWindowAtom,
- .xclient.format = 32,
- .xclient.data.l = { 1, 1, 0, 0 },
- };
- XSendEvent(dpy, root, False, SubstructureRedirectMask, &xev);
XMapRaised(dpy, win);
XRaiseWindow(dpy, win);
+
+ /* TODO: move pointer to the middle of the window */
XWarpPointer(dpy, prev, win, 0, 0, 0, 0, 0, 0);
XSetInputFocus(dpy, win, RevertToNone, CurrentTime);
+
XCloseDisplay(dpy);
return 0;
}
@@ -149,12 +143,12 @@ int main(int argc, char *argv[])
qsort(list, nwin, sizeof(*list), compar);
if (focused == PointerRoot || focused == None) {
- return switch_to(dpy, root, focused, list[previous ? nwin - 1 : 0]);
+ return switch_to(dpy, focused, list[previous ? nwin - 1 : 0]);
}
for (size_t i = 0; i < nwin; i++) {
if (list[i] == focused) {
- return switch_to(dpy, root, focused, list[(i + (previous ? -1 : 1)) % nwin]);
+ return switch_to(dpy, focused, list[(i + (previous ? -1 : 1)) % nwin]);
}
}