menu.c, fns.h, dat.h, config.h: add omnipresent windows, add config option to enable or disable menu item; config.h, key.c: add keyboard shortcut for sticky windows
This commit is contained in:
parent
8ffa8d334b
commit
dd9e049a8c
5 changed files with 45 additions and 6 deletions
4
config.h
4
config.h
|
@ -12,6 +12,8 @@
|
|||
#define SMENUFGCOL 0x000000
|
||||
#define SMENUBGCOL 0x1f9b92
|
||||
|
||||
// #define SHOWSTICK
|
||||
|
||||
#define SHORTCUTMOD Mod4Mask
|
||||
#define MODBITS (1<<6)
|
||||
|
||||
|
@ -21,6 +23,7 @@
|
|||
#define MOVE_KEY XK_v
|
||||
#define RESIZE_KEY XK_r
|
||||
#define DESTROY_KEY XK_d
|
||||
#define STICK_KEY XK_s
|
||||
|
||||
#define SNAPLEFT_KEY XK_h
|
||||
#define SNAPRIGHT_KEY XK_l
|
||||
|
@ -38,3 +41,4 @@
|
|||
#define PREVVIRT_KEY XK_Left
|
||||
|
||||
#define LAUNCH_KEY XK_slash
|
||||
|
||||
|
|
8
dat.h
8
dat.h
|
@ -6,7 +6,11 @@
|
|||
#define CORNER _corner
|
||||
#define INSET _inset
|
||||
#define MAXHIDDEN 128
|
||||
#define B3FIXED 5
|
||||
#ifdef SHOWSTICK
|
||||
#define B3FIXED 6
|
||||
#else
|
||||
#define B3FIXED 5
|
||||
#endif
|
||||
#define NUMVIRTUALS 12
|
||||
|
||||
#define AllButtonMask (Button1Mask|Button2Mask|Button3Mask \
|
||||
|
@ -188,4 +192,4 @@ extern int ignore_badwindow;
|
|||
|
||||
/* key.c and event.c share this */
|
||||
|
||||
extern int kbLaunch;
|
||||
extern int kbLaunch;
|
||||
|
|
2
fns.h
2
fns.h
|
@ -81,7 +81,7 @@ void button2();
|
|||
void initb2menu();
|
||||
void switch_to();
|
||||
void switch_to_c();
|
||||
|
||||
void stick();
|
||||
|
||||
|
||||
/* client.c */
|
||||
|
|
5
key.c
5
key.c
|
@ -43,6 +43,7 @@ keysetup(void)
|
|||
int mcode = XKeysymToKeycode(dpy, MAX_KEY);
|
||||
int vcode = XKeysymToKeycode(dpy, MOVE_KEY);
|
||||
int rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
|
||||
int scode = XKeysymToKeycode(dpy, STICK_KEY);
|
||||
int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY);
|
||||
int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY);
|
||||
int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY);
|
||||
|
@ -64,6 +65,7 @@ keysetup(void)
|
|||
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);
|
||||
XGrabKey(dpy, scode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, hcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, lcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, jcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
|
@ -95,6 +97,7 @@ keypress(XKeyEvent *e)
|
|||
int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY);
|
||||
int mcode = XKeysymToKeycode(dpy, MAX_KEY);
|
||||
int vcode = XKeysymToKeycode(dpy, MOVE_KEY);
|
||||
int scode = XKeysymToKeycode(dpy, STICK_KEY);
|
||||
int rcode = XKeysymToKeycode(dpy, RESIZE_KEY);
|
||||
int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
|
||||
int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY);
|
||||
|
@ -128,6 +131,8 @@ keypress(XKeyEvent *e)
|
|||
reshape(current, Button3, sweep, 0);
|
||||
if (e->keycode == mcode && (e->state&SHORTCUTMOD) == (MODBITS))
|
||||
quickreshape(current, -BORDER, -BORDER, ra.width + 2*BORDER, ra.height + 2*BORDER);
|
||||
if (e->keycode == scode && (e->state&SHORTCUTMOD) == (MODBITS))
|
||||
stick(current);
|
||||
|
||||
/* half snap */
|
||||
if (e->keycode == hcode && (e->state&SHORTCUTMOD) == (MODBITS))
|
||||
|
|
32
menu.c
32
menu.c
|
@ -58,6 +58,9 @@ char *b3items[B3FIXED+MAXHIDDEN+1] =
|
|||
"Move",
|
||||
"Delete",
|
||||
"Hide",
|
||||
#ifdef SHOWSTICK
|
||||
"Stick",
|
||||
#endif
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -67,7 +70,12 @@ enum
|
|||
Reshape,
|
||||
Move,
|
||||
Delete,
|
||||
#ifdef SHOWSTICK
|
||||
Hide,
|
||||
Stick
|
||||
#else
|
||||
Hide
|
||||
#endif
|
||||
};
|
||||
|
||||
Menu b3menu =
|
||||
|
@ -119,7 +127,6 @@ button(XButtonEvent *e)
|
|||
}
|
||||
switch (e->button){
|
||||
case Button1:
|
||||
printf("button 1 on client");
|
||||
fflush(stdout);
|
||||
if(c){
|
||||
if (ffm)
|
||||
|
@ -177,6 +184,11 @@ button(XButtonEvent *e)
|
|||
case Hide:
|
||||
hide(selectwin(1, 0, s));
|
||||
break;
|
||||
#ifdef SHOWSTICK
|
||||
case Stick:
|
||||
stick(selectwin(1, 0, s));
|
||||
break;
|
||||
#endif
|
||||
default: /* unhide window */
|
||||
unhide(n - B3FIXED, 1);
|
||||
break;
|
||||
|
@ -347,6 +359,20 @@ unhidec(Client *c, int map)
|
|||
c->label, (int)c->window);
|
||||
}
|
||||
|
||||
void
|
||||
stick(Client *c)
|
||||
{
|
||||
printf("BEFORE STICK:\n");
|
||||
printf("virtual on client: %d\n", c->virt);
|
||||
printf("virtual: %d\n", virt);
|
||||
if (numvirtuals > 1 && c->virt >= 0 )
|
||||
c->virt = -1;
|
||||
else c->virt = virt;
|
||||
printf("AFTER STICK:\n");
|
||||
printf("virtual on client: %d\n", c->virt);
|
||||
printf("virtual: %d\n", virt);
|
||||
}
|
||||
|
||||
void
|
||||
renamec(Client *c, char *name)
|
||||
{
|
||||
|
@ -384,7 +410,7 @@ switch_to_c(int n, Client *c)
|
|||
if(c->parent == DefaultRootWindow(dpy))
|
||||
return;
|
||||
|
||||
if(c->virt != virt && c->state == NormalState){
|
||||
if(c->virt != virt && c->state == NormalState && c->virt >= 0){
|
||||
XUnmapWindow(dpy, c->parent);
|
||||
XUnmapWindow(dpy, c->window);
|
||||
setstate(c, IconicState);
|
||||
|
@ -432,7 +458,7 @@ switch_to(int n)
|
|||
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);
|
||||
execlp("notify-send", "notify-send", "-c", "virtual", virtmsg, (char*)0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue