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 MENUBGCOL 0x000000
#define SMENUFGCOL 0x000000
#define SMENUBGCOL 0x797979
#define SMENUBGCOL 0x1f9b92
#define SHORTCUTMOD Mod4Mask
#define MODBITS (1<<6)

View file

@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <X11/X.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
@ -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;
}

24
key.c
View file

@ -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);
@ -115,8 +118,10 @@ 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 == ucode && (e->state&SHORTCUTMOD) == (MODBITS))
unhide(0, 1);
if (e->keycode == vcode && (e->state&SHORTCUTMOD) == (MODBITS))
move(current, Button3);
if (e->keycode == rcode && (e->state&SHORTCUTMOD) == (MODBITS))
@ -173,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);
}
@ -191,6 +203,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;

12
menu.c
View file

@ -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