#define SWM_D_SPAWN 0x0800
#define SWM_D_EVENTQ 0x1000
#define SWM_D_CONF 0x2000
+#define SWM_D_BAR 0x4000
u_int32_t swm_debug = 0
| SWM_D_MISC
| SWM_D_SPAWN
| SWM_D_EVENTQ
| SWM_D_CONF
+ | SWM_D_BAR
;
#else
#define DPRINTF(x...)
#define Y(r) (r)->g.y
#define WIDTH(r) (r)->g.w
#define HEIGHT(r) (r)->g.h
+#define SH_MIN(w) (w)->sh_mask & PMinSize
+#define SH_MIN_W(w) (w)->sh.min_width
+#define SH_MIN_H(w) (w)->sh.min_height
+#define SH_MAX(w) (w)->sh_mask & PMaxSize
+#define SH_MAX_W(w) (w)->sh.max_width
+#define SH_MAX_H(w) (w)->sh.max_height
+#define SH_INC(w) (w)->sh_mask & PResizeInc
+#define SH_INC_W(w) (w)->sh.width_inc
+#define SH_INC_H(w) (w)->sh.height_inc
#define SWM_MAX_FONT_STEPS (3)
-#define WINID(w) (w ? w->id : 0)
-#define YESNO(x) (x ? "yes" : "no")
+#define WINID(w) ((w) ? (w)->id : 0)
+#define YESNO(x) ((x) ? "yes" : "no")
#define SWM_FOCUS_DEFAULT (0)
#define SWM_FOCUS_SYNERGY (1)
TAILQ_ENTRY(search_window) entry;
int idx;
struct ws_win *win;
+ GC gc;
Window indicator;
};
TAILQ_HEAD(search_winlist, search_window);
};
/* dialog windows */
-double dialog_ratio = .6;
+double dialog_ratio = 0.6;
/* status bar */
#define SWM_BAR_MAX (256)
#define SWM_BAR_JUSTIFY_LEFT (0)
#define SWM_BAR_JUSTIFY_CENTER (1)
#define SWM_BAR_JUSTIFY_RIGHT (2)
#define SWM_BAR_OFFSET (4)
+#define SWM_BAR_FONTS "-*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*," \
+ "-*-profont-*-*-*-*-*-*-*-*-*-*-*-*," \
+ "-*-times-medium-r-*-*-*-*-*-*-*-*-*-*," \
+ "-misc-fixed-medium-r-*-*-*-*-*-*-*-*-*-*"
+
+#ifdef X_HAVE_UTF8_STRING
+#define DRAWSTRING(x...) Xutf8DrawString(x)
+#else
+#define DRAWSTRING(x...) XmbDrawString(x)
+#endif
+
char *bar_argv[] = { NULL, NULL };
int bar_pipe[2];
-char bar_ext[SWM_BAR_MAX];
+unsigned char bar_ext[SWM_BAR_MAX];
char bar_vertext[SWM_BAR_MAX];
int bar_version = 0;
sig_atomic_t bar_alarm = 0;
int border_width = 1;
int verbose_layout = 0;
pid_t bar_pid;
-GC bar_gc;
-XGCValues bar_gcv;
-int bar_fidx = 0;
-XFontStruct *bar_fs;
-char *bar_fonts[] = { NULL, NULL, NULL, NULL };/* XXX Make fully dynamic */
-char *spawn_term[] = { NULL, NULL }; /* XXX Make fully dynamic */
+XFontSet bar_fs;
+XFontSetExtents *bar_fs_extents;
+char *bar_fonts;
+char *spawn_term[] = { NULL, NULL }; /* XXX fully dynamic */
struct passwd *pwd;
#define SWM_MENU_FN (2)
struct swm_screen *s; /* always valid, never changes */
XWindowAttributes wa;
XSizeHints sh;
+ long sh_mask;
XClassHint ch;
XWMHints *hints;
};
unsigned long color;
char *name;
} c[SWM_S_COLOR_MAX];
+
+ GC bar_gc;
};
struct swm_screen *screens;
int num_screens;
/* quirks */
struct quirk {
+ TAILQ_ENTRY(quirk) entry;
char *class;
char *name;
unsigned long quirk;
#define SWM_Q_FULLSCREEN (1<<4) /* remove border */
#define SWM_Q_FOCUSPREV (1<<5) /* focus on caller */
};
-int quirks_size = 0, quirks_length = 0;
-struct quirk *quirks = NULL;
+TAILQ_HEAD(quirk_list, quirk);
+struct quirk_list quirks = TAILQ_HEAD_INITIALIZER(quirks);
/*
* Supported EWMH hints should be added to
{"_NET_WM_ACTION_CLOSE", None},
};
-void store_float_geom(struct ws_win *, struct swm_region *);
-int floating_toggle_win(struct ws_win *);
-void spawn_select(struct swm_region *, union arg *, char *, int *);
+void store_float_geom(struct ws_win *, struct swm_region *);
+int floating_toggle_win(struct ws_win *);
+void spawn_select(struct swm_region *, union arg *, char *, int *);
+unsigned char *get_win_name(Display *, Window);
int
get_property(Window id, Atom atom, long count, Atom type,
char *
xrandr_geteventname(XEvent *e)
{
- char *name = NULL;
+ char *name = NULL;
switch(e->type - xrandr_eventbase) {
case RRScreenChangeNotify:
XWindowAttributes wa;
if (r->ws == NULL) {
- fprintf(stderr, "dumpwins: invalid workspace\n");
+ warnx("dumpwins: invalid workspace");
return;
}
- fprintf(stderr, "=== managed window list ws %02d ===\n", r->ws->idx);
+ warnx("=== managed window list ws %02d ===", r->ws->idx);
TAILQ_FOREACH(win, &r->ws->winlist, entry) {
state = getstate(win->id);
if (!XGetWindowAttributes(display, win->id, &wa))
- fprintf(stderr, "window: 0x%lx, failed "
- "XGetWindowAttributes\n", win->id);
- fprintf(stderr, "window: 0x%lx, map_state: %d, state: %d, "
- "transient: 0x%lx\n",
- win->id, wa.map_state, state, win->transient);
+ warnx("window: 0x%lx, failed XGetWindowAttributes",
+ win->id);
+ warnx("window: 0x%lx, map_state: %d, state: %d, "
+ "transient: 0x%lx", win->id, wa.map_state, state,
+ win->transient);
}
- fprintf(stderr, "===== unmanaged window list =====\n");
+ warnx("===== unmanaged window list =====");
TAILQ_FOREACH(win, &r->ws->unmanagedlist, entry) {
state = getstate(win->id);
if (!XGetWindowAttributes(display, win->id, &wa))
- fprintf(stderr, "window: 0x%lx, failed "
- "XGetWindowAttributes\n", win->id);
- fprintf(stderr, "window: 0x%lx, map_state: %d, state: %d, "
- "transient: 0x%lx\n",
- win->id, wa.map_state, state, win->transient);
+ warnx("window: 0x%lx, failed XGetWindowAttributes",
+ win->id);
+ warnx("window: 0x%lx, map_state: %d, state: %d, "
+ "transient: 0x%lx", win->id, wa.map_state, state,
+ win->transient);
}
- fprintf(stderr, "=================================\n");
+ warnx("=================================");
}
#else
void
if (status)
result = screen_def.pixel;
else
- fprintf(stderr, "color '%s' not found.\n", colorname);
+ warnx("color '%s' not found", colorname);
return (result);
}
y > DisplayHeight(display, sidx) ||
w + x > DisplayWidth(display, sidx) ||
h + y > DisplayHeight(display, sidx)) {
- fprintf(stderr, "ignoring region %ux%u+%u+%u "
- "- not within screen boundaries "
- "(%ux%u)\n", w, h, x, y,
+ warnx("ignoring region %ux%u+%u+%u - not within screen "
+ "boundaries (%ux%u)", w, h, x, y,
DisplayWidth(display, sidx), DisplayHeight(display, sidx));
return;
}
void
bar_print(struct swm_region *r, char *s)
{
- int textwidth, x = 0;
- size_t len;
+ int x = 0;
+ size_t len;
+ XRectangle ibox, lbox;
XClearWindow(display, r->bar_window);
- XSetForeground(display, bar_gc, r->s->c[SWM_S_COLOR_BAR_FONT].color);
len = strlen(s);
- textwidth = XTextWidth(bar_fs, s, len);
+ XmbTextExtents(bar_fs, s, len, &ibox, &lbox);
switch (bar_justify) {
case SWM_BAR_JUSTIFY_LEFT:
x = SWM_BAR_OFFSET;
break;
case SWM_BAR_JUSTIFY_CENTER:
- x = (WIDTH(r) - textwidth) / 2;
+ x = (WIDTH(r) - lbox.width) / 2;
break;
case SWM_BAR_JUSTIFY_RIGHT:
- x = WIDTH(r) - textwidth - SWM_BAR_OFFSET;
+ x = WIDTH(r) - lbox.width - SWM_BAR_OFFSET;
break;
}
if (x < SWM_BAR_OFFSET)
x = SWM_BAR_OFFSET;
- XDrawString(display, r->bar_window, bar_gc, x, bar_fs->ascent, s, len);
+ DRAWSTRING(display, r->bar_window, bar_fs, r->s->bar_gc,
+ x, (bar_fs_extents->max_logical_extent.height - lbox.height) / 2 -
+ lbox.y, s, len);
}
void
kill(bar_pid, SIGTERM);
bar_pid = 0;
}
- strlcpy(bar_ext, "", sizeof bar_ext);
+ strlcpy((char *)bar_ext, "", sizeof bar_ext);
bar_extra = 0;
}
strlcat(s, " ", sz);
}
out:
- if (xch)
+ if (xch) {
+ XFree(xch->res_name);
+ XFree(xch->res_class);
XFree(xch);
+ }
}
void
bar_window_name(char *s, ssize_t sz, struct ws_win *cur_focus)
{
- char *title;
+ unsigned char *title;
if (window_name_enabled && cur_focus != NULL) {
- XFetchName(display, cur_focus->id, &title);
- if (title) {
+ title = get_win_name(display, cur_focus->id);
+ if (title != NULL) {
+ DNPRINTF(SWM_D_BAR, "bar_window_name: title: %s\n",
+ title);
+
if (cur_focus->floating)
strlcat(s, "(f) ", sz);
- strlcat(s, title, sz);
+ strlcat(s, (char *)title, sz);
strlcat(s, " ", sz);
XFree(title);
}
size_t len;
char ws[SWM_BAR_MAX];
char s[SWM_BAR_MAX];
- char cn[SWM_BAR_MAX];
+ unsigned char cn[SWM_BAR_MAX];
char loc[SWM_BAR_MAX];
char *b, *stack = "";
while ((b = fgetln(stdin, &len)) != NULL)
if (b && b[len - 1] == '\n') {
b[len - 1] = '\0';
- strlcpy(bar_ext, b, sizeof bar_ext);
+ strlcpy((char *)bar_ext, b, sizeof bar_ext);
}
if (b == NULL && errno != EAGAIN) {
- fprintf(stderr, "bar_update: bar_extra failed: "
- "errno: %d %s\n", errno, strerror(errno));
+ warn("bar_update: bar_extra failed");
bar_extra_stop();
}
} else
- strlcpy(bar_ext, "", sizeof bar_ext);
+ strlcpy((char *)bar_ext, "", sizeof bar_ext);
if (clock_enabled == 0)
strlcpy(s, "", sizeof s);
else {
time(&tmt);
localtime_r(&tmt, &tm);
- strftime(s, sizeof s, clock_format, &tm);
+ len = strftime(s, sizeof s, clock_format, &tm);
+ s[len] = '\0';
strlcat(s, " ", sizeof s);
}
for (i = 0; i < ScreenCount(display); i++) {
x = 1;
TAILQ_FOREACH(r, &screens[i].rl, entry) {
- strlcpy(cn, "", sizeof cn);
+ strlcpy((char *)cn, "", sizeof cn);
strlcpy(ws, "", sizeof ws);
if (r && r->ws) {
- bar_urgent(cn, sizeof cn);
- bar_class_name(cn, sizeof cn, r->ws->focus);
- bar_window_name(cn, sizeof cn, r->ws->focus);
+ bar_urgent((char *)cn, sizeof cn);
+ bar_class_name((char *)cn, sizeof cn,
+ r->ws->focus);
+ bar_window_name((char *)cn, sizeof cn,
+ r->ws->focus);
if (r->ws->name)
snprintf(ws, sizeof ws, "<%s>",
r->ws->name);
struct swm_region *tmpr;
int i, sc = ScreenCount(display);
- DNPRINTF(SWM_D_MISC, "bar_toggle\n");
+ DNPRINTF(SWM_D_BAR, "bar_toggle\n");
if (bar_enabled)
for (i = 0; i < sc; i++)
void
bar_setup(struct swm_region *r)
{
+ char *default_string;
+ char **missing_charsets;
+ int num_missing_charsets = 0;
int i, x, y;
if (bar_fs) {
- XFreeFont(display, bar_fs);
+ XFreeFontSet(display, bar_fs);
bar_fs = NULL;
}
- for (i = 0; bar_fonts[i] != NULL; i++) {
- bar_fs = XLoadQueryFont(display, bar_fonts[i]);
- if (bar_fs) {
- bar_fidx = i;
- break;
- }
+
+ DNPRINTF(SWM_D_BAR, "bar_setup: loading bar_fonts: %s\n", bar_fonts);
+
+ bar_fs = XCreateFontSet(display, bar_fonts, &missing_charsets,
+ &num_missing_charsets, &default_string);
+
+ if (num_missing_charsets > 0) {
+ warnx("Unable to load charset(s):");
+
+ for (i = 0; i < num_missing_charsets; ++i)
+ warnx("%s", missing_charsets[i]);
+
+ XFreeStringList(missing_charsets);
+
+ if (strcmp(default_string, ""))
+ warnx("Glyphs from those sets will be replaced "
+ "by '%s'.", default_string);
+ else
+ warnx("Glyphs from those sets won't be drawn.");
}
- if (bar_fonts[i] == NULL)
- errx(1, "couldn't load font");
+
if (bar_fs == NULL)
- errx(1, "couldn't create font structure");
+ errx(1, "Error creating font set structure.");
+
+ bar_fs_extents = XExtentsOfFontSet(bar_fs);
- bar_height = bar_fs->ascent + bar_fs->descent + 1 +
+ bar_height = bar_fs_extents->max_logical_extent.height +
2 * bar_border_width;
+
+ if (bar_height < 1)
+ bar_height = 1;
+
x = X(r);
y = bar_at_bottom ? (Y(r) + HEIGHT(r) - bar_height) : Y(r);
bar_height - 2 * bar_border_width,
bar_border_width, r->s->c[SWM_S_COLOR_BAR_BORDER].color,
r->s->c[SWM_S_COLOR_BAR].color);
- bar_gc = XCreateGC(display, r->bar_window, 0, &bar_gcv);
- XSetFont(display, bar_gc, bar_fs->fid);
XSelectInput(display, r->bar_window, VisibilityChangeMask);
if (bar_enabled)
XMapRaised(display, r->bar_window);
- DNPRINTF(SWM_D_MISC, "bar_setup: bar_window: 0x%lx\n", r->bar_window);
+ DNPRINTF(SWM_D_BAR, "bar_setup: bar_window: 0x%lx\n", r->bar_window);
if (signal(SIGALRM, bar_signal) == SIG_ERR)
err(1, "could not install bar_signal");
if (win == NULL)
return;
+ /* send notification of unchanged state. */
+ ce.type = ConfigureNotify;
+ ce.x = X(win);
+ ce.y = Y(win);
+ ce.width = WIDTH(win);
+ ce.height = HEIGHT(win);
+ ce.override_redirect = False;
if (ev == NULL) {
/* EWMH */
- ce.type = ConfigureNotify;
ce.display = display;
ce.event = win->id;
ce.window = win->id;
- ce.x = X(win);
- ce.y = Y(win);
- ce.width = WIDTH(win);
- ce.height = HEIGHT(win);
ce.border_width = border_width;
ce.above = None;
- ce.override_redirect = False;
} else {
/* normal */
- ce.type = ConfigureNotify;
ce.display = ev->display;
ce.event = ev->window;
ce.window = ev->window;
- ce.x = ev->x;
- ce.y = ev->y;
- ce.width = ev->width;
- ce.height = ev->height;
+
+ /* make response appear more WM_SIZE_HINTS-compliant */
+ if (win->sh_mask)
+ DNPRINTF(SWM_D_MISC, "config_win: hints: window: 0x%lx,"
+ " sh_mask: %ld, min: %d x %d, max: %d x %d, inc: "
+ "%d x %d\n", win->id, win->sh_mask, SH_MIN_W(win),
+ SH_MIN_H(win), SH_MAX_W(win), SH_MAX_H(win),
+ SH_INC_W(win), SH_INC_H(win));
+
+ /* min size */
+ if (SH_MIN(win)) {
+ /* the hint may be set... to 0! */
+ if (SH_MIN_W(win) > 0 && ce.width < SH_MIN_W(win))
+ ce.width = SH_MIN_W(win);
+ if (SH_MIN_H(win) > 0 && ce.height < SH_MIN_H(win))
+ ce.height = SH_MIN_H(win);
+ }
+
+ /* max size */
+ if (SH_MAX(win)) {
+ /* may also be advertized as 0 */
+ if (SH_MAX_W(win) > 0 && ce.width > SH_MAX_W(win))
+ ce.width = SH_MAX_W(win);
+ if (SH_MAX_H(win) > 0 && ce.height > SH_MAX_H(win))
+ ce.height = SH_MAX_H(win);
+ }
+
+ /* resize increment. */
+ if (SH_INC(win)) {
+ if (SH_INC_W(win) > 1 && ce.width > SH_INC_W(win))
+ ce.width -= (ce.width - SH_MIN_W(win)) %
+ SH_INC_W(win);
+ if (SH_INC_H(win) > 1 && ce.height > SH_INC_H(win))
+ ce.height -= (ce.height - SH_MIN_H(win)) %
+ SH_INC_H(win);
+ }
+
+ /* adjust x and y for requested border_width. */
+ ce.x += border_width - ev->border_width;
+ ce.y += border_width - ev->border_width;
ce.border_width = ev->border_width;
ce.above = ev->above;
- ce.override_redirect = False;
}
DNPRINTF(SWM_D_MISC, "config_win: ewmh: %s, window: 0x%lx, (x,y) w x h: "
unmap_all();
XCloseDisplay(display);
execvp(start_argv[0], start_argv);
- fprintf(stderr, "execvp failed\n");
- perror(" failed");
+ warn("execvp failed");
quit(NULL, NULL);
}
setenv("LD_PRELOAD", SWM_LIB, 1);
if (asprintf(&ret, "%d", ws_idx) == -1) {
- perror("_SWM_WS");
+ warn("spawn: asprintf SWM_WS");
_exit(1);
}
setenv("_SWM_WS", ret, 1);
ret = NULL;
if (asprintf(&ret, "%d", getpid()) == -1) {
- perror("_SWM_PID");
+ warn("spawn: asprintf _SWM_PID");
_exit(1);
}
setenv("_SWM_PID", ret, 1);
ret = NULL;
if (setsid() == -1) {
- perror("setsid");
+ warn("spawn: setsid");
_exit(1);
}
* leave stderr open to record errors
*/
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
- perror("open");
+ warn("spawn: open");
_exit(1);
}
dup2(fd, STDIN_FILENO);
execvp(args->argv[0], args->argv);
- perror("execvp");
+ warn("spawn: execvp");
_exit(1);
}
PropModeReplace, (unsigned char *)&win->id,1);
}
- if (window_name_enabled)
+ if (window_name_enabled || title_class_enabled || title_name_enabled)
bar_update();
}
if (win->transient) {
parent = find_window(win->transient);
if (parent == NULL) {
- fprintf(stderr, "not possible bug\n");
+ warnx("not possible bug");
continue;
}
TAILQ_REMOVE(wl, win, entry);
if (window_name_enabled || title_name_enabled ||
title_class_enabled)
bar_update();
-
return;
}
}
unsigned char *
-get_win_name(Display *dpy, Window win, Atom wname, Atom stype,
- unsigned long *slen)
+get_win_name(Display *dpy, Window win)
{
int status, retfmt;
unsigned long nitems, nbytes, nextra;
unsigned char *prop = NULL;
Atom rettype;
- status = XGetWindowProperty(dpy, win, wname, 0L, 0L, False, stype,
- &rettype, &retfmt, &nitems, &nbytes, &prop);
+ status = XGetWindowProperty(dpy, win, a_netwmname, 0L, 0L, False,
+ a_utf8_string, &rettype, &retfmt, &nitems, &nbytes, &prop);
if (status != Success)
return (NULL);
XFree(prop);
- status = XGetWindowProperty(dpy, win, wname, 0L, nbytes, False,
- stype, &rettype, &retfmt, &nitems, &nextra, &prop);
+ status = XGetWindowProperty(dpy, win, a_netwmname, 0L, nbytes, False,
+ a_utf8_string, &rettype, &retfmt, &nitems, &nextra, &prop);
if (status != Success) {
XFree(prop);
return (NULL);
}
- if (rettype != stype) {
+ if (rettype != a_utf8_string) {
XFree(prop);
return (NULL);
}
- *slen = nitems;
return (prop);
}
FILE *lfile;
unsigned char *name;
int count = 0;
- unsigned long len;
DNPRINTF(SWM_D_MISC, "uniconify\n");
if (win->iconic == 0)
continue;
- name = get_win_name(display, win->id, a_netwmname,
- a_utf8_string, &len);
+ name = get_win_name(display, win->id);
if (name == NULL)
continue;
fprintf(lfile, "%s.%lu\n", name, win->id);
while ((sw = TAILQ_FIRST(&search_wl)) != NULL) {
XDestroyWindow(display, sw->indicator);
+ XFreeGC(display, sw->gc);
TAILQ_REMOVE(&search_wl, sw, entry);
free(sw);
}
struct ws_win *win = NULL;
struct search_window *sw = NULL;
Window w;
- GC gc;
XGCValues gcv;
int i;
char s[8];
FILE *lfile;
size_t len;
- int textwidth;
+ XRectangle ibox, lbox;
DNPRINTF(SWM_D_MISC, "search_win\n");
sw = calloc(1, sizeof(struct search_window));
if (sw == NULL) {
- fprintf(stderr, "search_win: calloc: %s",
- strerror(errno));
+ warn("search_win: calloc");
fclose(lfile);
search_win_cleanup();
return;
snprintf(s, sizeof s, "%d", i);
len = strlen(s);
- textwidth = XTextWidth(bar_fs, s, len);
+
+ XmbTextExtents(bar_fs, s, len, &ibox, &lbox);
w = XCreateSimpleWindow(display,
- win->id, 0, 0, textwidth + 12,
- bar_fs->ascent + bar_fs->descent + 4, 1,
+ win->id, 0, 0,lbox.width + 4,
+ bar_fs_extents->max_logical_extent.height, 1,
r->s->c[SWM_S_COLOR_UNFOCUS].color,
r->s->c[SWM_S_COLOR_FOCUS].color);
sw->indicator = w;
TAILQ_INSERT_TAIL(&search_wl, sw, entry);
- gc = XCreateGC(display, w, 0, &gcv);
- XSetFont(display, gc, bar_fs->fid);
+ sw->gc = XCreateGC(display, w, 0, &gcv);
XMapRaised(display, w);
- XSetForeground(display, gc, r->s->c[SWM_S_COLOR_BAR].color);
+ XSetForeground(display, sw->gc, r->s->c[SWM_S_COLOR_BAR].color);
- XDrawString(display, w, gc, 6, bar_fs->ascent + 2, s, len);
+ DRAWSTRING(display, w, bar_fs, sw->gc, 2,
+ (bar_fs_extents->max_logical_extent.height -
+ lbox.height) / 2 - lbox.y, s, len);
fprintf(lfile, "%d\n", i);
i++;
TAILQ_FOREACH(win, &search_r->ws->winlist, entry) {
if (win->iconic == 0)
continue;
- name = get_win_name(display, win->id, a_netwmname,
- a_utf8_string, &len);
+ name = get_win_name(display, win->id);
if (name == NULL)
continue;
if (asprintf(&s, "%s.%lu", name, win->id) == -1) {
searchpid = 0;
if ((resp = calloc(1, MAX_RESP_LEN + 1)) == NULL) {
- fprintf(stderr, "search: calloc\n");
+ warn("search: calloc");
goto done;
}
rbytes = read(select_resp_pipe[0], resp, MAX_RESP_LEN);
if (rbytes <= 0) {
- fprintf(stderr, "search: read error: %s\n", strerror(errno));
+ warn("search: read error");
goto done;
}
resp[rbytes] = '\0';
{ "invalid key func", NULL, {0} },
};
struct key {
+ TAILQ_ENTRY(key) entry;
unsigned int mod;
KeySym keysym;
enum keyfuncid funcid;
char *spawn_name;
};
-int keys_size = 0, keys_length = 0;
-struct key *keys = NULL;
+TAILQ_HEAD(key_list, key);
+struct key_list keys = TAILQ_HEAD_INITIALIZER(keys);
/* mouse */
enum { client_click, root_click };
update_modkey(unsigned int mod)
{
int i;
+ struct key *kp;
mod_key = mod;
- for (i = 0; i < keys_length; i++)
- if (keys[i].mod & ShiftMask)
- keys[i].mod = mod | ShiftMask;
+ TAILQ_FOREACH(kp, &keys, entry)
+ if (kp->mod & ShiftMask)
+ kp->mod = mod | ShiftMask;
else
- keys[i].mod = mod;
+ kp->mod = mod;
for (i = 0; i < LENGTH(buttons); i++)
if (buttons[i].mask & ShiftMask)
prog = &spawns[i];
}
if (prog == NULL) {
- fprintf(stderr, "spawn_custom: program %s not found\n",
- spawn_name);
+ warnx("spawn_custom: program %s not found", spawn_name);
return (-1);
}
== NULL)
err(1, "spawn_custom bar color");
} else if (!strcasecmp(ap, "$bar_font")) {
- if ((real_args[i] = strdup(bar_fonts[bar_fidx]))
+ if ((real_args[i] = strdup(bar_fonts))
== NULL)
err(1, "spawn_custom bar fonts");
} else if (!strcasecmp(ap, "$bar_font_color")) {
}
if (prog->argv == NULL) {
- fprintf(stderr,
- "error: setspawn: cannot find program: %s", prog->name);
+ warnx("error: setspawn: cannot find program: %s", prog->name);
free(prog);
return;
}
spawns = malloc((size_t)spawns_size *
sizeof(struct spawn_prog));
if (spawns == NULL) {
- fprintf(stderr, "setspawn: malloc failed\n");
- perror(" failed");
+ warn("setspawn: malloc failed");
quit(NULL, NULL);
}
} else if (spawns_length == spawns_size) {
spawns = realloc(spawns, (size_t)spawns_size *
sizeof(struct spawn_prog));
if (spawns == NULL) {
- fprintf(stderr, "setspawn: realloc failed\n");
- perror(" failed");
+ warn("setspawn: realloc failed");
quit(NULL, NULL);
}
}
i = spawns_length++;
spawns[i] = *prog;
} else {
- fprintf(stderr, "spawns array problem?\n");
+ warnx("spawns array problem?");
if (spawns == NULL) {
- fprintf(stderr, "spawns array is NULL!\n");
+ warnx("spawns array is NULL!");
quit(NULL, NULL);
}
}
}
void
+key_insert(unsigned int mod, KeySym ks, enum keyfuncid kfid, char *spawn_name)
+{
+ struct key *kp;
+
+ DNPRINTF(SWM_D_KEY, "key_insert: enter %s [%s]\n",
+ keyfuncs[kfid].name, spawn_name);
+
+ if ((kp = malloc(sizeof *kp)) == NULL)
+ err(1, "key_insert: malloc");
+
+ kp->mod = mod;
+ kp->keysym = ks;
+ kp->funcid = kfid;
+ kp->spawn_name = strdupsafe(spawn_name);
+ TAILQ_INSERT_TAIL(&keys, kp, entry);
+
+ DNPRINTF(SWM_D_KEY, "key_insert: leave\n");
+}
+
+void
+key_remove(struct key *kp)
+{
+ DNPRINTF(SWM_D_KEY, "key_remove: %s\n", keyfuncs[kp->funcid].name);
+
+ TAILQ_REMOVE(&keys, kp, entry);
+ free(kp->spawn_name);
+ free(kp);
+
+ DNPRINTF(SWM_D_KEY, "key_remove: leave\n");
+}
+
+void
+key_replace(struct key *kp, unsigned int mod, KeySym ks, enum keyfuncid kfid,
+ char *spawn_name)
+{
+ DNPRINTF(SWM_D_KEY, "key_replace: %s [%s]\n", keyfuncs[kp->funcid].name,
+ spawn_name);
+
+ key_remove(kp);
+ key_insert(mod, ks, kfid, spawn_name);
+
+ DNPRINTF(SWM_D_KEY, "key_replace: leave\n");
+}
+
+void
setkeybinding(unsigned int mod, KeySym ks, enum keyfuncid kfid,
char *spawn_name)
{
- int i, j;
+ struct key *kp;
+
DNPRINTF(SWM_D_KEY, "setkeybinding: enter %s [%s]\n",
keyfuncs[kfid].name, spawn_name);
- /* find existing */
- for (i = 0; i < keys_length; i++) {
- if (keys[i].mod == mod && keys[i].keysym == ks) {
- if (kfid == kf_invalid) {
- /* found: delete */
- DNPRINTF(SWM_D_KEY,
- "setkeybinding: delete #%d %s\n",
- i, keyfuncs[keys[i].funcid].name);
- free(keys[i].spawn_name);
- j = keys_length - 1;
- if (i < j)
- keys[i] = keys[j];
- keys_length--;
- DNPRINTF(SWM_D_KEY, "setkeybinding: leave\n");
- return;
- } else {
- /* found: replace */
- DNPRINTF(SWM_D_KEY,
- "setkeybinding: replace #%d %s [%s]\n",
- i, keyfuncs[keys[i].funcid].name,
- spawn_name);
- free(keys[i].spawn_name);
- keys[i].mod = mod;
- keys[i].keysym = ks;
- keys[i].funcid = kfid;
- keys[i].spawn_name = strdupsafe(spawn_name);
- DNPRINTF(SWM_D_KEY, "setkeybinding: leave\n");
- return;
- }
+
+ TAILQ_FOREACH(kp, &keys, entry) {
+ if (kp->mod == mod && kp->keysym == ks) {
+ if (kfid == kf_invalid)
+ key_remove(kp);
+ else
+ key_replace(kp, mod, ks, kfid, spawn_name);
+ DNPRINTF(SWM_D_KEY, "setkeybinding: leave\n");
+ return;
}
}
if (kfid == kf_invalid) {
- fprintf(stderr,
- "error: setkeybinding: cannot find mod/key combination");
+ warnx("error: setkeybinding: cannot find mod/key combination");
DNPRINTF(SWM_D_KEY, "setkeybinding: leave\n");
return;
}
- /* not found: add */
- if (keys_size == 0 || keys == NULL) {
- keys_size = 4;
- DNPRINTF(SWM_D_KEY, "setkeybinding: init list %d\n", keys_size);
- keys = malloc((size_t)keys_size * sizeof(struct key));
- if (keys == NULL) {
- fprintf(stderr, "malloc failed\n");
- perror(" failed");
- quit(NULL, NULL);
- }
- } else if (keys_length == keys_size) {
- keys_size *= 2;
- DNPRINTF(SWM_D_KEY, "setkeybinding: grow list %d\n", keys_size);
- keys = realloc(keys, (size_t)keys_size * sizeof(struct key));
- if (keys == NULL) {
- fprintf(stderr, "realloc failed\n");
- perror(" failed");
- quit(NULL, NULL);
- }
- }
- if (keys_length < keys_size) {
- j = keys_length++;
- DNPRINTF(SWM_D_KEY, "setkeybinding: add #%d %s [%s]\n",
- j, keyfuncs[kfid].name, spawn_name);
- keys[j].mod = mod;
- keys[j].keysym = ks;
- keys[j].funcid = kfid;
- keys[j].spawn_name = strdupsafe(spawn_name);
- } else {
- fprintf(stderr, "keys array problem?\n");
- if (keys == NULL) {
- fprintf(stderr, "keys array problem\n");
- quit(NULL, NULL);
- }
- }
+
+ key_insert(mod, ks, kfid, spawn_name);
DNPRINTF(SWM_D_KEY, "setkeybinding: leave\n");
}
void
clear_keys(void)
{
- int i;
+ struct key *kp_loop, *kp_next;
- /* clear all key bindings, if any */
- for (i = 0; i < keys_length; i++)
- free(keys[i].spawn_name);
- keys_length = 0;
+ kp_loop = TAILQ_FIRST(&keys);
+ while (kp_loop != NULL) {
+ kp_next = TAILQ_NEXT(kp_loop, entry);
+ key_remove(kp_loop);
+ kp_loop = kp_next;
+ }
}
int
void
grabkeys(void)
{
- unsigned int i, j, k;
+ unsigned int j, k;
KeyCode code;
unsigned int modifiers[] =
{ 0, LockMask, numlockmask, numlockmask | LockMask };
+ struct key *kp;
DNPRINTF(SWM_D_MISC, "grabkeys\n");
updatenumlockmask();
if (TAILQ_EMPTY(&screens[k].rl))
continue;
XUngrabKey(display, AnyKey, AnyModifier, screens[k].root);
- for (i = 0; i < keys_length; i++) {
- if ((code = XKeysymToKeycode(display, keys[i].keysym)))
+ TAILQ_FOREACH(kp, &keys, entry) {
+ if ((code = XKeysymToKeycode(display, kp->keysym)))
for (j = 0; j < LENGTH(modifiers); j++)
XGrabKey(display, code,
- keys[i].mod | modifiers[j],
+ kp->mod | modifiers[j],
screens[k].root, True,
GrabModeAsync, GrabModeAsync);
}
}
void
-setquirk(const char *class, const char *name, const int quirk)
+quirk_insert(const char *class, const char *name, unsigned long quirk)
{
- int i, j;
+ struct quirk *qp;
- /* find existing */
- for (i = 0; i < quirks_length; i++) {
- if (!strcmp(quirks[i].class, class) &&
- !strcmp(quirks[i].name, name)) {
- if (!quirk) {
- /* found: delete */
- DNPRINTF(SWM_D_QUIRK,
- "setquirk: delete #%d %s:%s\n",
- i, quirks[i].class, quirks[i].name);
- free(quirks[i].class);
- free(quirks[i].name);
- j = quirks_length - 1;
- if (i < j)
- quirks[i] = quirks[j];
- quirks_length--;
- return;
- } else {
- /* found: replace */
- DNPRINTF(SWM_D_QUIRK,
- "setquirk: replace #%d %s:%s\n",
- i, quirks[i].class, quirks[i].name);
- free(quirks[i].class);
- free(quirks[i].name);
- quirks[i].class = strdup(class);
- quirks[i].name = strdup(name);
- quirks[i].quirk = quirk;
- return;
- }
+ DNPRINTF(SWM_D_QUIRK, "quirk_insert: %s:%s [%lu]\n", class, name,
+ quirk);
+
+ if ((qp = malloc(sizeof *qp)) == NULL)
+ err(1, "quirk_insert: malloc");
+ if ((qp->class = strdup(class)) == NULL)
+ err(1, "quirk_insert: strdup");
+ if ((qp->name = strdup(name)) == NULL)
+ err(1, "quirk_insert: strdup");
+
+ qp->quirk = quirk;
+ TAILQ_INSERT_TAIL(&quirks, qp, entry);
+
+ DNPRINTF(SWM_D_QUIRK, "quirk_insert: leave\n");
+}
+
+void
+quirk_remove(struct quirk *qp)
+{
+ DNPRINTF(SWM_D_QUIRK, "quirk_remove: %s:%s [%lu]\n", qp->class,
+ qp->name, qp->quirk);
+
+ TAILQ_REMOVE(&quirks, qp, entry);
+ free(qp->class);
+ free(qp->name);
+ free(qp);
+
+ DNPRINTF(SWM_D_QUIRK, "quirk_remove: leave\n");
+}
+
+void
+quirk_replace(struct quirk *qp, const char *class, const char *name,
+ unsigned long quirk)
+{
+ DNPRINTF(SWM_D_QUIRK, "quirk_replace: %s:%s [%lu]\n", qp->class,
+ qp->name, qp->quirk);
+
+ quirk_remove(qp);
+ quirk_insert(class, name, quirk);
+
+ DNPRINTF(SWM_D_QUIRK, "quirk_replace: leave\n");
+}
+
+void
+setquirk(const char *class, const char *name, unsigned long quirk)
+{
+ struct quirk *qp;
+
+ DNPRINTF(SWM_D_QUIRK, "setquirk: enter %s:%s [%lu]\n", class, name,
+ quirk);
+
+ TAILQ_FOREACH(qp, &quirks, entry) {
+ if (!strcmp(qp->class, class) && !strcmp(qp->name, name)) {
+ if (!quirk)
+ quirk_remove(qp);
+ else
+ quirk_replace(qp, class, name, quirk);
+ DNPRINTF(SWM_D_QUIRK, "setquirk: leave\n");
+ return;
}
}
if (!quirk) {
- fprintf(stderr,
- "error: setquirk: cannot find class/name combination");
+ warnx("error: setquirk: cannot find class/name combination");
return;
}
- /* not found: add */
- if (quirks_size == 0 || quirks == NULL) {
- quirks_size = 4;
- DNPRINTF(SWM_D_QUIRK, "setquirk: init list %d\n", quirks_size);
- quirks = malloc((size_t)quirks_size * sizeof(struct quirk));
- if (quirks == NULL) {
- fprintf(stderr, "setquirk: malloc failed\n");
- perror(" failed");
- quit(NULL, NULL);
- }
- } else if (quirks_length == quirks_size) {
- quirks_size *= 2;
- DNPRINTF(SWM_D_QUIRK, "setquirk: grow list %d\n", quirks_size);
- quirks = realloc(quirks,
- (size_t)quirks_size * sizeof(struct quirk));
- if (quirks == NULL) {
- fprintf(stderr, "setquirk: realloc failed\n");
- perror(" failed");
- quit(NULL, NULL);
- }
- }
- if (quirks_length < quirks_size) {
- DNPRINTF(SWM_D_QUIRK, "setquirk: add %d\n", quirks_length);
- j = quirks_length++;
- quirks[j].class = strdup(class);
- quirks[j].name = strdup(name);
- quirks[j].quirk = quirk;
- } else {
- fprintf(stderr, "quirks array problem?\n");
- if (quirks == NULL) {
- fprintf(stderr, "quirks array problem!\n");
- quit(NULL, NULL);
- }
- }
+
+ quirk_insert(class, name, quirk);
+ DNPRINTF(SWM_D_QUIRK, "setquirk: leave\n");
}
int
setconfvalue(char *selector, char *value, int flags)
{
int i;
+ char *b;
switch (flags) {
case SWM_S_BAR_DELAY:
border_width = atoi(value);
break;
case SWM_S_BAR_FONT:
- free(bar_fonts[0]);
- if ((bar_fonts[0] = strdup(value)) == NULL)
- err(1, "setconfvalue: bar_font");
+ b = bar_fonts;
+ if (asprintf(&bar_fonts, "%s,%s", value, bar_fonts) == -1)
+ err(1, "setconfvalue: asprintf: failed to allocate "
+ "memory for bar_fonts.");
+
+ free(b);
break;
case SWM_S_BAR_ACTION:
free(bar_argv[0]);
DNPRINTF(SWM_D_CONF, "conf_load: begin\n");
if (filename == NULL) {
- fprintf(stderr, "conf_load: no filename\n");
+ warnx("conf_load: no filename");
return (1);
}
if ((config = fopen(filename, "r")) == NULL) {
optval = strdup(cp);
/* call function to deal with it all */
if (configopt[optind].func(optsub, optval,
- configopt[optind].funcflags) != 0) {
- fprintf(stderr, "%s line %zd: %s\n",
- filename, lineno, line);
+ configopt[optind].funcflags) != 0)
errx(1, "%s: line %zd: invalid data for %s",
filename, lineno, configopt[optind].optname);
- }
free(optval);
free(optsub);
free(line);
out:
free(line);
fclose(config);
+ DNPRINTF(SWM_D_CONF, "conf_load: end with error.\n");
return (1);
}
" for 0x%lx trans 0x%lx\n", win->id, win->transient);
if (win->hints == NULL) {
- fprintf(stderr, "no hints for 0x%lx\n", win->id);
+ warnx("no hints for 0x%lx", win->id);
return;
}
XFree(wmh);
if ((wmh = XGetWMHints(display, w->id)) == NULL) {
- fprintf(stderr, "can't get hints for 0x%lx\n",
- w->id);
+ warnx("can't get hints for 0x%lx", w->id);
continue;
}
const char *errstr;
XWindowChanges wc;
struct pid_e *p;
+ struct quirk *qp;
if ((win = find_window(id)) != NULL)
return (win); /* already being managed */
False, XA_STRING, &type, &format, &nitems, &bytes, &prop);
}
XGetWindowAttributes(display, id, &win->wa);
- XGetWMNormalHints(display, id, &win->sh, &mask);
+ XGetWMNormalHints(display, id, &win->sh, &win->sh_mask);
win->hints = XGetWMHints(display, id);
XGetTransientForHint(display, id, &trans);
if (trans) {
if (ww->ws->r)
r = ww->ws->r;
else
- fprintf(stderr,
- "manage_window: fix this "
- "bug mcbride\n");
+ warnx("manage_window: fix this "
+ "bug mcbride");
border_me = 1;
}
}
border_me = 1;
}
- for (i = 0; i < quirks_length; i++){
- if (!strcmp(win->ch.res_class, quirks[i].class) &&
- !strcmp(win->ch.res_name, quirks[i].name)) {
+ TAILQ_FOREACH(qp, &quirks, entry) {
+ if (!strcmp(win->ch.res_class, qp->class) &&
+ !strcmp(win->ch.res_name, qp->name)) {
DNPRINTF(SWM_D_CLASS, "manage_window: found: "
"class: %s, name: %s\n", win->ch.res_class,
win->ch.res_name);
- if (quirks[i].quirk & SWM_Q_FLOAT) {
+ if (qp->quirk & SWM_Q_FLOAT) {
win->floating = 1;
border_me = 1;
}
- win->quirks = quirks[i].quirk;
+ win->quirks = qp->quirk;
}
}
}
focus_prev(win);
+ if (win->hints) {
+ XFree(win->hints);
+ win->hints = NULL;
+ }
+
TAILQ_REMOVE(&win->ws->winlist, win, entry);
TAILQ_INSERT_TAIL(&win->ws->unmanagedlist, win, entry);
void
keypress(XEvent *e)
{
- unsigned int i;
KeySym keysym;
XKeyEvent *ev = &e->xkey;
+ struct key *kp;
keysym = XKeycodeToKeysym(display, (KeyCode)ev->keycode, 0);
- for (i = 0; i < keys_length; i++)
- if (keysym == keys[i].keysym
- && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
- && keyfuncs[keys[i].funcid].func) {
- if (keys[i].funcid == kf_spawn_custom)
+ TAILQ_FOREACH(kp, &keys, entry)
+ if (keysym == kp->keysym
+ && CLEANMASK(kp->mod) == CLEANMASK(ev->state)
+ && keyfuncs[kp->funcid].func) {
+ if (kp->funcid == kf_spawn_custom)
spawn_custom(
root_to_region(ev->root),
- &(keyfuncs[keys[i].funcid].args),
- keys[i].spawn_name
+ &(keyfuncs[kp->funcid].args),
+ kp->spawn_name
);
else
- keyfuncs[keys[i].funcid].func(
+ keyfuncs[kp->funcid].func(
root_to_region(ev->root),
- &(keyfuncs[keys[i].funcid].args)
+ &(keyfuncs[kp->funcid].args)
);
}
}
configurenotify(XEvent *e)
{
struct ws_win *win;
- long mask;
DNPRINTF(SWM_D_EVENT, "configurenotify: window: 0x%lx\n",
e->xconfigure.window);
win = find_window(e->xconfigure.window);
if (win) {
- XGetWMNormalHints(display, win->id, &win->sh, &mask);
+ XGetWMNormalHints(display, win->id, &win->sh, &win->sh_mask);
adjust_font(win);
if (font_adjusted)
stack();
SWM_S_COLOR_FOCUS : SWM_S_COLOR_UNFOCUS].color);
break;
default:
- fprintf(stderr, "ignoring focusevent\n");
+ warnx("ignoring focusevent");
DNPRINTF(SWM_D_FOCUS, "ignoring focusevent\n");
break;
}
{
struct ws_win *win;
XPropertyEvent *ev = &e->xproperty;
-
+#ifdef SWM_DEBUG
+ char *name;
+ name = XGetAtomName(display, ev->atom);
DNPRINTF(SWM_D_EVENT, "propertynotify: window: 0x%lx, atom: %s\n",
- ev->window, XGetAtomName(display, ev->atom));
+ ev->window, name);
+ XFree(name);
+#endif
win = find_window(ev->window);
if (win == NULL)
case XA_WM_NORMAL_HINTS:
long mask;
XGetWMNormalHints(display, win->id, &win->sh, &mask);
- fprintf(stderr, "normal hints: flag 0x%x\n", win->sh.flags);
+ warnx("normal hints: flag 0x%x", win->sh.flags);
if (win->sh.flags & PMinSize) {
WIDTH(win) = win->sh.min_width;
HEIGHT(win) = win->sh.min_height;
- fprintf(stderr, "min %d %d\n", WIDTH(win), HEIGHT(win));
+ warnx("min %d %d", WIDTH(win), HEIGHT(win));
}
XMoveResizeWindow(display, win->id,
X(win), Y(win), WIDTH(win), HEIGHT(win));
int
xerror(Display *d, XErrorEvent *ee)
{
- /* fprintf(stderr, "error: %p %p\n", display, ee); */
+ /* warnx("error: %p %p", display, ee); */
return (-1);
}
int i, j, k;
int errorbase, major, minor;
struct workspace *ws;
+ XGCValues gcv;
if ((screens = calloc(ScreenCount(display),
sizeof(struct swm_screen))) == NULL)
setscreencolor("black", i + 1, SWM_S_COLOR_BAR);
setscreencolor("rgb:a0/a0/a0", i + 1, SWM_S_COLOR_BAR_FONT);
+ /* create graphics context on screen with default font color */
+ screens[i].bar_gc = XCreateGC(display, screens[i].root, 0,
+ &gcv);
+
+ XSetForeground(display, screens[i].bar_gc,
+ screens[i].c[SWM_S_COLOR_BAR_FONT].color);
+
/* set default cursor */
XDefineCursor(display, screens[i].root,
XCreateFontCursor(display, XC_left_ptr));
void
setup_globals(void)
{
- if ((bar_fonts[0] = strdup("-*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*"))
- == NULL)
- err(1, "setup_globals: strdup");
- if ((bar_fonts[1] = strdup("-*-times-medium-r-*-*-*-*-*-*-*-*-*-*"))
- == NULL)
- err(1, "setup_globals: strdup");
- if ((bar_fonts[2] = strdup("-misc-fixed-medium-r-*-*-*-*-*-*-*-*-*-*"))
- == NULL)
- err(1, "setup_globals: strdup");
+ if ((bar_fonts = strdup(SWM_BAR_FONTS)) == NULL)
+ err(1, "setup_globals: strdup: failed to allocate memory.");
+
if ((spawn_term[0] = strdup("xterm")) == NULL)
- err(1, "setup_globals: strdup");
+ err(1, "setup_globals: strdup: failed to allocate memory.");
+
if ((clock_format = strdup("%a %b %d %R %Z %Y")) == NULL)
- err(1, "strdup");
+ err(1, "setup_globals: strdup: failed to allocate memory.");
}
void
struct sigaction sact;
start_argv = argv;
- fprintf(stderr, "Welcome to scrotwm V%s Build: %s\n",
- SCROTWM_VERSION, buildstr);
+ warnx("Welcome to scrotwm V%s Build: %s", SCROTWM_VERSION, buildstr);
if (!setlocale(LC_CTYPE, "") || !setlocale(LC_TIME, "") ||
!XSupportsLocale())
warnx("no locale support");
+ if (!X_HAVE_UTF8_STRING)
+ warnx("no UTF-8 support");
+
if (!(display = XOpenDisplay(0)))
errx(1, "can not open display");
if (pwd == NULL)
errx(1, "invalid user: %d", getuid());
- setup_screens();
setup_globals();
+ setup_screens();
setup_keys();
setup_quirks();
setup_spawn();
if (S_ISREG(sb.st_mode))
cfile = conf;
}
- if (cfile)
- conf_load(cfile, SWM_CONF_DEFAULT);
+
+ /* load conf (if any) and refresh font color in bar graphics contexts */
+ if (cfile && conf_load(cfile, SWM_CONF_DEFAULT) == 0)
+ for (i = 0; i < ScreenCount(display); ++i)
+ XSetForeground(display, screens[i].bar_gc,
+ screens[i].c[SWM_S_COLOR_BAR_FONT].color);
setup_ewmh();
/* set some values to work around bad programs */
done:
teardown_ewmh();
bar_extra_stop();
- XFreeGC(display, bar_gc);
+
+ for (i = 0; i < ScreenCount(display); ++i)
+ if (screens[i].bar_gc != NULL)
+ XFreeGC(display, screens[i].bar_gc);
+
+ XFreeFontSet(display, bar_fs);
XCloseDisplay(display);
return (0);