Provide padding settings for monitors

If a padding space is requested for a status bar, it concerns the
underlying monitor.
This commit is contained in:
Bastien Dejean 2013-12-28 10:30:49 +01:00
parent 6561ab1c48
commit b972f0abbd
8 changed files with 72 additions and 48 deletions

View file

@ -2,12 +2,12 @@
.\" Title: bspwm .\" Title: bspwm
.\" Author: [see the "Author" section] .\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 12/27/2013 .\" Date: 12/28/2013
.\" Manual: Bspwm Manual .\" Manual: Bspwm Manual
.\" Source: Bspwm 0.8.7 .\" Source: Bspwm 0.8.7
.\" Language: English .\" Language: English
.\" .\"
.TH "BSPWM" "1" "12/27/2013" "Bspwm 0\&.8\&.7" "Bspwm Manual" .TH "BSPWM" "1" "12/28/2013" "Bspwm 0\&.8\&.7" "Bspwm Manual"
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" * Define some portability stuff .\" * Define some portability stuff
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
@ -1083,6 +1083,12 @@ Ignore EWMH requests to focus a window\&.
.RS 4 .RS 4
Consider disabled monitors as disconnected\&. Consider disabled monitors as disconnected\&.
.RE .RE
.SS "Monitor and Desktop Settings"
.PP
\fItop_padding\fR, \fIright_padding\fR, \fIbottom_padding\fR, \fIleft_padding\fR
.RS 4
Padding space added at the sides of the monitor or desktop\&.
.RE
.SS "Desktop Settings" .SS "Desktop Settings"
.PP .PP
\fIwindow_gap\fR \fIwindow_gap\fR
@ -1090,11 +1096,6 @@ Consider disabled monitors as disconnected\&.
Size of the gap that separates windows\&. Size of the gap that separates windows\&.
.RE .RE
.PP .PP
\fItop_padding\fR, \fIright_padding\fR, \fIbottom_padding\fR, \fIleft_padding\fR
.RS 4
Padding space added at the sides of the desktop\&.
.RE
.PP
\fIborder_width\fR \fIborder_width\fR
.RS 4 .RS 4
Window border width\&. Window border width\&.

View file

@ -658,17 +658,20 @@ Global Settings
'remove_disabled_monitor':: 'remove_disabled_monitor'::
Consider disabled monitors as disconnected. Consider disabled monitors as disconnected.
Desktop Settings Monitor and Desktop Settings
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'window_gap'::
Size of the gap that separates windows.
'top_padding':: 'top_padding'::
'right_padding':: 'right_padding'::
'bottom_padding':: 'bottom_padding'::
'left_padding':: 'left_padding'::
Padding space added at the sides of the desktop. Padding space added at the sides of the monitor or desktop.
Desktop Settings
~~~~~~~~~~~~~~~~
'window_gap'::
Size of the gap that separates windows.
'border_width':: 'border_width'::
Window border width. Window border width.

View file

