From 2abf2ea65172a29e188498e8e774d1e9587de7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Thu, 12 Apr 2012 22:59:55 +0200 Subject: [PATCH 1/7] move clients on tag change if they ignore tags --- src/tag.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tag.c b/src/tag.c index a9c9d06..2649fa9 100644 --- a/src/tag.c +++ b/src/tag.c @@ -46,6 +46,8 @@ tag_new(struct screen *s, char *name) void tag_screen(struct screen *s, struct tag *t) { + struct client *c; + if(t == s->seltag && TAILQ_NEXT(TAILQ_FIRST(&s->tags), next)) t = t->prev; @@ -55,6 +57,10 @@ tag_screen(struct screen *s, struct tag *t) t->prev = s->seltag; s->seltag = t; + /* Move clients if they ignore tags */ + SLIST_FOREACH(c, &W->h.client, next) + if (c->flags & CLIENT_IGNORE_TAG) + tag_client(c->screen->seltag, c); clients_arrange_map(); if(!SLIST_EMPTY(&t->clients) && !(W->flags & WMFS_SCAN)) From 762700bd2ce3d41dabf84774fc149a9ae53e1532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Thu, 12 Apr 2012 23:05:03 +0200 Subject: [PATCH 2/7] fix last commit: add wmfs header changes --- src/wmfs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wmfs.h b/src/wmfs.h index 34511fb..aec91ae 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 */ From 9cc33f89045a3ceda94c3daaf0cf499f519c713c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Fri, 13 Apr 2012 14:56:59 +0200 Subject: [PATCH 3/7] fix focus on tag change --- src/tag.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tag.c b/src/tag.c index 2649fa9..053c79c 100644 --- a/src/tag.c +++ b/src/tag.c @@ -61,8 +61,20 @@ tag_screen(struct screen *s, struct tag *t) SLIST_FOREACH(c, &W->h.client, next) if (c->flags & CLIENT_IGNORE_TAG) tag_client(c->screen->seltag, c); + clients_arrange_map(); + /* Update focus */ + if (t->sel == NULL) + { + SLIST_FOREACH(c, &W->h.client, next) + if (c->tag == t) + { + client_focus(c); + break; + } + } + if(!SLIST_EMPTY(&t->clients) && !(W->flags & WMFS_SCAN)) client_focus( client_tab_next(t->sel)); From 0085dd16e3e6d7423e3a5bea5495a9df4af2999b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Fri, 13 Apr 2012 15:21:50 +0200 Subject: [PATCH 4/7] Add a toggle_ignore_tag uicb command. Don't tab if two client haven't the same ignore_tag rule --- src/client.c | 22 ++++++++++++++++++++- src/client.h | 1 + src/config.h | 55 ++++++++++++++++++++++++++-------------------------- src/tag.c | 4 ++-- 4 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/client.c b/src/client.c index bea7ea8..8575c2c 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 + || (c->flags & CLIENT_IGNORE_TAG) != (cm->flags & CLIENT_IGNORE_TAG)) 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 4645849..394e0d6 100644 --- a/src/client.h +++ b/src/client.h @@ -58,6 +58,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 */ diff --git a/src/config.h b/src/config.h index 7e250de..9b83688 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/tag.c b/src/tag.c index 053c79c..4a2e968 100644 --- a/src/tag.c +++ b/src/tag.c @@ -59,8 +59,8 @@ tag_screen(struct screen *s, struct tag *t) /* Move clients if they ignore tags */ SLIST_FOREACH(c, &W->h.client, next) - if (c->flags & CLIENT_IGNORE_TAG) - tag_client(c->screen->seltag, c); + if (c->flags & CLIENT_IGNORE_TAG && c->screen == s) + tag_client(s->seltag, c); clients_arrange_map(); From 3d450c3d20504c50109a3d5e1b2cd3fec54d003b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Fri, 13 Apr 2012 21:21:40 +0200 Subject: [PATCH 5/7] fix client moving --- src/tag.c | 24 ++++++++---------------- src/wmfs.h | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/tag.c b/src/tag.c index 4a2e968..6717ba7 100644 --- a/src/tag.c +++ b/src/tag.c @@ -48,33 +48,24 @@ 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; - /* Move clients if they ignore tags */ - SLIST_FOREACH(c, &W->h.client, next) - if (c->flags & CLIENT_IGNORE_TAG && c->screen == s) - tag_client(s->seltag, c); - clients_arrange_map(); /* Update focus */ - if (t->sel == NULL) - { - SLIST_FOREACH(c, &W->h.client, next) - if (c->tag == t) - { - client_focus(c); - break; - } - } - if(!SLIST_EMPTY(&t->clients) && !(W->flags & WMFS_SCAN)) client_focus( client_tab_next(t->sel)); @@ -107,7 +98,8 @@ tag_client(struct tag *t, struct client *c) } } - c->flags &= ~CLIENT_RULED; + if (!(c->flags & CLIENT_IGNORE_TAG)) + c->flags &= ~CLIENT_RULED; /* Client remove */ if(!t) diff --git a/src/wmfs.h b/src/wmfs.h index aec91ae..0a79fc7 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -216,7 +216,7 @@ struct client #define CLIENT_FREE 0x1000 #define CLIENT_TILED 0x2000 #define CLIENT_MOUSE 0x4000 -#define CLIENT_IGNORE_TAG 0x8000 +#define CLIENT_IGNORE_TAG 0x8000 Flags flags; Window win, frame, tmp; SLIST_ENTRY(client) next; /* Global list */ From c692505b44476a22f53e89f8d78bc194ef7cf757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Fri, 13 Apr 2012 21:42:31 +0200 Subject: [PATCH 6/7] fix infinite loop --- src/tag.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tag.c b/src/tag.c index 6717ba7..555f834 100644 --- a/src/tag.c +++ b/src/tag.c @@ -98,8 +98,7 @@ tag_client(struct tag *t, struct client *c) } } - if (!(c->flags & CLIENT_IGNORE_TAG)) - c->flags &= ~CLIENT_RULED; + c->flags &= ~CLIENT_RULED; /* Client remove */ if(!t) From e65c6a706ac152b7846d001fb21951f4ff7fafa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Fri, 13 Apr 2012 23:18:36 +0200 Subject: [PATCH 7/7] fix client integration on the screen --- src/client.c | 2 +- src/client.h | 7 +++++-- src/layout.c | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/client.c b/src/client.c index 8575c2c..182172a 100644 --- a/src/client.c +++ b/src/client.c @@ -549,7 +549,7 @@ _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->flags & CLIENT_IGNORE_TAG) != (cm->flags & CLIENT_IGNORE_TAG)) + || !COMPCLIENT(c, cm)) return; layout_split_arrange_closed(c); diff --git a/src/client.h b/src/client.h index 394e0d6..eb10c95 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); @@ -188,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/layout.c b/src/layout.c index ce998b1..b73cea6 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: