create hide_edge_borders option
This commit is contained in:
committed by
Michael Stapelberg
parent
48f1e383ca
commit
f27735f620
@ -200,6 +200,7 @@ new_float { return TOKNEWFLOAT; }
|
||||
normal { return TOK_NORMAL; }
|
||||
none { return TOK_NONE; }
|
||||
1pixel { return TOK_1PIXEL; }
|
||||
hide_edge_borders { return TOK_HIDE_EDGE_BORDERS; }
|
||||
focus_follows_mouse { return TOKFOCUSFOLLOWSMOUSE; }
|
||||
force_focus_wrapping { return TOK_FORCE_FOCUS_WRAPPING; }
|
||||
force_xinerama { return TOK_FORCE_XINERAMA; }
|
||||
|
@ -735,6 +735,7 @@ void parse_file(const char *f) {
|
||||
%token TOK_NORMAL "normal"
|
||||
%token TOK_NONE "none"
|
||||
%token TOK_1PIXEL "1pixel"
|
||||
%token TOK_HIDE_EDGE_BORDERS "hide_edge_borders"
|
||||
%token TOKFOCUSFOLLOWSMOUSE "focus_follows_mouse"
|
||||
%token TOK_FORCE_FOCUS_WRAPPING "force_focus_wrapping"
|
||||
%token TOK_FORCE_XINERAMA "force_xinerama"
|
||||
@ -833,6 +834,7 @@ line:
|
||||
| workspace_layout
|
||||
| new_window
|
||||
| new_float
|
||||
| hide_edge_borders
|
||||
| focus_follows_mouse
|
||||
| force_focus_wrapping
|
||||
| force_xinerama
|
||||
@ -1474,6 +1476,14 @@ bool:
|
||||
}
|
||||
;
|
||||
|
||||
hide_edge_borders:
|
||||
TOK_HIDE_EDGE_BORDERS bool
|
||||
{
|
||||
DLOG("hide edge borders = %d\n", $2);
|
||||
config.hide_edge_borders = $2;
|
||||
}
|
||||
;
|
||||
|
||||
focus_follows_mouse:
|
||||
TOKFOCUSFOLLOWSMOUSE bool
|
||||
{
|
||||
|
38
src/con.c
38
src/con.c
@ -934,12 +934,32 @@ Con *con_descend_direction(Con *con, direction_t direction) {
|
||||
*
|
||||
*/
|
||||
Rect con_border_style_rect(Con *con) {
|
||||
adjacent_t adjacent_to = ADJ_NONE;
|
||||
Rect result;
|
||||
if (config.hide_edge_borders)
|
||||
adjacent_to = con_adjacent_borders(con);
|
||||
switch (con_border_style(con)) {
|
||||
case BS_NORMAL:
|
||||
return (Rect){2, 0, -(2 * 2), -2};
|
||||
result = (Rect){2, 0, -(2 * 2), -2};
|
||||
if (adjacent_to & ADJ_LEFT_SCREEN_EDGE) {
|
||||
result.x -= 2;
|
||||
result.width += 2;
|
||||
}
|
||||
if (adjacent_to & ADJ_RIGHT_SCREEN_EDGE) {
|
||||
result.width += 2;
|
||||
}
|
||||
return result;
|
||||
|
||||
case BS_1PIXEL:
|
||||
return (Rect){1, 1, -2, -2};
|
||||
result = (Rect){1, 1, -2, -2};
|
||||
if (adjacent_to & ADJ_LEFT_SCREEN_EDGE) {
|
||||
result.x -= 1;
|
||||
result.width += 1;
|
||||
}
|
||||
if (adjacent_to & ADJ_RIGHT_SCREEN_EDGE) {
|
||||
result.width += 1;
|
||||
}
|
||||
return result;
|
||||
|
||||
case BS_NONE:
|
||||
return (Rect){0, 0, 0, 0};
|
||||
@ -949,6 +969,20 @@ Rect con_border_style_rect(Con *con) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns adjacent borders of the window. We need this if hide_edge_borders is
|
||||
* enabled.
|
||||
*/
|
||||
adjacent_t con_adjacent_borders(Con *con) {
|
||||
adjacent_t result = ADJ_NONE;
|
||||
Con *output = con_get_output(con);
|
||||
if (con->rect.x == output->rect.x)
|
||||
result |= ADJ_LEFT_SCREEN_EDGE;
|
||||
if (con->rect.x + con->rect.width == output->rect.x + output->rect.width)
|
||||
result |= ADJ_RIGHT_SCREEN_EDGE;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use this function to get a container’s border style. This is important
|
||||
* because when inside a stack, the border style is always BS_NORMAL.
|
||||
|
19
src/x.c
19
src/x.c
@ -299,6 +299,9 @@ void x_window_kill(xcb_window_t window, kill_window_t kill_window) {
|
||||
void x_draw_decoration(Con *con) {
|
||||
Con *parent = con->parent;
|
||||
bool leaf = con_is_leaf(con);
|
||||
adjacent_t adjacent_to = ADJ_NONE;
|
||||
if (config.hide_edge_borders)
|
||||
adjacent_to = con_adjacent_borders(con);
|
||||
/* This code needs to run for:
|
||||
* • leaf containers
|
||||
* • non-leaf containers which are in a stacked/tabbed container
|
||||
@ -408,12 +411,16 @@ void x_draw_decoration(Con *con) {
|
||||
* rectangle because some childs are not freely resizable and we want
|
||||
* their background color to "shine through". */
|
||||
xcb_change_gc(conn, con->pm_gc, XCB_GC_FOREGROUND, (uint32_t[]){ p->color->background });
|
||||
xcb_rectangle_t borders[] = {
|
||||
{ 0, 0, br.x, r->height },
|
||||
{ 0, r->height + br.height + br.y, r->width, r->height },
|
||||
{ r->width + br.width + br.x, 0, r->width, r->height }
|
||||
};
|
||||
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 3, borders);
|
||||
if (!(adjacent_to & ADJ_LEFT_SCREEN_EDGE)) {
|
||||
xcb_rectangle_t leftline = { 0, 0, br.x, r->height };
|
||||
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &leftline);
|
||||
}
|
||||
if (!(adjacent_to & ADJ_RIGHT_SCREEN_EDGE)) {
|
||||
xcb_rectangle_t rightline = { r->width + br.width + br.x, 0, r->width, r->height };
|
||||
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &rightline);
|
||||
}
|
||||
xcb_rectangle_t bottomline = { 0, r->height + br.height + br.y, r->width, r->height };
|
||||
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, 1, &bottomline);
|
||||
/* 1pixel border needs an additional line at the top */
|
||||
if (p->border_style == BS_1PIXEL) {
|
||||
xcb_rectangle_t topline = { br.x, 0, con->rect.width + br.width + br.x, br.y };
|
||||
|
Reference in New Issue
Block a user