From daae7d47649e9e5e4e0f31d7e333f6f95f215bc7 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 14 Jul 2009 22:59:24 +0200 Subject: [PATCH] Client/Layout: Remove tile_switch uicb function; add client_swap_{next, prev}. --- src/client.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++------ src/config.c | 3 ++- src/mouse.c | 6 ++--- src/wmfs.h | 9 +++---- wmfs.1 | 7 +++++- wmfsrc.in | 7 ++++-- 6 files changed, 82 insertions(+), 18 deletions(-) diff --git a/src/client.c b/src/client.c index 48c50d9..cc06f13 100644 --- a/src/client.c +++ b/src/client.c @@ -135,6 +135,61 @@ uicb_client_next(uicb_t cmd) return; } +/** Swap the current client with the next one + *\param cmd uicb_t type unused + */ +void +uicb_client_swap_next(uicb_t cmd) +{ + Client *c = NULL; + + if(!sel && !sel->tile) + return; + + /* Find the next client */ + for(c = sel->next; c && ishide(c, selscreen); c = c->next); + if(!c) + for(c = clients; c && ishide(c, selscreen); c = c->next); + + if(c) + { + client_swap(sel, c); + client_focus(c); + } + + return; +} + +/** Swap the current client with the previous one + *\param cmd uicb_t type unused + */ +void +uicb_client_swap_prev(uicb_t cmd) +{ + Client *c = NULL, *d; + + if(!sel && !sel->tile) + return; + + /* Find the previous client */ + for(d = clients; d != sel; d = d->next) + if(!ishide(d, selscreen)) + c = d; + + if(!c) + for(; d; d = d->next) + if(!ishide(d, selscreen)) + c = d; + + if(c) + { + client_swap(sel, c); + client_focus(c); + } + + return; +} + /** Set the focus to a client * \param c Client pointer */ @@ -570,8 +625,8 @@ client_moveresize(Client *c, XRectangle geo, Bool r) frame_moveresize(c, c->geo); - XMoveResizeWindow(dpy, c->win, BORDH, TBARH, c->geo.width, - c->geo.height); + XMoveResizeWindow(dpy, c->win, BORDH, TBARH, + c->geo.width, c->geo.height); client_configure(c); client_update_attributes(c); @@ -628,7 +683,7 @@ client_size_hints(Client *c) c->baseh = size.min_height; } else - c->basew = c->baseh = 0; + c->basew = c->baseh = 1; /* inc */ if(size.flags & PResizeInc) @@ -637,7 +692,7 @@ client_size_hints(Client *c) c->inch = size.height_inc; } else - c->incw = c->inch = 0; + c->incw = c->inch = 1; /* max */ if(size.flags & PMaxSize) @@ -646,7 +701,7 @@ client_size_hints(Client *c) c->maxh = size.max_height; } else - c->maxw = c->maxh = 0; + c->maxw = c->maxh = 1; /* min */ if(size.flags & PMinSize) @@ -690,8 +745,7 @@ client_swap(Client *c1, Client *c2) CHECK(!c1->free); CHECK(!c2->free); - if((c1->screen == c2->screen - && c1->tag != c2->tag)) + if(c1 == c2 || (c1->screen == c2->screen && c1->tag != c2->tag)) return; /* Swap only the windows */ diff --git a/src/config.c b/src/config.c index 6029315..64ff641 100644 --- a/src/config.c +++ b/src/config.c @@ -44,6 +44,8 @@ conf_init_func_list(void) {"client_kill", uicb_client_kill }, {"client_prev", uicb_client_prev }, {"client_next", uicb_client_next }, + {"client_swap_next", uicb_client_swap_next }, + {"client_swap_prev", uicb_client_swap_prev }, {"client_screen_next", uicb_client_screen_next }, {"client_screen_prev", uicb_client_screen_prev }, {"toggle_max", uicb_togglemax }, @@ -61,7 +63,6 @@ conf_init_func_list(void) {"mouse_move", uicb_mouse_move }, {"mouse_resize", uicb_mouse_resize }, {"client_raise", uicb_client_raise }, - {"tile_switch", uicb_tile_switch }, {"toggle_free", uicb_togglefree }, {"screen_select", uicb_screen_select }, {"screen_next", uicb_screen_next }, diff --git a/src/mouse.c b/src/mouse.c index cdcafe9..12ec1db 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -79,7 +79,7 @@ mouse_move(Client *c) xgc.function = GXinvert; xgc.subwindow_mode = IncludeInferiors; xgc.line_width = BORDH; - gci = XCreateGC(dpy, ROOT, GCFunction|GCSubwindowMode|GCLineWidth, &xgc); + gci = XCreateGC(dpy, ROOT, GCFunction | GCSubwindowMode | GCLineWidth, &xgc); if(!c->tile && !c->lmax) mouse_dragborder(c->geo, gci); @@ -105,7 +105,7 @@ mouse_move(Client *c) if(c != sclient) { client_swap(c, sclient); - break; + /* break; */ } } @@ -199,7 +199,7 @@ mouse_resize(Client *c) xgc.function = GXinvert; xgc.subwindow_mode = IncludeInferiors; xgc.line_width = BORDH; - gci = XCreateGC(dpy, ROOT, GCFunction|GCSubwindowMode|GCLineWidth, &xgc); + gci = XCreateGC(dpy, ROOT, GCFunction | GCSubwindowMode | GCLineWidth, &xgc); if(!c->tile) { diff --git a/src/wmfs.h b/src/wmfs.h index c67b5c1..cf20184 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -164,11 +164,13 @@ void client_unmap(Client *c); void client_set_wanted_tag(Client *c); void client_update_attributes(Client *c); void uicb_client_raise(uicb_t); -void uicb_client_prev(uicb_t); void uicb_client_next(uicb_t); +void uicb_client_prev(uicb_t); +void uicb_client_swap_next(uicb_t); +void uicb_client_swap_prev(uicb_t); void uicb_client_kill(uicb_t); -void uicb_client_screen_next(uicb_t cmd); -void uicb_client_screen_prev(uicb_t cmd); +void uicb_client_screen_next(uicb_t); +void uicb_client_screen_prev(uicb_t); /* ewmh.c */ void ewmh_init_hints(void); @@ -291,7 +293,6 @@ Client *tiled_client(int screen, Client *c); void mirror_vertical(int screen); void mirror_horizontal(int screen); /* }}} */ -void uicb_tile_switch(uicb_t); void uicb_togglemax(uicb_t); void uicb_togglefree(uicb_t); void uicb_layout_prev(uicb_t); diff --git a/wmfs.1 b/wmfs.1 index a521c73..14d7507 100644 --- a/wmfs.1 +++ b/wmfs.1 @@ -133,7 +133,12 @@ Decrease the nmaster (-1)\fR .PP \fBAlt + t\fR .RS 4 -Switch the current client with the master client\fR +Swap the current client with the next\fR +.RE +.PP +\fBAlt\-Shift + t\fR +.RS 4 +Swap the current client with the previous\fR .RE .PP \fBAlt + p\fR diff --git a/wmfsrc.in b/wmfsrc.in index 71da2fa..b39f8f8 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -186,8 +186,11 @@ keys # Quit wmfs. key { mod = {"Control", "Alt", "Shift"} key = "q" func = "quit" } - # Switch current client with master client. - key { mod = {"Alt"} key = "t" func = "tile_switch" } + # Swap current client with the next. + key { mod = {"Alt"} key = "t" func = "client_swap_next" } + + # Swap current client with the previous. + key { mod = {"Alt", "Shift"} key = "t" func = "client_swap_prev" } # Toggle maximum the selected client. key { mod = {"Alt"} key = "m" func = "toggle_max" }