Client/Mouse: Add tile movement and so client_swap.
This commit is contained in:
parent
f9a2c441f3
commit
23d00abb5a
60
src/client.c
60
src/client.c
@ -629,6 +629,66 @@ client_size_hints(Client *c)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Swap 2 clients
|
||||
* \param a First client
|
||||
* \param b Second client
|
||||
*/
|
||||
void
|
||||
client_swap(Client *a, Client *b)
|
||||
{
|
||||
Client *an, *bn, *ap, *bp;
|
||||
|
||||
if(!a || !b)
|
||||
return;
|
||||
|
||||
ap = a->prev;
|
||||
an = a->next;
|
||||
bp = b->prev;
|
||||
bn = b->next;
|
||||
|
||||
if(a == b->next)
|
||||
{
|
||||
a->next = b;
|
||||
b->prev = a;
|
||||
|
||||
if((a->prev = bp))
|
||||
bp->next = a;
|
||||
if((b->next = an))
|
||||
an->prev = b;
|
||||
}
|
||||
else if(b == a->next)
|
||||
{
|
||||
a->prev = b;
|
||||
b->next = a;
|
||||
|
||||
if((b->prev = ap))
|
||||
ap->next = b;
|
||||
if((a->next = bn))
|
||||
bn->prev = a;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((a->next = bn))
|
||||
a->next->prev = a;
|
||||
if((a->prev = bp))
|
||||
a->prev->next = a;
|
||||
if((b->prev = ap))
|
||||
b->prev->next = b;
|
||||
if((b->next = an))
|
||||
b->next->prev = b;
|
||||
}
|
||||
|
||||
if(clients == a)
|
||||
clients = b;
|
||||
else if(clients == b)
|
||||
clients = a;
|
||||
|
||||
arrange(a->screen);
|
||||
arrange(b->screen);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Raise a client
|
||||
* \param c Client pointer
|
||||
*/
|
||||
|
||||
36
src/mouse.c
36
src/mouse.c
@ -45,12 +45,12 @@ mouse_move(Client *c)
|
||||
int oscreen = c->screen;
|
||||
int dint;
|
||||
uint duint;
|
||||
Window dw;
|
||||
Window dw, sw;
|
||||
Client *sclient;
|
||||
XRectangle geo = c->geo;
|
||||
XEvent ev;
|
||||
|
||||
if(c->max || c->tile || c->lmax
|
||||
|| c->state_fullscreen || c->state_dock)
|
||||
if(c->max || c->lmax || c->state_fullscreen || c->state_dock)
|
||||
return;
|
||||
|
||||
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync,
|
||||
@ -65,18 +65,30 @@ mouse_move(Client *c)
|
||||
|
||||
if(ev.type == MotionNotify)
|
||||
{
|
||||
geo.x = (ocx + (ev.xmotion.x - mx));
|
||||
geo.y = (ocy + (ev.xmotion.y - my));
|
||||
/* To move the client in the tile grid */
|
||||
if(c->tile)
|
||||
{
|
||||
XQueryPointer(dpy, ROOT, &dw, &sw, &mx, &my, &dint, &dint, &duint);
|
||||
|
||||
|
||||
if(c->screen != oscreen)
|
||||
arrange(c->screen);
|
||||
|
||||
if(c->free || tags[c->screen][c->tag].layout.func == freelayout)
|
||||
client_moveresize(c, geo, True);
|
||||
if((sclient = client_gb_win(sw))
|
||||
|| (sclient = client_gb_frame(sw))
|
||||
|| (sclient = client_gb_titlebar(sw)))
|
||||
client_swap(c, sclient);
|
||||
}
|
||||
/* To move a client normally, in freelayout */
|
||||
else
|
||||
break;
|
||||
{
|
||||
geo.x = (ocx + (ev.xmotion.x - mx));
|
||||
geo.y = (ocy + (ev.xmotion.y - my));
|
||||
|
||||
if(c->screen != oscreen)
|
||||
arrange(c->screen);
|
||||
|
||||
if(c->free || tags[c->screen][c->tag].layout.func == freelayout)
|
||||
client_moveresize(c, geo, True);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(ev.type == MapRequest
|
||||
|| ev.type == Expose
|
||||
|
||||
@ -140,6 +140,7 @@ void client_manage(Window w, XWindowAttributes *wa);
|
||||
void client_moveresize(Client *c, XRectangle geo, Bool r);
|
||||
void client_maximize(Client *c);
|
||||
void client_size_hints(Client *c);
|
||||
void client_swap(Client *a, Client *b);
|
||||
void client_raise(Client *c);
|
||||
void client_unhide(Client *c);
|
||||
void client_unmanage(Client *c);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user