X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fhandlers.c;h=d058b650eec5f39c2224742ad4982d7eae221d3e;hb=1335e4a4c9c7af2f4ade5169d8385b1bd4c1b0e2;hp=17693f82dd9171cea8b55bce754f89402bb16493;hpb=6e81d1c5e47d0793ee7c73d5a74de1d00d88d3a5;p=i3%2Fi3 diff --git a/src/handlers.c b/src/handlers.c index 17693f82..d058b650 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -89,7 +89,7 @@ int handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_press_event_ * */ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_event_t *event) { - printf("enter_notify\n"); + printf("enter_notify for %08x\n", event->event); /* This was either a focus for a client’s parent (= titlebar)… */ Client *client = table_get(byParent, event->event); @@ -110,6 +110,10 @@ int handle_enter_notify(void *ignored, xcb_connection_t *conn, xcb_enter_notify_ return 1; } + /* When in stacking, enter notifications are ignored. Focus will be changed via keyboard only. */ + if (client->container->mode == MODE_STACK) + return 1; + set_focus(conn, client); return 1; @@ -143,6 +147,8 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ if (con == NULL) { printf("dock. done.\n"); + xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); + xcb_flush(conn); return 1; } @@ -150,6 +156,8 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ if (!border_click) { printf("client. done.\n"); + xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); + xcb_flush(conn); return 1; } @@ -200,7 +208,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ } xcb_window_t helpwin = create_window(conn, helprect, XCB_WINDOW_CLASS_INPUT_OUTPUT, 0, NULL); - uint32_t values[1] = {get_colorpixel(conn, helpwin, "#4c7899")}; + uint32_t values[1] = {get_colorpixel(conn, NULL, helpwin, "#4c7899")}; xcb_void_cookie_t cookie = xcb_change_window_attributes_checked(conn, helpwin, XCB_CW_BACK_PIXEL, values); check_error(conn, cookie, "Could not change window attributes (background color)"); @@ -288,6 +296,10 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ return 1; } +/* + * A new window appeared on the screen (=was mapped), so let’s manage it. + * + */ int handle_map_notify_event(void *prophs, xcb_connection_t *conn, xcb_map_notify_event_t *event) { window_attributes_t wa = { TAG_VALUE }; wa.u.override_redirect = event->override_redirect; @@ -321,9 +333,14 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_ } if (client->container != NULL) { + Client *to_focus = CIRCLEQ_NEXT_OR_NULL(&(client->container->clients), client, clients); + if (to_focus == NULL) + to_focus = CIRCLEQ_PREV_OR_NULL(&(client->container->clients), client, clients); if (client->container->currently_focused == client) - client->container->currently_focused = NULL; + client->container->currently_focused = to_focus; CIRCLEQ_REMOVE(&(client->container->clients), client, clients); + if (to_focus != NULL) + set_focus(c, to_focus); } printf("child of 0x%08x.\n", client->frame); @@ -331,6 +348,9 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_ xcb_destroy_window(c, client->frame); xcb_flush(c); table_remove(byParent, client->frame); + + cleanup_table(client->container->workspace); + free(client); render_layout(c); @@ -354,7 +374,7 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state, strncpy(client->name, xcb_get_property_value(prop), client->name_len); printf("rename to \"%.*s\".\n", client->name_len, client->name); - decorate_window(conn, client); + decorate_window(conn, client, client->frame, client->titlegc, 0); xcb_flush(conn); return 1; @@ -365,11 +385,28 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state, * */ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *e) { + printf("got expose_event\n"); + /* e->count is the number of minimum remaining expose events for this window, so we + skip all events but the last one */ + if (e->count != 0) + return 1; + Client *client = table_get(byParent, e->window); - if(!client || e->count != 0) + if (client == NULL) { + /* There was no client in the table, so this is probably an expose event for + one of our stack_windows. */ + struct Stack_Window *stack_win; + SLIST_FOREACH(stack_win, &stack_wins, stack_windows) + if (stack_win->window == e->window) { + render_container(conn, stack_win->container); + return 1; + } return 1; + } + printf("handle_expose_event()\n"); - decorate_window(conn, client); + if (client->container->mode != MODE_STACK) + decorate_window(conn, client, client->frame, client->titlegc, 0); return 1; }