From: Michael Stapelberg Date: Sun, 8 Nov 2009 11:43:01 +0000 (+0100) Subject: Implement configuration setting to change the default border of windows X-Git-Tag: 3.d~11 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=64c99cb2358af530906b889d62b7bd94b40ed71e;p=i3%2Fi3 Implement configuration setting to change the default border of windows --- diff --git a/include/client.h b/include/client.h index 88335f62..9da3a5ec 100644 --- a/include/client.h +++ b/include/client.h @@ -85,6 +85,14 @@ bool client_is_floating(Client *client); */ void client_change_border(xcb_connection_t *conn, Client *client, char border_type); +/** + * Change the border type for the given client to normal (n), 1px border (p) or + * completely borderless (b) without actually re-rendering the layout. Useful + * for calling it when initializing a new client. + * + */ +bool client_init_border(xcb_connection_t *conn, Client *client, char border_type); + /** * Unmap the client, correctly setting any state which is needed. * diff --git a/include/config.h b/include/config.h index f11a7b5b..32e29cf1 100644 --- a/include/config.h +++ b/include/config.h @@ -76,6 +76,8 @@ struct Config { int container_stack_limit; int container_stack_limit_value; + const char *default_border; + /** The modifier which needs to be pressed in combination with your mouse * buttons to do things with floating windows (move, resize) */ uint32_t floating_modifier; diff --git a/src/cfgparse.l b/src/cfgparse.l index 11d67dd7..a80329fd 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -43,6 +43,7 @@ set[^\n]* { return TOKCOMMENT; } ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; } ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; } new_container { return TOKNEWCONTAINER; } +new_window { return TOKNEWWINDOW; } default { yylval.number = MODE_DEFAULT; return TOKCONTAINERMODE; } stacking { yylval.number = MODE_STACK; return TOKCONTAINERMODE; } tabbed { yylval.number = MODE_TABBED; return TOKCONTAINERMODE; } diff --git a/src/cfgparse.y b/src/cfgparse.y index 9d34508a..1669b4ab 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -194,6 +194,7 @@ void parse_file(const char *f) { %token TOKARROW %token TOKMODE %token TOKNEWCONTAINER +%token TOKNEWWINDOW %token TOKCONTAINERMODE %token TOKSTACKLIMIT @@ -209,6 +210,7 @@ line: | mode | floating_modifier | new_container + | new_window | workspace | assign | ipcsocket @@ -367,6 +369,14 @@ new_container: } ; +new_window: + TOKNEWWINDOW WHITESPACE WORD + { + LOG("new windows should start in mode %s\n", $3); + config.default_border = strdup($3); + } + ; + workspace: TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen optional_workspace_name { diff --git a/src/client.c b/src/client.c index 6cd11d9d..215140c2 100644 --- a/src/client.c +++ b/src/client.c @@ -258,30 +258,41 @@ bool client_is_floating(Client *client) { /* * Change the border type for the given client to normal (n), 1px border (p) or - * completely borderless (b). + * completely borderless (b) without actually re-rendering the layout. Useful + * for calling it when initializing a new client. * */ -void client_change_border(xcb_connection_t *conn, Client *client, char border_type) { +bool client_init_border(xcb_connection_t *conn, Client *client, char border_type) { switch (border_type) { case 'n': LOG("Changing to normal border\n"); client->titlebar_position = TITLEBAR_TOP; client->borderless = false; - break; + return true; case 'p': LOG("Changing to 1px border\n"); client->titlebar_position = TITLEBAR_OFF; client->borderless = false; - break; + return true; case 'b': LOG("Changing to borderless\n"); client->titlebar_position = TITLEBAR_OFF; client->borderless = true; - break; + return true; default: LOG("Unknown border mode\n"); - return; + return false; } +} + +/* + * Change the border type for the given client to normal (n), 1px border (p) or + * completely borderless (b). + * + */ +void client_change_border(xcb_connection_t *conn, Client *client, char border_type) { + if (!client_init_border(conn, client, border_type)) + return; /* Ensure that the child’s position inside our window gets updated */ client->force_reconfigure = true; diff --git a/src/manage.c b/src/manage.c index d4500134..23476448 100644 --- a/src/manage.c +++ b/src/manage.c @@ -183,6 +183,9 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, new->floating_rect.width = width; new->floating_rect.height = height; + if (config.default_border != NULL) + client_init_border(conn, new, config.default_border[1]); + mask = 0; /* Don’t generate events for our new window, it should *not* be managed */