Implement configuration setting to change the default border of windows
This commit is contained in:
parent
876417f49d
commit
64c99cb235
|
@ -85,6 +85,14 @@ bool client_is_floating(Client *client);
|
||||||
*/
|
*/
|
||||||
void client_change_border(xcb_connection_t *conn, Client *client, char border_type);
|
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.
|
* Unmap the client, correctly setting any state which is needed.
|
||||||
*
|
*
|
||||||
|
|
|
@ -76,6 +76,8 @@ struct Config {
|
||||||
int container_stack_limit;
|
int container_stack_limit;
|
||||||
int container_stack_limit_value;
|
int container_stack_limit_value;
|
||||||
|
|
||||||
|
const char *default_border;
|
||||||
|
|
||||||
/** The modifier which needs to be pressed in combination with your mouse
|
/** The modifier which needs to be pressed in combination with your mouse
|
||||||
* buttons to do things with floating windows (move, resize) */
|
* buttons to do things with floating windows (move, resize) */
|
||||||
uint32_t floating_modifier;
|
uint32_t floating_modifier;
|
||||||
|
|
|
@ -43,6 +43,7 @@ set[^\n]* { return TOKCOMMENT; }
|
||||||
ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
ipc-socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
||||||
ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
ipc_socket { BEGIN(BIND_AWS_COND); return TOKIPCSOCKET; }
|
||||||
new_container { return TOKNEWCONTAINER; }
|
new_container { return TOKNEWCONTAINER; }
|
||||||
|
new_window { return TOKNEWWINDOW; }
|
||||||
default { yylval.number = MODE_DEFAULT; return TOKCONTAINERMODE; }
|
default { yylval.number = MODE_DEFAULT; return TOKCONTAINERMODE; }
|
||||||
stacking { yylval.number = MODE_STACK; return TOKCONTAINERMODE; }
|
stacking { yylval.number = MODE_STACK; return TOKCONTAINERMODE; }
|
||||||
tabbed { yylval.number = MODE_TABBED; return TOKCONTAINERMODE; }
|
tabbed { yylval.number = MODE_TABBED; return TOKCONTAINERMODE; }
|
||||||
|
|
|
@ -194,6 +194,7 @@ void parse_file(const char *f) {
|
||||||
%token TOKARROW
|
%token TOKARROW
|
||||||
%token TOKMODE
|
%token TOKMODE
|
||||||
%token TOKNEWCONTAINER
|
%token TOKNEWCONTAINER
|
||||||
|
%token TOKNEWWINDOW
|
||||||
%token TOKCONTAINERMODE
|
%token TOKCONTAINERMODE
|
||||||
%token TOKSTACKLIMIT
|
%token TOKSTACKLIMIT
|
||||||
|
|
||||||
|
@ -209,6 +210,7 @@ line:
|
||||||
| mode
|
| mode
|
||||||
| floating_modifier
|
| floating_modifier
|
||||||
| new_container
|
| new_container
|
||||||
|
| new_window
|
||||||
| workspace
|
| workspace
|
||||||
| assign
|
| assign
|
||||||
| ipcsocket
|
| 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:
|
workspace:
|
||||||
TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen optional_workspace_name
|
TOKWORKSPACE WHITESPACE NUMBER WHITESPACE TOKSCREEN WHITESPACE screen optional_workspace_name
|
||||||
{
|
{
|
||||||
|
|
23
src/client.c
23
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
|
* 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) {
|
switch (border_type) {
|
||||||
case 'n':
|
case 'n':
|
||||||
LOG("Changing to normal border\n");
|
LOG("Changing to normal border\n");
|
||||||
client->titlebar_position = TITLEBAR_TOP;
|
client->titlebar_position = TITLEBAR_TOP;
|
||||||
client->borderless = false;
|
client->borderless = false;
|
||||||
break;
|
return true;
|
||||||
case 'p':
|
case 'p':
|
||||||
LOG("Changing to 1px border\n");
|
LOG("Changing to 1px border\n");
|
||||||
client->titlebar_position = TITLEBAR_OFF;
|
client->titlebar_position = TITLEBAR_OFF;
|
||||||
client->borderless = false;
|
client->borderless = false;
|
||||||
break;
|
return true;
|
||||||
case 'b':
|
case 'b':
|
||||||
LOG("Changing to borderless\n");
|
LOG("Changing to borderless\n");
|
||||||
client->titlebar_position = TITLEBAR_OFF;
|
client->titlebar_position = TITLEBAR_OFF;
|
||||||
client->borderless = true;
|
client->borderless = true;
|
||||||
break;
|
return true;
|
||||||
default:
|
default:
|
||||||
LOG("Unknown border mode\n");
|
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 */
|
/* Ensure that the child’s position inside our window gets updated */
|
||||||
client->force_reconfigure = true;
|
client->force_reconfigure = true;
|
||||||
|
|
|
@ -183,6 +183,9 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
|
||||||
new->floating_rect.width = width;
|
new->floating_rect.width = width;
|
||||||
new->floating_rect.height = height;
|
new->floating_rect.height = height;
|
||||||
|
|
||||||
|
if (config.default_border != NULL)
|
||||||
|
client_init_border(conn, new, config.default_border[1]);
|
||||||
|
|
||||||
mask = 0;
|
mask = 0;
|
||||||
|
|
||||||
/* Don’t generate events for our new window, it should *not* be managed */
|
/* Don’t generate events for our new window, it should *not* be managed */
|
||||||
|
|
Loading…
Reference in New Issue