{
uint32_t i, n;
xcb_atom_t *type;
-
xcb_get_property_cookie_t c;
xcb_get_property_reply_t *r;
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
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);
{
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));
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);
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;
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);
}
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;
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
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);
}
if (font_adjusted)
font_adjusted--;
+ if (focus_mode == SWM_FOCUS_DEFAULT)
+ event_drain(XCB_ENTER_NOTIFY);
+
DNPRINTF(SWM_D_STACK, "stack: end\n");
}
}
xcb_flush(conn);
+ event_drain(XCB_ENTER_NOTIFY);
}
void
screens[i].idx = i;
TAILQ_INIT(&screens[i].rl);
TAILQ_INIT(&screens[i].orl);
- screens[i].root = RootWindow(display, i);
+ screens[i].root = get_screen(i)->root;
/* set default colors */
setscreencolor("red", i + 1, SWM_S_COLOR_FOCUS);
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
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());