This commit is contained in:
Iris Lightshard 2021-01-04 00:37:58 -05:00
commit 2da43562b5
4 changed files with 34 additions and 6 deletions

View file

@ -10,7 +10,7 @@
#define MENUFGCOL 0x797979 #define MENUFGCOL 0x797979
#define MENUBGCOL 0x000000 #define MENUBGCOL 0x000000
#define SMENUFGCOL 0x000000 #define SMENUFGCOL 0x000000
#define SMENUBGCOL 0x797979 #define SMENUBGCOL 0x1f9b92
#define SHORTCUTMOD Mod4Mask #define SHORTCUTMOD Mod4Mask
#define MODBITS (1<<6) #define MODBITS (1<<6)

View file

@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h>
#include <X11/X.h> #include <X11/X.h>
#include <X11/Xos.h> #include <X11/Xos.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -287,6 +288,7 @@ newwindow(XCreateWindowEvent *e)
} }
if (kbLaunch) if (kbLaunch)
{ {
usleep(100000);
quickreshape(c, c->screen->width/5, c->screen->height/5, 3*c->screen->width/5, 3*c->screen->height/5); quickreshape(c, c->screen->width/5, c->screen->height/5, 3*c->screen->width/5, 3*c->screen->height/5);
kbLaunch = 0; kbLaunch = 0;
} }

18
key.c
View file

@ -39,6 +39,7 @@ keysetup(void)
int tabcode = XKeysymToKeycode(dpy, XK_Tab); int tabcode = XKeysymToKeycode(dpy, XK_Tab);
int dcode = XKeysymToKeycode(dpy, DESTROY_KEY); int dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
int icode = XKeysymToKeycode(dpy, ICON_KEY); int icode = XKeysymToKeycode(dpy, ICON_KEY);
int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY);
int mcode = XKeysymToKeycode(dpy, MAX_KEY); int mcode = XKeysymToKeycode(dpy, MAX_KEY);
int vcode = XKeysymToKeycode(dpy, MOVE_KEY); int vcode = XKeysymToKeycode(dpy, MOVE_KEY);
int rcode = XKeysymToKeycode(dpy, RESIZE_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, tabcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
XGrabKey(dpy, dcode, SHORTCUTMOD, 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, 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, rcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
XGrabKey(dpy, vcode, 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); XGrabKey(dpy, mcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
@ -90,6 +92,7 @@ keypress(XKeyEvent *e)
int tabcode = XKeysymToKeycode(dpy, XK_Tab); int tabcode = XKeysymToKeycode(dpy, XK_Tab);
int dcode = XKeysymToKeycode(dpy, DESTROY_KEY); int dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
int icode = XKeysymToKeycode(dpy, ICON_KEY); int icode = XKeysymToKeycode(dpy, ICON_KEY);
int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY);
int mcode = XKeysymToKeycode(dpy, MAX_KEY); int mcode = XKeysymToKeycode(dpy, MAX_KEY);
int vcode = XKeysymToKeycode(dpy, MOVE_KEY); int vcode = XKeysymToKeycode(dpy, MOVE_KEY);
int rcode = XKeysymToKeycode(dpy, RESIZE_KEY); int rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
@ -117,6 +120,8 @@ keypress(XKeyEvent *e)
delete(current, 0); delete(current, 0);
if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS)) if (e->keycode == icode && (e->state&SHORTCUTMOD) == (MODBITS))
hide(current); hide(current);
if (e->keycode == ucode && (e->state&SHORTCUTMOD) == (MODBITS))
unhide(0, 1);
if (e->keycode == vcode && (e->state&SHORTCUTMOD) == (MODBITS)) if (e->keycode == vcode && (e->state&SHORTCUTMOD) == (MODBITS))
move(current, Button3); move(current, Button3);
if (e->keycode == rcode && (e->state&SHORTCUTMOD) == (MODBITS)) if (e->keycode == rcode && (e->state&SHORTCUTMOD) == (MODBITS))
@ -173,11 +178,18 @@ keypress(XKeyEvent *e)
/* switch virts */ /* switch virts */
if (e->keycode == rightcode && (e->state&SHORTCUTMOD) == (MODBITS)) if (e->keycode == rightcode && (e->state&SHORTCUTMOD) == (MODBITS))
if (numvirtuals > 1 && virt < numvirtuals - 1) if (numvirtuals > 1)
if (virt < numvirtuals - 1)
switch_to(virt + 1); switch_to(virt + 1);
else
switch_to(0);
if (e->keycode == leftcode && (e->state&SHORTCUTMOD) == (MODBITS)) if (e->keycode == leftcode && (e->state&SHORTCUTMOD) == (MODBITS))
if (numvirtuals >1 && virt > 0) if (numvirtuals >1)
if (virt > 0)
switch_to(virt - 1); switch_to(virt - 1);
else
switch_to(numvirtuals - 1);
XAllowEvents(dpy, SyncKeyboard, e->time); XAllowEvents(dpy, SyncKeyboard, e->time);
} }
@ -191,6 +203,8 @@ keyrelease(XKeyEvent *e)
void void
quickreshape(Client *c, int x, int y, int dx, int dy) quickreshape(Client *c, int x, int y, int dx, int dy)
{ {
if (c == 0)
return;
XMoveResizeWindow(dpy, c->parent, x,y, dx, dy); XMoveResizeWindow(dpy, c->parent, x,y, dx, dy);
c->x = x + BORDER; c->x = x + BORDER;
c->y = y + BORDER; c->y = y + BORDER;

12
menu.c
View file

@ -410,6 +410,7 @@ switch_to_c(int n, Client *c)
void void
switch_to(int n) switch_to(int n)
{ {
static char virtmsg[32];
if(n == virt) if(n == virt)
return; return;
currents[virt] = current; currents[virt] = current;
@ -422,6 +423,17 @@ switch_to(int n)
switch_to_c(n, clients); switch_to_c(n, clients);
current = currents[virt]; 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 void