char *bar_argv[] = { NULL, NULL };
int bar_pipe[2];
-unsigned char bar_ext[SWM_BAR_MAX];
+char bar_ext[SWM_BAR_MAX];
char bar_vertext[SWM_BAR_MAX];
int bar_version = 0;
sig_atomic_t bar_alarm = 0;
void expose(xcb_expose_event_t *);
void fake_keypress(struct ws_win *, xcb_keysym_t, uint16_t);
struct pid_e *find_pid(pid_t);
-struct ws_win *find_unmanaged_window(xcb_window_t);
+struct ws_win *find_unmanaged_window(xcb_window_t);
struct ws_win *find_window(xcb_window_t);
void floating_toggle(struct swm_region *, union arg *);
int floating_toggle_win(struct ws_win *);
expand_tilde(const char *s)
{
struct passwd *ppwd;
- int i, max;
+ int i;
+ long max;
char *user;
const char *sc = s;
char *result;
kill(bar_pid, SIGTERM);
bar_pid = 0;
}
- strlcpy((char *)bar_ext, "", sizeof bar_ext);
+ strlcpy(bar_ext, "", sizeof bar_ext);
bar_extra = 0;
}
while ((b = fgetln(stdin, &len)) != NULL)
if (b && b[len - 1] == '\n') {
b[len - 1] = '\0';
- strlcpy((char *)bar_ext, b, sizeof bar_ext);
+ strlcpy(bar_ext, b, sizeof bar_ext);
}
if (b == NULL && errno != EAGAIN) {
warn("bar_update: bar_extra failed");
bar_extra_stop();
}
} else
- strlcpy((char *)bar_ext, "", sizeof bar_ext);
+ strlcpy(bar_ext, "", sizeof bar_ext);
bar_fmt_print();
alarm(bar_delay);
if (!XftColorAllocValue(display, DefaultVisual(display, r->s->idx),
DefaultColormap(display, r->s->idx), &color, &bar_font_color))
- warn("unable to allocate Xft color");
+ warn("Xft error: unable to allocate color.");
bar_height = bar_font->height + 2 * bar_border_width;
} else {
DNPRINTF(SWM_D_EVENT, "get_pointer_win: none.\n");
}
+ free(r);
}
return win;
XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
r = xcb_get_property_reply(conn, c, NULL);
- if (!r || r->type == XCB_NONE) {
- free(r);
- /* Use WM_NAME instead; no UTF-8. */
- c = xcb_get_property(conn, 0, win, XCB_ATOM_WM_NAME,
- XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
- r = xcb_get_property_reply(conn, c, NULL);
-
- if(!r || r->type == XCB_NONE) {
+ if (r) {
+ if (r->type == XCB_NONE) {
free(r);
- return NULL;
+ /* Use WM_NAME instead; no UTF-8. */
+ c = xcb_get_property(conn, 0, win, XCB_ATOM_WM_NAME,
+ XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
+ r = xcb_get_property_reply(conn, c, NULL);
+
+ if (!r)
+ return (NULL);
+ if (r->type == XCB_NONE) {
+ free(r);
+ return (NULL);
+ }
}
- }
+ if (r->length > 0)
+ name = strndup(xcb_get_property_value(r),
+ xcb_get_property_value_length(r));
- if (r->length > 0)
- name = strndup(xcb_get_property_value(r),
- xcb_get_property_value_length(r));
+ free(r);
+ }
- free(r);
return (name);
}
{
xcb_timestamp_t timestamp = 0;
struct swm_region *r = NULL;
- int resize_step = 0;
+ int resize_stp = 0;
struct swm_geometry g;
int top = 0, left = 0, resizing;
int dx, dy;
switch (args->id) {
case SWM_ARG_ID_WIDTHSHRINK:
WIDTH(win) -= SWM_RESIZE_STEPS;
- resize_step = 1;
+ resize_stp = 1;
break;
case SWM_ARG_ID_WIDTHGROW:
WIDTH(win) += SWM_RESIZE_STEPS;
- resize_step = 1;
+ resize_stp = 1;
break;
case SWM_ARG_ID_HEIGHTSHRINK:
HEIGHT(win) -= SWM_RESIZE_STEPS;
- resize_step = 1;
+ resize_stp = 1;
break;
case SWM_ARG_ID_HEIGHTGROW:
HEIGHT(win) += SWM_RESIZE_STEPS;
- resize_step = 1;
+ resize_stp = 1;
break;
default:
break;
}
- if (resize_step) {
+ if (resize_stp) {
constrain_window(win, r, 1);
update_window(win);
store_float_geom(win,r);
move(struct ws_win *win, union arg *args)
{
xcb_timestamp_t timestamp = 0;
- int move_step = 0, moving;
+ int move_stp = 0, moving;
struct swm_region *r = NULL;
xcb_query_pointer_reply_t *qpr;
xcb_generic_event_t *evt;
focus_flush();
- move_step = 0;
+ move_stp = 0;
switch (args->id) {
case SWM_ARG_ID_MOVELEFT:
X(win) -= (SWM_MOVE_STEPS - border_width);
- move_step = 1;
+ move_stp = 1;
break;
case SWM_ARG_ID_MOVERIGHT:
X(win) += (SWM_MOVE_STEPS - border_width);
- move_step = 1;
+ move_stp = 1;
break;
case SWM_ARG_ID_MOVEUP:
Y(win) -= (SWM_MOVE_STEPS - border_width);
- move_step = 1;
+ move_stp = 1;
break;
case SWM_ARG_ID_MOVEDOWN:
Y(win) += (SWM_MOVE_STEPS - border_width);
- move_step = 1;
+ move_stp = 1;
break;
default:
break;
}
- if (move_step) {
+ if (move_stp) {
constrain_window(win, r, 0);
update_window(win);
store_float_geom(win, r);
return;
}
if (kfid == KF_INVALID) {
- warnx("error: setkeybinding: cannot find mod/key combination");
+ warnx("bind: Key combination already unbound.");
DNPRINTF(SWM_D_KEY, "setkeybinding: leave\n");
return;
}
{
struct key *kp;
int num_screens, k, j;
- unsigned int modifiers[3];
+ unsigned int modifiers[4];
xcb_keycode_t *code;
DNPRINTF(SWM_D_MISC, "grabkeys\n");
modifiers[0] = 0;
modifiers[1] = numlockmask;
- modifiers[2] = numlockmask | XCB_MOD_MASK_LOCK;
+ modifiers[2] = XCB_MOD_MASK_LOCK;
+ modifiers[3] = numlockmask | XCB_MOD_MASK_LOCK;
num_screens = xcb_setup_roots_length(xcb_get_setup(conn));
for (k = 0; k < num_screens; k++) {
void
grabbuttons(struct ws_win *win)
{
- int i;
+ unsigned int modifiers[4];
+ int i, j;
DNPRINTF(SWM_D_MOUSE, "grabbuttons: win 0x%x\n", win->id);
+ updatenumlockmask();
+
+ modifiers[0] = 0;
+ modifiers[1] = numlockmask;
+ modifiers[2] = XCB_MOD_MASK_LOCK;
+ modifiers[3] = numlockmask | XCB_MOD_MASK_LOCK;
for (i = 0; i < LENGTH(buttons); i++)
if (buttons[i].action == client_click)
- xcb_grab_button(conn, 0, win->id, BUTTONMASK,
- XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
- XCB_WINDOW_NONE, XCB_CURSOR_NONE,
- buttons[i].button, buttons[i].mask);
+ for (j = 0; j < LENGTH(modifiers); ++j)
+ xcb_grab_button(conn, 0, win->id, BUTTONMASK,
+ XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
+ XCB_WINDOW_NONE, XCB_CURSOR_NONE,
+ buttons[i].button, buttons[i].mask |
+ modifiers[j]);
}
const char *quirkname[] = {
/* Focus on empty region */
/* If no windows on region if its empty. */
r = root_to_region(e->root, SWM_CK_POINTER);
- if (r && TAILQ_EMPTY(&r->ws->winlist)) {
+ if (r == NULL) {
+ DNPRINTF(SWM_D_EVENT, "buttonpress: "
+ "NULL region; ignoring.\n");
+ goto out;
+ }
+
+ if (TAILQ_EMPTY(&r->ws->winlist)) {
old_r = root_to_region(e->root, SWM_CK_FOCUS);
if (old_r && old_r != r)
unfocus_win(old_r->ws->focus);
WIDTH(win) = win->g_float.w;
HEIGHT(win) = win->g_float.h;
- stack_floater(win, win->ws->r);
-
- focus_flush();
+ if (r) {
+ stack_floater(win, r);
+ focus_flush();
+ }
} else {
config_win(win, e);
xcb_flush(conn);
if (e->event == e->root) {
/* If no windows on pointer region, then focus root. */
r = root_to_region(e->root, SWM_CK_POINTER);
+ if (r == NULL) {
+ DNPRINTF(SWM_D_EVENT, "enterntoify: "
+ "NULL region; ignoring.\n");
+ return;
+ }
+
if (TAILQ_EMPTY(&r->ws->winlist)) {
old_r = root_to_region(e->root, SWM_CK_FOCUS);
if (old_r && old_r != r)
}
#endif
-/* lets us use one switch statement for arbitrary mode/detail combinations */
-#define MERGE_MEMBERS(a,b) (((a & 0xffff) << 16) | (b & 0xffff))
-
void
mapnotify(xcb_map_notify_event_t *e)
{