Client/Mouse: Add client_swap (new trial)
This commit is contained in:
parent
59f203ee8f
commit
96cc645788
32
src/client.c
32
src/client.c
@ -664,6 +664,38 @@ client_size_hints(Client *c)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Swap two clients
|
||||
*\param 1 c1 First client
|
||||
*\param 2 c2 Second client
|
||||
*/
|
||||
void
|
||||
client_swap(Client *c1, Client *c2)
|
||||
{
|
||||
/* Swap juste the window */
|
||||
swap_ptr((void**)&c1->win, (void**)&c2->win);
|
||||
swap_ptr((void**)&c1->title, (void**)&c2->title);
|
||||
|
||||
/* Re-adapt the window position with its new frame */
|
||||
XReparentWindow(dpy, c1->win, c1->frame, BORDH, TBARH);
|
||||
XReparentWindow(dpy, c2->win, c2->frame, BORDH, TBARH);
|
||||
|
||||
/* Resize the window */
|
||||
XResizeWindow(dpy, c1->win, c2->geo.width, c2->geo.height);
|
||||
XResizeWindow(dpy, c2->win, c1->geo.width, c1->geo.height);
|
||||
|
||||
/* Re-get the client size hints */
|
||||
client_size_hints(c1);
|
||||
client_size_hints(c2);
|
||||
|
||||
|
||||
/* Arrange */
|
||||
arrange(c1->screen);
|
||||
if(c1->screen != c2->screen)
|
||||
arrange(c2->screen);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Set the wanted tag of a client
|
||||
*\param c Client pointer
|
||||
*/
|
||||
|
||||
10
src/mouse.c
10
src/mouse.c
@ -57,7 +57,7 @@ mouse_move(Client *c)
|
||||
uint duint;
|
||||
Window dw, sw;
|
||||
Client *sclient;
|
||||
XRectangle geo = c->geo, ogeo;
|
||||
XRectangle geo = c->geo;
|
||||
XGCValues xgc;
|
||||
GC gci;
|
||||
XEvent ev;
|
||||
@ -101,9 +101,11 @@ mouse_move(Client *c)
|
||||
|| (sclient = client_gb_frame(sw))
|
||||
|| (sclient = client_gb_titlebar(sw)))
|
||||
{
|
||||
ogeo = c->geo;
|
||||
client_moveresize(c, sclient->geo, False);
|
||||
client_moveresize(sclient, ogeo, False);
|
||||
if(c != sclient)
|
||||
{
|
||||
client_swap(c, sclient);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* To move a client from one tag to another */
|
||||
|
||||
15
src/util.c
15
src/util.c
@ -236,6 +236,21 @@ spawn(const char *format, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Swap two pointer.
|
||||
*\param x First pointer
|
||||
*\param y Second pointer
|
||||
*/
|
||||
void
|
||||
swap_ptr(void **x, void **y)
|
||||
{
|
||||
void *t = *x;
|
||||
|
||||
*x = *y;
|
||||
*y = t;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Execute a sh command
|
||||
* \param cmd Command (uicb_t type)
|
||||
*/
|
||||
|
||||
@ -145,6 +145,7 @@ Client* client_manage(Window w, XWindowAttributes *wa, Bool ar);
|
||||
void client_moveresize(Client *c, XRectangle geo, Bool r);
|
||||
void client_maximize(Client *c);
|
||||
void client_size_hints(Client *c);
|
||||
void client_swap(Client *c1, Client *c2);
|
||||
void client_raise(Client *c);
|
||||
void client_unhide(Client *c);
|
||||
void client_unmanage(Client *c);
|
||||
@ -238,6 +239,7 @@ char* alias_to_str(char *conf_choice);
|
||||
/* }}} */
|
||||
XRectangle get_mouse_pos(void);
|
||||
void spawn(const char *str, ...);
|
||||
void swap_ptr(void **x, void **y);
|
||||
void uicb_spawn(uicb_t);
|
||||
|
||||
/* tag.c */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user