From: Michael D. Lowis Date: Wed, 25 Mar 2020 10:56:22 +0000 (-0400) Subject: added warp pointer to window actions but focus is broken. Can't seem to figure it... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=5fdbf8f82eb27e71e063125a8c15fe561d64fbfb;p=proto%2Fanvil.git added warp pointer to window actions but focus is broken. Can't seem to figure it out. --- diff --git a/anvil.h b/anvil.h index dd22797..1433f22 100644 --- a/anvil.h +++ b/anvil.h @@ -130,6 +130,7 @@ void mons_lower(Monitor* mon, Client* c); void mons_colsplit(void); void mons_coljoin(void); void mons_coladjust(Monitor* mon, Column* col, int wdiff); +void mons_tilemove(Location* loc, int hdiff); /* client.c */ extern Client* Focused; @@ -146,6 +147,7 @@ void client_show(Client* c, int show); void client_readprops(Client* c); void client_shade(Client* c); void client_setshade(Client* c, int shade); +void client_warpmouse(Client* c); /* mouse.c */ void mouse_down(XButtonEvent* ev, Location* loc); diff --git a/client.c b/client.c index b586356..19f476b 100644 --- a/client.c +++ b/client.c @@ -214,3 +214,8 @@ void client_setshade(Client* c, int shade) XUnmapWindow(X.disp, c->win); } } + +void client_warpmouse(Client* c) +{ + XWarpPointer(X.disp, None, c->frame, 0, 0, 0, 0, (c->w/2), (MIN_HEIGHT/2)); +} diff --git a/mons.c b/mons.c index f51f626..f074785 100644 --- a/mons.c +++ b/mons.c @@ -91,6 +91,7 @@ void mons_addclient(Client* c) { Monitor* mon = pickmon(); add_client(mon, c, PtrX); + client_warpmouse(c); } void mons_delclient(Client* c) @@ -306,6 +307,31 @@ void mons_coladjust(Monitor* mon, Column* col, int wdiff) } } +void mons_tilemove(Location* loc, int hdiff) +{ + Monitor* mon = pickmon(); + Column* col = pickcol(mon->cspace->columns, PtrX); + if (loc->monitor != mon || loc->column != col) + { + remove_client(loc, loc->client); + client_setshade(loc->client, 0); + if (col->focused) + { + monocled_add(mon, col,loc->client); + } + else + { + stacked_add(mon, col, loc->client); + } + } + else + { + stacked_addheight(loc->monitor, loc->column, loc->client, hdiff); + } + client_warpmouse(loc->client); + client_focus(loc->client); +} + static Monitor* pickmon(void) { get_mouse(&PtrX, &PtrY); @@ -317,7 +343,7 @@ static Monitor* pickmon(void) break; } } - assert(mon); + mon = (mon ? mon : Monitors); return mon; } @@ -396,8 +422,12 @@ static void add_client(Monitor* mon, Client* c, int ptrx) for (; col && col->clients; col = col->next); if (!col) { - /* otherwise pick the current column */ + /* otherwise pick the column to the right or current column */ col = pickcol(mon->cspace->columns, ptrx - mon->x); + if (col->next) + { + col = col->next; + } } /* add in monocled or stacked mode */ if (col->focused) diff --git a/mouse.c b/mouse.c index 37c6555..6a3e51f 100644 --- a/mouse.c +++ b/mouse.c @@ -70,7 +70,15 @@ static void stacked_click(XButtonEvent* ev, Location* loc) } else if (ev->button == Button3) { - monocled_set(loc->monitor, loc->column, loc->client); + if (PRESSED(ev->state, Button1)) + { + /* TODO: implement expand in place */ + puts("expand in place"); + } + else + { + monocled_set(loc->monitor, loc->column, loc->client); + } } } @@ -111,12 +119,15 @@ void mouse_up(XButtonEvent* ev, Location* loc) /* TODO: handle button 1 drag to resize, reposition, and move windows */ if (X.mode == M_TILE_RESIZE) { - stacked_addheight(loc->monitor, loc->column, loc->client, ev->y_root - X.start_y); + mons_tilemove(loc, ev->y_root - X.start_y); } else if (X.mode == M_COL_RESIZE) { mons_coladjust(loc->monitor, loc->column, ev->x_root - X.start_x); } + else if (loc->column) + { + } X.mode = M_IDLE; } diff --git a/tile.c b/tile.c index 2788d89..db0ece2 100644 --- a/tile.c +++ b/tile.c @@ -135,7 +135,7 @@ void stacked_addheight(Monitor* mon, Column* col, Client* c, int amount) for (; prev && prev->next != c; prev = prev->next); if (prev) { - amount = (amount == 0 ? (int)(-c->h * 0.25) : amount); + amount = (amount == 0 ? min((int)(-c->h * 0.25), -2*MIN_HEIGHT) : amount); int miny = (prev->y + MIN_HEIGHT); int maxy = min((mon->y + mon->h) , (c->y + c->h)) - MIN_HEIGHT; c->y = max(miny, min(maxy, c->y + amount));