Merge branch 'master' of github.com:seanpringle/xoat

Conflicts:
	config.h
This commit is contained in:
Sean Pringle
2013-01-27 11:40:56 +10:00
6 changed files with 76 additions and 67 deletions

1
.gitattributes vendored
View File

@@ -1 +0,0 @@
config.h merge=ours

View File

@@ -71,9 +71,10 @@ client* window_build_client(Window win)
? 1:0; ? 1:0;
// detect our own title bars // detect our own title bars
for_monitors(i, m) for_spots(j) if (TITLE)
if (m->bars[j] && m->bars[j]->window == c->window) for_monitors(i, m) for_spots(j)
{ c->ours = 1; c->manage = 0; break; } if (m->bars[j] && m->bars[j]->window == c->window)
{ c->ours = 1; c->manage = 0; break; }
if (c->manage) if (c->manage)
{ {
@@ -272,7 +273,7 @@ void client_raise_family(client *c)
client_stack_family(c, &raise); client_stack_family(c, &raise);
if (!c->full) if (!c->full && TITLE)
{ {
// raise spot's title bar in case some other fullscreen or max v/h window has obscured // raise spot's title bar in case some other fullscreen or max v/h window has obscured
monitor *m = &monitors[c->monitor]; monitor *m = &monitors[c->monitor];

View File

@@ -6,11 +6,15 @@
#define BORDER_URGENT "Red" #define BORDER_URGENT "Red"
#define GAP 2 #define GAP 2
// Title bar xft font // Title bar xft font.
// Setting this to NULL will disable title bars
//#define TITLE NULL
#define TITLE "sans:size=8" #define TITLE "sans:size=8"
// Title bar style
#define TITLE_BLUR "Black" #define TITLE_BLUR "Black"
#define TITLE_FOCUS "White" #define TITLE_FOCUS "White"
#define TITLE_ELLIPSIS 30 #define TITLE_ELLIPSIS 32
// There are three static tiles called SPOT1, SPOT2, and SPOT3. // There are three static tiles called SPOT1, SPOT2, and SPOT3.
// Want more tiles? Different layouts? Floating? Go away ;) // Want more tiles? Different layouts? Floating? Go away ;)
@@ -114,10 +118,14 @@ binding keys[] = {
{ .mod = ShiftMask|Mod4Mask, .key = XK_Prior, .act = action_move_monitor, .num = -1 }, { .mod = ShiftMask|Mod4Mask, .key = XK_Prior, .act = action_move_monitor, .num = -1 },
// Launcher // Launcher
{ .mod = Mod4Mask, .key = XK_x, .act = action_command, .data = "dmenu_run" }, { .mod = Mod4Mask, .key = XK_x, .act = action_command, .data = "dmenu_run" },
{ .mod = Mod4Mask, .key = XK_F1, .act = action_command, .data = "konsole" },
{ .mod = Mod4Mask, .key = XK_F2, .act = action_command, .data = "chromium" },
{ .mod = Mod4Mask, .key = XK_F3, .act = action_command, .data = "pcmanfm" },
// Find or start apps by WM_CLASS (lower case match). // Find or start apps by WM_CLASS (lower case match).
// Only works for apps that use some form of their binary name as their class... // Only works for apps that use some form of their binary name as their class...
{ .mod = AnyModifier, .key = XK_F1, .act = action_find_or_start, .data = "xterm" }, { .mod = AnyModifier, .key = XK_F1, .act = action_find_or_start, .data = "konsole" },
{ .mod = AnyModifier, .key = XK_F2, .act = action_find_or_start, .data = "chromium" }, { .mod = AnyModifier, .key = XK_F2, .act = action_find_or_start, .data = "chromium" },
{ .mod = AnyModifier, .key = XK_F3, .act = action_find_or_start, .data = "pcmanfm" },
}; };

View File

@@ -144,6 +144,7 @@ void button_press(XEvent *ev)
if (c && c->manage) if (c && c->manage)
client_activate(c); client_activate(c);
else else
if (TITLE)
for_monitors(i, m) for_spots(j) for_monitors(i, m) for_spots(j)
if (m->bars[j]->window == e->subwindow) if (m->bars[j]->window == e->subwindow)
spot_focus_top_window(j, i, None); spot_focus_top_window(j, i, None);

88
setup.c
View File

@@ -57,6 +57,7 @@ void setup()
// detect and adjust for panel struts // detect and adjust for panel struts
monitor padded[MONITORS]; monitor padded[MONITORS];
memmove(padded, monitors, sizeof(monitor) * MONITORS); memmove(padded, monitors, sizeof(monitor) * MONITORS);
wm_strut all_struts; memset(&all_struts, 0, sizeof(wm_strut));
for_windows(i, c) for_windows(i, c)
{ {
@@ -65,45 +66,37 @@ void setup()
int v1 = v2 ? 0: GETPROP_LONG(c->window, atoms[_NET_WM_STRUT], (unsigned long*)&strut, 4); int v1 = v2 ? 0: GETPROP_LONG(c->window, atoms[_NET_WM_STRUT], (unsigned long*)&strut, 4);
if (!c->visible || (!v1 && !v2)) continue; if (!c->visible || (!v1 && !v2)) continue;
for_monitors(j, m) all_struts.left = MAX(all_struts.left, strut.left);
all_struts.right = MAX(all_struts.right, strut.right);
all_struts.top = MAX(all_struts.top, strut.top);
all_struts.bottom = MAX(all_struts.bottom, strut.bottom);
}
for_monitors(j, m)
{
monitor *p = &padded[j];
// monitor left side of root window?
if (all_struts.left > 0 && !m->x)
{ {
monitor *p = &padded[j]; p->x += all_struts.left;
// convert _NET_WM_STRUT to _PARTIAL p->w -= all_struts.left;
if (v1) }
{ // monitor right side of root window?
strut.ly1 = m->y; strut.ly2 = m->y + m->h; if (all_struts.right > 0 && m->x + m->w == screen_w)
strut.ry1 = m->y; strut.ry3 = m->y + m->h; {
strut.tx1 = m->x; strut.tx2 = m->x + m->w; p->w -= all_struts.right;
strut.bx1 = m->x; strut.bx2 = m->x + m->w; }
} // monitor top side of root window?
// monitor left side of root window? if (all_struts.top > 0 && !m->y)
if (strut.left > 0 && !m->x {
&& INTERSECT(0, strut.ly1, strut.left, strut.ly2 - strut.ly1, m->x, m->y, m->w, m->h)) p->y += all_struts.top;
{ p->h -= all_struts.top;
p->x = MAX(p->x, strut.left); }
p->w = MIN(p->w, m->x + m->w - strut.left); // monitor bottom side of root window?
} if (all_struts.bottom > 0 && m->y + m->h == screen_h)
else {
// monitor right side of root window? p->h -= all_struts.bottom;
if (strut.right > 0 && m->x + m->w == screen_w
&& INTERSECT(screen_w - strut.right, strut.ry1, strut.right, strut.ry3 - strut.ry1, m->x, m->y, m->w, m->h))
{
p->w = MIN(p->w, m->x + m->w - strut.right);
}
// monitor top side of root window?
if (strut.top > 0 && !m->y
&& INTERSECT(strut.tx1, 0, strut.tx2 - strut.tx1, strut.top, m->x, m->y, m->w, m->h))
{
p->y = MAX(p->y, strut.top);
p->h = MIN(p->h, m->y + m->h - strut.top);
}
else
// monitor bottom side of root window?
if (strut.bottom > 0 && m->y + m->h == screen_h
&& INTERSECT(strut.bx1, screen_h - strut.bottom, strut.bx2 - strut.bx1, strut.bottom, m->x, m->y, m->w, m->h))
{
p->h = MIN(p->h, m->y + m->h - strut.bottom);
}
} }
} }
memmove(monitors, padded, sizeof(monitor) * MONITORS); memmove(monitors, padded, sizeof(monitor) * MONITORS);
@@ -192,16 +185,19 @@ void setup()
XGrabButton(display, Button3, AnyModifier, root, True, ButtonPressMask, GrabModeSync, GrabModeSync, None, None); XGrabButton(display, Button3, AnyModifier, root, True, ButtonPressMask, GrabModeSync, GrabModeSync, None, None);
// create title bars // create title bars
STACK_FREE(&windows); if (TITLE)
for_monitors(i, m) for_spots(j)
{ {
m->bars[j] = textbox_create(root, TB_AUTOHEIGHT|TB_LEFT, m->spots[j].x, m->spots[j].y, m->spots[j].w, 0, STACK_FREE(&windows);
TITLE, TITLE_BLUR, BORDER_BLUR, NULL, NULL); for_monitors(i, m) for_spots(j)
XSelectInput(display, m->bars[j]->window, ExposureMask); {
m->bars[j] = textbox_create(root, TB_AUTOHEIGHT|TB_LEFT, m->spots[j].x, m->spots[j].y, m->spots[j].w, 0,
TITLE, TITLE_BLUR, BORDER_BLUR, NULL, NULL);
XSelectInput(display, m->bars[j]->window, ExposureMask);
m->spots[j].y += m->bars[j]->h; m->spots[j].y += m->bars[j]->h;
m->spots[j].h -= m->bars[j]->h; m->spots[j].h -= m->bars[j]->h;
spot_update_bar(j, i); spot_update_bar(j, i);
}
} }
// setup existing managable windows // setup existing managable windows

28
spot.c
View File

@@ -51,25 +51,29 @@ void spot_update_bar(int spot, int mon)
} }
if (tmp) XFree(tmp); if (tmp) XFree(tmp);
} }
if (c && !c->full && *title && m->bars[spot]) if (TITLE)
{ {
int focus = c->window == current || (spot == current_spot && mon == current_mon); if (c && !c->full && *title && m->bars[spot])
char *color = focus && c->window == current ? TITLE_FOCUS : TITLE_BLUR; {
char *border = focus && c->window == current ? BORDER_FOCUS: BORDER_BLUR; int focus = c->window == current || (spot == current_spot && mon == current_mon);
textbox_font(m->bars[spot], TITLE, color, border); char *color = focus && c->window == current ? TITLE_FOCUS : TITLE_BLUR;
textbox_text(m->bars[spot], title); char *border = focus && c->window == current ? BORDER_FOCUS: BORDER_BLUR;
textbox_draw(m->bars[spot]); textbox_font(m->bars[spot], TITLE, color, border);
textbox_show(m->bars[spot]); textbox_text(m->bars[spot], title);
textbox_draw(m->bars[spot]);
textbox_show(m->bars[spot]);
}
else
if (m->bars[spot])
textbox_hide(m->bars[spot]);
} }
else
if (m->bars[spot])
textbox_hide(m->bars[spot]);
} }
void update_bars() void update_bars()
{ {
int i, j; monitor *m; int i, j; monitor *m;
for_monitors(i, m) for_spots(j) spot_update_bar(j, i); if (TITLE) for_monitors(i, m) for_spots(j)
spot_update_bar(j, i);
} }
Window spot_focus_top_window(int spot, int mon, Window except) Window spot_focus_top_window(int spot, int mon, Window except)