Turn {top,right,bottom,left}_padding into desktop settings

This commit is contained in:
Bastien Dejean 2013-12-25 10:06:02 +01:00
parent 986825a118
commit 471fd2c7fc
9 changed files with 60 additions and 61 deletions

View file

@ -118,6 +118,7 @@ desktop_t *make_desktop(const char *name)
d->layout = LAYOUT_TILED;
d->prev = d->next = NULL;
d->root = d->focus = NULL;
d->top_padding = d->right_padding = d->bottom_padding = d->left_padding = 0;
d->window_gap = WINDOW_GAP;
d->border_width = BORDER_WIDTH;
d->floating = false;

View file

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

View file

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

View file

@ -865,27 +865,32 @@ bool set_setting(coordinates_t loc, char *name, char *value)
if (sscanf(value, "%u", &bw) != 1)
return false;
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)) {
int wg;
if (sscanf(value, "%i", &wg) != 1)
return false;
DESKSET(window_gap, wg)
#undef DESKSET
#define MONSET(k) \
} else if (streq(#k, name)) { \
int v; \
if (sscanf(value, "%i", &v) != 1) \
return false; \
if (loc.monitor != NULL) \
loc.monitor->k = v; \
else \
for (monitor_t *m = mon_head; m!= NULL; m = m->next) \
m->k = v;
MONSET(top_padding)
MONSET(right_padding)
MONSET(bottom_padding)
MONSET(left_padding)
#undef MONSET
#define SETSTR(s) \
} else if (streq(#s, name)) { \
return snprintf(s, sizeof(s), "%s", value) >= 0;
@ -1003,17 +1008,17 @@ bool get_setting(coordinates_t loc, char *name, char* rsp)
snprintf(rsp, BUFSIZ, "%s", external_rules_command);
else if (streq("status_prefix", name))
snprintf(rsp, BUFSIZ, "%s", status_prefix);
#define MONGET(k) \
#define DESKGET(k) \
else if (streq(#k, name)) \
if (loc.monitor == NULL) \
if (loc.desktop == NULL) \
return false; \
else \
snprintf(rsp, BUFSIZ, "%i", loc.monitor->k);
MONGET(top_padding)
MONGET(right_padding)
MONGET(bottom_padding)
MONGET(left_padding)
#undef MONGET
snprintf(rsp, BUFSIZ, "%i", loc.desktop->k);
DESKGET(top_padding)
DESKGET(right_padding)
DESKGET(bottom_padding)
DESKGET(left_padding)
#undef DESKGET
#define GETOPACITY(s) \
else if (streq(#s, name)) \
snprintf(rsp, BUFSIZ, "%lf", s);

View file

@ -42,7 +42,6 @@ monitor_t *make_monitor(xcb_rectangle_t rect)
m->prev = m->next = NULL;
m->desk = m->desk_head = m->desk_tail = NULL;
m->rectangle = rect;
m->top_padding = m->right_padding = m->bottom_padding = m->left_padding = 0;
m->wired = true;
m->num_sticky = 0;
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));
continue;
} else {
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);
snprintf(line, sizeof(line), "%s %ux%u%+i%+i", m->name, m->rectangle.width, m->rectangle.height, m->rectangle.x, m->rectangle.y);
strncat(rsp, line, REMLEN(rsp));
if (m == mon)
strncat(rsp, " *", REMLEN(rsp));
@ -68,7 +68,7 @@ void query_desktops(monitor_t *m, domain_t dom, coordinates_t loc, unsigned int
strncat(rsp, line, REMLEN(rsp));
continue;
} else {
snprintf(line, sizeof(line), "%s %u %i %c %c", d->name, d->border_width, d->window_gap, (d->layout == LAYOUT_TILED ? 'T' : 'M'), (d->floating ? 'f' : '-'));
snprintf(line, sizeof(line), "%s %u %i %i,%i,%i,%i %c %c", d->name, d->border_width, d->window_gap, d->top_padding, d->right_padding, d->bottom_padding, d->left_padding, (d->layout == LAYOUT_TILED ? 'T' : 'M'), (d->floating ? 'f' : '-'));
strncat(rsp, line, REMLEN(rsp));
if (d == m->desk)
strncat(rsp, " *", REMLEN(rsp));

View file

@ -64,36 +64,36 @@ void restore_tree(char *file_path)
level++;
if (level == 0) {
int x, y, left, right, top, bottom;
int x, y;
unsigned int w, h;
char end = 0;
name[0] = '\0';
sscanf(line + level, "%s %ux%u%i%i %i,%i,%i,%i %c", name, &w, &h, &x, &y, &top, &right, &bottom, &left, &end);
sscanf(line + level, "%s %ux%u%i%i %c", name, &w, &h, &x, &y, &end);
m = find_monitor(name);
if (m == NULL)
continue;
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)
mon = m;
} else if (level == 2) {
if (m == NULL)
continue;
int wg;
int wg, top, right, bottom, left;
unsigned int bw;
char floating, layout = 0, end = 0;
name[0] = '\0';
loc.desktop = NULL;
sscanf(line + level, "%s %u %i %c %c %c", name, &bw, &wg, &layout, &floating, &end);
sscanf(line + level, "%s %u %i %i,%i,%i,%i %c %c %c", name, &bw, &wg, &top, &right, &bottom, &left, &layout, &floating, &end);
locate_desktop(name, &loc);
d = loc.desktop;
if (d == NULL)
continue;
d->border_width = bw;
d->window_gap = wg;
d->top_padding = top;
d->right_padding = right;
d->bottom_padding = bottom;
d->left_padding = left;
if (layout == 'M')
d->layout = LAYOUT_MONOCLE;
else if (layout == 'T')
@ -101,7 +101,6 @@ void restore_tree(char *file_path)
d->floating = (floating == '-' ? false : true);
if (end != 0)
m->desk = d;
} else {
if (m == NULL || d == NULL)
continue;
@ -123,7 +122,6 @@ void restore_tree(char *file_path)
birth->parent = n;
}
n = birth;
char br;
if (isupper(line[level])) {
char st;

8
tree.c
View file

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

View file

@ -194,6 +194,10 @@ struct desktop_t {
node_t *focus;
desktop_t *prev;
desktop_t *next;
int top_padding;
int right_padding;
int bottom_padding;
int left_padding;
int window_gap;
unsigned int border_width;
bool floating;
@ -206,10 +210,6 @@ struct monitor_t {
xcb_rectangle_t rectangle;
xcb_window_t root;
bool wired;
int top_padding;
int right_padding;
int bottom_padding;
int left_padding;
desktop_t *desk;
desktop_t *desk_head;
desktop_t *desk_tail;