diff --git a/client.c b/client.c index 2fff881..c5f78e7 100755 --- a/client.c +++ b/client.c @@ -8,6 +8,7 @@ #include #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 + diff --git a/config.h b/config.h index 89bbddf..46786ee 100755 --- a/config.h +++ b/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\ } diff --git a/event.c b/event.c index 6e1f493..1a0b85c 100755 --- a/event.c +++ b/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 } } diff --git a/fns.h b/fns.h index 6da358c..565d071 100755 --- a/fns.h +++ b/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(); diff --git a/key.c b/key.c index c40e558..cad863f 100755 --- a/key.c +++ b/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; ikeycode == 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 diff --git a/main.c b/main.c index 35d686c..0507620 100755 --- a/main.c +++ b/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; diff --git a/manage.c b/manage.c index ef40b9a..0586ee8 100755 --- a/manage.c +++ b/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; diff --git a/menu.c b/menu.c index ce4c824..53e9e6a 100755 --- a/menu.c +++ b/menu.c @@ -14,9 +14,9 @@ #include #include #include +#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 } }