From b3f1e7da541dfbb16194fd693c56238b2624b013 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 18 Mar 2020 13:13:58 -0400 Subject: [PATCH] fixed issue with stacking order and added more mouse actions --- anvil.h | 35 +++++++++++++++++++++++++++-- mons.c | 20 +++++++++++------ mouse.c | 69 ++++++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 100 insertions(+), 24 deletions(-) diff --git a/anvil.h b/anvil.h index c5e0bc4..b157eaa 100644 --- a/anvil.h +++ b/anvil.h @@ -24,11 +24,42 @@ Management Notes: * Windows can tile in a column or float on workspaces * Columns can have different layouts: manual, stacked, monocle - TODO: window border is wrong width on right and bottom for some reason... TODO: warp mouse pointer to title bars on new windows - TODO: account for frame size in client x,y,w,h fields TODO: implement mouse handling for tiling methods +Mouse Actions: + Floating: + Btn Click 1: + Btn Drag 1: Move Window + Btn Click 2: Close Window + Btn Click 3: + Btn Click 4: Lower Window + Btn Click 5: Raise Window + + Monocled: + Btn Click 1: + Btn Drag 1: + Btn Click 2: Close Window + Btn Click 3: Lower Window + Btn Click 4: + Btn Click 5: + + Stacked: + Btn Click 1: + Btn Drag 1: + Btn Click 2: Close Window + Btn Click 3: + Btn Click 4: + Btn Click 5: + + Expanded: + Btn Click 1: + Btn Drag 1: + Btn Click 2: Close Window + Btn Click 3: + Btn Click 4: + Btn Click 5: + */ enum { diff --git a/mons.c b/mons.c index 040cec9..41bae58 100644 --- a/mons.c +++ b/mons.c @@ -42,21 +42,27 @@ void mons_init(void) void mons_layer(Monitor* mon) { - /* lower all of the floating windows first */ - for (Client* client = mon->cspace->floating; client; client = client->next) + int nwins = 0; + Window* wins = NULL; + for (Client* c = mon->cspace->floating; c; c = c->next) { - XLowerWindow(X.disp, client->win); - XLowerWindow(X.disp, client->frame); + wins = realloc(wins, ++nwins); + wins[nwins-1] = c->frame; } /* now lower all of the tiled windows */ for (Column* col = mon->cspace->columns; col; col = col->next) { - for (Client* client = col->clients; client; client = client->next) + for (Client* c = col->clients; c; c = c->next) { - XLowerWindow(X.disp, client->win); - XLowerWindow(X.disp, client->frame); + wins = realloc(wins, ++nwins); + wins[nwins-1] = c->frame; } } + if (nwins) + { + XRestackWindows(X.disp, wins, nwins); + XSync(X.disp, False); + } } /* adds a new client to the most appropriate monitor */ diff --git a/mouse.c b/mouse.c index d44c814..f698378 100644 --- a/mouse.c +++ b/mouse.c @@ -7,7 +7,15 @@ static inline int PRESSED(int mods, int btn) static void float_click(XButtonEvent* ev, Location* loc) { - if (ev->button == Button1) + if (ev->button == Button2) + { + client_close(loc->client); + } + else if (ev->button == Button4) + { + mons_lower(loc->monitor, loc->client); + } + else if (ev->button == Button5) { mons_raise(loc->monitor, loc->client); if (ev->y > (TITLE_HEIGHT + BORDER_WIDTH)) @@ -16,17 +24,9 @@ static void float_click(XButtonEvent* ev, Location* loc) warp_mouse(loc->client); } } - else if (ev->button == Button2) - { - client_close(loc->client); - } - else if (ev->button == Button3) - { - mons_lower(loc->monitor, loc->client); - } } -static void monocle_click(XButtonEvent* ev, Location* loc) +static void monocled_click(XButtonEvent* ev, Location* loc) { if (ev->button == Button2) { @@ -46,6 +46,22 @@ static void monocle_click(XButtonEvent* ev, Location* loc) mons_layer(loc->monitor); } +static void stacked_click(XButtonEvent* ev, Location* loc) +{ + if (ev->button == Button2) + { + client_close(loc->client); + } +} + +static void expanded_click(XButtonEvent* ev, Location* loc) +{ + if (ev->button == Button2) + { + client_close(loc->client); + } +} + void mouse_click(XButtonEvent* ev, Location* loc) { if (!loc->column) @@ -54,15 +70,15 @@ void mouse_click(XButtonEvent* ev, Location* loc) } else if (loc->column->mode == TILE_MONOCLE) { - monocle_click(ev, loc); + monocled_click(ev, loc); } else if (loc->column->mode == TILE_STACKED) { - puts("tiled (S) mouse click"); + stacked_click(ev, loc); } else if (loc->column->mode == TILE_EXPAND) { - puts("tiled (E) mouse click"); + expanded_click(ev, loc); } } @@ -82,15 +98,38 @@ static void float_drag(XMotionEvent* ev, Location* loc) } } +static void monocled_drag(XMotionEvent* ev, Location* loc) +{ + (void)ev, (void)loc; +} + +static void stacked_drag(XMotionEvent* ev, Location* loc) +{ + (void)ev, (void)loc; +} + +static void expanded_drag(XMotionEvent* ev, Location* loc) +{ + (void)ev, (void)loc; +} + void mouse_drag(XMotionEvent* ev, Location* loc) { if (!loc->column) { float_drag(ev, loc); } - else + else if (loc->column->mode == TILE_MONOCLE) + { + monocled_drag(ev, loc); + } + else if (loc->column->mode == TILE_STACKED) + { + stacked_drag(ev, loc); + } + else if (loc->column->mode == TILE_EXPAND) { - puts("tiled mouse drag"); + expanded_drag(ev, loc); } } -- 2.52.0