]> git.sur5r.net Git - i3/i3/commitdiff
Implement configuration setting to change the default border of windows
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 8 Nov 2009 11:43:01 +0000 (12:43 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 8 Nov 2009 11:43:01 +0000 (12:43 +0100)
include/client.h
include/config.h
src/cfgparse.l
src/cfgparse.y
src/client.c
src/manage.c

index 88335f6269624ac21ee9b8af40755253d2212f1f..9da3a5ecbd2b4f9ec24d38d1dbb25190c4cb0961 100644 (file)
@@ -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.
  *
index f11a7b5b249384ce92e807199cb4a688ac764279..32e29cf1f1d6d0428cfc46fece8cd4f6b945e6d8 100644 (file)
@@ -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;
index 11d67dd744322e6011fd821cc3f57ca827d91d95..a80329fddf2b84e631bffb943d11910c77875d44 100644 (file)
@@ -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; }
index 9d34508a6d9566f2a5403960567bae986f147e7f..1669b4ab7b854f992733e325a50c23305082af5c 100644 (file)
@@ -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", $<string>3);
+                config.default_border = strdup($<string>3);
+        }
+        ;
+
 workspace:
         TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen optional_workspace_name
         {
index 6cd11d9d636231d7d9cdcc9aba77698e327bc576..215140c2915294a6a2b50d36e15e3481ce595a4a 100644 (file)
@@ -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;
index d45001341511f9987069d9b30211460421528fa2..23476448dd43ea1922f0f90667ffd4f919ad4fc9 100644 (file)
@@ -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 */