Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
fix mouseretab
Browse files Browse the repository at this point in the history
  • Loading branch information
phillbush committed May 17, 2021
1 parent f1da645 commit 90781cc
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions shod.c
Original file line number Diff line number Diff line change
Expand Up @@ -3340,7 +3340,7 @@ outlinedraw(struct Outline *outline)
XChangeGC(dpy, gc, GCFunction | GCSubwindowMode, &val);
}

/* initiate button pressing and grab pointer */
/* press button with mouse */
static void
mousebutton(struct Client *c, int region)
{
Expand Down Expand Up @@ -3381,18 +3381,18 @@ mousebutton(struct Client *c, int region)
XUngrabPointer(dpy, CurrentTime);
}

/* initiate retabbing and grab pointer */
/* detach tab from window with mouse */
static void
mouseretab(struct Client *c, struct Tab *t, int xroot, int yroot, int x, int y)
mouseretab(struct Tab *t, int xroot, int yroot, int x, int y)
{
struct Client *newc;
struct Client *c;
struct Winres res;
XEvent ev;
int pos;

tabdetach(t, xroot - x, yroot - y);
tabfocus(c->seltab);
clientretab(c);
tabfocus(t->c->seltab);
clientretab(t->c);
XGrabPointer(dpy, t->title, False, ButtonReleaseMask | Button3MotionMask, GrabModeAsync, GrabModeAsync, None, cursor[CursNormal], CurrentTime);
while (!XMaskEvent(dpy, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask, &ev)) {
switch(ev.type) {
Expand All @@ -3409,23 +3409,26 @@ mouseretab(struct Client *c, struct Tab *t, int xroot, int yroot, int x, int y)
case ButtonRelease:
xroot = ev.xbutton.x_root;
yroot = ev.xbutton.y_root;
XUnmapWindow(dpy, t->title);
goto done;
case MotionNotify:
tabmove(t, ev.xmotion.x_root - x, ev.xmotion.y_root - y);
break;
}
}
done:
if ((newc = getclientbytitle(xroot, yroot, &pos)) != NULL) {
clienttab(newc, t, pos);
if ((c = getclientbytitle(xroot, yroot, &pos)) != NULL) {
clienttab(c, t, pos);
} else {
newc = clientadd(xroot, yroot, t->winw, t->winh, 0);
managenormal(newc, t);
c = clientadd(xroot, yroot, t->winw, t->winh, 0);
managenormal(c, t);
}
clientretab(c);
clientdecorate(c, clientgetstyle(c), 1, 0, FrameNone);
XUngrabPointer(dpy, CurrentTime);
}

/* initiate moving with mouse and grab pointer */
/* move frame with mouse */
static void
mousemove(struct Client *c, struct Tab *t, int xroot, int yroot, enum Octant octant, int region)
{
Expand Down Expand Up @@ -3478,7 +3481,7 @@ mousemove(struct Client *c, struct Tab *t, int xroot, int yroot, enum Octant oct
XUngrabPointer(dpy, CurrentTime);
}

/* initiate resizing with mouse and grab pointer */
/* resize frame with mouse */
static void
mouseresize(struct Client *c, int xroot, int yroot, enum Octant octant)
{
Expand Down Expand Up @@ -3673,7 +3676,7 @@ xeventbuttonpress(XEvent *e)
(region == FrameBorder && ev->button == Button1)) {
mouseresize(c, ev->x_root, ev->y_root, octant);
} else if (region == FrameTitle && ev->button == Button3 && t != NULL && t->c != NULL && t->title == ev->window) {
mouseretab(c, t, ev->x_root, ev->y_root, ev->x, ev->y);
mouseretab(t, ev->x_root, ev->y_root, ev->x, ev->y);
} else if (region == FrameTitle && ev->button == Button1) {
tabfocus(t);
if (lastc == c && ev->time - lasttime < DOUBLECLICK) {
Expand Down

0 comments on commit 90781cc

Please sign in to comment.