diff --git a/src/client.c b/src/client.c index 4086f1c..ca45f3f 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); @@ -1471,6 +1472,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..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); @@ -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.c b/src/config.c index 506b92f..82265b0 100644 --- a/src/config.c +++ b/src/config.c @@ -235,9 +235,19 @@ 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 */ + W->cfocus = 0; + tmp = fetch_opt_first(sec, "enter", "focus").str; + if(strstr(tmp, "enter")) + W->cfocus |= CFOCUS_ENTER; + if(strstr(tmp, "click")) + W->cfocus |= CFOCUS_CLICK; + /* [mouse] */ /* for client frame AND titlebar */ if((mb = fetch_section(sec, "mouse"))) 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/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/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: diff --git a/src/tag.c b/src/tag.c index a9c9d06..555f834 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 34511fb..1abd2ee 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 */ @@ -349,6 +350,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; 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 a42a9cf..66fc412 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_ignore_tag" [/key] + # Launcher [key] mod = {"Super"} key = "p" func = "launcher" cmd = "exec" [/key]