X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=665d02074784c2a5491d53898e2bd5192f33f1d7;hb=b4ff36a69396ed4afb8712ddc0d5e2cf557b4edc;hp=3d29c4e0c99854217eae08e51dcadd406b94b0f0;hpb=c02d3f6db8386bd455991cf06343b5e66fe01ac7;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 3d29c4e..665d020 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; @@ -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; } @@ -6177,7 +6182,7 @@ grabkeys(void) { 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"); @@ -6185,7 +6190,8 @@ grabkeys(void) 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++) { @@ -6211,16 +6217,25 @@ grabkeys(void) 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[] = { @@ -7657,9 +7672,10 @@ configurerequest(xcb_configure_request_event_t *e) 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);