From ae6903668b4cd2141cf261790ad27a16f25c1498 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 29 Feb 2020 00:44:42 -0500 Subject: [PATCH 1/6] add usleep() call to newWindow(); a delay is needed now (for whatever reason) to give urxvt time to properly handle a resize event --- event.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/event.c b/event.c index d6fa2a1..d6f9425 100755 --- a/event.c +++ b/event.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -287,6 +288,7 @@ newwindow(XCreateWindowEvent *e) } if (kbLaunch) { + usleep(100000); quickreshape(c, c->screen->width/5, c->screen->height/5, 3*c->screen->width/5, 3*c->screen->height/5); kbLaunch = 0; } From 467f53aa0b22ed3221ba5464ad33d3ad3bb3f984 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 29 Feb 2020 10:38:12 -0500 Subject: [PATCH 2/6] add guard against mangling root window in quickreshape() --- key.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/key.c b/key.c index 2c5e7ad..8bdc6ee 100755 --- a/key.c +++ b/key.c @@ -115,7 +115,7 @@ keypress(XKeyEvent *e) alttab(e->state&ShiftMask); if(e->keycode == dcode && (e->state&SHORTCUTMOD) == (MODBITS)) delete(current, 0); - if(e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) + if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) hide(current); if (e->keycode == vcode && (e->state&SHORTCUTMOD) == (MODBITS)) move(current, Button3); @@ -191,6 +191,8 @@ keyrelease(XKeyEvent *e) void quickreshape(Client *c, int x, int y, int dx, int dy) { + if (c == 0) + return; XMoveResizeWindow(dpy, c->parent, x,y, dx, dy); c->x = x + BORDER; c->y = y + BORDER; From 53c10d5987d418e17d3db1f853cf82b884f0009e Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 29 Feb 2020 13:04:01 -0500 Subject: [PATCH 3/6] restore unhide shortcut --- key.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/key.c b/key.c index 8bdc6ee..15586e7 100755 --- a/key.c +++ b/key.c @@ -39,6 +39,7 @@ keysetup(void) int tabcode = XKeysymToKeycode(dpy, XK_Tab); int dcode = XKeysymToKeycode(dpy, DESTROY_KEY); int icode = XKeysymToKeycode(dpy, ICON_KEY); + int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY); int mcode = XKeysymToKeycode(dpy, MAX_KEY); int vcode = XKeysymToKeycode(dpy, MOVE_KEY); int rcode = XKeysymToKeycode(dpy, RESIZE_KEY); @@ -59,6 +60,7 @@ keysetup(void) XGrabKey(dpy, tabcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync); XGrabKey(dpy, dcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync); XGrabKey(dpy, icode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync); + XGrabKey(dpy, ucode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync); XGrabKey(dpy, rcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync); XGrabKey(dpy, vcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync); XGrabKey(dpy, mcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync); @@ -90,6 +92,7 @@ keypress(XKeyEvent *e) int tabcode = XKeysymToKeycode(dpy, XK_Tab); int dcode = XKeysymToKeycode(dpy, DESTROY_KEY); int icode = XKeysymToKeycode(dpy, ICON_KEY); + int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY); int mcode = XKeysymToKeycode(dpy, MAX_KEY); int vcode = XKeysymToKeycode(dpy, MOVE_KEY); int rcode = XKeysymToKeycode(dpy, RESIZE_KEY); @@ -117,6 +120,8 @@ keypress(XKeyEvent *e) delete(current, 0); if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) hide(current); + if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) + unhide(hidden[0]); if (e->keycode == vcode && (e->state&SHORTCUTMOD) == (MODBITS)) move(current, Button3); if (e->keycode == rcode && (e->state&SHORTCUTMOD) == (MODBITS)) From 704120b4d45de99930475143d754fc54263e3ece Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 29 Feb 2020 13:05:10 -0500 Subject: [PATCH 4/6] fix unhide shortcut --- key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/key.c b/key.c index 15586e7..5468ccd 100755 --- a/key.c +++ b/key.c @@ -120,7 +120,7 @@ keypress(XKeyEvent *e) delete(current, 0); if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) hide(current); - if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) + if (e->keycode == ucode && (e->state&SHORTCUTMOD) == (MODBITS)) unhide(hidden[0]); if (e->keycode == vcode && (e->state&SHORTCUTMOD) == (MODBITS)) move(current, Button3); From c409aaa045283842252bd9c51371a7b1354e18ce Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 29 Feb 2020 13:08:58 -0500 Subject: [PATCH 5/6] ok, fixed unhide shortcut (really this time!) --- key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/key.c b/key.c index 5468ccd..8d3672b 100755 --- a/key.c +++ b/key.c @@ -121,7 +121,7 @@ keypress(XKeyEvent *e) if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) hide(current); if (e->keycode == ucode && (e->state&SHORTCUTMOD) == (MODBITS)) - unhide(hidden[0]); + unhide(0, 1); if (e->keycode == vcode && (e->state&SHORTCUTMOD) == (MODBITS)) move(current, Button3); if (e->keycode == rcode && (e->state&SHORTCUTMOD) == (MODBITS)) From 95b857a77ced04b9a2037efe017b21e59857b704 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 6 Aug 2020 23:50:28 -0400 Subject: [PATCH 6/6] added notifications for virtual desktop switching --- config.h | 2 +- key.c | 15 +++++++++++---- menu.c | 12 ++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index 8100644..be7257b 100755 --- a/config.h +++ b/config.h @@ -10,7 +10,7 @@ #define MENUFGCOL 0x797979 #define MENUBGCOL 0x000000 #define SMENUFGCOL 0x000000 -#define SMENUBGCOL 0x797979 +#define SMENUBGCOL 0x1f9b92 #define SHORTCUTMOD Mod4Mask #define MODBITS (1<<6) diff --git a/key.c b/key.c index 8d3672b..40c0e8b 100755 --- a/key.c +++ b/key.c @@ -178,11 +178,18 @@ keypress(XKeyEvent *e) /* switch virts */ if (e->keycode == rightcode && (e->state&SHORTCUTMOD) == (MODBITS)) - if (numvirtuals > 1 && virt < numvirtuals - 1) - switch_to(virt + 1); + if (numvirtuals > 1) + if (virt < numvirtuals - 1) + switch_to(virt + 1); + else + switch_to(0); + if (e->keycode == leftcode && (e->state&SHORTCUTMOD) == (MODBITS)) - if (numvirtuals >1 && virt > 0) - switch_to(virt - 1); + if (numvirtuals >1) + if (virt > 0) + switch_to(virt - 1); + else + switch_to(numvirtuals - 1); XAllowEvents(dpy, SyncKeyboard, e->time); } diff --git a/menu.c b/menu.c index ae9592a..290b8f9 100755 --- a/menu.c +++ b/menu.c @@ -410,6 +410,7 @@ switch_to_c(int n, Client *c) void switch_to(int n) { + static char virtmsg[32]; if(n == virt) return; currents[virt] = current; @@ -422,6 +423,17 @@ switch_to(int n) switch_to_c(n, clients); current = currents[virt]; + if(fork() == 0) + { + close(ConnectionNumber(dpy)); + if(dpy != '\0') + putenv(dpy); + signal(SIGINT, SIG_DFL); + signal(SIGTERM, SIG_DFL); + signal(SIGHUP, SIG_DFL); + sprintf(virtmsg, "virtual: switched to %s", b2items[virt]); + execlp("notify-send", "notify-send", "-c virtual", virtmsg, (char*)0); + } } void