@ -863,32 +863,41 @@ bool set_setting(coordinates_t loc, char *name, char *value)
if (sscanf(value, "%u", &bw) != 1) if (sscanf(value, "%u", &bw) != 1)
return false; return false;
DESKSET(border_width, bw) DESKSET(border_width, bw)
} else if (streq("top_padding", name)) {
int tp;
if (sscanf(value, "%i", &tp) != 1)
return false;
DESKSET(top_padding, tp)
} else if (streq("right_padding", name)) {
int rp;
if (sscanf(value, "%i", &rp) != 1)
return false;
DESKSET(right_padding, rp)
} else if (streq("bottom_padding", name)) {
int bp;
if (sscanf(value, "%i", &bp) != 1)
return false;
DESKSET(bottom_padding, bp)
} else if (streq("left_padding", name)) {
int lp;
if (sscanf(value, "%i", &lp) != 1)
return false;
DESKSET(left_padding, lp)
} else if (streq("window_gap", name)) { } else if (streq("window_gap", name)) {
int wg; int wg;
if (sscanf(value, "%i", &wg) != 1) if (sscanf(value, "%i", &wg) != 1)
return false; return false;
DESKSET(window_gap, wg) DESKSET(window_gap, wg)
#undef DESKSET #undef DESKSET
#define MONDESKSET(k, v) \
if (loc.desktop != NULL) \
loc.desktop->k = v; \
else if (loc.monitor != NULL) \
loc.monitor->k = v; \
else \
for (monitor_t *m = mon_head; m != NULL; m = m->next) \
m->k = v;
} else if (streq("top_padding", name)) {
int tp;
if (sscanf(value, "%i", &tp) != 1)
return false;
MONDESKSET(top_padding, tp)
} else if (streq("right_padding", name)) {
int rp;
if (sscanf(value, "%i", &rp) != 1)
return false;
MONDESKSET(right_padding, rp)
} else if (streq("bottom_padding", name)) {
int bp;
if (sscanf(value, "%i", &bp) != 1)
return false;
MONDESKSET(bottom_padding, bp)
} else if (streq("left_padding", name)) {
int lp;
if (sscanf(value, "%i", &lp) != 1)
return false;
MONDESKSET(left_padding, lp)
#undef MONDESKSET
#define SETSTR(s) \ #define SETSTR(s) \
} else if (streq(#s, name)) { \ } else if (streq(#s, name)) { \
return snprintf(s, sizeof(s), "%s", value) >= 0; return snprintf(s, sizeof(s), "%s", value) >= 0;
@ -986,16 +995,18 @@ bool get_setting(coordinates_t loc, char *name, char* rsp)
snprintf(rsp, BUFSIZ, "%s", external_rules_command); snprintf(rsp, BUFSIZ, "%s", external_rules_command);
else if (streq("status_prefix", name)) else if (streq("status_prefix", name))
snprintf(rsp, BUFSIZ, "%s", status_prefix); snprintf(rsp, BUFSIZ, "%s", status_prefix);
#define DESKGET(k) \ #define MONDESKGET(k) \
else if (streq(#k, name)) \ else if (streq(#k, name)) \
if (loc.desktop == NULL) \ if (loc.desktop != NULL) \
return false; \ snprintf(rsp, BUFSIZ, "%i", loc.desktop->k); \
else if (loc.monitor != NULL) \
snprintf(rsp, BUFSIZ, "%i", loc.monitor->k); \
else \ else \
snprintf(rsp, BUFSIZ, "%i", loc.desktop->k); return false;
DESKGET(top_padding) MONDESKGET(top_padding)
DESKGET(right_padding) MONDESKGET(right_padding)
DESKGET(bottom_padding) MONDESKGET(bottom_padding)
DESKGET(left_padding) MONDESKGET(left_padding)
#undef DESKGET #undef DESKGET
#define GETCOLOR(s) \ #define GETCOLOR(s) \
else if (streq(#s, name)) \ else if (streq(#s, name)) \

View file

@ -42,6 +42,7 @@ monitor_t *make_monitor(xcb_rectangle_t rect)
m->prev = m->next = NULL; m->prev = m->next = NULL;
m->desk = m->desk_head = m->desk_tail = NULL; m->desk = m->desk_head = m->desk_tail = NULL;
m->rectangle = rect; m->rectangle = rect;
m->top_padding = m->right_padding = m->bottom_padding = m->left_padding = 0;
m->wired = true; m->wired = true;
m->num_sticky = 0; m->num_sticky = 0;
uint32_t mask = XCB_CW_EVENT_MASK; uint32_t mask = XCB_CW_EVENT_MASK;

View file

@ -44,7 +44,7 @@ void query_monitors(coordinates_t loc, domain_t dom, char *rsp)
strncat(rsp, line, REMLEN(rsp)); strncat(rsp, line, REMLEN(rsp));
continue; continue;
} else { } else {
snprintf(line, sizeof(line), "%s %ux%u%+i%+i", m->name, m->rectangle.width, m->rectangle.height, m->rectangle.x, m->rectangle.y); snprintf(line, sizeof(line), "%s %ux%u%+i%+i %i,%i,%i,%i", m->name, m->rectangle.width, m->rectangle.height, m->rectangle.x, m->rectangle.y, m->top_padding, m->right_padding, m->bottom_padding, m->left_padding);
strncat(rsp, line, REMLEN(rsp)); strncat(rsp, line, REMLEN(rsp));
if (m == mon) if (m == mon)
strncat(rsp, " *", REMLEN(rsp)); strncat(rsp, " *", REMLEN(rsp));

View file

@ -64,15 +64,19 @@ void restore_tree(char *file_path)
level++; level++;
if (level == 0) { if (level == 0) {
int x, y; int x, y, top, right, bottom, left;
unsigned int w, h; unsigned int w, h;
char end = 0; char end = 0;
name[0] = '\0'; name[0] = '\0';
sscanf(line + level, "%s %ux%u%i%i %c", name, &w, &h, &x, &y, &end); sscanf(line + level, "%s %ux%u%i%i %i,%i,%i,%i %c", name, &w, &h, &x, &y, &top, &right, &bottom, &left, &end);
m = find_monitor(name); m = find_monitor(name);
if (m == NULL) if (m == NULL)
continue; continue;
m->rectangle = (xcb_rectangle_t) {x, y, w, h}; m->rectangle = (xcb_rectangle_t) {x, y, w, h};
m->top_padding = top;
m->right_padding = right;
m->bottom_padding = bottom;
m->left_padding = left;
if (end != 0) if (end != 0)
mon = m; mon = m;
} else if (level == 2) { } else if (level == 2) {

8
tree.c
View file

@ -44,10 +44,10 @@ void arrange(monitor_t *m, desktop_t *d)
xcb_rectangle_t rect = m->rectangle; xcb_rectangle_t rect = m->rectangle;
int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : d->window_gap); int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : d->window_gap);
rect.x += d->left_padding + wg; rect.x += m->left_padding + d->left_padding + wg;
rect.y += d->top_padding + wg; rect.y += m->top_padding + d->top_padding + wg;
rect.width -= d->left_padding + d->right_padding + wg; rect.width -= m->left_padding + d->left_padding + d->right_padding + m->right_padding + wg;
rect.height -= d->top_padding + d->bottom_padding + wg; rect.height -= m->top_padding + d->top_padding + d->bottom_padding + m->bottom_padding + wg;
apply_layout(m, d, d->root, rect, rect); apply_layout(m, d, d->root, rect, rect);
} }

View file

@ -200,6 +200,10 @@ struct monitor_t {
xcb_rectangle_t rectangle; xcb_rectangle_t rectangle;
xcb_window_t root; xcb_window_t root;
bool wired; bool wired;
int top_padding;
int right_padding;
int bottom_padding;
int left_padding;
desktop_t *desk; desktop_t *desk;
desktop_t *desk_head; desktop_t *desk_head;
desktop_t *desk_tail; desktop_t *desk_tail;