X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=spectrwm.c;h=829bba0a53c88c8901eb97c9f41ffbcef6e5ff7c;hb=9daf16e4b60699b18c80c9cdb4494af10140f840;hp=93040fee35ababf24526f4cd333a8e13bbf4928c;hpb=a53bbb5e6d641b2d09f64142d990118a46785b11;p=spectrwm.git diff --git a/spectrwm.c b/spectrwm.c index 93040fe..829bba0 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -843,7 +843,6 @@ ewmh_autoquirk(struct ws_win *win) { uint32_t i, n; xcb_atom_t *type; - xcb_get_property_cookie_t c; xcb_get_property_reply_t *r; @@ -2156,11 +2155,11 @@ fake_keypress(struct ws_win *win, xcb_keysym_t keysym, uint16_t modifiers) event.response_type = XCB_KEY_PRESS; xcb_send_event(conn, True, win->id, - XCB_EVENT_MASK_KEY_PRESS, (char *)&event); + XCB_EVENT_MASK_KEY_PRESS, (const char *)&event); event.response_type = XCB_KEY_RELEASE; xcb_send_event(conn, True, win->id, - XCB_EVENT_MASK_KEY_RELEASE, (char *)&event); + XCB_EVENT_MASK_KEY_RELEASE, (const char *)&event); } void @@ -2189,8 +2188,8 @@ restart(struct swm_region *r, union arg *args) struct swm_region * root_to_region(xcb_window_t root) { - struct swm_region *r = NULL; - int i, num_screens; + struct swm_region *r = NULL; + int i, num_screens; xcb_query_pointer_reply_t *qpr; DNPRINTF(SWM_D_MISC, "root_to_region: window: 0x%x\n", root); @@ -2241,7 +2240,6 @@ find_window(xcb_window_t id) { struct ws_win *win; int i, j, num_screens; - xcb_query_tree_cookie_t c; xcb_query_tree_reply_t *r; num_screens = xcb_setup_roots_length(xcb_get_setup(conn)); @@ -2251,8 +2249,7 @@ find_window(xcb_window_t id) if (id == win->id) return (win); - c = xcb_query_tree(conn, id); - r = xcb_query_tree_reply(conn, c, NULL); + r = xcb_query_tree_reply(conn, xcb_query_tree(conn, id), NULL); if (!r) return (NULL); @@ -2456,7 +2453,6 @@ void focus_win(struct ws_win *win) { struct ws_win *cfw = NULL; - xcb_get_input_focus_cookie_t c; xcb_get_input_focus_reply_t *r; xcb_window_t cur_focus = XCB_WINDOW_NONE; @@ -2480,8 +2476,7 @@ focus_win(struct ws_win *win) return; } - c = xcb_get_input_focus(conn); - r = xcb_get_input_focus_reply(conn, c, NULL); + r = xcb_get_input_focus_reply(conn, xcb_get_input_focus(conn), NULL); if (r) { cur_focus = r->focus; free(r); @@ -2520,6 +2515,20 @@ focus_win(struct ws_win *win) } void +event_drain(uint8_t rt) +{ + xcb_generic_event_t *evt; + + xcb_flush(conn); + while ((evt = xcb_poll_for_event(conn))) { + if (XCB_EVENT_RESPONSE_TYPE(evt) != rt) + event_handle(evt); + + free(evt); + } +} + +void switchws(struct swm_region *r, union arg *args) { int wsid = args->id, unmap_old = 0; @@ -2573,7 +2582,10 @@ switchws(struct swm_region *r, union arg *args) TAILQ_FOREACH(win, &old_ws->winlist, entry) unmap_window(win); - xcb_flush(conn); + if (focus_mode == SWM_FOCUS_DEFAULT) + event_drain(XCB_ENTER_NOTIFY); + else + xcb_flush(conn); } void @@ -2985,9 +2997,12 @@ cycle_layout(struct swm_region *r, union arg *args) ws->cur_layout = &layouts[0]; stack(); + bar_update(); - a.id = SWM_ARG_ID_FOCUSCUR; + if (focus_mode == SWM_FOCUS_DEFAULT) + event_drain(XCB_ENTER_NOTIFY); + a.id = SWM_ARG_ID_FOCUSCUR; focus(r, &a); } @@ -3045,6 +3060,9 @@ stack(void) { if (font_adjusted) font_adjusted--; + if (focus_mode == SWM_FOCUS_DEFAULT) + event_drain(XCB_ENTER_NOTIFY); + DNPRINTF(SWM_D_STACK, "stack: end\n"); } @@ -4117,6 +4135,7 @@ floating_toggle(struct swm_region *r, union arg *args) } xcb_flush(conn); + event_drain(XCB_ENTER_NOTIFY); } void @@ -7453,6 +7472,19 @@ setup_globals(void) if ((clock_format = strdup("%a %b %d %R %Z %Y")) == NULL) err(1, "setup_globals: strdup: failed to allocate memory."); + + if ((syms = xcb_key_symbols_alloc(conn)) == NULL) + errx(1, "unable to allocate key symbols"); + + astate = get_atom_from_string("WM_STATE"); + aprot = get_atom_from_string("WM_PROTOCOLS"); + adelete = get_atom_from_string("WM_DELETE_WINDOW"); + takefocus = get_atom_from_string("WM_TAKE_FOCUS"); + a_wmname = get_atom_from_string("WM_NAME"); + a_netwmname = get_atom_from_string("_NET_WM_NAME"); + a_utf8_string = get_atom_from_string("UTF8_STRING"); + a_string = get_atom_from_string("STRING"); + a_swm_iconic = get_atom_from_string("_SWM_ICONIC"); } void @@ -7596,19 +7628,6 @@ main(int argc, char *argv[]) errx(1, "can not get XCB connection"); xfd = xcb_get_file_descriptor(conn); - syms = xcb_key_symbols_alloc(conn); - if (!syms) - errx(1, "unable to allocate key symbols"); - - astate = get_atom_from_string("WM_STATE"); - aprot = get_atom_from_string("WM_PROTOCOLS"); - adelete = get_atom_from_string("WM_DELETE_WINDOW"); - takefocus = get_atom_from_string("WM_TAKE_FOCUS"); - a_wmname = get_atom_from_string("WM_NAME"); - a_netwmname = get_atom_from_string("_NET_WM_NAME"); - a_utf8_string = get_atom_from_string("UTF8_STRING"); - a_string = get_atom_from_string("STRING"); - a_swm_iconic = get_atom_from_string("_SWM_ICONIC"); /* look for local and global conf file */ pwd = getpwuid(getuid());