From 80eadd6f5c91aacbf36a1223661334ac39a94c47 Mon Sep 17 00:00:00 2001 From: Jeu2 Date: Thu, 12 Apr 2012 12:04:57 +0200 Subject: [PATCH 01/10] add ability to set a default rule modified: src/client.c modified: src/config.c modified: src/wmfs.h --- src/client.c | 35 ++++++++++++++++++++++++++++++++++- src/config.c | 8 +++++++- src/wmfs.h | 1 + 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index bea7ea8..136bcca 100644 --- a/src/client.c +++ b/src/client.c @@ -882,6 +882,7 @@ client_apply_rule(struct client *c) XFree(data); } + // Apply a specific rule SLIST_FOREACH(r, &W->h.rule, next) { if(s) @@ -902,7 +903,8 @@ client_apply_rule(struct client *c) if(r->tag != -1) c->tag = tag_gb_id(c->screen, r->tag); - c->theme = r->theme; + if (r->theme) + c->theme = r->theme; /* free = false for originally free client */ if(r->flags & RULE_FREE) @@ -929,6 +931,37 @@ client_apply_rule(struct client *c) if(wmname) free(wmname); + + // Apply default rule + if (!(c->flags & CLIENT_RULED) && (r = W->crule) != NULL) + { + if(r->screen != -1) + c->screen = screen_gb_id(r->screen); + + c->tag = c->screen->seltag; + if(r->tag != -1) + c->tag = tag_gb_id(c->screen, r->tag); + + if (r->theme) + c->theme = r->theme; + + /* free = false for originally free client */ + if(r->flags & RULE_FREE) + c->flags |= CLIENT_FREE; + else + c->flags &= ~CLIENT_FREE; + + /* Free rule is not compatible with tab rule */ + if(r->flags & RULE_TAB) + W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */ + + /* TODO + if(r->flags & RULE_IGNORE_TAG) + {} + */ + + c->flags |= CLIENT_RULED; + } } struct client* diff --git a/src/config.c b/src/config.c index 506b92f..8802f74 100644 --- a/src/config.c +++ b/src/config.c @@ -261,6 +261,7 @@ config_rule(void) n = fetch_section_count(ks); SLIST_INIT(&W->h.rule); + W->crule = NULL; /* [rule] */ for(i = 0; i < n; ++i) @@ -284,7 +285,12 @@ config_rule(void) else r->theme = W->ctheme; - SLIST_INSERT_HEAD(&W->h.rule, r, next); + if (!strcmp(r->name, "default")) + { + W->crule = r; + } + else + SLIST_INSERT_HEAD(&W->h.rule, r, next); } free(ks); diff --git a/src/wmfs.h b/src/wmfs.h index 34511fb..1be645e 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -349,6 +349,7 @@ struct wmfs char *confpath; struct barwin *last_clicked_barwin; struct theme *ctheme; + struct rule *crule; /* Log file */ FILE *log; From 4a186874aa27dd970ae26ae0f662d448565c66e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Thu, 12 Apr 2012 13:39:37 +0200 Subject: [PATCH 02/10] fix crash --- src/client.c | 6 ++---- src/config.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/client.c b/src/client.c index 136bcca..9e0d14c 100644 --- a/src/client.c +++ b/src/client.c @@ -903,8 +903,7 @@ client_apply_rule(struct client *c) if(r->tag != -1) c->tag = tag_gb_id(c->screen, r->tag); - if (r->theme) - c->theme = r->theme; + c->theme = r->theme; /* free = false for originally free client */ if(r->flags & RULE_FREE) @@ -942,8 +941,7 @@ client_apply_rule(struct client *c) if(r->tag != -1) c->tag = tag_gb_id(c->screen, r->tag); - if (r->theme) - c->theme = r->theme; + c->theme = r->theme; /* free = false for originally free client */ if(r->flags & RULE_FREE) diff --git a/src/config.c b/src/config.c index 8802f74..8247266 100644 --- a/src/config.c +++ b/src/config.c @@ -285,7 +285,7 @@ config_rule(void) else r->theme = W->ctheme; - if (!strcmp(r->name, "default")) + if (r->name && !strcmp(r->name, "default")) { W->crule = r; } From 3540bb1cadfb9ba71cf280d1e35e4423ec5c5fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Thu, 12 Apr 2012 14:52:47 +0200 Subject: [PATCH 03/10] clean code --- src/client.c | 95 +++++++++++++++++++++------------------------------- src/config.c | 8 +---- src/wmfs.h | 1 - 3 files changed, 39 insertions(+), 65 deletions(-) diff --git a/src/client.c b/src/client.c index 9e0d14c..19f533d 100644 --- a/src/client.c +++ b/src/client.c @@ -846,6 +846,36 @@ client_frame_new(struct client *c) XReparentWindow(W->dpy, c->win, c->frame, c->border, c->tbarw); } +static void +_apply_rule(struct client *c, struct rule *r) +{ + if(r->screen != -1) + c->screen = screen_gb_id(r->screen); + + c->tag = c->screen->seltag; + if(r->tag != -1) + c->tag = tag_gb_id(c->screen, r->tag); + + c->theme = r->theme; + + /* free = false for originally free client */ + if(r->flags & RULE_FREE) + c->flags |= CLIENT_FREE; + else + c->flags &= ~CLIENT_FREE; + + /* Free rule is not compatible with tab rule */ + if(r->flags & RULE_TAB) + W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */ + + /* TODO + if(r->flags & RULE_IGNORE_TAG) + {} + */ + + c->flags |= CLIENT_RULED; +} + #define RINSTANCE 0x01 #define RCLASS 0x02 #define RROLE 0x04 @@ -854,6 +884,7 @@ static void client_apply_rule(struct client *c) { struct rule *r; + struct rule *defaultr = NULL; char *wmname = NULL; char *role = NULL; int f; @@ -882,9 +913,11 @@ client_apply_rule(struct client *c) XFree(data); } - // Apply a specific rule + /* Apply a specific rule */ SLIST_FOREACH(r, &W->h.rule, next) { + if (r->instance && !strcmp(r->instance, "*")) + defaultr = r; if(s) { FLAGAPPLY(flags, (xch.res_name && r->instance && !strcmp(xch.res_name, r->instance)), RINSTANCE); @@ -895,33 +928,7 @@ client_apply_rule(struct client *c) FLAGAPPLY(flags, ((role && r->role && !strcmp(role, r->role)) || !role || !r->role), RROLE); if(flags & (RINSTANCE | RCLASS | RNAME) && flags & RROLE) - { - if(r->screen != -1) - c->screen = screen_gb_id(r->screen); - - c->tag = c->screen->seltag; - if(r->tag != -1) - c->tag = tag_gb_id(c->screen, r->tag); - - c->theme = r->theme; - - /* free = false for originally free client */ - if(r->flags & RULE_FREE) - c->flags |= CLIENT_FREE; - else - c->flags &= ~CLIENT_FREE; - - /* Free rule is not compatible with tab rule */ - if(r->flags & RULE_TAB) - W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */ - - /* TODO - if(r->flags & RULE_IGNORE_TAG) - {} - */ - - c->flags |= CLIENT_RULED; - } + _apply_rule(c, r); flags = 0; } @@ -931,35 +938,9 @@ client_apply_rule(struct client *c) if(wmname) free(wmname); - // Apply default rule - if (!(c->flags & CLIENT_RULED) && (r = W->crule) != NULL) - { - if(r->screen != -1) - c->screen = screen_gb_id(r->screen); - - c->tag = c->screen->seltag; - if(r->tag != -1) - c->tag = tag_gb_id(c->screen, r->tag); - - c->theme = r->theme; - - /* free = false for originally free client */ - if(r->flags & RULE_FREE) - c->flags |= CLIENT_FREE; - else - c->flags &= ~CLIENT_FREE; - - /* Free rule is not compatible with tab rule */ - if(r->flags & RULE_TAB) - W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */ - - /* TODO - if(r->flags & RULE_IGNORE_TAG) - {} - */ - - c->flags |= CLIENT_RULED; - } + /* Apply default rule */ + if (!(c->flags & CLIENT_RULED) && defaultr != NULL) + _apply_rule(c, defaultr); } struct client* diff --git a/src/config.c b/src/config.c index 8247266..2f1a488 100644 --- a/src/config.c +++ b/src/config.c @@ -261,7 +261,6 @@ config_rule(void) n = fetch_section_count(ks); SLIST_INIT(&W->h.rule); - W->crule = NULL; /* [rule] */ for(i = 0; i < n; ++i) @@ -285,12 +284,7 @@ config_rule(void) else r->theme = W->ctheme; - if (r->name && !strcmp(r->name, "default")) - { - W->crule = r; - } - else - SLIST_INSERT_HEAD(&W->h.rule, r, next); + SLIST_INSERT_HEAD(&W->h.rule, r, next); } free(ks); diff --git a/src/wmfs.h b/src/wmfs.h index 1be645e..34511fb 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -349,7 +349,6 @@ struct wmfs char *confpath; struct barwin *last_clicked_barwin; struct theme *ctheme; - struct rule *crule; /* Log file */ FILE *log; From 653d8d9b7be7e014866b36f02bd841caec13e37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Thu, 12 Apr 2012 15:04:24 +0200 Subject: [PATCH 04/10] fix indentation --- src/client.c | 46 +++++++++++++++++++++++----------------------- src/config.c | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/client.c b/src/client.c index 19f533d..c2b33f2 100644 --- a/src/client.c +++ b/src/client.c @@ -849,31 +849,31 @@ client_frame_new(struct client *c) static void _apply_rule(struct client *c, struct rule *r) { - if(r->screen != -1) - c->screen = screen_gb_id(r->screen); + if(r->screen != -1) + c->screen = screen_gb_id(r->screen); - c->tag = c->screen->seltag; - if(r->tag != -1) - c->tag = tag_gb_id(c->screen, r->tag); + c->tag = c->screen->seltag; + if(r->tag != -1) + c->tag = tag_gb_id(c->screen, r->tag); - c->theme = r->theme; + c->theme = r->theme; - /* free = false for originally free client */ - if(r->flags & RULE_FREE) - c->flags |= CLIENT_FREE; - else - c->flags &= ~CLIENT_FREE; + /* free = false for originally free client */ + if(r->flags & RULE_FREE) + c->flags |= CLIENT_FREE; + else + c->flags &= ~CLIENT_FREE; - /* Free rule is not compatible with tab rule */ - if(r->flags & RULE_TAB) - W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */ + /* Free rule is not compatible with tab rule */ + if(r->flags & RULE_TAB) + W->flags ^= WMFS_TABNOC; /* < can be disable by client_tab_next_opened */ - /* TODO - if(r->flags & RULE_IGNORE_TAG) - {} - */ + /* TODO + if(r->flags & RULE_IGNORE_TAG) + {} + */ - c->flags |= CLIENT_RULED; + c->flags |= CLIENT_RULED; } #define RINSTANCE 0x01 @@ -916,8 +916,8 @@ client_apply_rule(struct client *c) /* Apply a specific rule */ SLIST_FOREACH(r, &W->h.rule, next) { - if (r->instance && !strcmp(r->instance, "*")) - defaultr = r; + if (r->instance && !strcmp(r->instance, "*")) + defaultr = r; if(s) { FLAGAPPLY(flags, (xch.res_name && r->instance && !strcmp(xch.res_name, r->instance)), RINSTANCE); @@ -928,7 +928,7 @@ client_apply_rule(struct client *c) FLAGAPPLY(flags, ((role && r->role && !strcmp(role, r->role)) || !role || !r->role), RROLE); if(flags & (RINSTANCE | RCLASS | RNAME) && flags & RROLE) - _apply_rule(c, r); + _apply_rule(c, r); flags = 0; } @@ -940,7 +940,7 @@ client_apply_rule(struct client *c) /* Apply default rule */ if (!(c->flags & CLIENT_RULED) && defaultr != NULL) - _apply_rule(c, defaultr); + _apply_rule(c, defaultr); } struct client* diff --git a/src/config.c b/src/config.c index 2f1a488..506b92f 100644 --- a/src/config.c +++ b/src/config.c @@ -284,7 +284,7 @@ config_rule(void) else r->theme = W->ctheme; - SLIST_INSERT_HEAD(&W->h.rule, r, next); + SLIST_INSERT_HEAD(&W->h.rule, r, next); } free(ks); From ea517457e4560f94c1e6478dcb8f2a693c1e30d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Anger?= Date: Thu, 12 Apr 2012 15:09:31 +0200 Subject: [PATCH 05/10] fix last indentation issue --- src/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.c b/src/client.c index c2b33f2..4086f1c 100644 --- a/src/client.c +++ b/src/client.c @@ -884,7 +884,7 @@ static void client_apply_rule(struct client *c) { struct rule *r; - struct rule *defaultr = NULL; + struct rule *defaultr = NULL; char *wmname = NULL; char *role = NULL; int f; 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 06/10] 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 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 07/10] 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 08/10] 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 09/10] 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] From fcc8ad77aa51eef7ed78233f53a929784550298a Mon Sep 17 00:00:00 2001 From: arnault Date: Sun, 15 Apr 2012 22:42:48 +0200 Subject: [PATCH 10/10] add default rule sample in wmfsrc --- wmfsrc | 1 + 1 file changed, 1 insertion(+) diff --git a/wmfsrc b/wmfsrc index 66fc412..dff1b19 100644 --- a/wmfsrc +++ b/wmfsrc @@ -136,6 +136,7 @@ [rules] [rule] + # use instance = "*" for a all-clients rule instance = "chromium" # role = ""