From: Michael D. Lowis Date: Thu, 2 Apr 2020 11:10:34 +0000 (-0400) Subject: tweaked mouse handling to have close operation require ModKey press as well. This... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=29e17fa7bb105ca42082ac5615040b904fe11b40;p=proto%2Fanvil.git tweaked mouse handling to have close operation require ModKey press as well. This allows use to use middle click to expand clients in place. Also added Shift+ModKey to toggle between floating and tiled --- diff --git a/anvil.h b/anvil.h index d955314..e32152e 100644 --- a/anvil.h +++ b/anvil.h @@ -109,6 +109,11 @@ typedef struct { #define MIN_HEIGHT (TITLE_HEIGHT+BORDER_WIDTH) #define MIN_COL_FACT 0.20 #define FONT_NAME "-*-lucida-bold-r-normal-sans-14-*-*-*-p-*-iso10646-1" +#ifdef __APPLE__ +#define MODKEY Mod1Mask +#else +#define MODKEY Mod4Mask +#endif /* anvil.c */ extern XConf X; diff --git a/keys.c b/keys.c index 72bd1e8..5dabd8b 100644 --- a/keys.c +++ b/keys.c @@ -50,12 +50,6 @@ static void colsplit(Arg *arg) mons_colsplit(); } -#ifdef __APPLE__ -#define MODKEY Mod1Mask -#else -#define MODKEY Mod4Mask -#endif - static char* pickexec[] = { "pickexec", NULL }; static char* terminal[] = { "xterm", NULL }; static char* locker[] = { "slock", NULL }; diff --git a/mouse.c b/mouse.c index 7a6a294..f2d9611 100644 --- a/mouse.c +++ b/mouse.c @@ -17,7 +17,18 @@ static void float_click(XButtonEvent* ev, Location* loc) } else if (ev->button == Button2) { - client_close(loc->client); + if (ev->state & MODKEY) + { + client_close(loc->client); + } + else if (ev->state & (MODKEY|ShiftMask)) + { + puts("to tile mode"); + } + else + { + puts("undefined"); + } } else if (ev->button == Button3) { @@ -41,7 +52,18 @@ static void monocled_click(XButtonEvent* ev, Location* loc) } else if (ev->button == Button2) { - client_close(loc->client); + if (ev->state & MODKEY) + { + client_close(loc->client); + } + else if (ev->state & (MODKEY|ShiftMask)) + { + puts("to float mode"); + } + else + { + puts("expand client"); + } } else if (ev->button == Button3) { @@ -66,20 +88,23 @@ static void stacked_click(XButtonEvent* ev, Location* loc) } else if (ev->button == Button2) { - client_close(loc->client); - } - else if (ev->button == Button3) - { - if (PRESSED(ev->state, Button1)) + if (ev->state & MODKEY) { - /* TODO: implement expand in place */ - puts("expand in place"); + client_close(loc->client); + } + else if (ev->state & (MODKEY|ShiftMask)) + { + puts("to float mode"); } else { - monocled_set(loc->monitor, loc->column, loc->client); + puts("expand in place"); } } + else if (ev->button == Button3) + { + monocled_set(loc->monitor, loc->column, loc->client); + } } void mouse_down(XButtonEvent* ev, Location* loc) @@ -124,35 +149,18 @@ void mouse_up(XButtonEvent* ev, Location* loc) { mons_coladjust(loc->monitor, loc->column, ev->x_root - X.start_x); } - else if (loc->column) + else { + /* nothing to do here */ } X.mode = M_IDLE; } -static void monocled_drag(XMotionEvent* ev, Location* loc) -{ - (void)ev, (void)loc; -} - -static void stacked_drag(XMotionEvent* ev, Location* loc) -{ - (void)ev, (void)loc; -} - void mouse_drag(XMotionEvent* ev, Location* loc) { if (!loc->column) { float_drag(ev, loc); } - else if (loc->column->focused) - { - monocled_drag(ev, loc); - } - else - { - stacked_drag(ev, loc); - } }