From ac362e33dfa395224af92830cddce875f0c9ba69 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sat, 4 Apr 2020 22:00:20 -0400 Subject: [PATCH] added shortcut to toggle between floating and tiled --- anvil.h | 4 ++++ build.sh | 2 +- keys.c | 24 ++++++++++++++++-------- mouse.c | 3 --- tile.c | 3 +-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/anvil.h b/anvil.h index 13b9331..db02775 100644 --- a/anvil.h +++ b/anvil.h @@ -17,6 +17,10 @@ #define max(a,b) (a > b ? a : b) /* TODO: warp mouse pointer to title bars on new windows */ +/* TODO: Add shortcuts to transfer windows between monitors */ +/* TODO: warp the mouse to titlebar on various locations */ +/* TODO: make sure mouse warps to the correct titlebar and floating windows don't get in the way */ +/* TODO: add floating addclient function */ enum { M_INIT, diff --git a/build.sh b/build.sh index ca67477..ab48db1 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ cc -g -Wall -Wextra -Werror -I/usr/X11R6/include -L/usr/X11R6/lib -o anvil *.c -lX11 -lXinerama -lm error="$?" ctags * -grep -n 'TODO' *.c | sed -e 's/: \+/: /' -e 's/\/\* *//g' -e 's/ *\*\/$//' -e 's/TODO: *//' +grep -n 'TODO' *.[ch]| sed -e 's/: \+/: /' -e 's/\/\* *//g' -e 's/ *\*\/$//' -e 's/TODO: *//' printf "\a" if [ $error -ne 0 ]; then printf "\a" diff --git a/keys.c b/keys.c index 5dabd8b..9cdf4da 100644 --- a/keys.c +++ b/keys.c @@ -50,21 +50,29 @@ static void colsplit(Arg *arg) mons_colsplit(); } +static void togfloat(Arg *arg) +{ + (void)arg; + Location loc; + if (Focused && mons_find(Focused->win, &loc)) + { + mons_togglefloat(&loc); + } +} + static char* pickexec[] = { "pickexec", NULL }; static char* terminal[] = { "xterm", NULL }; static char* locker[] = { "slock", NULL }; -/* TODO: Add shortcuts to resize columns */ -/* TODO: Add shortcuts to transfer windows between monitors */ -/* TODO: Add shortcuts to toggle between tiled and floating */ static Key keys[] = { - { MODKEY|ShiftMask, XK_q, quit, { 0 } }, - { MODKEY, XK_p, runcmd, { .cmd = pickexec } }, - { MODKEY|ShiftMask, XK_Return, runcmd, { .cmd = terminal } }, - { MODKEY|ShiftMask, XK_l, runcmd, { .cmd = locker } }, - { MODKEY|ShiftMask, XK_c, killwin, { 0 } }, + { MODKEY, XK_p, runcmd, { .cmd = pickexec } }, { MODKEY, XK_minus, coljoin, { 0 } }, { MODKEY, XK_equal, colsplit, { 0 } }, + { MODKEY|ShiftMask, XK_q, quit, { 0 } }, + { MODKEY|ShiftMask, XK_Return, runcmd, { .cmd = terminal } }, + { MODKEY|ShiftMask, XK_l, runcmd, { .cmd = locker } }, + { MODKEY|ShiftMask, XK_c, killwin, { 0 } }, + { MODKEY|ShiftMask, XK_f, togfloat, { 0 } }, { MODKEY, XK_1, set_workspace, { .i = 0 } }, { MODKEY, XK_2, set_workspace, { .i = 1 } }, diff --git a/mouse.c b/mouse.c index 2b81e63..548a77d 100644 --- a/mouse.c +++ b/mouse.c @@ -1,8 +1,5 @@ #include "anvil.h" -/* TODO: warp the mouse to titlebar on various locations */ -/* TODO: make sure mouse warps to the correct titlebar and floating windows don't get in the way */ - static inline int PRESSED(int mods, int btn) { return ((mods & (1 << (btn + 7))) == (1 << (btn + 7))); diff --git a/tile.c b/tile.c index 43cc049..af2b205 100644 --- a/tile.c +++ b/tile.c @@ -1,6 +1,6 @@ #include "anvil.h" -static void coldims(Monitor* mon, Column* col, int *x, int *y, int *w, int *h) +static void coldims(Monitor *mon, Column *col, int *x, int *y, int *w, int *h) { Column* c; *x = mon->x, *y = mon->y, *w = col->width-2, *h = mon->h-2; @@ -55,7 +55,6 @@ void monocled_set(Monitor* mon, Column* col, Client* c) void stacked_add(Monitor* mon, Column* col, Client* c) { - /* TODO: add floating client add function */ coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h)); if (col->clients) { -- 2.52.0