sane typedef names

This commit is contained in:
Sean Pringle
2014-12-29 21:41:51 +10:00
parent a45ac3e8b6
commit be1a3d88b5
9 changed files with 106 additions and 106 deletions

View File

@@ -24,43 +24,43 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
void action_move(void *data, int num, client *cli) void action_move(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
client_raise_family(cli); client_raise_family(cli);
client_place_spot(cli, num, cli->monitor, 1); client_place_spot(cli, num, cli->monitor, 1);
} }
void action_move_direction(void *data, int num, client *cli) void action_move_direction(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
client_raise_family(cli); client_raise_family(cli);
client_place_spot(cli, spot_choose_by_direction(cli->spot, cli->monitor, num), cli->monitor, 1); client_place_spot(cli, spot_choose_by_direction(cli->spot, cli->monitor, num), cli->monitor, 1);
} }
void action_focus(void *data, int num, client *cli) void action_focus(void *data, int num, Client *cli)
{ {
spot_try_focus_top_window(num, current_mon, None); spot_try_focus_top_window(num, current_mon, None);
} }
void action_focus_direction(void *data, int num, client *cli) void action_focus_direction(void *data, int num, Client *cli)
{ {
spot_try_focus_top_window(spot_choose_by_direction(current_spot, current_mon, num), current_mon, None); spot_try_focus_top_window(spot_choose_by_direction(current_spot, current_mon, num), current_mon, None);
} }
void action_close(void *data, int num, client *cli) void action_close(void *data, int num, Client *cli)
{ {
if (cli && !client_send_wm_protocol(cli, atoms[WM_DELETE_WINDOW])) if (cli && !client_send_wm_protocol(cli, atoms[WM_DELETE_WINDOW]))
XKillClient(display, cli->window); XKillClient(display, cli->window);
} }
void action_cycle(void *data, int num, client *cli) void action_cycle(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
STACK_INIT(order); STACK_INIT(order);
if (spot_stack_clients(cli->spot, cli->monitor, &order) > 1) if (spot_stack_clients(cli->spot, cli->monitor, &order) > 1)
{ {
int i; client *c = NULL; int i; Client *c = NULL;
for_stack_rev(&order, i, c) if (c->manage && c->transient == None && c->window != cli->window) for_stack_rev(&order, i, c) if (c->manage && c->transient == None && c->window != cli->window)
{ {
client_activate(c); client_activate(c);
@@ -69,29 +69,29 @@ void action_cycle(void *data, int num, client *cli)
} }
} }
void action_raise_nth(void *data, int num, client *cli) void action_raise_nth(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
int i, n = 0; client *c; int i, n = 0; Client *c;
for_windows(i, c) if (c->manage && c->spot == cli->spot && c->monitor == cli->monitor && num == n++) for_windows(i, c) if (c->manage && c->spot == cli->spot && c->monitor == cli->monitor && num == n++)
{ client_activate(c); break; } { client_activate(c); break; }
} }
void action_command(void *data, int num, client *cli) void action_command(void *data, int num, Client *cli)
{ {
exec_cmd(data); exec_cmd(data);
} }
void action_find_or_start(void *data, int num, client *cli) void action_find_or_start(void *data, int num, Client *cli)
{ {
int i; client *c; char *class = data; int i; Client *c; char *class = data;
for_windows(i, c) for_windows(i, c)
if (c->visible && c->manage && c->class && !strcasecmp(c->class, class)) if (c->visible && c->manage && c->class && !strcasecmp(c->class, class))
{ client_activate(c); return; } { client_activate(c); return; }
exec_cmd(class); exec_cmd(class);
} }
void action_move_monitor(void *data, int num, client *cli) void action_move_monitor(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
client_raise_family(cli); client_raise_family(cli);
@@ -100,14 +100,14 @@ void action_move_monitor(void *data, int num, client *cli)
current_mon = cli->monitor; current_mon = cli->monitor;
} }
void action_focus_monitor(void *data, int num, client *cli) void action_focus_monitor(void *data, int num, Client *cli)
{ {
int i, mon = MAX(0, MIN(current_mon+num, nmonitors-1)); int i, mon = MAX(0, MIN(current_mon+num, nmonitors-1));
if (spot_focus_top_window(current_spot, mon, None)) return; if (spot_focus_top_window(current_spot, mon, None)) return;
for_spots(i) if (spot_focus_top_window(i, mon, None)) break; for_spots(i) if (spot_focus_top_window(i, mon, None)) break;
} }
void action_fullscreen(void *data, int num, client *cli) void action_fullscreen(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
@@ -122,7 +122,7 @@ void action_fullscreen(void *data, int num, client *cli)
client_raise_family(cli); client_raise_family(cli);
} }
void action_maximize(void *data, int num, client *cli) void action_maximize(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
cli->max = !cli->max; cli->max = !cli->max;
@@ -130,14 +130,14 @@ void action_maximize(void *data, int num, client *cli)
client_place_spot(cli, cli->spot, cli->monitor, 1); client_place_spot(cli, cli->spot, cli->monitor, 1);
} }
void action_maximize_vert(void *data, int num, client *cli) void action_maximize_vert(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
cli->maxv = client_toggle_state(cli, atoms[_NET_WM_STATE_MAXIMIZE_VERT]); cli->maxv = client_toggle_state(cli, atoms[_NET_WM_STATE_MAXIMIZE_VERT]);
client_place_spot(cli, cli->spot, cli->monitor, 1); client_place_spot(cli, cli->spot, cli->monitor, 1);
} }
void action_maximize_horz(void *data, int num, client *cli) void action_maximize_horz(void *data, int num, Client *cli)
{ {
if (!cli) return; if (!cli) return;
cli->maxh = client_toggle_state(cli, atoms[_NET_WM_STATE_MAXIMIZE_HORZ]); cli->maxh = client_toggle_state(cli, atoms[_NET_WM_STATE_MAXIMIZE_HORZ]);

View File

@@ -24,14 +24,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
int client_has_state(client *c, Atom state) int client_has_state(Client *c, Atom state)
{ {
for (int i = 0; i < ATOMLIST && c->states[i]; i++) for (int i = 0; i < ATOMLIST && c->states[i]; i++)
if (c->states[i] == state) return 1; if (c->states[i] == state) return 1;
return 0; return 0;
} }
int client_toggle_state(client *c, Atom state) int client_toggle_state(Client *c, Atom state)
{ {
int i, j, rc = 0; int i, j, rc = 0;
for (i = 0, j = 0; i < ATOMLIST && c->states[i]; i++, j++) for (i = 0, j = 0; i < ATOMLIST && c->states[i]; i++, j++)
@@ -50,12 +50,12 @@ int client_toggle_state(client *c, Atom state)
return rc; return rc;
} }
client* window_build_client(Window win) Client* window_build_client(Window win)
{ {
int i, j; XClassHint chint; XWMHints *hints; monitor *m; int i, j; XClassHint chint; XWMHints *hints; Monitor *m;
if (win == None) return NULL; if (win == None) return NULL;
client *c = calloc(1, sizeof(client)); Client *c = calloc(1, sizeof(Client));
c->window = win; c->window = win;
if (XGetWindowAttributes(display, c->window, &c->attr)) if (XGetWindowAttributes(display, c->window, &c->attr))
@@ -150,14 +150,14 @@ client* window_build_client(Window win)
return NULL; return NULL;
} }
void client_free(client *c) void client_free(Client *c)
{ {
if (!c) return; if (!c) return;
free(c->class); free(c->class);
free(c); free(c);
} }
void client_update_border(client *c) void client_update_border(Client *c)
{ {
XColor color; Colormap map = DefaultColormap(display, DefaultScreen(display)); XColor color; Colormap map = DefaultColormap(display, DefaultScreen(display));
char *colorname = c->window == current ? BORDER_FOCUS: (c->urgent ? BORDER_URGENT: BORDER_BLUR); char *colorname = c->window == current ? BORDER_FOCUS: (c->urgent ? BORDER_URGENT: BORDER_BLUR);
@@ -165,7 +165,7 @@ void client_update_border(client *c)
XSetWindowBorderWidth(display, c->window, c->full ? 0: BORDER); XSetWindowBorderWidth(display, c->window, c->full ? 0: BORDER);
} }
int client_send_wm_protocol(client *c, Atom protocol) int client_send_wm_protocol(Client *c, Atom protocol)
{ {
Atom protocols[ATOMLIST]; int i, n; Atom protocols[ATOMLIST]; int i, n;
if ((n = GETPROP_ATOM(c->window, atoms[WM_PROTOCOLS], protocols, ATOMLIST))) if ((n = GETPROP_ATOM(c->window, atoms[WM_PROTOCOLS], protocols, ATOMLIST)))
@@ -174,10 +174,10 @@ int client_send_wm_protocol(client *c, Atom protocol)
return 0; return 0;
} }
void client_place_spot(client *c, int spot, int mon, int force) void client_place_spot(Client *c, int spot, int mon, int force)
{ {
if (!c) return; if (!c) return;
int i; client *t; int i; Client *t;
// try to center over our transient parent // try to center over our transient parent
if (!force && c->transient && (t = window_build_client(c->transient))) if (!force && c->transient && (t = window_build_client(c->transient)))
@@ -199,7 +199,7 @@ void client_place_spot(client *c, int spot, int mon, int force)
} }
c->spot = spot; c->monitor = mon; c->spot = spot; c->monitor = mon;
monitor *m = &monitors[c->monitor]; Monitor *m = &monitors[c->monitor];
int x = m->spots[spot].x, y = m->spots[spot].y, w = m->spots[spot].w, h = m->spots[spot].h; int x = m->spots[spot].x, y = m->spots[spot].y, w = m->spots[spot].w, h = m->spots[spot].h;
if (c->type == atoms[_NET_WM_WINDOW_TYPE_DIALOG]) if (c->type == atoms[_NET_WM_WINDOW_TYPE_DIALOG])
@@ -267,9 +267,9 @@ void client_place_spot(client *c, int spot, int mon, int force)
XMoveResizeWindow(display, c->window, x, y, w, h); XMoveResizeWindow(display, c->window, x, y, w, h);
} }
void client_stack_family(client *c, stack *raise) void client_stack_family(Client *c, Stack *raise)
{ {
int i; client *o, *self = NULL; int i; Client *o, *self = NULL;
for_windows(i, o) for_windows(i, o)
{ {
if (o->manage && o->visible && o->transient == c->window) if (o->manage && o->visible && o->transient == c->window)
@@ -285,10 +285,10 @@ void client_stack_family(client *c, stack *raise)
} }
} }
void client_raise_family(client *c) void client_raise_family(Client *c)
{ {
if (!c) return; if (!c) return;
int i; client *o; STACK_INIT(raise); STACK_INIT(family); int i; Client *o; STACK_INIT(raise); STACK_INIT(family);
for_windows(i, o) if (o->type == atoms[_NET_WM_WINDOW_TYPE_DOCK]) for_windows(i, o) if (o->type == atoms[_NET_WM_WINDOW_TYPE_DOCK])
client_stack_family(o, &raise); client_stack_family(o, &raise);
@@ -301,7 +301,7 @@ void client_raise_family(client *c)
if (!c->full && TITLE) 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];
raise.windows[raise.depth] = m->bars[c->spot]->window; raise.windows[raise.depth] = m->bars[c->spot]->window;
raise.clients[raise.depth] = NULL; raise.clients[raise.depth] = NULL;
raise.depth++; raise.depth++;
@@ -313,10 +313,10 @@ void client_raise_family(client *c)
STACK_FREE(&family); STACK_FREE(&family);
} }
void client_set_focus(client *c) void client_set_focus(Client *c)
{ {
if (!c || !c->visible || c->window == current) return; if (!c || !c->visible || c->window == current) return;
client *o; Window old = current; Client *o; Window old = current;
current = c->window; current = c->window;
current_spot = c->spot; current_spot = c->spot;
@@ -333,7 +333,7 @@ void client_set_focus(client *c)
client_update_border(c); client_update_border(c);
} }
void client_activate(client *c) void client_activate(Client *c)
{ {
client_raise_family(c); client_raise_family(c);
client_set_focus(c); client_set_focus(c);

View File

@@ -44,7 +44,7 @@
// .spot1_height_pct = N // .spot1_height_pct = N
// Height of SPOT2 as percentage of screen height. // Height of SPOT2 as percentage of screen height.
layout layouts[] = { Layout layouts[] = {
// Look at xrandr output to determine your monitor order. // Look at xrandr output to determine your monitor order.
{ .spot_start = SMART, .spot1_align = LEFT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // primary monitor { .spot_start = SMART, .spot1_align = LEFT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // primary monitor
{ .spot_start = SMART, .spot1_align = RIGHT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // secondary monitor, etc... { .spot_start = SMART, .spot1_align = RIGHT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // secondary monitor, etc...
@@ -66,7 +66,7 @@ layout layouts[] = {
// action_maximize_horz // action_maximize_horz
// If you use "AnyModifier" place those keys at the end of the array. // If you use "AnyModifier" place those keys at the end of the array.
binding keys[] = { Binding keys[] = {
// Change focus to a spot by direction. // Change focus to a spot by direction.
{ .mod = Mod4Mask, .key = XK_Left, .act = action_focus_direction, .num = LEFT }, { .mod = Mod4Mask, .key = XK_Left, .act = action_focus_direction, .num = LEFT },

28
event.c
View File

@@ -26,7 +26,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void create_notify(XEvent *e) void create_notify(XEvent *e)
{ {
client *c = window_build_client(e->xcreatewindow.window); Client *c = window_build_client(e->xcreatewindow.window);
if (c && c->manage) if (c && c->manage)
window_listen(c->window); window_listen(c->window);
client_free(c); client_free(c);
@@ -35,7 +35,7 @@ void create_notify(XEvent *e)
void configure_request(XEvent *ev) void configure_request(XEvent *ev)
{ {
XConfigureRequestEvent *e = &ev->xconfigurerequest; XConfigureRequestEvent *e = &ev->xconfigurerequest;
client *c = window_build_client(e->window); Client *c = window_build_client(e->window);
if (c && c->manage && c->visible && !c->transient) if (c && c->manage && c->visible && !c->transient)
{ {
client_update_border(c); client_update_border(c);
@@ -58,7 +58,7 @@ void configure_request(XEvent *ev)
void configure_notify(XEvent *e) void configure_notify(XEvent *e)
{ {
client *c = window_build_client(e->xconfigure.window); Client *c = window_build_client(e->xconfigure.window);
if (c && c->manage) if (c && c->manage)
{ {
while (XCheckTypedEvent(display, ConfigureNotify, e)); while (XCheckTypedEvent(display, ConfigureNotify, e));
@@ -70,11 +70,11 @@ void configure_notify(XEvent *e)
void map_request(XEvent *e) void map_request(XEvent *e)
{ {
client *c = window_build_client(e->xmaprequest.window); Client *c = window_build_client(e->xmaprequest.window);
if (c && c->manage) if (c && c->manage)
{ {
c->monitor = current_mon; c->monitor = current_mon;
monitor *m = &monitors[c->monitor]; Monitor *m = &monitors[c->monitor];
int spot = have_layout(c->monitor) ? layouts[c->monitor].spot_start: SMART; int spot = have_layout(c->monitor) ? layouts[c->monitor].spot_start: SMART;
if (spot == CURRENT) if (spot == CURRENT)
@@ -96,7 +96,7 @@ void map_request(XEvent *e)
void map_notify(XEvent *e) void map_notify(XEvent *e)
{ {
client *a = NULL, *c = window_build_client(e->xmap.window); Client *a = NULL, *c = window_build_client(e->xmap.window);
if (c && c->manage) if (c && c->manage)
{ {
client_raise_family(c); client_raise_family(c);
@@ -128,14 +128,14 @@ void key_press(XEvent *ev)
unsigned int state = e->state & ~(LockMask|NumlockMask); unsigned int state = e->state & ~(LockMask|NumlockMask);
while (XCheckTypedEvent(display, KeyPress, ev)); while (XCheckTypedEvent(display, KeyPress, ev));
binding *bind = NULL; Binding *bind = NULL;
for (int i = 0; i < sizeof(keys)/sizeof(binding) && !bind; i++) for (int i = 0; i < sizeof(keys)/sizeof(Binding) && !bind; i++)
if (keys[i].key == key && (keys[i].mod == AnyModifier || keys[i].mod == state)) if (keys[i].key == key && (keys[i].mod == AnyModifier || keys[i].mod == state))
bind = &keys[i]; bind = &keys[i];
if (bind && bind->act) if (bind && bind->act)
{ {
client *cli = window_build_client(current); Client *cli = window_build_client(current);
bind->act(bind->data, bind->num, cli); bind->act(bind->data, bind->num, cli);
client_free(cli); client_free(cli);
update_bars(); update_bars();
@@ -144,9 +144,9 @@ void key_press(XEvent *ev)
void button_press(XEvent *ev) void button_press(XEvent *ev)
{ {
int i, j; monitor *m; int i, j; Monitor *m;
XButtonEvent *e = &ev->xbutton; latest = e->time; XButtonEvent *e = &ev->xbutton; latest = e->time;
client *c = window_build_client(e->subwindow); Client *c = window_build_client(e->subwindow);
if (c && c->manage) if (c && c->manage)
client_activate(c); client_activate(c);
else else
@@ -171,7 +171,7 @@ void client_message(XEvent *ev)
warnx("restart!"); warnx("restart!");
EXECSH(self); EXECSH(self);
} }
client *c = window_build_client(e->window); Client *c = window_build_client(e->window);
if (c && c->manage) if (c && c->manage)
{ {
if (e->message_type == atoms[_NET_ACTIVE_WINDOW]) client_activate(c); if (e->message_type == atoms[_NET_ACTIVE_WINDOW]) client_activate(c);
@@ -184,7 +184,7 @@ void property_notify(XEvent *ev)
{ {
XPropertyEvent *e = &ev->xproperty; XPropertyEvent *e = &ev->xproperty;
client *c = window_build_client(e->window); Client *c = window_build_client(e->window);
if (e->window == root && e->atom == atoms[WM_NAME]) if (e->window == root && e->atom == atoms[WM_NAME])
{ {
// root name appears in SPOT1 bar, for status etc // root name appears in SPOT1 bar, for status etc
@@ -211,7 +211,7 @@ void expose(XEvent *e)
void any_event(XEvent *e) void any_event(XEvent *e)
{ {
client *c = window_build_client(e->xany.window); Client *c = window_build_client(e->xany.window);
if (c && c->visible && c->manage) if (c && c->visible && c->manage)
client_update_border(c); client_update_border(c);
client_free(c); client_free(c);

2
ewmh.c
View File

@@ -26,7 +26,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void ewmh_client_list() void ewmh_client_list()
{ {
int i; client *c; STACK_INIT(wins); int i; Client *c; STACK_INIT(wins);
for_windows_rev(i, c) if (c->manage) for_windows_rev(i, c) if (c->manage)
wins.windows[wins.depth++] = c->window; wins.windows[wins.depth++] = c->window;
SETPROP_WIND(root, atoms[_NET_CLIENT_LIST_STACKING], wins.windows, wins.depth); SETPROP_WIND(root, atoms[_NET_CLIENT_LIST_STACKING], wins.windows, wins.depth);

12
setup.c
View File

@@ -31,7 +31,7 @@ typedef struct {
void setup() void setup()
{ {
int i, j; client *c; monitor *m; int i, j; Client *c; Monitor *m;
int screen_w = WidthOfScreen(DefaultScreenOfDisplay(display)); int screen_w = WidthOfScreen(DefaultScreenOfDisplay(display));
int screen_h = HeightOfScreen(DefaultScreenOfDisplay(display)); int screen_h = HeightOfScreen(DefaultScreenOfDisplay(display));
@@ -55,8 +55,8 @@ 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)); wm_strut all_struts; memset(&all_struts, 0, sizeof(wm_strut));
for_windows(i, c) for_windows(i, c)
@@ -74,7 +74,7 @@ void setup()
for_monitors(j, m) for_monitors(j, m)
{ {
monitor *p = &padded[j]; Monitor *p = &padded[j];
// monitor left side of root window? // monitor left side of root window?
if (all_struts.left > 0 && !m->x) if (all_struts.left > 0 && !m->x)
@@ -99,7 +99,7 @@ void setup()
p->h -= all_struts.bottom; p->h -= all_struts.bottom;
} }
} }
memmove(monitors, padded, sizeof(monitor) * MONITORS); memmove(monitors, padded, sizeof(Monitor) * MONITORS);
// calculate spot boxes // calculate spot boxes
for_monitors(i, m) for_monitors(i, m)
@@ -176,7 +176,7 @@ void setup()
XFreeModifiermap(modmap); XFreeModifiermap(modmap);
// process config.h key bindings // process config.h key bindings
for (i = 0; i < sizeof(keys)/sizeof(binding); i++) for (i = 0; i < sizeof(keys)/sizeof(Binding); i++)
{ {
XGrabKey(display, XKeysymToKeycode(display, keys[i].key), keys[i].mod, root, True, GrabModeAsync, GrabModeAsync); XGrabKey(display, XKeysymToKeycode(display, keys[i].key), keys[i].mod, root, True, GrabModeAsync, GrabModeAsync);
if (keys[i].mod == AnyModifier) continue; if (keys[i].mod == AnyModifier) continue;

16
spot.c
View File

@@ -28,9 +28,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void spot_update_bar(int spot, int mon) void spot_update_bar(int spot, int mon)
{ {
int i, n = 0, len = 0; client *o, *c = NULL; int i, n = 0, len = 0; Client *o, *c = NULL;
char title[SPOT_BUFF]; *title = 0; char title[SPOT_BUFF]; *title = 0;
monitor *m = &monitors[mon]; Monitor *m = &monitors[mon];
if (spot == SPOT1) if (spot == SPOT1)
{ {
@@ -80,14 +80,14 @@ void spot_update_bar(int spot, int mon)
void update_bars() void update_bars()
{ {
int i, j; monitor *m; int i, j; Monitor *m;
if (TITLE) for_monitors(i, m) for_spots(j) if (TITLE) for_monitors(i, m) for_spots(j)
spot_update_bar(j, i); 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)
{ {
int i; client *c; int i; Client *c;
for_windows(i, c) if (c->window != except && c->manage && c->spot == spot && c->monitor == mon) for_windows(i, c) if (c->window != except && c->manage && c->spot == spot && c->monitor == mon)
{ {
client_raise_family(c); client_raise_family(c);
@@ -114,7 +114,7 @@ Window spot_try_focus_top_window(int spot, int mon, Window except)
int spot_choose_by_direction(int spot, int mon, int dir) int spot_choose_by_direction(int spot, int mon, int dir)
{ {
monitor *m = &monitors[mon]; Monitor *m = &monitors[mon];
int spot1_align = have_layout(mon) ? layouts[mon].spot1_align : LEFT ; int spot1_align = have_layout(mon) ? layouts[mon].spot1_align : LEFT ;
if (m->w < m->h) // rotated? if (m->w < m->h) // rotated?
@@ -134,14 +134,14 @@ int spot_choose_by_direction(int spot, int mon, int dir)
int spot_count_windows(int spot, int mon) int spot_count_windows(int spot, int mon)
{ {
int i, n = 0; client *c; int i, n = 0; Client *c;
for_windows(i, c) if (c->manage && c->spot == spot && c->monitor == mon) n++; for_windows(i, c) if (c->manage && c->spot == spot && c->monitor == mon) n++;
return n; return n;
} }
int spot_stack_clients(int spot, int mon, stack *stk) int spot_stack_clients(int spot, int mon, Stack *stk)
{ {
int i; client *c; int i; Client *c;
for_windows(i, c) if (c->manage && c->spot == spot && c->monitor == mon) for_windows(i, c) if (c->manage && c->spot == spot && c->monitor == mon)
client_stack_family(c, stk); client_stack_family(c, stk);
return stk->depth; return stk->depth;

View File

@@ -98,7 +98,7 @@ void window_listen(Window win)
// build windows cache // build windows cache
void query_windows() void query_windows()
{ {
unsigned int nwins; int i; Window w1, w2, *wins; client *c; unsigned int nwins; int i; Window w1, w2, *wins; Client *c;
if (windows.depth || !(XQueryTree(display, root, &w1, &w2, &wins, &nwins) && wins)) if (windows.depth || !(XQueryTree(display, root, &w1, &w2, &wins, &nwins) && wins))
return; return;
for (i = nwins-1; i > -1 && windows.depth < STACK; i--) for (i = nwins-1; i > -1 && windows.depth < STACK; i--)

72
xoat.c
View File

@@ -60,17 +60,17 @@ Display *display;
enum { SPOT1=1, SPOT2, SPOT3, CURRENT, SMART }; enum { SPOT1=1, SPOT2, SPOT3, CURRENT, SMART };
enum { LEFT=1, RIGHT, UP, DOWN }; enum { LEFT=1, RIGHT, UP, DOWN };
typedef struct { typedef struct _Box {
short x, y, w, h; short x, y, w, h;
} box; } Box;
typedef struct { typedef struct _Monitor {
short x, y, w, h; short x, y, w, h;
box spots[SPOT3+1]; Box spots[SPOT3+1];
textbox *bars[SPOT3+1]; textbox *bars[SPOT3+1];
} monitor; } Monitor;
typedef struct { typedef struct _Client {
Window window; Window window;
XWindowAttributes attr; XWindowAttributes attr;
Window transient, leader; Window transient, leader;
@@ -78,45 +78,45 @@ typedef struct {
short monitor, visible, manage, input, urgent, full, ours, maxv, maxh; short monitor, visible, manage, input, urgent, full, ours, maxv, maxh;
unsigned long spot, max; unsigned long spot, max;
char *class; char *class;
} client; } Client;
typedef struct { typedef struct _Stack {
short depth; short depth;
client *clients[STACK]; Client *clients[STACK];
Window windows[STACK]; Window windows[STACK];
} stack; } Stack;
typedef struct { typedef struct _Binding {
unsigned int mod; unsigned int mod;
KeySym key; KeySym key;
void (*act)(void*, int, client*); void (*act)(void*, int, Client*);
void *data; void *data;
int num; int num;
} binding; } Binding;
typedef struct { typedef struct _Layout {
short spot_start, spot1_align, spot1_width_pct, spot2_height_pct; short spot_start, spot1_align, spot1_width_pct, spot2_height_pct;
} layout; } Layout;
#define have_layout(i) (sizeof(layouts) / sizeof(layout) > (i)) #define have_layout(i) (sizeof(layouts) / sizeof(Layout) > (i))
client* window_build_client(Window); Client* window_build_client(Window);
void client_free(client*); void client_free(Client*);
void action_move(void*, int, client*); void action_move(void*, int, Client*);
void action_focus(void*, int, client*); void action_focus(void*, int, Client*);
void action_move_direction(void*, int, client*); void action_move_direction(void*, int, Client*);
void action_focus_direction(void*, int, client*); void action_focus_direction(void*, int, Client*);
void action_close(void*, int, client*); void action_close(void*, int, Client*);
void action_cycle(void*, int, client*); void action_cycle(void*, int, Client*);
void action_raise_nth(void*, int, client*); void action_raise_nth(void*, int, Client*);
void action_command(void*, int, client*); void action_command(void*, int, Client*);
void action_find_or_start(void*, int, client*); void action_find_or_start(void*, int, Client*);
void action_move_monitor(void*, int, client*); void action_move_monitor(void*, int, Client*);
void action_focus_monitor(void*, int, client*); void action_focus_monitor(void*, int, Client*);
void action_fullscreen(void*, int, client*); void action_fullscreen(void*, int, Client*);
void action_maximize_vert(void*, int, client*); void action_maximize_vert(void*, int, Client*);
void action_maximize_horz(void*, int, client*); void action_maximize_horz(void*, int, Client*);
void action_maximize(void*, int, client*); void action_maximize(void*, int, Client*);
#include "config.h" #include "config.h"
@@ -124,7 +124,7 @@ void action_maximize(void*, int, client*);
#define OVERLAP(a,b,c,d) (((a)==(c) && (b)==(d)) || MIN((a)+(b), (c)+(d)) - MAX((a), (c)) > 0) #define OVERLAP(a,b,c,d) (((a)==(c) && (b)==(d)) || MIN((a)+(b), (c)+(d)) - MAX((a), (c)) > 0)
#define INTERSECT(x,y,w,h,x1,y1,w1,h1) (OVERLAP((x),(w),(x1),(w1)) && OVERLAP((y),(h),(y1),(h1))) #define INTERSECT(x,y,w,h,x1,y1,w1,h1) (OVERLAP((x),(w),(x1),(w1)) && OVERLAP((y),(h),(y1),(h1)))
#define STACK_INIT(n) stack (n); memset(&(n), 0, sizeof(stack)) #define STACK_INIT(n) Stack (n); memset(&(n), 0, sizeof(Stack))
#define STACK_FREE(s) while ((s)->depth) client_free((s)->clients[--(s)->depth]) #define STACK_FREE(s) while ((s)->depth) client_free((s)->clients[--(s)->depth])
#define for_stack(s,i,c)\ #define for_stack(s,i,c)\
@@ -155,11 +155,11 @@ void action_maximize(void*, int, client*);
Time latest; Time latest;
char *self; char *self;
unsigned int NumlockMask; unsigned int NumlockMask;
monitor monitors[MONITORS]; Monitor monitors[MONITORS];
int nmonitors = 1; int nmonitors = 1;
short current_spot, current_mon; short current_spot, current_mon;
Window root, ewmh, current = None; Window root, ewmh, current = None;
stack windows; Stack windows;
static int (*xerror)(Display *, XErrorEvent *); static int (*xerror)(Display *, XErrorEvent *);
void catch_exit(int sig) void catch_exit(int sig)