X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fhandlers.c;h=1daefbc912de21b21f93aeb9c33c6d3d6165e01f;hb=bf3cd41b5ddf1e757515ab5fbf811be56e5f69cc;hp=56e29607b6f0cd624a3d339a1b2315af43e1bda6;hpb=884214f14fdbd0a4a368d2a36d5e50324fa1d52a;p=i3%2Fi3 diff --git a/src/handlers.c b/src/handlers.c index 56e29607..1daefbc9 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -16,7 +16,6 @@ #include #include #include -#include #define SN_API_NOT_YET_FROZEN 1 #include @@ -215,7 +214,7 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) { /* Skip events where the pointer was over a child window, we are only * interested in events on the root window. */ - if (event->child != 0) + if (event->child != XCB_NONE) return; Con *con; @@ -228,7 +227,7 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) { if (config.disable_focus_follows_mouse) return; - if (con->layout != L_DEFAULT) + if (con->layout != L_DEFAULT && con->layout != L_SPLITV && con->layout != L_SPLITH) return; /* see over which rect the user is */ @@ -245,8 +244,6 @@ static void handle_motion_notify(xcb_motion_notify_event_t *event) { x_push_changes(croot); return; } - - return; } /* @@ -266,7 +263,7 @@ static void handle_mapping_notify(xcb_mapping_notify_event_t *event) { ungrab_all_keys(conn); translate_keysyms(); - grab_all_keys(conn, false); + grab_all_keys(conn); return; } @@ -753,7 +750,7 @@ static void handle_client_message(xcb_client_message_event_t *event) { DLOG("Marking con = %p urgent\n", con); con_set_urgency(con, true); } else - DLOG("Ignoring request for con = %p", con); + DLOG("Ignoring request for con = %p.\n", con); } tree_render(); @@ -762,7 +759,7 @@ static void handle_client_message(xcb_client_message_event_t *event) { uint32_t rnd = event->data.data32[1]; DLOG("[i3 sync protocol] Sending random value %d back to X11 window 0x%08x\n", rnd, window); - void *reply = scalloc(32); + void *reply = scalloc(32, 1); xcb_client_message_event_t *ev = reply; ev->response_type = XCB_CLIENT_MESSAGE; @@ -880,7 +877,7 @@ static void handle_client_message(xcb_client_message_event_t *event) { floating_drag_window(con->parent, &fake); break; case _NET_WM_MOVERESIZE_SIZE_TOPLEFT... _NET_WM_MOVERESIZE_SIZE_LEFT: - floating_resize_window(con->parent, FALSE, &fake); + floating_resize_window(con->parent, false, &fake); break; default: DLOG("_NET_WM_MOVERESIZE direction %d not implemented\n", direction); @@ -892,15 +889,15 @@ static void handle_client_message(xcb_client_message_event_t *event) { } } -#if 0 -int handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, - xcb_atom_t atom, xcb_get_property_reply_t *property) { - /* TODO: Implement this one. To do this, implement a little test program which sleep(1)s - before changing this property. */ - ELOG("_NET_WM_WINDOW_TYPE changed, this is not yet implemented.\n"); - return 0; +bool handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, + xcb_atom_t atom, xcb_get_property_reply_t *reply) { + Con *con; + if ((con = con_by_window_id(window)) == NULL || con->window == NULL) + return false; + + window_update_type(con->window, reply); + return true; } -#endif /* * Handles the size hints set by a window, but currently only the part necessary for displaying @@ -1264,7 +1261,8 @@ static struct property_handler_t property_handlers[] = { {0, UINT_MAX, handle_transient_for}, {0, 128, handle_windowrole_change}, {0, 128, handle_class_change}, - {0, UINT_MAX, handle_strut_partial_change}}; + {0, UINT_MAX, handle_strut_partial_change}, + {0, UINT_MAX, handle_window_type}}; #define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t)) /* @@ -1284,6 +1282,7 @@ void property_handlers_init(void) { property_handlers[6].atom = A_WM_WINDOW_ROLE; property_handlers[7].atom = XCB_ATOM_WM_CLASS; property_handlers[8].atom = A__NET_WM_STRUT_PARTIAL; + property_handlers[9].atom = A__NET_WM_WINDOW_TYPE; } static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) { @@ -1319,7 +1318,9 @@ static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) * */ void handle_event(int type, xcb_generic_event_t *event) { - DLOG("event type %d, xkb_base %d\n", type, xkb_base); + if (type != XCB_MOTION_NOTIFY) + DLOG("event type %d, xkb_base %d\n", type, xkb_base); + if (randr_base > -1 && type == randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) { handle_screen_change(event); @@ -1336,7 +1337,9 @@ void handle_event(int type, xcb_generic_event_t *event) { keysyms = xcb_key_symbols_alloc(conn); ungrab_all_keys(conn); translate_keysyms(); - grab_all_keys(conn, false); + grab_all_keys(conn); + if (((xcb_xkb_new_keyboard_notify_event_t *)event)->changed & XCB_XKB_NKN_DETAIL_KEYCODES) + (void)load_keymap(); } else if (state->xkbType == XCB_XKB_MAP_NOTIFY) { if (event_is_ignored(event->sequence, type)) { DLOG("Ignoring map notify event for sequence %d.\n", state->sequence); @@ -1347,26 +1350,16 @@ void handle_event(int type, xcb_generic_event_t *event) { keysyms = xcb_key_symbols_alloc(conn); ungrab_all_keys(conn); translate_keysyms(); - grab_all_keys(conn, false); + grab_all_keys(conn); + (void)load_keymap(); } } else if (state->xkbType == XCB_XKB_STATE_NOTIFY) { DLOG("xkb state group = %d\n", state->group); - - /* See The XKB Extension: Library Specification, section 14.1 */ - /* We check if the current group (each group contains - * two levels) has been changed. Mode_switch activates - * group XCB_XKB_GROUP_2 */ if (xkb_current_group == state->group) return; xkb_current_group = state->group; - if (state->group == XCB_XKB_GROUP_1) { - DLOG("Mode_switch disabled\n"); - ungrab_all_keys(conn); - grab_all_keys(conn, false); - } else { - DLOG("Mode_switch enabled\n"); - grab_all_keys(conn, true); - } + ungrab_all_keys(conn); + grab_all_keys(conn); } return;