From f9624a9f2ea8538e41b0ade3b1efacdad0224f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Sat, 14 Apr 2012 11:43:51 +0200 Subject: [PATCH 01/11] add focus configuration --- src/config.c | 11 +++++++++++ src/event.c | 7 ++++++- src/wmfs.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 506b92f..dc5f4cf 100644 --- a/src/config.c +++ b/src/config.c @@ -235,9 +235,20 @@ config_client(void) sec = fetch_section_first(NULL, "client"); W->client_mod = modkey_keysym(fetch_opt_first(sec, "Super", "key_modifier").str); + + /* Get theme */ tmp = fetch_opt_first(sec, "default", "theme").str; W->ctheme = name_to_theme(tmp); + /* Get focus configuration */ + tmp = fetch_opt_first(sec, "enter", "focus").str; + if(!strcmp(tmp, "enter")) + W->cfocus = CFOCUS_ENTER; + else if(!strcmp(tmp, "click")) + W->cfocus = CFOCUS_CLICK; + else + W->cfocus = 0; + /* [mouse] */ /* for client frame AND titlebar */ if((mb = fetch_section(sec, "mouse"))) diff --git a/src/event.c b/src/event.c index fe165e9..7b9dc26 100644 --- a/src/event.c +++ b/src/event.c @@ -27,6 +27,7 @@ event_buttonpress(XEvent *e) XButtonEvent *ev = &e->xbutton; struct mousebind *m; struct barwin *b; + struct client *c; screen_update_sel(); status_flush_surface(); @@ -44,6 +45,9 @@ event_buttonpress(XEvent *e) break; } + if((c = client_gb_win(ev->window)) && c != W->client + && ev->button == 1 && W->cfocus & CFOCUS_CLICK) + client_focus(c); } static void @@ -67,7 +71,8 @@ event_enternotify(XEvent *e) c->flags ^= CLIENT_IGNORE_ENTER; else if(c->tag->flags & TAG_IGNORE_ENTER) c->tag->flags ^= TAG_IGNORE_ENTER; - else if(c != W->client && !(c->flags & CLIENT_TABBED)) + else if(c != W->client && !(c->flags & CLIENT_TABBED) + && W->cfocus & CFOCUS_ENTER) client_focus(c); } } diff --git a/src/wmfs.h b/src/wmfs.h index 34511fb..a9257a1 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -349,6 +349,9 @@ struct wmfs char *confpath; struct barwin *last_clicked_barwin; struct theme *ctheme; +#define CFOCUS_ENTER 0x01 +#define CFOCUS_CLICK 0x02 + Flags cfocus; /* Focus configuration, can be set to 0, CFOCUS_ENTER or CFOCUS_CLICK*/ /* Log file */ FILE *log; 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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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: From bb952d8c8ea9eb441fda62f1af43f8e899b15778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Sat, 14 Apr 2012 23:05:16 +0200 Subject: [PATCH 09/11] better focus configuration : allow "enter click" --- src/config.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/config.c b/src/config.c index dc5f4cf..82265b0 100644 --- a/src/config.c +++ b/src/config.c @@ -241,13 +241,12 @@ config_client(void) W->ctheme = name_to_theme(tmp); /* Get focus configuration */ + W->cfocus = 0; tmp = fetch_opt_first(sec, "enter", "focus").str; - if(!strcmp(tmp, "enter")) - W->cfocus = CFOCUS_ENTER; - else if(!strcmp(tmp, "click")) - W->cfocus = CFOCUS_CLICK; - else - W->cfocus = 0; + if(strstr(tmp, "enter")) + W->cfocus |= CFOCUS_ENTER; + if(strstr(tmp, "click")) + W->cfocus |= CFOCUS_CLICK; /* [mouse] */ /* for client frame AND titlebar */ From ae2756452e434e225cbf88bd04d709ca0b26358e Mon Sep 17 00:00:00 2001 From: arnault Date: Sun, 15 Apr 2012 02:44:05 +0200 Subject: [PATCH 10/11] add client focus option and client toggle ignore_tag keybind in wmfsrc --- wmfsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wmfsrc b/wmfsrc index a42a9cf..0ee1607 100644 --- a/wmfsrc +++ b/wmfsrc @@ -118,6 +118,12 @@ theme = "default" key_modifier = "Super" + # Focus type: + # enter : focus follow mouse (default) + # click : click to focus + # everything-else : disable mouse focus support + focus = enter + [mouse] button = "1" func = "client_focus_click" [/mouse] [mouse] button = "1" func = "mouse_swap" [/mouse] [mouse] button = "2" func = "mouse_tab" [/mouse] @@ -256,6 +262,9 @@ # Toggle client free/tile [key] mod = {"Super"} key = "f" func = "client_toggle_free" [/key] + # Toggle client ignore_tag + [key] mod = {"Super", "Shift"} key = "f" func = "client_toggle_free" [/key] + # Launcher [key] mod = {"Super"} key = "p" func = "launcher" cmd = "exec" [/key] From 756bb3fbce687fc611f0671937850af8e3ac8607 Mon Sep 17 00:00:00 2001 From: arnault Date: Sun, 15 Apr 2012 02:50:12 +0200 Subject: [PATCH 11/11] update man with toggle_ignore_tag uicb function --- wmfs.1 | 9 ++++++++- wmfsrc | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wmfs.1 b/wmfs.1 index 0b732d3..9e5eeb5 100644 --- a/wmfs.1 +++ b/wmfs.1 @@ -63,6 +63,11 @@ Exit WMFS Toggle free the selected client .RE .PP +\fBSuper + Shift + f \fR +.RS 4 +Toggle ignore_tag the selected client +.RE +.PP \fBAlt + Tab\fR .RS 4 Give the focus to the next client @@ -624,8 +629,10 @@ move focus to previous tab-client\&. give focus to client with a clic\&. .PP \fB\ client_toggle_free\fR -togle free the client\&. +toggle free the selected client\&. .PP +\fB\ client_toggle_ignore_tag\fR +toggle ignore_tag the selected client\&. \fB\ client_tab_next_opened\fR open the client in a tab\&. .PP diff --git a/wmfsrc b/wmfsrc index 0ee1607..66fc412 100644 --- a/wmfsrc +++ b/wmfsrc @@ -263,7 +263,7 @@ [key] mod = {"Super"} key = "f" func = "client_toggle_free" [/key] # Toggle client ignore_tag - [key] mod = {"Super", "Shift"} key = "f" func = "client_toggle_free" [/key] + [key] mod = {"Super", "Shift"} key = "f" func = "client_toggle_ignore_tag" [/key] # Launcher [key] mod = {"Super"} key = "p" func = "launcher" cmd = "exec" [/key]