diff --git a/src/client.c b/src/client.c index bea7ea8e..182172a4 100644 --- a/src/client.c +++ b/src/client.c @@ -548,7 +548,8 @@ _client_tab(struct client *c, struct client *cm) /* Do not tab already tabbed client */ if(c->flags & (CLIENT_TABBED | CLIENT_TABMASTER) - || c->tag != cm->tag || c == cm) + || c->tag != cm->tag || c == cm + || !COMPCLIENT(c, cm)) return; layout_split_arrange_closed(c); @@ -1459,6 +1460,25 @@ uicb_client_toggle_free(Uicb cmd) } } +void uicb_client_toggle_ignore_tag(Uicb cmd) +{ + struct client *c; + (void)cmd; + + if(!(W->client)) + return; + + W->client->flags ^= CLIENT_IGNORE_TAG; + + /* Set tabbed client of toggled client as ignore_tag */ + if(W->client->flags & CLIENT_TABMASTER) + { + SLIST_FOREACH(c, &W->client->tag->clients, tnext) + if(c->tabmaster == W->client && c != W->client) + c->flags ^= CLIENT_IGNORE_TAG; + } +} + void uicb_client_tab_next_opened(Uicb cmd) { diff --git a/src/client.h b/src/client.h index 4645849d..eb10c954 100644 --- a/src/client.h +++ b/src/client.h @@ -18,6 +18,9 @@ SLIST_FOREACH(V, H, F) \ if(!(V->flags & CLIENT_FREE)) +/* Are two clients compatibles ? (to be tabbed together) */ +#define COMPCLIENT(C1, C2) ((C1->flags & CLIENT_IGNORE_TAG) == (C2->flags & CLIENT_IGNORE_TAG)) + void client_configure(struct client *c); struct client *client_gb_win(Window w); struct client *client_gb_frame(Window w); @@ -58,6 +61,7 @@ void client_update_props(struct client *c, Flags f); void client_fac_hint(struct client *c); void uicb_client_untab(Uicb cmd); void uicb_client_toggle_free(Uicb cmd); +void uicb_client_toggle_ignore_tag(Uicb cmd); void uicb_client_tab_next_opened(Uicb cmd); /* Generated */ @@ -187,14 +191,14 @@ clients_tag_arrange_map(struct tag *t) } static inline struct client* -client_get_larger(struct tag *t) +client_get_larger(struct tag *t, bool ignoring_tag) { struct client *c, *lc = NULL; int tmp, l = 0; FOREACH_NFCLIENT(c, &t->clients, tnext) { - if((tmp = (c->geo.w + c->geo.h)) > l) + if((tmp = (c->geo.w + c->geo.h)) > l && (c->flags & CLIENT_IGNORE_TAG) == ignoring_tag) { l = tmp; lc = c; diff --git a/src/config.h b/src/config.h index 7e250dec..9b83688e 100644 --- a/src/config.h +++ b/src/config.h @@ -55,33 +55,34 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] = { "layout_integrate_bottom", uicb_layout_integrate_Bottom }, /* Client */ - { "client_close", uicb_client_close }, - { "client_resize_right", uicb_client_resize_Right }, - { "client_resize_left", uicb_client_resize_Left }, - { "client_resize_top", uicb_client_resize_Top }, - { "client_resize_bottom", uicb_client_resize_Bottom }, - { "client_focus_right", uicb_client_focus_Right }, - { "client_focus_left", uicb_client_focus_Left }, - { "client_focus_top", uicb_client_focus_Top }, - { "client_focus_bottom", uicb_client_focus_Bottom }, - { "client_tab_right", uicb_client_tab_Right }, - { "client_tab_left", uicb_client_tab_Left }, - { "client_tab_top", uicb_client_tab_Top }, - { "client_tab_bottom", uicb_client_tab_Bottom }, - { "client_swap_right", uicb_client_swap_Right }, - { "client_swap_left", uicb_client_swap_Left }, - { "client_swap_top", uicb_client_swap_Top }, - { "client_swap_bottom", uicb_client_swap_Bottom }, - { "client_focus_next", uicb_client_focus_next }, - { "client_focus_prev", uicb_client_focus_prev }, - { "client_swap_next", uicb_client_swapsel_next }, - { "client_swap_prev", uicb_client_swapsel_prev }, - { "client_untab", uicb_client_untab }, - { "client_focus_next_tab", uicb_client_focus_next_tab }, - { "client_focus_prev_tab", uicb_client_focus_prev_tab }, - { "client_focus_click", uicb_client_focus_click }, - { "client_toggle_free", uicb_client_toggle_free }, - { "client_tab_next_opened", uicb_client_tab_next_opened }, + { "client_close", uicb_client_close }, + { "client_resize_right", uicb_client_resize_Right }, + { "client_resize_left", uicb_client_resize_Left }, + { "client_resize_top", uicb_client_resize_Top }, + { "client_resize_bottom", uicb_client_resize_Bottom }, + { "client_focus_right", uicb_client_focus_Right }, + { "client_focus_left", uicb_client_focus_Left }, + { "client_focus_top", uicb_client_focus_Top }, + { "client_focus_bottom", uicb_client_focus_Bottom }, + { "client_tab_right", uicb_client_tab_Right }, + { "client_tab_left", uicb_client_tab_Left }, + { "client_tab_top", uicb_client_tab_Top }, + { "client_tab_bottom", uicb_client_tab_Bottom }, + { "client_swap_right", uicb_client_swap_Right }, + { "client_swap_left", uicb_client_swap_Left }, + { "client_swap_top", uicb_client_swap_Top }, + { "client_swap_bottom", uicb_client_swap_Bottom }, + { "client_focus_next", uicb_client_focus_next }, + { "client_focus_prev", uicb_client_focus_prev }, + { "client_swap_next", uicb_client_swapsel_next }, + { "client_swap_prev", uicb_client_swapsel_prev }, + { "client_untab", uicb_client_untab }, + { "client_focus_next_tab", uicb_client_focus_next_tab }, + { "client_focus_prev_tab", uicb_client_focus_prev_tab }, + { "client_focus_click", uicb_client_focus_click }, + { "client_toggle_free", uicb_client_toggle_free }, + { "client_toggle_ignore_tag", uicb_client_toggle_ignore_tag }, + { "client_tab_next_opened", uicb_client_tab_next_opened }, /* Status */ { "status" , uicb_status }, diff --git a/src/layout.c b/src/layout.c index ce998b19..b73cea6c 100644 --- a/src/layout.c +++ b/src/layout.c @@ -395,8 +395,9 @@ layout_split_integrate(struct client *c, struct client *sc) if(!sc || sc == c || sc->tag != c->tag - || (sc->flags & CLIENT_FREE)) - sc = client_get_larger(c->tag); + || (sc->flags & CLIENT_FREE) + || !COMPCLIENT(c, sc)) + sc = client_get_larger(c->tag, c->flags & CLIENT_IGNORE_TAG); /* Largest not correct */ if(!sc || sc == c) @@ -419,13 +420,14 @@ layout_split_integrate(struct client *c, struct client *sc) } /* Tab Next Opened Client option */ - if(W->flags & WMFS_TABNOC) + if(W->flags & WMFS_TABNOC && COMPCLIENT(c, sc)) { W->flags ^= WMFS_TABNOC; _client_tab(c, sc); return; } + /* If there are clients but we can tab with them, split the screen. */ c->flags |= CLIENT_TILED; g = layout_split(sc, (sc->geo.h < sc->geo.w)); @@ -437,6 +439,7 @@ layout_split_integrate(struct client *c, struct client *sc) client_fac_hint(sc); layout_save_set(c->tag); + W->flags &= ~WMFS_TABNOC; } /* Arrange inter-clients holes: diff --git a/src/tag.c b/src/tag.c index a9c9d067..555f834b 100644 --- a/src/tag.c +++ b/src/tag.c @@ -46,17 +46,26 @@ tag_new(struct screen *s, char *name) void tag_screen(struct screen *s, struct tag *t) { + struct client *c; + + /* Return to the previous tag */ if(t == s->seltag && TAILQ_NEXT(TAILQ_FIRST(&s->tags), next)) t = t->prev; if(!t) t = TAILQ_FIRST(&s->tags); + /* Move clients which ignore tags */ + SLIST_FOREACH(c, &W->h.client, next) + if (c->flags & CLIENT_IGNORE_TAG) + tag_client(t, c); + t->prev = s->seltag; s->seltag = t; clients_arrange_map(); + /* Update focus */ if(!SLIST_EMPTY(&t->clients) && !(W->flags & WMFS_SCAN)) client_focus( client_tab_next(t->sel)); diff --git a/src/wmfs.h b/src/wmfs.h index a9257a1b..1abd2ee6 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -216,6 +216,7 @@ struct client #define CLIENT_FREE 0x1000 #define CLIENT_TILED 0x2000 #define CLIENT_MOUSE 0x4000 +#define CLIENT_IGNORE_TAG 0x8000 Flags flags; Window win, frame, tmp; SLIST_ENTRY(client) next; /* Global list */