X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=ff3dfbda2ce47093c5e69aa311c9434e0709efe9;hb=56804a63310639e363b6c394c93ff4efaf7b56e3;hp=f47613465d6d8b9e6c1cda9c930dcbe7ba94b5a6;hpb=8d6f43bd88e79d5222889eb3f1a2f0ac25f1695b;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index f476134..ff3dfbd 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -348,7 +348,7 @@ double dialog_ratio = 0.6; 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; @@ -871,7 +871,7 @@ char *expand_tilde(const char *); 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 *); @@ -1852,7 +1852,7 @@ bar_extra_stop(void) kill(bar_pid, SIGTERM); bar_pid = 0; } - strlcpy((char *)bar_ext, "", sizeof bar_ext); + strlcpy(bar_ext, "", sizeof bar_ext); bar_extra = 0; } @@ -2198,14 +2198,14 @@ bar_update(void) 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); @@ -2405,7 +2405,7 @@ xft_init(struct swm_region *r) 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; @@ -2802,6 +2802,7 @@ get_pointer_win(xcb_window_t root) } else { DNPRINTF(SWM_D_EVENT, "get_pointer_win: none.\n"); } + free(r); } return win; @@ -4488,24 +4489,28 @@ get_win_name(xcb_window_t 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); } @@ -5940,7 +5945,7 @@ setkeybinding(unsigned int mod, KeySym ks, enum keyfuncid kfid, 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; } @@ -7442,7 +7447,13 @@ buttonpress(xcb_button_press_event_t *e) /* 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); @@ -7816,6 +7827,12 @@ enternotify(xcb_enter_notify_event_t *e) 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)