From a1dd74da5a6074da934fba53ecf70b8da23aae26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Tue, 7 Dec 2010 21:32:04 -0200 Subject: [PATCH] Implement default border styles (thanks litemotiv). --- include/config.h | 3 ++- include/data.h | 3 ++- src/cfgparse.l | 3 +++ src/cfgparse.y | 15 ++++++++++++--- src/con.c | 4 ++++ src/config.c | 1 + 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/include/config.h b/include/config.h index abbee5e7..eaa14f60 100644 --- a/include/config.h +++ b/include/config.h @@ -107,7 +107,8 @@ struct Config { * comes with i3. Thus, you can turn it off entirely. */ bool disable_workspace_bar; - const char *default_border; + /** The default border style for new windows. */ + border_style_t default_border; /** The modifier which needs to be pressed in combination with your mouse * buttons to do things with floating windows (move, resize) */ diff --git a/include/data.h b/include/data.h index 06ceef0b..6f4a4738 100644 --- a/include/data.h +++ b/include/data.h @@ -42,6 +42,7 @@ typedef struct Window i3Window; *****************************************************************************/ typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t; typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t; +typedef enum { BS_NORMAL = 0, BS_NONE = 1, BS_1PIXEL = 3 } border_style_t; enum { BIND_NONE = 0, @@ -331,7 +332,7 @@ struct Con { enum { CF_NONE = 0, CF_OUTPUT = 1, CF_GLOBAL = 2 } fullscreen_mode; enum { L_DEFAULT = 0, L_STACKED = 1, L_TABBED = 2 } layout; - enum { BS_NORMAL = 0, BS_NONE = 1, BS_1PIXEL = 3 } border_style; + border_style_t border_style; /** floating? (= not in tiling layout) This cannot be simply a bool * because we want to keep track of whether the status was set by the * application (by setting _NET_WM_WINDOW_TYPE appropriately) or by the diff --git a/src/cfgparse.l b/src/cfgparse.l index 93ce916c..66afb14b 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -94,6 +94,9 @@ ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; } restart_state { BEGIN(BIND_AWS_COND); return TOKRESTARTSTATE; } new_container { return TOKNEWCONTAINER; } new_window { return TOKNEWWINDOW; } +normal { return TOK_NORMAL; } +none { return TOK_NONE; } +1pixel { return TOK_1PIXEL; } focus_follows_mouse { return TOKFOCUSFOLLOWSMOUSE; } workspace_bar { return TOKWORKSPACEBAR; } default { /* yylval.number = MODE_DEFAULT; */return TOKCONTAINERMODE; } diff --git a/src/cfgparse.y b/src/cfgparse.y index eaed7c5d..c93c33e6 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -225,6 +225,9 @@ void parse_file(const char *f) { %token TOKMODE "mode" %token TOKNEWCONTAINER "new_container" %token TOKNEWWINDOW "new_window" +%token TOK_NORMAL "normal" +%token TOK_NONE "none" +%token TOK_1PIXEL "1pixel" %token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse" %token TOKWORKSPACEBAR "workspace_bar" %token TOKCONTAINERMODE "default/stacking/tabbed" @@ -411,13 +414,19 @@ new_container: ; new_window: - TOKNEWWINDOW WHITESPACE WORD + TOKNEWWINDOW WHITESPACE border_style { - DLOG("new windows should start in mode %s\n", $3); - config.default_border = sstrdup($3); + DLOG("new windows should start with border style %d\n", $3); + config.default_border = $3; } ; +border_style: + TOK_NORMAL { $$ = BS_NORMAL; } + | TOK_NONE { $$ = BS_NONE; } + | TOK_1PIXEL { $$ = BS_1PIXEL; } + ; + bool: NUMBER { diff --git a/src/con.c b/src/con.c index 57ed12e0..8e94c326 100644 --- a/src/con.c +++ b/src/con.c @@ -35,6 +35,7 @@ Con *con_new(Con *parent) { TAILQ_INSERT_TAIL(&all_cons, new, all_cons); new->type = CT_CON; new->name = strdup(""); + new->border_style = config.default_border; static int cnt = 0; LOG("opening window %d\n", cnt); @@ -554,6 +555,9 @@ int con_border_style(Con *con) { if (con->parent->layout == L_STACKED) return BS_NORMAL; + if (con->parent->layout == L_TABBED && con->border_style != BS_NORMAL) + return con_num_children(con->parent) == 1 ? con->border_style : BS_NORMAL; + return con->border_style; } diff --git a/src/config.c b/src/config.c index c02d1c2a..e60fd9b0 100644 --- a/src/config.c +++ b/src/config.c @@ -365,6 +365,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, INIT_COLOR(config.bar.urgent, "#2f343a", "#900000", "#ffffff"); config.restart_state_path = "~/.i3/_restart.json"; + config.default_border = BS_NORMAL; parse_configuration(override_configpath); -- 2.39.5