Skip to content

Commit

Permalink
Fixed tilemovemouse to work with current dwm, and replaced movemouse
Browse files Browse the repository at this point in the history
keybinding with tilemovemouse in config.h.
  • Loading branch information
sfauzia committed May 9, 2011
1 parent 48e55d5 commit 881456f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
4 changes: 3 additions & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz \
dwm-5.7.2-attachaside.diff \
dwm-5.7-fancybar.diff \
focusmaster.c \
push.c)
push.c \
tilemovemouse.c)
md5sums=('f0b422bfeaa812d66c6dd15c3cc92a6b'
'939f403a71b6e85261d09fc3412269ee'
'39a557beb09afe4e727bc4aed64b2cd6'
Expand All @@ -42,6 +43,7 @@ build() {
cp $srcdir/config.h config.h
cp $srcdir/focusmaster.c focusmaster.c
cp $srcdir/push.c push.c
cp $srcdir/tilemovemouse.c tilemovemouse.c

sed -i 's/CPPFLAGS =/CPPFLAGS +=/g' config.mk
sed -i 's/CFLAGS =/CFLAGS +=/g' config.mk
Expand Down
4 changes: 3 additions & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_q, quit, {0} },
};

#include "tilemovemouse.c"
/* button definitions */
/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
Expand All @@ -126,7 +127,8 @@ static Button buttons[] = {
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
/* { ClkClientWin, MODKEY, Button1, movemouse, {0} }, */
{ ClkClientWin, MODKEY, Button1, tilemovemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
Expand Down
62 changes: 62 additions & 0 deletions tilemovemouse.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
void
insertbefore(Client *a, Client *b) /* insert a before b in the client list */
{
Client **x = &selmon->clients;

while(*x != b && *x)
x = & (*x)->next;
*x = a;
a->next = b;
}

void
insertafter(Client *a, Client *b) /* insert a after b in the client list */
{
a->next = b->next;
b->next = a;
}

void
tilemovemouse(const Arg *arg) {
/* Could EnterNotify events be used instead? */
Client *sel = selmon->sel;
Client *c, *d;
XEvent ev;
int x, y;
Bool after;

if(!(c = sel))
return;
if(c->isfloating || !selmon->lt[selmon->sellt]->arrange){
movemouse(NULL);
return;
}
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove], CurrentTime) != GrabSuccess)
return;
do {
XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
switch (ev.type) {
case ConfigureRequest:
case Expose:
case MapRequest:
handler[ev.type](&ev);
break;
case MotionNotify:
x = ev.xmotion.x;
y = ev.xmotion.y;
after = False;
for(d = nexttiled(selmon->clients); d; d = nexttiled(d->next)){
if(d == c)
after = True;
else if(INRECT(x, y, d->x, d->y, d->w+2*borderpx, d->h+2*borderpx)){
detach(c);
after ? insertafter(c, d) : insertbefore(c,d);
arrange(selmon);
break;
}
}
}
} while(ev.type != ButtonRelease);
XUngrabPointer(dpy, CurrentTime);
}

0 comments on commit 881456f

Please sign in to comment.