Implement default border styles (thanks litemotiv).

This commit is contained in:
Fernando Tarlá Cardoso Lemos 2010-12-07 21:32:04 -02:00 committed by Michael Stapelberg
parent 41eb810531
commit a1dd74da5a
6 changed files with 24 additions and 5 deletions

View File

@ -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) */

View File

@ -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

View File

@ -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; }

View File

@ -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", $<string>3);
config.default_border = sstrdup($<string>3);
DLOG("new windows should start with border style %d\n", $<number>3);
config.default_border = $<number>3;
}
;
border_style:
TOK_NORMAL { $<number>$ = BS_NORMAL; }
| TOK_NONE { $<number>$ = BS_NONE; }
| TOK_1PIXEL { $<number>$ = BS_1PIXEL; }
;
bool:
NUMBER
{

View File

@ -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;
}

View File

@ -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);