Add tile_gap option.

Pixel width of empty space between tiled windows.

Add region_padding option.
Pixel width of empty space within region borders.
This commit is contained in:
Reginald Kennedy 2012-10-24 19:11:46 +08:00
parent ec0be0e550
commit 94c892a9de
3 changed files with 41 additions and 11 deletions

View file

@ -321,6 +321,9 @@ e.g.\& screen[1]:800x1200+0+0.
To make a region span multiple monitors, create a region big enough to cover To make a region span multiple monitors, create a region big enough to cover
them all, e.g. screen[1]:2048x768+0+0 makes the region span two monitors with them all, e.g. screen[1]:2048x768+0+0 makes the region span two monitors with
1024x768 resolution sitting one next to the other. 1024x768 resolution sitting one next to the other.
.It Ic region_padding
Pixel width of empty space within region borders.
Disable by setting to 0.
.It Ic spawn_position .It Ic spawn_position
Position in stack to place newly spawned windows. Position in stack to place newly spawned windows.
Possible values are Possible values are
@ -354,6 +357,9 @@ Users may need to set program[term] (see the
section) to use an alternate copy of the section) to use an alternate copy of the
.Xr xterm 1 .Xr xterm 1
binary without the setgid bit set. binary without the setgid bit set.
.It Ic tile_gap
Pixel width of empty space between tiled windows.
Disable by setting to 0.
.It Ic title_class_enabled .It Ic title_class_enabled
Enable or disable displaying the window class in the status bar. Enable or disable displaying the window class in the status bar.
Enable by setting to 1. Enable by setting to 1.

View file

