diff options
| author | ProsperousPotato <ProsperousPotato@users.noreply.github.com> | 2025-12-31 17:36:07 +0000 |
|---|---|---|
| committer | ProsperousPotato <ProsperousPotato@users.noreply.github.com> | 2025-12-31 17:36:07 +0000 |
| commit | 48f53402aa54f0c0ca28990db090ead7634f3f39 (patch) | |
| tree | 4b9ff9afaccb11d406f7a54735f49b09fca185a3 | |
| parent | 006a46e099311a161ceb4612c6a220fbc5b881f9 (diff) | |
add tiled move to mod|shift + lmb
| -rw-r--r-- | config.h | 25 | ||||
| -rw-r--r-- | dwm.c | 60 |
2 files changed, 70 insertions, 15 deletions
@@ -161,20 +161,21 @@ static const Key keys[] = { /* button definitions */ static const Button buttons[] = { - /* click event mask button function argument */ - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + /* click event mask button function argument */ + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, // regular window move + { ClkClientWin, MODKEY|ShiftMask, Button1, movemouse, {.i = 1} }, // tiled window move + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, /* Focus windows with scroll wheel */ - { ClkClientWin, MODKEY, Button4, focusstack, {.i = -1 } }, - { ClkClientWin, MODKEY, Button5, focusstack, {.i = +1 } }, - { ClkRootWin, MODKEY, Button4, focusstack, {.i = -1 } }, - { ClkRootWin, MODKEY, Button5, focusstack, {.i = +1 } }, + { ClkClientWin, MODKEY, Button4, focusstack, {.i = -1 } }, + { ClkClientWin, MODKEY, Button5, focusstack, {.i = +1 } }, + { ClkRootWin, MODKEY, Button4, focusstack, {.i = -1 } }, + { ClkRootWin, MODKEY, Button5, focusstack, {.i = +1 } }, /* Focus monitors with side mouse buttons */ - { ClkClientWin, MODKEY, Button8, focusmon, {.i = -1 } }, - { ClkClientWin, MODKEY, Button9, focusmon, {.i = +1 } }, - { ClkRootWin, MODKEY, Button8, focusmon, {.i = -1 } }, - { ClkRootWin, MODKEY, Button9, focusmon, {.i = +1 } }, + { ClkClientWin, MODKEY, Button8, focusmon, {.i = -1 } }, + { ClkClientWin, MODKEY, Button9, focusmon, {.i = +1 } }, + { ClkRootWin, MODKEY, Button8, focusmon, {.i = -1 } }, + { ClkRootWin, MODKEY, Button9, focusmon, {.i = +1 } }, }; @@ -1239,11 +1239,65 @@ movemouse(const Arg *arg) ny = selmon->wy; else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap) ny = selmon->wy + selmon->wh - HEIGHT(c); - if (!c->isfloating && selmon->lt[selmon->sellt]->arrange - && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) - togglefloating(NULL); + if (arg->i != 1) { + if (!c->isfloating && selmon->lt[selmon->sellt]->arrange + && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) + togglefloating(NULL); + } if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) resize(c, nx, ny, c->w, c->h, 1); + else if (arg->i == 1 && (selmon->lt[selmon->sellt]->arrange || !c->isfloating)) { + if ((m = recttomon(ev.xmotion.x_root, ev.xmotion.y_root, 1, 1)) != selmon) { + sendmon(c, m); + selmon = m; + focus(NULL); + } + + Client *cc = c->mon->clients; + while (1) { + if (cc == 0) break; + if( + cc != c && !cc->isfloating && ISVISIBLE(cc) && + ev.xmotion.x_root > cc->x && + ev.xmotion.x_root < cc->x + cc->w && + ev.xmotion.y_root > cc->y && + ev.xmotion.y_root < cc->y + cc->h ) { + break; + } + + cc = cc->next; + } + + if (cc) { + Client *cl1, *cl2, ocl1; + + if (!selmon->lt[selmon->sellt]->arrange) return; + + cl1 = c; + cl2 = cc; + ocl1 = *cl1; + strcpy(cl1->name, cl2->name); + cl1->win = cl2->win; + cl1->x = cl2->x; + cl1->y = cl2->y; + cl1->w = cl2->w; + cl1->h = cl2->h; + + cl2->win = ocl1.win; + strcpy(cl2->name, ocl1.name); + cl2->x = ocl1.x; + cl2->y = ocl1.y; + cl2->w = ocl1.w; + cl2->h = ocl1.h; + + selmon->sel = cl2; + + c = cc; + focus(c); + + arrange(cl1->mon); + } + } break; } } while (ev.type != ButtonRelease); |
