From 404424f51836437cd0346a80acc7de77b19f6f81 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sun, 7 Mar 2021 23:35:01 -0500 Subject: [PATCH 01/17] config.h: reorganize config.h and update documentation; key,c: make all keybinds except alt-tab optional --- config.h | 207 +++++++++++++++++++++++++++++++++---------------------- key.c | 166 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 288 insertions(+), 85 deletions(-) diff --git a/config.h b/config.h index 42494ef..624d275 100644 --- a/config.h +++ b/config.h @@ -1,101 +1,44 @@ -#define SHOLDCOL 0xC8C8C8 -#define HOLDCOL 0x444444 +/*********************** + * RYUDO CONFIGURATION * + **********************/ + +/*************** + * LOOK & FEEL * + **************/ + +/* Border colors */ #define SBORDERCOL 0x17736C #define BORDERCOL 0x000000 + +/* Window sweep border color */ #define GHOSTCOL 0x797979 + +/* Hold mode border colors -- if you don't use 9term you don't need to + * care what these are + */ +#define SHOLDCOL 0xC8C8C8 +#define HOLDCOL 0x444444 + +/* Border width in pixels */ #define BORDER 4 -/* Should be even */ +/* Gap size, in pixels, for pseudo-tiling. Should be even */ #define GAPSZ 4 +/* Menu border width and color */ #define MENUBORDER 0 #define MBORDERCOL 0x000000 + +/* Normal menu colors */ #define MENUFGCOL 0x797979 #define MENUBGCOL 0x000000 + +/* Selected menu colors */ #define SMENUFGCOL 0x000000 #define SMENUBGCOL 0x1F9B92 -/* This sets the size ratio for windows spawned via keyboard or - * center-snapped; CENTERNUM should be >= 2, so use 2/4 instead of 1/2 - */ -#define CENTERNUM 2 -#define CENTERDEN 3 - -/* Centered windows should maximize vertically by default? - * This is the behavior of new windows spawned with the launch shortcut - * and of centered windows with SHORTCUTMOD + SNAPCENTER_KEY -- - * use SHORTCUTMOD + SHIFT + SNAPCENTER_KEY to get the other behavior. - */ -#define CENTERVMAX - -/* Show 'Stick' menuitem? */ -//#define SHOWSTICK - -/* Notify on virtual desktop switch? */ -#define VIRTNOTIFY - -/* The summary and message to pass to the notifcation daeomon */ -#define VIRTHEADER "virtual" -#define VIRTMSG "[%s]" - -/* Modifier key and associated modifier bits; - * 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) - -/* Shortcut keys */ - -#define MAX_KEY XK_m -#define ICON_KEY XK_i -#define UNHIDE_KEY XK_u -#define MOVE_KEY XK_v -#define RESIZE_KEY XK_r -#define DESTROY_KEY XK_d -#define STICK_KEY XK_s -#define ZOOM_KEY XK_z - -#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 -#define SNAPBOTTOM_KEY XK_j - -#define SNAPTOPLEFT_KEY XK_q -#define SNAPBOTTOMLEFT_KEY XK_w -#define SNAPBOTTOMRIGHT_KEY XK_o -#define SNAPTOPRIGHT_KEY XK_p - -#define SNAPCENTER_KEY XK_c - -#define NEXTVIRT_KEY XK_Right -#define PREVVIRT_KEY XK_Left - -#define LAUNCH_KEY XK_slash - // clang-format off -/* List of window classes to spawn as sticky; - * Class values for currently open windows are conveniently shown in the last - * column of the 'xshove' command given with no arguments. - * Remember the backslash at the end of non-terminating lines! - */ - -#define AUTOSTICK {\ - "XOsview", \ - "XClock", \ - 0 \ -} - /* List of fonts to try, in order, for rendering the menus. * Remember the backslash at the end of non-terminating lines! */ @@ -133,3 +76,103 @@ } // clang-format on + +/************ + * BEHAVIOR * + ***********/ + +/* This sets the size ratio for windows spawned via keyboard or + * center-snapped; CENTERNUM should be >= 2, so use 2/4 instead of 1/2 + */ +#define CENTERNUM 2 +#define CENTERDEN 3 + +/* Centered windows should maximize vertically by default? + * This is the behavior of new windows spawned with the launch shortcut + * and of centered windows with SHORTCUTMOD + SNAPCENTER_KEY -- + * use SHORTCUTMOD + SHIFT + SNAPCENTER_KEY to get the other behavior. + */ +#define CENTERVMAX + +/* Show 'Stick' menuitem? */ +//#define SHOWSTICK + +/* Notify on virtual desktop switch? */ +#define VIRTNOTIFY + +/* The summary and message to pass to the notifcation daeomon */ +#define VIRTHEADER "virtual" +#define VIRTMSG "[%s]" + +// clang-format off + +/* List of window classes to spawn as sticky; + * Class values for currently open windows are conveniently shown in the last + * column of the 'xshove' command given with no arguments. + * Remember the backslash at the end of non-terminating lines! + */ + +/* You can remove/comment the entire macro to improve performance if you + * don't use this feature! + */ + +#define AUTOSTICK {\ + "XOsview", \ + "XClock", \ + 0 \ +} + +// clang-format on + +/*************** + * KEYBINDINGS * + **************/ + +/* Modifier key and associated modifier bits; + * 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) + +/* Shortcut keys */ +/* Any of these can be commented out/omitted if you want to free up + * your keyboard shortcuts for other things. Alt-tab is always bound. + */ + +#define MAX_KEY XK_m +#define ICON_KEY XK_i +#define UNHIDE_KEY XK_u +#define MOVE_KEY XK_v +#define RESIZE_KEY XK_r +#define DESTROY_KEY XK_d +#define STICK_KEY XK_s +#define ZOOM_KEY XK_z + +#define SNAPLEFT_KEY XK_h +#define SNAPRIGHT_KEY XK_l +#define SNAPTOP_KEY XK_k +#define SNAPBOTTOM_KEY XK_j + +#define SNAPTOPLEFT_KEY XK_q +#define SNAPBOTTOMLEFT_KEY XK_w +#define SNAPBOTTOMRIGHT_KEY XK_o +#define SNAPTOPRIGHT_KEY XK_p + +#define SNAPCENTER_KEY XK_c + +#define NEXTVIRT_KEY XK_Right +#define PREVVIRT_KEY XK_Left + +#define LAUNCH_KEY XK_slash + +// ignore these for now -- this is a feature in development +#define STICKYTOFRONT_KEY XK_t +#define STICKYTOBACK_KEY XK_b diff --git a/key.c b/key.c index 84189ab..bd96264 100644 --- a/key.c +++ b/key.c @@ -30,26 +30,66 @@ static void alttab(int shift); void keysetup(void) { int i; int tabcode = XKeysymToKeycode(dpy, XK_Tab); +#ifdef DESTROY_KEY int dcode = XKeysymToKeycode(dpy, DESTROY_KEY); +#endif +#ifdef ICON_KEY int icode = XKeysymToKeycode(dpy, ICON_KEY); +#endif +#ifdef UNHIDE_KEY int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY); +#endif +#ifdef MAX_KEY int mcode = XKeysymToKeycode(dpy, MAX_KEY); +#endif +#ifdef MOVE_KEY int vcode = XKeysymToKeycode(dpy, MOVE_KEY); +#endif +#ifdef RESIZE_KEY int rcode = XKeysymToKeycode(dpy, RESIZE_KEY); +#endif +#ifdef STICK_KEY int scode = XKeysymToKeycode(dpy, STICK_KEY); +#endif +#ifdef SNAPLEFT_KEY int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY); +#endif +#ifdef SNAPRIGHT_KEY int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY); +#endif +#ifdef SNAPBOTTOM_KEY int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY); +#endif +#ifdef SNAPTOP_KEY int kcode = XKeysymToKeycode(dpy, SNAPTOP_KEY); +#endif +#ifdef SNAPTOPLEFT_KEY int qcode = XKeysymToKeycode(dpy, SNAPTOPLEFT_KEY); +#endif +#ifdef SNAPBOTTOMLEFT_KEY int wcode = XKeysymToKeycode(dpy, SNAPBOTTOMLEFT_KEY); +#endif +#ifdef SNAPBOTTOMRIGHT_KEY int ocode = XKeysymToKeycode(dpy, SNAPBOTTOMRIGHT_KEY); +#endif +#ifdef SNAPTOPRIGHT_KEY int pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY); +#endif +#ifdef SNAPCENTER_KEY int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY); +#endif +#ifdef LAUNCH_KEY int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY); +#endif +#ifdef ZOOM_KEY int zcode = XKeysymToKeycode(dpy, ZOOM_KEY); +#endif +#ifdef NEXTVIRT_KEY int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY); +#endif +#ifdef PREVVIRT_KEY int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY); +#endif #ifdef DEVEL int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY); int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY); @@ -64,6 +104,7 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#ifdef DESTROY_KEY XGrabKey( dpy, dcode, @@ -72,6 +113,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef ICON_KEY XGrabKey( dpy, icode, @@ -80,6 +123,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef UNHIDE_KEY XGrabKey( dpy, ucode, @@ -88,6 +133,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef RESIZE_KEY XGrabKey( dpy, rcode, @@ -96,6 +143,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef MOVE_KEY XGrabKey( dpy, vcode, @@ -104,6 +153,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef MAX_KEY XGrabKey( dpy, mcode, @@ -112,6 +163,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef STICK_KEY XGrabKey( dpy, scode, @@ -120,6 +173,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPLEFT_KEY XGrabKey( dpy, hcode, @@ -128,6 +183,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPRIGHT_KEY XGrabKey( dpy, lcode, @@ -136,6 +193,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPBOTTOM_KEY XGrabKey( dpy, jcode, @@ -144,6 +203,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPTOP_KEY XGrabKey( dpy, kcode, @@ -152,6 +213,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPTOPLEFT_KEY XGrabKey( dpy, qcode, @@ -160,6 +223,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPBOTTOMLEFT_KEY XGrabKey( dpy, wcode, @@ -168,6 +233,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPBOTTOMRIGHT_KEY XGrabKey( dpy, ocode, @@ -176,6 +243,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPTOPRIGHT_KEY XGrabKey( dpy, pcode, @@ -184,6 +253,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef SNAPCENTER_KEY XGrabKey( dpy, ccode, @@ -200,6 +271,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef PREVVIRT_KEY XGrabKey( dpy, leftcode, @@ -208,6 +281,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef NEXTVIRT_KEY XGrabKey( dpy, rightcode, @@ -216,6 +291,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef LAUNCH_KEY XGrabKey( dpy, slcode, @@ -224,6 +301,8 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif +#ifdef ZOOM_KEY XGrabKey( dpy, zcode, @@ -232,6 +311,7 @@ void keysetup(void) { 0, GrabModeSync, GrabModeAsync); +#endif XGrabKey( dpy, tabcode, @@ -272,26 +352,66 @@ void keypress(XKeyEvent* e) { * process key press here */ int tabcode = XKeysymToKeycode(dpy, XK_Tab); +#ifdef DESTROY_KEY int dcode = XKeysymToKeycode(dpy, DESTROY_KEY); +#endif +#ifdef ICON_KEY int icode = XKeysymToKeycode(dpy, ICON_KEY); +#endif +#ifdef UNHIDE_KEY int ucode = XKeysymToKeycode(dpy, UNHIDE_KEY); +#endif +#ifdef MAX_KEY int mcode = XKeysymToKeycode(dpy, MAX_KEY); +#endif +#ifdef MOVE_KEY int vcode = XKeysymToKeycode(dpy, MOVE_KEY); +#endif +#ifdef STICK_KEY int scode = XKeysymToKeycode(dpy, STICK_KEY); +#endif +#ifdef RESIZE_KEY int rcode = XKeysymToKeycode(dpy, RESIZE_KEY); +#endif +#ifdef LAUNCH_KEY int slcode = XKeysymToKeycode(dpy, LAUNCH_KEY); +#endif +#ifdef ZOOM_KEY int zcode = XKeysymToKeycode(dpy, ZOOM_KEY); +#endif +#ifdef SNAPLEFT_KEY int hcode = XKeysymToKeycode(dpy, SNAPLEFT_KEY); +#endif +#ifdef SNAPRIGHT_KEY int lcode = XKeysymToKeycode(dpy, SNAPRIGHT_KEY); +#endif +#ifdef SNAPBOTTOM_KEY int jcode = XKeysymToKeycode(dpy, SNAPBOTTOM_KEY); +#endif +#ifdef SNAPTOP_KEY int kcode = XKeysymToKeycode(dpy, SNAPTOP_KEY); +#endif +#ifdef SNAPTOPLEFT_KEY int qcode = XKeysymToKeycode(dpy, SNAPTOPLEFT_KEY); +#endif +#ifdef SNAPBOTTOMLEFT_KEY int wcode = XKeysymToKeycode(dpy, SNAPBOTTOMLEFT_KEY); +#endif +#ifdef SNAPBOTTOMRIGHT_KEY int ocode = XKeysymToKeycode(dpy, SNAPBOTTOMRIGHT_KEY); +#endif +#ifdef SNAPTOPRIGHT_KEY int pcode = XKeysymToKeycode(dpy, SNAPTOPRIGHT_KEY); +#endif +#ifdef SNAPCENTER_KEY int ccode = XKeysymToKeycode(dpy, SNAPCENTER_KEY); +#endif +#ifdef NEXTVIRT_KEY int rightcode = XKeysymToKeycode(dpy, NEXTVIRT_KEY); +#endif +#ifdef PREVVIRT_KEY int leftcode = XKeysymToKeycode(dpy, PREVVIRT_KEY); +#endif #ifdef DEVEL int tcode = XKeysymToKeycode(dpy, STICKYTOFRONT_KEY); int bcode = XKeysymToKeycode(dpy, STICKYTOBACK_KEY); @@ -303,16 +423,27 @@ void keypress(XKeyEvent* e) { /* basic wm functionality */ if (e->keycode == tabcode && (e->state & Mod1Mask) == (1 << 3)) alttab(e->state & ShiftMask); +#ifdef DESTROY_KEY else if (e->keycode == dcode && (e->state & SHORTCUTMOD) == (MODBITS)) delete (current, 0); +#endif +#ifdef ICON_KEY else if (e->keycode == icode && (e->state & SHORTCUTMOD) == (MODBITS)) hide(current); +#endif +#ifdef UNHIDE_KEY else if (e->keycode == ucode && (e->state & SHORTCUTMOD) == (MODBITS)) unhide(0, 1); +#endif +#ifdef MOVE_KEY else if (e->keycode == vcode && (e->state & SHORTCUTMOD) == (MODBITS)) move(current, Button3); +#endif +#ifdef RESIZE_KEY else if (e->keycode == rcode && (e->state & SHORTCUTMOD) == (MODBITS)) reshape(current, Button3, sweep, 0); +#endif +#ifdef MAX_KEY else if (e->keycode == mcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -320,12 +451,18 @@ void keypress(XKeyEvent* e) { -BORDER, ra.width + 2 * BORDER, ra.height + 2 * BORDER); +#endif +#ifdef STICK_KEY else if (e->keycode == scode && (e->state & SHORTCUTMOD) == (MODBITS)) stick(current); +#endif +#ifdef ZOOM_KEY else if (e->keycode == zcode && (e->state & SHORTCUTMOD) == (MODBITS)) zoom = !zoom; +#endif /* half snap */ +#ifdef SNAPLEFT_KEY else if (e->keycode == hcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -333,6 +470,8 @@ void keypress(XKeyEvent* e) { GAPSZ, ra.width / 2 - 1.5 * GAPSZ, ra.height - 2 * GAPSZ); +#endif +#ifdef SNAPRIGHT_KEY else if (e->keycode == lcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -340,6 +479,8 @@ void keypress(XKeyEvent* e) { GAPSZ, ra.width / 2 - 1.5 * GAPSZ, ra.height - 2 * GAPSZ); +#endif +#ifdef SNAPBOTTOM_KEY else if (e->keycode == jcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -347,6 +488,8 @@ void keypress(XKeyEvent* e) { ra.height / 2 + 0.5 * GAPSZ, ra.width - 2 * GAPSZ, ra.height / 2 - 1.5 * GAPSZ); +#endif +#ifdef SNAPTOP_KEY else if (e->keycode == kcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -354,8 +497,10 @@ void keypress(XKeyEvent* e) { GAPSZ, ra.width - 2 * GAPSZ, ra.height / 2 - 1.5 * GAPSZ); +#endif /* quarter snap */ +#ifdef SNAPTOPLEFT_KEY else if (e->keycode == qcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -363,6 +508,8 @@ void keypress(XKeyEvent* e) { GAPSZ, ra.width / 2 - 1.5 * GAPSZ, ra.height / 2 - 1.5 * GAPSZ); +#endif +#ifdef SNAPBOTTOMLEFT_KEY else if (e->keycode == wcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -370,6 +517,8 @@ void keypress(XKeyEvent* e) { ra.height / 2 + 0.5 * GAPSZ, ra.width / 2 - 1.5 * GAPSZ, ra.height / 2 - 1.5 * GAPSZ); +#endif +#ifdef SNAPBOTTOMRIGHT_KEY else if (e->keycode == ocode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -377,6 +526,8 @@ void keypress(XKeyEvent* e) { ra.height / 2 + 0.5 * GAPSZ, ra.width / 2 - 1.5 * GAPSZ, ra.height / 2 - 1.5 * GAPSZ); +#endif +#ifdef SNAPTOPRIGHT_KEY else if (e->keycode == pcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( current, @@ -384,8 +535,10 @@ void keypress(XKeyEvent* e) { GAPSZ, ra.width / 2 - 1.5 * GAPSZ, ra.height / 2 - 1.5 * GAPSZ); +#endif /* center snap */ +#ifdef CENTERSNAP_KEY else if (e->keycode == ccode && (e->state & SHORTCUTMOD) == (MODBITS)) { if ((e->state & ShiftMask) == (1 << 0)) { #ifdef CENTERVMAX @@ -401,6 +554,7 @@ void keypress(XKeyEvent* e) { #endif } } +#endif #ifdef DEVEL /* manage autostuck windows */ @@ -411,7 +565,8 @@ void keypress(XKeyEvent* e) { #endif /* launch */ - if (e->keycode == slcode && (e->state & SHORTCUTMOD) == (MODBITS)) { +#ifdef LAUNCH_KEY + else if (e->keycode == slcode && (e->state & SHORTCUTMOD) == (MODBITS)) { kbLaunch = 1; if (fork() == 0) { close(ConnectionNumber(dpy)); @@ -431,21 +586,26 @@ void keypress(XKeyEvent* e) { perror("ryudo: exec urxvt/9term/xterm failed"); } } +#endif /* switch virts */ - if (e->keycode == rightcode && (e->state & SHORTCUTMOD) == (MODBITS)) +#ifdef NEXTVIRT_KEY + else if (e->keycode == rightcode && (e->state & SHORTCUTMOD) == (MODBITS)) if (numvirtuals > 1) if (virt < numvirtuals - 1) switch_to(virt + 1); else switch_to(0); +#endif - if (e->keycode == leftcode && (e->state & SHORTCUTMOD) == (MODBITS)) +#ifdef PREVVIRT_KEY + else if (e->keycode == leftcode && (e->state & SHORTCUTMOD) == (MODBITS)) if (numvirtuals > 1) if (virt > 0) switch_to(virt - 1); else switch_to(numvirtuals - 1); +#endif XAllowEvents(dpy, SyncKeyboard, e->time); } From 5f0c7eaf259ea65ea8c79df63eac644a438989d1 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 8 Mar 2021 15:51:53 -0500 Subject: [PATCH 02/17] add SHOWMAX option and maximize menu item, fix (I think) shuffle on delete to only shuffle if there is no current after deletion --- config.h | 3 +++ dat.h | 4 +++- menu.c | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/config.h b/config.h index 624d275..4b7c6c8 100644 --- a/config.h +++ b/config.h @@ -94,6 +94,9 @@ */ #define CENTERVMAX +/* Show 'Maximize' menuitem? */ +//#define SHOWMAX + /* Show 'Stick' menuitem? */ //#define SHOWSTICK diff --git a/dat.h b/dat.h index fd4ea2e..c2a70d1 100644 --- a/dat.h +++ b/dat.h @@ -6,7 +6,9 @@ #define CORNER _corner #define INSET _inset #define MAXHIDDEN 128 -#ifdef SHOWSTICK +#if defined (SHOWMAX) && defined (SHOWSTICK) +#define B3FIXED 7 +#elif defined (SHOWMAX) || defined (SHOWSTICK) #define B3FIXED 6 #else #define B3FIXED 5 diff --git a/menu.c b/menu.c index c496941..b9b727b 100644 --- a/menu.c +++ b/menu.c @@ -35,24 +35,38 @@ char* b3items[B3FIXED + MAXHIDDEN + 1] = { "New", "Reshape", "Move", - "Delete", - "Hide", +#if defined(SHOWMAX) && defined(SHOWSTICK) + "Maximize", + "Stick", +#else +#ifdef SHOWMAX + "Maximize", +#endif #ifdef SHOWSTICK "Stick", #endif +#endif + "Delete", + "Hide", 0}; enum { New, Reshape, Move, - Delete, -#ifdef SHOWSTICK - Hide, - Stick +#if defined(SHOWMAX) && defined(SHOWSTICK) + Maximize, + Stick, #else - Hide +#ifdef SHOWMAX + Maximize, #endif +#ifdef SHOWSTICK + Stick, +#endif +#endif + Delete, + Hide }; Menu b3menu = {b3items}; @@ -65,6 +79,9 @@ void button(XButtonEvent* e) { Window dw; ScreenInfo* s; + static XWindowAttributes ra; + XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &ra); + curtime = e->time; s = getscreen(e->root); if (s == 0) @@ -170,6 +187,23 @@ void button(XButtonEvent* e) { case Hide: hide(selectwin(1, 0, s)); break; +#ifdef SHOWMAX + case Maximize: + c = selectwin(1, 0, s); +#ifdef AUTOSTICK + if (isautostick(c)) + break; +#endif + quickreshape( + c, + -BORDER, + -BORDER, + ra.width + 2 * BORDER, + ra.height + 2 * BORDER); + active(c); + top(c); + break; +#endif #ifdef SHOWSTICK case Stick: stick(selectwin(1, 0, s)); @@ -260,13 +294,13 @@ void move(Client* c, int but) { } void delete (Client* c, int shift) { - int v; + //int v; if (c == 0) return; - v = c->virt; + //v = c->virt; if ((c->proto & Pdelete) && !shift) { sendcmessage(c->window, wm_protocols, wm_delete, 0, 0); - if (v == virt) { + if (!current) { shuffle(0); } } From 22f9147cabd1a1241ab45448a7f9c72ea537aa44 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 8 Mar 2021 15:52:39 -0500 Subject: [PATCH 03/17] manage.c: remove debugging message --- manage.c | 1 - 1 file changed, 1 deletion(-) diff --git a/manage.c b/manage.c index 1648f1e..8ae4f16 100644 --- a/manage.c +++ b/manage.c @@ -51,7 +51,6 @@ int manage(Client* c, int mapped) { strstr(c->class, "onsole") || strstr(c->class, "Alacritty"); isNew = 0; } - printf("%s: is9term = %d", c->class, c->is9term); } else { c->instance = 0; c->class = 0; From ae878964213b0a86f01c722114729dd4560f2c43 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Tue, 9 Mar 2021 00:34:00 -0500 Subject: [PATCH 04/17] key.c: fix unguarded else ifs for virt switching --- key.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/key.c b/key.c index bd96264..81d957b 100644 --- a/key.c +++ b/key.c @@ -538,7 +538,7 @@ void keypress(XKeyEvent* e) { #endif /* center snap */ -#ifdef CENTERSNAP_KEY +#ifdef SNAPCENTER_KEY else if (e->keycode == ccode && (e->state & SHORTCUTMOD) == (MODBITS)) { if ((e->state & ShiftMask) == (1 << 0)) { #ifdef CENTERVMAX @@ -590,21 +590,23 @@ void keypress(XKeyEvent* e) { /* switch virts */ #ifdef NEXTVIRT_KEY - else if (e->keycode == rightcode && (e->state & SHORTCUTMOD) == (MODBITS)) + else if (e->keycode == rightcode && (e->state & SHORTCUTMOD) == (MODBITS)) { if (numvirtuals > 1) if (virt < numvirtuals - 1) switch_to(virt + 1); else switch_to(0); + } #endif #ifdef PREVVIRT_KEY - else if (e->keycode == leftcode && (e->state & SHORTCUTMOD) == (MODBITS)) + else if (e->keycode == leftcode && (e->state & SHORTCUTMOD) == (MODBITS)) { if (numvirtuals > 1) if (virt > 0) switch_to(virt - 1); else switch_to(numvirtuals - 1); + } #endif XAllowEvents(dpy, SyncKeyboard, e->time); From 836136e1533801b6f2abe59fdb77d7cc9f28201f Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Tue, 9 Mar 2021 00:35:05 -0500 Subject: [PATCH 05/17] fns.h, menu.c, client.c, event.c: more reliably ensure active window on delete and virtswitch --- client.c | 5 +++++ event.c | 4 +--- fns.h | 1 + menu.c | 12 +++++------- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/client.c b/client.c index 594ec77..b73ac41 100644 --- a/client.c +++ b/client.c @@ -336,3 +336,8 @@ int isautostick(Client* c) { return 0; } #endif + +void ensureactive() { + if (!current) + shuffle(0); +} diff --git a/event.c b/event.c index 1c4f214..f7a2fc1 100644 --- a/event.c +++ b/event.c @@ -306,9 +306,7 @@ void destroy(Window w) { currents[i] = 0; rmclient(c); - //if (v == virt) { - // shuffle(0); - //} + ensureactive(); /* flush any errors generated by the window's sudden demise */ ignore_badwindow = 1; diff --git a/fns.h b/fns.h index 89f8769..cced2bf 100644 --- a/fns.h +++ b/fns.h @@ -97,6 +97,7 @@ void dump_revert(); void dump_clients(); void shuffle(int); int isautostick(Client* c); +void ensureactive(); /* grab.c */ int menuhit(); diff --git a/menu.c b/menu.c index b9b727b..aef0f2e 100644 --- a/menu.c +++ b/menu.c @@ -298,14 +298,11 @@ void delete (Client* c, int shift) { if (c == 0) return; //v = c->virt; - if ((c->proto & Pdelete) && !shift) { + if ((c->proto & Pdelete) && !shift) sendcmessage(c->window, wm_protocols, wm_delete, 0, 0); - if (!current) { - shuffle(0); - } - } else XKillClient(dpy, c->window); /* let event clean up */ + ensureactive(); } void hide(Client* c) { @@ -469,7 +466,9 @@ void switch_to(int n) { switch_to_c(n, clients); current = currents[virt]; + ensureactive(); top(current); +#ifdef VIRTNOTIFY if (fork() == 0) { close(ConnectionNumber(dpy)); if (dpy != '\0') @@ -477,7 +476,6 @@ void switch_to(int n) { signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); signal(SIGHUP, SIG_DFL); -#ifdef VIRTNOTIFY sprintf(virtmsg, VIRTMSG, b2items[virt]); execlp( "notify-send", @@ -487,8 +485,8 @@ void switch_to(int n) { VIRTHEADER, virtmsg, (char*)0); -#endif } +#endif } void initb2menu(int n) { b2items[n] = 0; } From 1102e2670740470648d564620bb2008a86cf2d39 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 10 Mar 2021 00:21:17 -0500 Subject: [PATCH 06/17] config.h: document everything --- config.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/config.h b/config.h index 4b7c6c8..51ae1a9 100644 --- a/config.h +++ b/config.h @@ -3,7 +3,7 @@ **********************/ /*************** - * LOOK & FEEL * + * LOOK & FEEL * [All of these are required options] **************/ /* Border colors */ @@ -54,8 +54,9 @@ 0 \ } -/* Names for the virtual desktops. You can define all 12, or only - * as many as you use. +/* Names for the virtual desktops. Even if you don't use all of them, + * it's safer to keep dummy or null values for all of them in case you + * start the program with a different number of virtuals by happenstance. * Remember the backslash at the end of non-terminating lines! */ @@ -78,14 +79,14 @@ // clang-format on /************ - * BEHAVIOR * + * BEHAVIOR * [Everything in this section is optional unless otherwise noted] ***********/ /* This sets the size ratio for windows spawned via keyboard or * center-snapped; CENTERNUM should be >= 2, so use 2/4 instead of 1/2 */ -#define CENTERNUM 2 -#define CENTERDEN 3 +#define CENTERNUM 2 // required unless you also comment/omit SNAPCENTER_KEY +#define CENTERDEN 3 // required unless you also comment/omit SNAPCENTER_KEY /* Centered windows should maximize vertically by default? * This is the behavior of new windows spawned with the launch shortcut @@ -95,10 +96,10 @@ #define CENTERVMAX /* Show 'Maximize' menuitem? */ -//#define SHOWMAX +// #define SHOWMAX /* Show 'Stick' menuitem? */ -//#define SHOWSTICK +// #define SHOWSTICK /* Notify on virtual desktop switch? */ #define VIRTNOTIFY @@ -115,20 +116,25 @@ * Remember the backslash at the end of non-terminating lines! */ -/* You can remove/comment the entire macro to improve performance if you - * don't use this feature! - */ - #define AUTOSTICK {\ "XOsview", \ "XClock", \ 0 \ } +/* List of window classes to REQUIRE window sweeping when spawning; + * Remember the backslash at the end of non-terminating lines! + */ + +#define ALWAYSDRAW {\ + "cmapcube", \ + 0 \ +} + // clang-format on /*************** - * KEYBINDINGS * + * KEYBINDINGS * [Any shortcut key can be omitted] **************/ /* Modifier key and associated modifier bits; @@ -146,9 +152,6 @@ #define MODBITS (1 << 6) /* Shortcut keys */ -/* Any of these can be commented out/omitted if you want to free up - * your keyboard shortcuts for other things. Alt-tab is always bound. - */ #define MAX_KEY XK_m #define ICON_KEY XK_i From c4a0ea2970e8887ea7f5c47427a84e4dd6d49089 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 10 Mar 2021 00:22:21 -0500 Subject: [PATCH 07/17] key.c: zoom maximizes current window --- key.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/key.c b/key.c index 81d957b..165ff0a 100644 --- a/key.c +++ b/key.c @@ -457,8 +457,17 @@ void keypress(XKeyEvent* e) { stick(current); #endif #ifdef ZOOM_KEY - else if (e->keycode == zcode && (e->state & SHORTCUTMOD) == (MODBITS)) + else if (e->keycode == zcode && (e->state & SHORTCUTMOD) == (MODBITS)) { zoom = !zoom; + if (zoom) { + quickreshape( + current, + -BORDER, + -BORDER, + ra.width + 2 * BORDER, + ra.height + 2 * BORDER); + } + } #endif /* half snap */ From 0e0de29de9018a7db94ba2538c06c3d1f1ad3eb3 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 10 Mar 2021 00:22:55 -0500 Subject: [PATCH 08/17] grab.c: don't grab server on sweeps -- fingers crossed! --- grab.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/grab.c b/grab.c index ad16a9d..860e6ec 100644 --- a/grab.c +++ b/grab.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1994-1996 David Hogan, see README for licence details */ +./* Copyright (c) 1994-1996 David Hogan, see README for licence details */ #include #include #include @@ -555,6 +555,9 @@ void misleep(int msec) { select(0, 0, 0, 0, &t); } +/* Not grabbing the server during sweep ops might make Xorg unstable. + -drkste */ + int sweepdrag( Client* c, int but, XButtonEvent* e0, BorderOrient bl, int (*recalc)(Client*, int, int, BorderOrient, int)) { @@ -578,7 +581,7 @@ int sweepdrag( getmouse(&cx, &cy, c->screen); else getmouse(&c->x, &c->y, c->screen); - XGrabServer(dpy); + //XGrabServer(dpy); if (bl != BorderUnknown) { notmoved = recalc(c, cx, cy, bl, notmoved); } @@ -588,12 +591,12 @@ int sweepdrag( if (XCheckMaskEvent(dpy, ButtonMask, &ev) == 0) { getmouse(&rx, &ry, c->screen); if (rx != cx || ry != cy || ++idle > 300) { - drawbound(c, 0); + drawbound(c, 1); if (rx == cx && ry == cy) { - XUngrabServer(dpy); + //XUngrabServer(dpy); XFlush(dpy); - misleep(500); - XGrabServer(dpy); + //misleep(500); + //XGrabServer(dpy); idle = 0; } if (e0 || bl != BorderUnknown) @@ -614,7 +617,7 @@ int sweepdrag( case ButtonRelease: drawbound(c, 0); ungrab(e); - XUngrabServer(dpy); + //XUngrabServer(dpy); if (e->button != but && c->init) goto bad; if (c->dx < 0) { From d20e89e3a68cd498be9e8cd1c71c77f18a26f5c3 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 10 Mar 2021 19:47:46 -0500 Subject: [PATCH 09/17] grab.c: remove erroneous period at beginning of file --- grab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grab.c b/grab.c index 860e6ec..b0b14c6 100644 --- a/grab.c +++ b/grab.c @@ -1,4 +1,4 @@ -./* Copyright (c) 1994-1996 David Hogan, see README for licence details */ +/* Copyright (c) 1994-1996 David Hogan, see README for licence details */ #include #include #include From a2d3fc7ffc3d7c9a329628d05e04d9cea9dfda72 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 10 Mar 2021 20:41:53 -0500 Subject: [PATCH 10/17] grab.c: fix rendering of sweep --- grab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grab.c b/grab.c index b0b14c6..a17ab6f 100644 --- a/grab.c +++ b/grab.c @@ -591,7 +591,7 @@ int sweepdrag( if (XCheckMaskEvent(dpy, ButtonMask, &ev) == 0) { getmouse(&rx, &ry, c->screen); if (rx != cx || ry != cy || ++idle > 300) { - drawbound(c, 1); + drawbound(c, 0); if (rx == cx && ry == cy) { //XUngrabServer(dpy); XFlush(dpy); From f03abb164ad317dec9ed6898ec757b7991aac6a0 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 10 Mar 2021 22:03:49 -0500 Subject: [PATCH 11/17] manage.c, config.h, fns.h: implement ALWAYDRAW option --- config.h | 1 - fns.h | 1 + manage.c | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config.h b/config.h index 51ae1a9..e1a38e4 100644 --- a/config.h +++ b/config.h @@ -127,7 +127,6 @@ */ #define ALWAYSDRAW {\ - "cmapcube", \ 0 \ } diff --git a/fns.h b/fns.h index cced2bf..7e88fa1 100644 --- a/fns.h +++ b/fns.h @@ -60,6 +60,7 @@ void setstate(); void setlabel(); void getproto(); void gettrans(); +int shouldalwaysdraw(Client* c); /* key.c */ void keypress(); diff --git a/manage.c b/manage.c index 8ae4f16..1e2fa8d 100644 --- a/manage.c +++ b/manage.c @@ -44,7 +44,11 @@ int manage(Client* c, int mapped) { if (XGetClassHint(dpy, c->window, &class) != 0) { /* ``Success'' */ c->instance = class.res_name; c->class = class.res_class; +#ifdef ALWAYSDRAW + c->is9term = shouldalwaysdraw(c); +#else c->is9term = 0; +#endif if (isNew) { c->is9term = strstr(c->class, "term") || strstr(c->class, "Term") || strstr(c->class, "urxvt") || strstr(c->class, "URxvt") || @@ -554,3 +558,18 @@ void getproto(Client* c) { XFree((char*)p); } + +#ifdef ALWAYSDRAW +int shouldalwaysdraw(Client* c) { + static char* alwaysdraw[] = ALWAYSDRAW; + char** a = alwaysdraw; + + while (*a) { + if (c && c->class && strstr(c->class, *a)) { + return 1; + } + ++a; + } + return 0; +} +#endif From a92efcd49f35963c365a054c21be5bb878ae67bf Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 26 Apr 2021 22:41:20 -0400 Subject: [PATCH 12/17] menu: ensure active window after iconfiy --- menu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/menu.c b/menu.c index aef0f2e..916650f 100644 --- a/menu.c +++ b/menu.c @@ -331,6 +331,7 @@ void hide(Client* c) { } numhidden++; b3items[B3FIXED + numhidden] = 0; + ensureactive(); } void unhide(int n, int map) { From 2a3fb338667360987d792f062448de079116a8a9 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 26 Apr 2021 22:43:10 -0400 Subject: [PATCH 13/17] config, fns, manage: terminal classes in config instead of hardcoded in manage() --- config.h | 23 ++++++++++++++++++++--- fns.h | 1 + manage.c | 17 ++++++++++++++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/config.h b/config.h index e1a38e4..1d16182 100644 --- a/config.h +++ b/config.h @@ -113,16 +113,33 @@ /* List of window classes to spawn as sticky; * Class values for currently open windows are conveniently shown in the last * column of the 'xshove' command given with no arguments. + * Can be partial strings. * Remember the backslash at the end of non-terminating lines! */ #define AUTOSTICK {\ - "XOsview", \ - "XClock", \ - 0 \ + "XOsview", \ + "XClock", \ + 0 \ +} + +/* List of terminal window classes -- include your favorite terminal here, + * and remove those you don't use. Can be partial strings. + * This array is required. Remember the backslash at the end of non- + * terminating lines! + */ + +#define TERMINALS {\ + "term", \ + "Term", \ + "xvt", \ + "Alacritty", \ + "onsole", \ + 0 \ } /* List of window classes to REQUIRE window sweeping when spawning; + * Can be partial strings. * Remember the backslash at the end of non-terminating lines! */ diff --git a/fns.h b/fns.h index 7e88fa1..ab65645 100644 --- a/fns.h +++ b/fns.h @@ -61,6 +61,7 @@ void setlabel(); void getproto(); void gettrans(); int shouldalwaysdraw(Client* c); +int isterminalwindow(Client* c); /* key.c */ void keypress(); diff --git a/manage.c b/manage.c index 1e2fa8d..45533fa 100644 --- a/manage.c +++ b/manage.c @@ -50,9 +50,7 @@ int manage(Client* c, int mapped) { c->is9term = 0; #endif if (isNew) { - 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"); + c->is9term = isterminalwindow(c); isNew = 0; } } else { @@ -573,3 +571,16 @@ int shouldalwaysdraw(Client* c) { return 0; } #endif + +int isterminalwindow(Client* c) { + static char* termnames[] = TERMINALS; + char** t = termnames; + + while (*t) { + if (c && c->class && strstr(c->class, *t)) { + return 1; + } + ++t; + } + return 0; +} From 548f2f7cbad8bb6aaf5b2522b3f8dff9511c7ae6 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 29 Apr 2021 00:41:36 -0400 Subject: [PATCH 14/17] event: fix configure requests where a window in another desktop requests focus; client, cursor, event, grab, key, manage, menu: clang-format --- client.c | 6 +++--- cursor.c | 6 ++---- event.c | 6 ++++-- grab.c | 10 +++++----- key.c | 16 ++++++++-------- manage.c | 22 +++++++++++----------- menu.c | 6 +++--- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/client.c b/client.c index b73ac41..b7e8d55 100644 --- a/client.c +++ b/client.c @@ -303,9 +303,9 @@ void shuffle(int up) { if (zoom) { quickreshape( c, - -BORDER, - -BORDER, - ra.width + 2 * BORDER, + -BORDER, + -BORDER, + ra.width + 2 * BORDER, ra.height + 2 * BORDER); } } else { diff --git a/cursor.c b/cursor.c index 75ff861..69d0c0f 100644 --- a/cursor.c +++ b/cursor.c @@ -141,8 +141,7 @@ static char grey_bits[] = {0x01, 0x04}; static XColor bl, wh; -Cursor getcursor(Cursordata* c, ScreenInfo* s) -{ +Cursor getcursor(Cursordata* c, ScreenInfo* s) { Pixmap f, m; f = XCreatePixmapFromBitmapData( @@ -166,8 +165,7 @@ Cursor getcursor(Cursordata* c, ScreenInfo* s) return XCreatePixmapCursor(dpy, f, m, &bl, &wh, c->hot[0], c->hot[1]); } -void initcurs(ScreenInfo* s) -{ +void initcurs(ScreenInfo* s) { XColor dummy; XAllocNamedColor(dpy, DefaultColormap(dpy, s->num), "black", &bl, &dummy); diff --git a/event.c b/event.c index f7a2fc1..44b928e 100644 --- a/event.c +++ b/event.c @@ -159,6 +159,8 @@ void configurereq(XConfigureRequestEvent* e) { XConfigureWindow(dpy, c->parent, e->value_mask, &wc); if (e->value_mask & CWStackMode) { + if (c->virt > 0 && c->virt != virt) + switch_to(c->virt); top(c); active(c); } @@ -292,14 +294,14 @@ void newwindow(XCreateWindowEvent* e) { void destroy(Window w) { int i; Client* c; -// int v; + // int v; curtime = CurrentTime; c = getclient(w, 0); if (c == 0) return; -// v = c->virt; + // v = c->virt; if (numvirtuals > 1) for (i = 0; i < numvirtuals; i++) if (currents[i] == c) diff --git a/grab.c b/grab.c index a17ab6f..136ab5f 100644 --- a/grab.c +++ b/grab.c @@ -581,7 +581,7 @@ int sweepdrag( getmouse(&cx, &cy, c->screen); else getmouse(&c->x, &c->y, c->screen); - //XGrabServer(dpy); + // XGrabServer(dpy); if (bl != BorderUnknown) { notmoved = recalc(c, cx, cy, bl, notmoved); } @@ -593,10 +593,10 @@ int sweepdrag( if (rx != cx || ry != cy || ++idle > 300) { drawbound(c, 0); if (rx == cx && ry == cy) { - //XUngrabServer(dpy); + // XUngrabServer(dpy); XFlush(dpy); - //misleep(500); - //XGrabServer(dpy); + // misleep(500); + // XGrabServer(dpy); idle = 0; } if (e0 || bl != BorderUnknown) @@ -617,7 +617,7 @@ int sweepdrag( case ButtonRelease: drawbound(c, 0); ungrab(e); - //XUngrabServer(dpy); + // XUngrabServer(dpy); if (e->button != but && c->init) goto bad; if (c->dx < 0) { diff --git a/key.c b/key.c index 165ff0a..a74d6b7 100644 --- a/key.c +++ b/key.c @@ -461,11 +461,11 @@ void keypress(XKeyEvent* e) { zoom = !zoom; if (zoom) { quickreshape( - current, - -BORDER, - -BORDER, - ra.width + 2 * BORDER, - ra.height + 2 * BORDER); + current, + -BORDER, + -BORDER, + ra.width + 2 * BORDER, + ra.height + 2 * BORDER); } } #endif @@ -508,7 +508,7 @@ void keypress(XKeyEvent* e) { ra.height / 2 - 1.5 * GAPSZ); #endif - /* quarter snap */ + /* quarter snap */ #ifdef SNAPTOPLEFT_KEY else if (e->keycode == qcode && (e->state & SHORTCUTMOD) == (MODBITS)) quickreshape( @@ -546,7 +546,7 @@ void keypress(XKeyEvent* e) { ra.height / 2 - 1.5 * GAPSZ); #endif - /* center snap */ + /* center snap */ #ifdef SNAPCENTER_KEY else if (e->keycode == ccode && (e->state & SHORTCUTMOD) == (MODBITS)) { if ((e->state & ShiftMask) == (1 << 0)) { @@ -573,7 +573,7 @@ void keypress(XKeyEvent* e) { stickystack(0); #endif - /* launch */ + /* launch */ #ifdef LAUNCH_KEY else if (e->keycode == slcode && (e->state & SHORTCUTMOD) == (MODBITS)) { kbLaunch = 1; diff --git a/manage.c b/manage.c index 45533fa..2f0ae24 100644 --- a/manage.c +++ b/manage.c @@ -224,9 +224,9 @@ int manage(Client* c, int mapped) { if (zoom) { quickreshape( c, - -BORDER, - -BORDER, - ra.width + 2 * BORDER, + -BORDER, + -BORDER, + ra.width + 2 * BORDER, ra.height + 2 * BORDER); } @@ -560,15 +560,15 @@ void getproto(Client* c) { #ifdef ALWAYSDRAW int shouldalwaysdraw(Client* c) { static char* alwaysdraw[] = ALWAYSDRAW; - char** a = alwaysdraw; - - while (*a) { - if (c && c->class && strstr(c->class, *a)) { - return 1; - } - ++a; + char** a = alwaysdraw; + + while (*a) { + if (c && c->class && strstr(c->class, *a)) { + return 1; } - return 0; + ++a; + } + return 0; } #endif diff --git a/menu.c b/menu.c index 916650f..530c477 100644 --- a/menu.c +++ b/menu.c @@ -182,7 +182,7 @@ void button(XButtonEvent* e) { case Delete: shift = 0; c = selectwin(1, &shift, s); - delete(c, shift); + delete (c, shift); break; case Hide: hide(selectwin(1, 0, s)); @@ -294,10 +294,10 @@ void move(Client* c, int but) { } void delete (Client* c, int shift) { - //int v; + // int v; if (c == 0) return; - //v = c->virt; + // v = c->virt; if ((c->proto & Pdelete) && !shift) sendcmessage(c->window, wm_protocols, wm_delete, 0, 0); else From 80d5a8db52eed2f354a9053c25be333ca13c8fef Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 12 May 2021 20:50:09 -0600 Subject: [PATCH 15/17] change build system --- build.sh | 6 ++++++ install.sh | 20 ++++++++++++++++++++ mkfile | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 build.sh create mode 100755 install.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..74ceeaf --- /dev/null +++ b/build.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +mk clean +mk o.rio + +mv o.rio ryudo diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..82ac188 --- /dev/null +++ b/install.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ -z "$PLAN9" ]; then + echo "PLAN9 not set;" + echo "Please set it to the location of your plan9port installation." + exit 1 +fi + +if [ $(whoami) != "root" ]; then + mkdir -p ~/bin/9 + cp ryudo ~/bin/9/ryudo + echo "ryudo has been installed to '${HOME}/bin/9/';" + echo "You may want to add it to your PATH." + echo "The manual pages were not installed." +else + cp ryudo $PLAN9/bin/ryudo + cp ryudo.1 $PLAN9/man/man1/ryudo.1 + echo "ryudo has been installed to '${PLAN9}/bin/';" + echo "The manual pages have been installed to '${PLAN9}/man/'" +fi diff --git a/mkfile b/mkfile index c4b22d2..052c9a3 100755 --- a/mkfile +++ b/mkfile @@ -1,5 +1,5 @@ <$PLAN9/src/mkhdr -<|sh /usr/lib/plan9/src/cmd/devdraw/mkwsysrules.sh # for X11 +<|sh $PLAN9/src/cmd/devdraw/mkwsysrules.sh # for X11 RIOFILES=\ client.$O\ From eb4238f6f1cd09b508ddf501e44b437aaf9565f0 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 12 May 2021 20:53:14 -0600 Subject: [PATCH 16/17] update README --- README.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c7fa617..d5a061b 100755 --- a/README.md +++ b/README.md @@ -52,17 +52,11 @@ window centered (its exact geometry is configurable via `config.h`). ### Dependencies, Building, Installation Being forked from Rio, Ryudo requires `plan9port`, `Xlib`, and `Xt`. If you enable notifications, it of course requires `notify-send`. -Make it with `mk ryudo` and then copy the resulting executable `ryudo` to -somewhere in your **PATH** -If you try to install it with `mk install` it will probably install -to `$PLAN9/bin/` under the name `rio`. This is less than ideal but I'm -not a master of mk, so my protocol is to use a mk target `ryudo` which -builds the program as `o.rio`, then calls `ryudomagic.sh` to rename -the program. A proper mkfile is planned before version 1.0. +Build with `build.sh` (calls `mk` and does some other magic), and install with `install.sh` (will install to a local folder if run as a normal user, or to your `$PLAN9/bin/` if run as root). -If you have trouble building, you might need to edit the **mkfile** at line 2 -to point to the proper location of your plan9port's **mkwsysrules.sh**. +If you have trouble building, you might need to edit the `mkfile` at line 2 +to point to the proper location of your plan9port's `mkwsysrules.sh`. ### Bugs and Caveats Of the bugs and caveats not already mentioned in Rio's readme: From ec7fa1925fc2e65db7b4f2c20a56b6f48885b737 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Wed, 12 May 2021 20:54:17 -0600 Subject: [PATCH 17/17] remove ryudomagic.sh --- ryudomagic.sh | 1 - 1 file changed, 1 deletion(-) delete mode 100755 ryudomagic.sh diff --git a/ryudomagic.sh b/ryudomagic.sh deleted file mode 100755 index 079ca9c..0000000 --- a/ryudomagic.sh +++ /dev/null @@ -1 +0,0 @@ -mv $O.rio ryudo