char *
expand_tilde(char *s)
{
- struct passwd *pwd;
+ struct passwd *ppwd;
int i, max;
char *user;
const char *sc = s;
user[i] = '\0';
s = &s[i];
- pwd = strlen(user) == 0 ? getpwuid(getuid()) : getpwnam(user);
- if (pwd == NULL)
+ ppwd = strlen(user) == 0 ? getpwuid(getuid()) : getpwnam(user);
+ if (ppwd == NULL)
result = strdup(sc);
else
- if (asprintf(&result, "%s%s", pwd->pw_dir, s) == -1)
+ if (asprintf(&result, "%s%s", ppwd->pw_dir, s) == -1)
result = NULL;
out:
if (result == NULL)
void
bar_setup(struct swm_region *r)
{
- char *font, *fontpos, *dup, *search;
+ char *font, *fontpos, *d, *search;
int count;
xcb_screen_t *screen;
uint32_t wa[3];
err(1, "bar_setup: calloc: failed to allocate memory.");
if (bar_font == NULL) {
- if ((dup = strdup(bar_fonts)) == NULL)
+ if ((d = strdup(bar_fonts)) == NULL)
errx(1, "insufficient memory.");
- search = dup;
+ search = d;
while ((font = strsep(&search, ",")) != NULL) {
if (*font == '\0')
continue;
break;
}
}
- free(dup);
+ free(d);
}
if (bar_font == NULL)
xcb_create_pixmap(conn, screen->root_depth, r->bar->buffer, r->bar->id,
WIDTH(r->bar), HEIGHT(r->bar));
- xcb_randr_select_input(conn, r->bar->id,
- XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE);
+ if (xrandr_support)
+ xcb_randr_select_input(conn, r->bar->id,
+ XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE);
if (bar_enabled)
map_window_raised(r->bar->id);
{
char *cp, *class, *name;
int retval;
- unsigned long quirks;
+ unsigned long qrks;
/* suppress unused warning since var is needed */
(void)flags;
*cp = '\0';
class = selector;
name = cp + 1;
- if ((retval = parsequirks(value, &quirks)) == 0)
- setquirk(class, name, quirks);
+ if ((retval = parsequirks(value, &qrks)) == 0)
+ setquirk(class, name, qrks);
return (retval);
}
int
setlayout(char *selector, char *value, int flags)
{
- int ws_id, i, x, mg, ma, si, raise, f = 0;
+ int ws_id, i, x, mg, ma, si, ar, f = 0;
int st = SWM_V_STACK, num_screens;
char s[1024];
struct workspace *ws;
bzero(s, sizeof s);
if (sscanf(value, "ws[%d]:%d:%d:%d:%d:%1023c",
- &ws_id, &mg, &ma, &si, &raise, s) != 6)
+ &ws_id, &mg, &ma, &si, &ar, s) != 6)
errx(1, "invalid layout entry, should be 'ws[<idx>]:"
"<master_grow>:<master_add>:<stack_inc>:<always_raise>:"
"<type>'");
ws = (struct workspace *)&screens[i].ws;
ws[ws_id].cur_layout = &layouts[st];
- ws[ws_id].always_raise = raise;
+ ws[ws_id].always_raise = ar;
if (st == SWM_MAX_STACK)
continue;
FILE *config;
char *line, *cp, *optsub, *optval;
size_t linelen, lineno = 0;
- int wordlen, i, optind;
+ int wordlen, i, optidx;
struct config_option *opt;
DNPRINTF(SWM_D_CONF, "conf_load: begin\n");
filename, lineno);
goto out;
}
- optind = -1;
+ optidx = -1;
for (i = 0; i < LENGTH(configopt); i++) {
opt = &configopt[i];
if (!strncasecmp(cp, opt->optname, wordlen) &&
(int)strlen(opt->optname) == wordlen) {
- optind = i;
+ optidx = i;
break;
}
}
- if (optind == -1) {
+ if (optidx == -1) {
warnx("%s: line %zd: unknown option %.*s",
filename, lineno, wordlen, cp);
goto out;
/* get RHS value */
optval = strdup(cp);
/* call function to deal with it all */
- if (configopt[optind].func(optsub, optval,
- configopt[optind].funcflags) != 0)
+ if (configopt[optidx].func(optsub, optval,
+ configopt[optidx].funcflags) != 0)
errx(1, "%s: line %zd: invalid data for %s",
- filename, lineno, configopt[optind].optname);
+ filename, lineno, configopt[optidx].optname);
free(optval);
free(optsub);
free(line);
void
check_conn(void)
{
- int err = xcb_connection_has_error(conn);
+ int errcode = xcb_connection_has_error(conn);
+#ifdef XCB_CONN_ERROR
char *s;
-
- switch (err) {
+ switch (errcode) {
case XCB_CONN_ERROR:
s = "Socket error, pipe error or other stream error.";
break;
default:
s = "Unknown error.";
}
-
- if (err)
- errx(err, "X CONNECTION ERROR: %s", s);
+ if (errcode)
+ errx(errcode, "X CONNECTION ERROR: %s", s);
+#else
+ if (errcode)
+ errx(errcode, "X CONNECTION ERROR");
+#endif
}
int
/* initial Xrandr setup */
xrandr_support = 0;
- c = xcb_randr_query_version(conn, 1, 1);
- r = xcb_randr_query_version_reply(conn, c, NULL);
- if (r) {
- if (r->major_version >= 1) {
- qep = xcb_get_extension_data(conn, &xcb_randr_id);
- if (qep) {
+ qep = xcb_get_extension_data(conn, &xcb_randr_id);
+ if (qep->present) {
+ c = xcb_randr_query_version(conn, 1, 1);
+ r = xcb_randr_query_version_reply(conn, c, NULL);
+ if (r) {
+ if (r->major_version >= 1) {
xrandr_support = 1;
xrandr_eventbase = qep->first_event;
}
+ free(r);
}
- free(r);
}
cursor_font = xcb_generate_id(conn);