From 325d1b301f3b6b5b1a7b7bc14113d0faff159330 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 19 Jun 2009 20:20:00 +0200 Subject: [PATCH] Implement the special workspace ~ for assignments, which will set clients floating automatically --- docs/userguide | 4 ++++ include/data.h | 3 +++ src/config.c | 8 +++++--- src/manage.c | 6 ++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/userguide b/docs/userguide index 0c7f9a07..4ba97ee9 100644 --- a/docs/userguide +++ b/docs/userguide @@ -237,6 +237,9 @@ i3 will get the title as soon as the application maps the window (mapping means actually displaying it on the screen), you’d need to have to match on Firefox in this case. +You can use the special workspace +~+ to specify that matching clients should +be put into floating mode. + *Syntax*: ---------------------------------------------------- assign ["]window class[/window title]["] [→] workspace @@ -248,6 +251,7 @@ assign urxvt 2 assign urxvt → 2 assign "urxvt" → 2 assign "urxvt/VIM" → 3 +assign "gecko" → ~ ---------------------- === Automatically starting applications on startup diff --git a/include/data.h b/include/data.h index 87dd4995..b468c1f7 100644 --- a/include/data.h +++ b/include/data.h @@ -223,6 +223,9 @@ struct Autostart { */ struct Assignment { char *windowclass_title; + /* floating is true if this was an assignment to the special workspace "~". + * Matching clients will be put into floating mode automatically. */ + bool floating; int workspace; TAILQ_ENTRY(Assignment) assignments; }; diff --git a/src/config.c b/src/config.c index 5d6312ed..197fd4e1 100644 --- a/src/config.c +++ b/src/config.c @@ -241,14 +241,16 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath) die("Malformed assignment, couldn't find target\n"); target++; - if (atoi(target) < 1 || atoi(target) > 10) + if (*target != '~' && (atoi(target) < 1 || atoi(target) > 10)) die("Malformed assignment, invalid workspace number\n"); LOG("assignment parsed: \"%s\" to \"%s\"\n", class_title, target); - struct Assignment *new = smalloc(sizeof(struct Assignment)); + struct Assignment *new = scalloc(sizeof(struct Assignment)); new->windowclass_title = class_title; - new->workspace = atoi(target); + if (*target == '~') + new->floating = true; + else new->workspace = atoi(target); TAILQ_INSERT_TAIL(&assignments, new, assignments); continue; } diff --git a/src/manage.c b/src/manage.c index aebfe546..dfbe12cc 100644 --- a/src/manage.c +++ b/src/manage.c @@ -315,6 +315,12 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, if (get_matching_client(conn, assign->windowclass_title, new) == NULL) continue; + if (assign->floating) { + new->floating = FLOATING_AUTO_ON; + LOG("Assignment matches, putting client into floating mode\n"); + break; + } + LOG("Assignment \"%s\" matches, so putting it on workspace %d\n", assign->windowclass_title, assign->workspace);