@ -374,6 +374,8 @@ int focus_default = SWM_STACK_TOP;
int spawn_position = SWM_STACK_TOP; int spawn_position = SWM_STACK_TOP;
int disable_border = 0; int disable_border = 0;
int border_width = 1; int border_width = 1;
int region_padding = 0;
int tile_gap = 0;
int verbose_layout = 0; int verbose_layout = 0;
time_t time_started; time_t time_started;
pid_t bar_pid; pid_t bar_pid;
@ -3946,10 +3948,12 @@ stack(void) {
DNPRINTF(SWM_D_STACK, "stack: workspace: %d " DNPRINTF(SWM_D_STACK, "stack: workspace: %d "
"(screen: %d, region: %d)\n", r->ws->idx, i, j++); "(screen: %d, region: %d)\n", r->ws->idx, i, j++);
/* start with screen geometry, adjust for bar */ /* Adjust stack area for region bar and padding. */
g = r->g; g = r->g;
g.w -= 2 * border_width; g.x += region_padding;
g.h -= 2 * border_width; g.y += region_padding;
g.w -= 2 * border_width + 2 * region_padding;
g.h -= 2 * border_width + 2 * region_padding;
if (bar_enabled && r->ws->bar_enabled) { if (bar_enabled && r->ws->bar_enabled) {
if (!bar_at_bottom) if (!bar_at_bottom)
g.y += bar_height; g.y += bar_height;
@ -4185,9 +4189,7 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
/* stack all the tiled windows */ /* stack all the tiled windows */
i = j = 0, s = stacks; i = j = 0, s = stacks;
TAILQ_FOREACH(win, &ws->winlist, entry) { TAILQ_FOREACH(win, &ws->winlist, entry) {
if (win->transient || win->floating) if (win->transient || win->floating || win->iconic)
continue;
if (win->iconic)
continue; continue;
if (win->ewmh_flags & EWMH_F_FULLSCREEN) { if (win->ewmh_flags & EWMH_F_FULLSCREEN) {
@ -4205,16 +4207,20 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
if (flip) if (flip)
win_g.x = r_g.x; win_g.x = r_g.x;
else else
win_g.x += win_g.w + 2 * border_width; win_g.x += win_g.w + 2 * border_width +
tile_gap;
win_g.w = (r_g.w - msize - win_g.w = (r_g.w - msize -
(stacks * 2 * border_width)) / stacks; (stacks * (2 * border_width + tile_gap))) / stacks;
if (s == 1) if (s == 1)
win_g.w += (r_g.w - msize - win_g.w += (r_g.w - msize -
(stacks * 2 * border_width)) % stacks; (stacks * (2 * border_width + tile_gap))) %
stacks;
s--; s--;
j = 0; j = 0;
} }
win_g.h = hrh - 2 * border_width;
win_g.h = hrh - 2 * border_width - tile_gap;
if (rot) { if (rot) {
h_inc = win->sh.width_inc; h_inc = win->sh.width_inc;
h_base = win->sh.base_width; h_base = win->sh.base_width;
@ -4222,6 +4228,7 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
h_inc = win->sh.height_inc; h_inc = win->sh.height_inc;
h_base = win->sh.base_height; h_base = win->sh.base_height;
} }
if (j == colno - 1) { if (j == colno - 1) {
win_g.h = hrh + extra; win_g.h = hrh + extra;
} else if (h_inc > 1 && h_inc < h_slice) { } else if (h_inc > 1 && h_inc < h_slice) {
@ -4241,7 +4248,7 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
if (j == 0) if (j == 0)
win_g.y = r_g.y; win_g.y = r_g.y;
else else
win_g.y += last_h + 2 * border_width; win_g.y += last_h + 2 * border_width + tile_gap;
if (disable_border && !(bar_enabled && ws->bar_enabled) && if (disable_border && !(bar_enabled && ws->bar_enabled) &&
winno == 1){ winno == 1){
@ -4251,6 +4258,7 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
} else { } else {
bordered = 1; bordered = 1;
} }
if (rot) { if (rot) {
if (X(win) != win_g.y || Y(win) != win_g.x || if (X(win) != win_g.y || Y(win) != win_g.x ||
WIDTH(win) != win_g.h || HEIGHT(win) != win_g.w) { WIDTH(win) != win_g.h || HEIGHT(win) != win_g.w) {
@ -6662,12 +6670,14 @@ enum {
SWM_S_FOCUS_CLOSE_WRAP, SWM_S_FOCUS_CLOSE_WRAP,
SWM_S_FOCUS_DEFAULT, SWM_S_FOCUS_DEFAULT,
SWM_S_FOCUS_MODE, SWM_S_FOCUS_MODE,
SWM_S_REGION_PADDING,
SWM_S_SPAWN_ORDER, SWM_S_SPAWN_ORDER,
SWM_S_SPAWN_TERM, SWM_S_SPAWN_TERM,
SWM_S_SS_APP, SWM_S_SS_APP,
SWM_S_SS_ENABLED, SWM_S_SS_ENABLED,
SWM_S_STACK_ENABLED, SWM_S_STACK_ENABLED,
SWM_S_TERM_WIDTH, SWM_S_TERM_WIDTH,
SWM_S_TILE_GAP,
SWM_S_TITLE_CLASS_ENABLED, SWM_S_TITLE_CLASS_ENABLED,
SWM_S_TITLE_NAME_ENABLED, SWM_S_TITLE_NAME_ENABLED,
SWM_S_URGENT_ENABLED, SWM_S_URGENT_ENABLED,
@ -6817,6 +6827,11 @@ setconfvalue(char *selector, char *value, int flags)
else else
errx(1, "focus_mode"); errx(1, "focus_mode");
break; break;
case SWM_S_REGION_PADDING:
region_padding = atoi(value);
if (region_padding < 0)
region_padding = 0;
break;
case SWM_S_SPAWN_ORDER: case SWM_S_SPAWN_ORDER:
if (!strcmp(value, "first")) if (!strcmp(value, "first"))
spawn_position = SWM_STACK_BOTTOM; spawn_position = SWM_STACK_BOTTOM;
@ -6847,6 +6862,11 @@ setconfvalue(char *selector, char *value, int flags)
if (term_width < 0) if (term_width < 0)
term_width = 0; term_width = 0;
break; break;
case SWM_S_TILE_GAP:
tile_gap = atoi(value);
if (tile_gap < 0)
tile_gap = 0;
break;
case SWM_S_TITLE_CLASS_ENABLED: case SWM_S_TITLE_CLASS_ENABLED:
title_class_enabled = atoi(value); title_class_enabled = atoi(value);
break; break;
@ -7117,12 +7137,14 @@ struct config_option configopt[] = {
{ "program", setconfspawn, 0 }, { "program", setconfspawn, 0 },
{ "quirk", setconfquirk, 0 }, { "quirk", setconfquirk, 0 },
{ "region", setconfregion, 0 }, { "region", setconfregion, 0 },
{ "region_padding", setconfvalue, SWM_S_REGION_PADDING },
{ "screenshot_app", setconfvalue, SWM_S_SS_APP }, { "screenshot_app", setconfvalue, SWM_S_SS_APP },
{ "screenshot_enabled", setconfvalue, SWM_S_SS_ENABLED }, { "screenshot_enabled", setconfvalue, SWM_S_SS_ENABLED },
{ "spawn_position", setconfvalue, SWM_S_SPAWN_ORDER }, { "spawn_position", setconfvalue, SWM_S_SPAWN_ORDER },
{ "spawn_term", setconfvalue, SWM_S_SPAWN_TERM }, { "spawn_term", setconfvalue, SWM_S_SPAWN_TERM },
{ "stack_enabled", setconfvalue, SWM_S_STACK_ENABLED }, { "stack_enabled", setconfvalue, SWM_S_STACK_ENABLED },
{ "term_width", setconfvalue, SWM_S_TERM_WIDTH }, { "term_width", setconfvalue, SWM_S_TERM_WIDTH },
{ "tile_gap", setconfvalue, SWM_S_TILE_GAP },
{ "title_class_enabled", setconfvalue, SWM_S_TITLE_CLASS_ENABLED }, { "title_class_enabled", setconfvalue, SWM_S_TITLE_CLASS_ENABLED },
{ "title_name_enabled", setconfvalue, SWM_S_TITLE_NAME_ENABLED }, { "title_name_enabled", setconfvalue, SWM_S_TITLE_NAME_ENABLED },
{ "urgent_enabled", setconfvalue, SWM_S_URGENT_ENABLED }, { "urgent_enabled", setconfvalue, SWM_S_URGENT_ENABLED },

View file

@ -32,6 +32,8 @@
# stack_enabled = 1 # stack_enabled = 1
# clock_enabled = 1 # clock_enabled = 1
# clock_format = %a %b %d %R %Z %Y # clock_format = %a %b %d %R %Z %Y
# region_padding = 0
# tile_gap = 0
# title_name_enabled = 0 # title_name_enabled = 0
# title_class_enabled = 0 # title_class_enabled = 0
# window_name_enabled = 0 # window_name_enabled = 0