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;
// detect our own title bars
for_monitors(i, m) for_spots(j)
if (m->bars[j] && m->bars[j]->window == c->window)
{ c->ours = 1; c->manage = 0; break; }
if (TITLE)
for_monitors(i, m) for_spots(j)
if (m->bars[j] && m->bars[j]->window == c->window)
{ c->ours = 1; c->manage = 0; break; }
if (c->manage)
{
@@ -272,7 +273,7 @@ void client_raise_family(client *c)
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
monitor *m = &monitors[c->monitor];

View File

@@ -6,11 +6,15 @@
#define BORDER_URGENT "Red"
#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"
// Title bar style
#define TITLE_BLUR "Black"
#define TITLE_FOCUS "White"
#define TITLE_ELLIPSIS 30
#define TITLE_ELLIPSIS 32
// There are three static tiles called SPOT1, SPOT2, and SPOT3.
// 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 },
// 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).
// 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_F3, .act = action_find_or_start, .data = "pcmanfm" },
};

View File

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

88
setup.c
View File

@@ -57,6 +57,7 @@ void setup()
// detect and adjust for panel struts
monitor padded[MONITORS];
memmove(padded, monitors, sizeof(monitor) * MONITORS);
wm_strut all_struts; memset(&all_struts, 0, sizeof(wm_strut));
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);
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];
// convert _NET_WM_STRUT to _PARTIAL
if (v1)
{
strut.ly1 = m->y; strut.ly2 = m->y + m->h;
strut.ry1 = m->y; strut.ry3 = m->y + m->h;
strut.tx1 = m->x; strut.tx2 = m->x + m->w;
strut.bx1 = m->x; strut.bx2 = m->x + m->w;
}
// monitor left side of root window?
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->x = MAX(p->x, strut.left);
p->w = MIN(p->w, m->x + m->w - strut.left);
}
else
// monitor right side of root window?
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);
}
p->x += all_struts.left;
p->w -= all_struts.left;
}
// monitor right side of root window?
if (all_struts.right > 0 && m->x + m->w == screen_w)
{
p->w -= all_struts.right;
}
// monitor top side of root window?
if (all_struts.top > 0 && !m->y)
{
p->y += all_struts.top;
p->h -= all_struts.top;
}
// monitor bottom side of root window?
if (all_struts.bottom > 0 && m->y + m->h == screen_h)
{
p->h -= all_struts.bottom;
}
}
memmove(monitors, padded, sizeof(monitor) * MONITORS);
@@ -192,16 +185,19 @@ void setup()
XGrabButton(display, Button3, AnyModifier, root, True, ButtonPressMask, GrabModeSync, GrabModeSync, None, None);
// create title bars
STACK_FREE(&windows);
for_monitors(i, m) for_spots(j)
if (TITLE)
{
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);
STACK_FREE(&windows);
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,
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].h -= m->bars[j]->h;
spot_update_bar(j, i);
m->spots[j].y += m->bars[j]->h;
m->spots[j].h -= m->bars[j]->h;
spot_update_bar(j, i);
}
}
// 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 (c && !c->full && *title && m->bars[spot])
if (TITLE)
{
int focus = c->window == current || (spot == current_spot && mon == current_mon);
char *color = focus && c->window == current ? TITLE_FOCUS : TITLE_BLUR;
char *border = focus && c->window == current ? BORDER_FOCUS: BORDER_BLUR;
textbox_font(m->bars[spot], TITLE, color, border);
textbox_text(m->bars[spot], title);
textbox_draw(m->bars[spot]);
textbox_show(m->bars[spot]);
if (c && !c->full && *title && m->bars[spot])
{
int focus = c->window == current || (spot == current_spot && mon == current_mon);
char *color = focus && c->window == current ? TITLE_FOCUS : TITLE_BLUR;
char *border = focus && c->window == current ? BORDER_FOCUS: BORDER_BLUR;
textbox_font(m->bars[spot], TITLE, color, border);
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()
{
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)