no focus for autostick windows, fix unhide with SHOWSTICK
This commit is contained in:
parent
bb3cc4a2ac
commit
d06638a1eb
8 changed files with 114 additions and 28 deletions
34
client.c
34
client.c
|
@ -8,6 +8,7 @@
|
|||
#include <X11/Xutil.h>
|
||||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
#include "config.h"
|
||||
|
||||
Client *clients;
|
||||
Client *current;
|
||||
|
@ -62,12 +63,17 @@ active(Client *c)
|
|||
{
|
||||
Client *cc;
|
||||
|
||||
|
||||
if(c == 0){
|
||||
fprintf(stderr, "ryudo: active(c==0)\n");
|
||||
return;
|
||||
}
|
||||
if(c == current)
|
||||
return;
|
||||
#ifdef AUTOSTICK
|
||||
if (isautostick(c))
|
||||
return;
|
||||
#endif
|
||||
if(current){
|
||||
setactive(current, 0);
|
||||
if(current->screen != c->screen)
|
||||
|
@ -254,7 +260,7 @@ void
|
|||
shuffle(int up)
|
||||
{
|
||||
Client **l, *c;
|
||||
|
||||
|
||||
if(clients == 0 || clients->next == 0)
|
||||
return;
|
||||
if(!up){
|
||||
|
@ -262,13 +268,18 @@ shuffle(int up)
|
|||
/*for(c=clients; c->next; c=c->next) */
|
||||
/* ; */
|
||||
for(l=&clients; (*l)->next; l=&(*l)->next)
|
||||
#ifdef AUTOSTICK
|
||||
if ((*l)->state == 1 && !isautostick(*l))
|
||||
c = *l;
|
||||
#else
|
||||
if ((*l)->state == 1)
|
||||
c = *l;
|
||||
#endif
|
||||
if (c == 0)
|
||||
return;
|
||||
XMapRaised(dpy, c->parent);
|
||||
top(c);
|
||||
active(c);
|
||||
top(c);
|
||||
active(c);
|
||||
}else{
|
||||
c = clients;
|
||||
for(l=&clients; *l; l=&(*l)->next)
|
||||
|
@ -283,3 +294,20 @@ shuffle(int up)
|
|||
/* active(clients); */
|
||||
}
|
||||
|
||||
#ifdef AUTOSTICK
|
||||
int
|
||||
isautostick(Client *c)
|
||||
{
|
||||
static char *autostick[] = AUTOSTICK;
|
||||
char **a = autostick;
|
||||
|
||||
while(*a){
|
||||
if(strstr(c->class, *a)) {
|
||||
return 1;
|
||||
}
|
||||
++a;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
20
config.h
20
config.h
|
@ -18,8 +18,22 @@
|
|||
/* Notify on virtual desktop switch? */
|
||||
#define VIRTNOTIFY
|
||||
|
||||
/* The summary and message to pass to the notifcation daeomon */
|
||||
#define VIRTHEADER "virtual"
|
||||
#define VIRTMSG "[%s]"
|
||||
|
||||
/* Deny focus to autostuck windows? (eg xosview, clock) */
|
||||
#define NOFOCUS
|
||||
|
||||
/* Modifier key and associated modifier bits;
|
||||
* See xkb documentation for valid choices here
|
||||
* Shift = (1<<0)
|
||||
* Lock = (1<<1)
|
||||
* Control = (1<<2)
|
||||
* Mod1 = (1<<3)
|
||||
* Mod2 = (1<<4)
|
||||
* Mod3 = (1<<5)
|
||||
* Mod4 = (1<<6)
|
||||
* Mod5 = (1<<7)
|
||||
*/
|
||||
#define SHORTCUTMOD Mod4Mask
|
||||
#define MODBITS (1<<6)
|
||||
|
@ -34,6 +48,9 @@
|
|||
#define DESTROY_KEY XK_d
|
||||
#define STICK_KEY XK_s
|
||||
|
||||
#define STICKYTOFRONT_KEY XK_t
|
||||
#define STICKYTOBACK_KEY XK_b
|
||||
|
||||
#define SNAPLEFT_KEY XK_h
|
||||
#define SNAPRIGHT_KEY XK_l
|
||||
#define SNAPTOP_KEY XK_k
|
||||
|
@ -59,6 +76,7 @@
|
|||
|
||||
#define AUTOSTICK {\
|
||||
"XOsview",\
|
||||
"XClock",\
|
||||
0\
|
||||
}
|
||||
|
||||
|
|
16
event.c
16
event.c
|
@ -15,6 +15,7 @@
|
|||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
#include "patchlevel.h"
|
||||
#include "config.h"
|
||||
|
||||
void
|
||||
mainloop(int shape_event)
|
||||
|
@ -23,7 +24,6 @@ mainloop(int shape_event)
|
|||
|
||||
for(;;){
|
||||
getevent(&ev);
|
||||
|
||||
#ifdef DEBUG_EV
|
||||
if(debug){
|
||||
ShowEvent(&ev);
|
||||
|
@ -537,10 +537,16 @@ focusin(XFocusChangeEvent *e)
|
|||
return;
|
||||
c = getclient(e->window, 0);
|
||||
if(c != 0 && c->window == e->window && c != current){
|
||||
/* someone grabbed keyboard or seized focus; make them current */
|
||||
XMapRaised(dpy, c->parent);
|
||||
top(c);
|
||||
active(c);
|
||||
#ifdef AUTOSTICK
|
||||
if (isautostick(c)){
|
||||
#endif
|
||||
/* someone grabbed keyboard or seized focus; make them current */
|
||||
XMapRaised(dpy, c->parent);
|
||||
top(c);
|
||||
active(c);
|
||||
#ifdef AUTOSTICK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
fns.h
4
fns.h
|
@ -65,7 +65,8 @@ void gettrans();
|
|||
void keypress();
|
||||
void keyrelease();
|
||||
void keysetup();
|
||||
void quickreshape();
|
||||
void quickreshape(Client *c, int x, int y, int dx, int dy);
|
||||
void stickystack(int);
|
||||
|
||||
/* menu.c */
|
||||
void button();
|
||||
|
@ -95,6 +96,7 @@ void rmclient();
|
|||
void dump_revert();
|
||||
void dump_clients();
|
||||
void shuffle(int);
|
||||
int isautostick(Client* c);
|
||||
|
||||
/* grab.c */
|
||||
int menuhit();
|
||||
|
|
41
key.c
41
key.c
|
@ -30,7 +30,6 @@ enum
|
|||
/*static int pgdowncode = 0x69; */
|
||||
|
||||
static void alttab(int shift);
|
||||
void quickreshape(Client*c, int x, int y, int dx, int dy);
|
||||
|
||||
void
|
||||
keysetup(void)
|
||||
|
@ -56,6 +55,10 @@ keysetup(void)
|
|||
int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY);
|
||||
int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY);
|
||||
int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY);
|
||||
#ifdef DEVEL
|
||||
int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY);
|
||||
int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY);
|
||||
#endif
|
||||
|
||||
for(i=0; i<num_screens; i++){
|
||||
XGrabKey(dpy, tabcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
|
@ -79,6 +82,10 @@ keysetup(void)
|
|||
XGrabKey(dpy, rightcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, slcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, tabcode, Mod1Mask|ShiftMask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
#ifdef DEVEL
|
||||
XGrabKey(dpy, tcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
XGrabKey(dpy, bcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
||||
#endif
|
||||
/* XGrabKey(dpy, pgupcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync); */
|
||||
/* XGrabKey(dpy, pgdowncode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync); */
|
||||
/* XGrabKey(dpy, altcode, 0, screens[i].root, 0, GrabModeSync, GrabModeAsync); */
|
||||
|
@ -111,7 +118,11 @@ keypress(XKeyEvent *e)
|
|||
int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY);
|
||||
int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY);
|
||||
int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY);
|
||||
|
||||
#ifdef DEVEL
|
||||
int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY);
|
||||
int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY);
|
||||
#endif
|
||||
|
||||
static XWindowAttributes ra;
|
||||
XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &ra);
|
||||
|
||||
|
@ -158,6 +169,14 @@ keypress(XKeyEvent *e)
|
|||
if (e->keycode == ccode && (e->state&SHORTCUTMOD) == (MODBITS))
|
||||
quickreshape(current, ra.width/5, ra.height/5, 3*ra.width/5, 3*ra.height/5);
|
||||
|
||||
#ifdef DEVEL
|
||||
/* manage autostuck windows */
|
||||
if (e->keycode == tcode && (e->state&SHORTCUTMOD) == (MODBITS))
|
||||
stickystack(1);
|
||||
if (e->keycode == bcode && (e->state&SHORTCUTMOD) == (MODBITS))
|
||||
stickystack(0);
|
||||
#endif
|
||||
|
||||
|
||||
/* launch */
|
||||
if (e->keycode == slcode && (e->state&SHORTCUTMOD) == (MODBITS)){
|
||||
|
@ -226,3 +245,21 @@ alttab(int shift)
|
|||
/* fprintf(stderr, "%sTab\n", shift ? "Back" : ""); */
|
||||
}
|
||||
|
||||
#ifdef DEVEL
|
||||
void
|
||||
stickystack(int toTop)
|
||||
{
|
||||
Client *c;
|
||||
if(toTop){
|
||||
for(c = clients; c->next; c = c->next){
|
||||
if(c && isautostick(c))
|
||||
top(c);
|
||||
}
|
||||
}else{
|
||||
for(c = clients; c->next; c = c->next){
|
||||
if(c && !isautostick(c))
|
||||
top(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
2
main.c
2
main.c
|
@ -19,7 +19,7 @@
|
|||
|
||||
char *version[] =
|
||||
{
|
||||
"ryudo version 0.2\nCopyright (c) 1994-1996 David Hogan,\n(c) 2004 Russ Cox,\n(c) 2019-2021 Derek Stevens", 0
|
||||
"ryudo version 0.3\nCopyright (c) 1994-1996 David Hogan,\n(c) 2004 Russ Cox,\n(c) 2019-2021 Derek Stevens", 0
|
||||
};
|
||||
|
||||
Display *dpy;
|
||||
|
|
6
manage.c
6
manage.c
|
@ -29,7 +29,6 @@ manage(Client *c, int mapped)
|
|||
XClassHint class;
|
||||
XWMHints *hints;
|
||||
XSetWindowAttributes attrs;
|
||||
|
||||
trace("manage", c, 0);
|
||||
XSelectInput(dpy, c->window, ColormapChangeMask | EnterWindowMask | PropertyChangeMask | FocusChangeMask | KeyPressMask);
|
||||
|
||||
|
@ -40,9 +39,12 @@ manage(Client *c, int mapped)
|
|||
c->class = class.res_class;
|
||||
c->is9term = 0;
|
||||
if(isNew){
|
||||
c->is9term = strstr(c->class, "term") || strstr(c->class, "Term") || strstr (c->class, "urxvt") || strstr (c->class, "URxvt");
|
||||
c->is9term = strstr(c->class, "term") || strstr(c->class, "Term")
|
||||
|| strstr(c->class, "urxvt") || strstr(c->class, "URxvt")
|
||||
|| strstr(c->class, "onsole") || strstr(c->class, "Alacritty");
|
||||
isNew = 0;
|
||||
}
|
||||
printf("%s: is9term = %d", c->class, c->is9term);
|
||||
}
|
||||
else {
|
||||
c->instance = 0;
|
||||
|
|
19
menu.c
19
menu.c
|
@ -14,9 +14,9 @@
|
|||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "config.h"
|
||||
#include "dat.h"
|
||||
#include "fns.h"
|
||||
#include "config.h"
|
||||
|
||||
Client *hiddenc[MAXHIDDEN];
|
||||
|
||||
|
@ -396,11 +396,6 @@ button2(int n)
|
|||
void
|
||||
switch_to_c(int n, Client *c)
|
||||
{
|
||||
#ifdef AUTOSTICK
|
||||
static char *autostick[] = AUTOSTICK;
|
||||
char **a = autostick;
|
||||
#endif
|
||||
|
||||
if(c == 0)
|
||||
return;
|
||||
|
||||
|
@ -411,11 +406,8 @@ switch_to_c(int n, Client *c)
|
|||
return;
|
||||
|
||||
#ifdef AUTOSTICK
|
||||
while(*a){
|
||||
if (strstr(c->class, *a) && c->virt >= 0) {
|
||||
stick(c);
|
||||
}
|
||||
++a;
|
||||
if(c->virt >= 0 && isautostick(c)){
|
||||
stick(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -461,6 +453,7 @@ switch_to(int n)
|
|||
|
||||
switch_to_c(n, clients);
|
||||
current = currents[virt];
|
||||
top(current);
|
||||
if(fork() == 0)
|
||||
{
|
||||
close(ConnectionNumber(dpy));
|
||||
|
@ -470,8 +463,8 @@ switch_to(int n)
|
|||
signal(SIGTERM, SIG_DFL);
|
||||
signal(SIGHUP, SIG_DFL);
|
||||
#ifdef VIRTNOTIFY
|
||||
sprintf(virtmsg, "virtual: switched to %s", b2items[virt]);
|
||||
execlp("notify-send", "notify-send", "-c", "virtual", virtmsg, (char*)0);
|
||||
sprintf(virtmsg, VIRTMSG, b2items[virt]);
|
||||
execlp("notify-send", "notify-send", "-c", "virtual", VIRTHEADER, virtmsg, (char*)0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue