X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fhandlers.c;h=d058b650eec5f39c2224742ad4982d7eae221d3e;hb=1335e4a4c9c7af2f4ade5169d8385b1bd4c1b0e2;hp=b4c5f94eab954882abf4db3e546ed8d9e8fa3b12;hpb=8b0bc8c3ff59e4478149144b119292824f6b0668;p=i3%2Fi3 diff --git a/src/handlers.c b/src/handlers.c index b4c5f94e..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; @@ -141,10 +145,19 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ *second = NULL; enum { O_HORIZONTAL, O_VERTICAL } orientation = O_VERTICAL; + if (con == NULL) { + printf("dock. done.\n"); + xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); + xcb_flush(conn); + return 1; + } + printf("event->event_x = %d, client->rect.width = %d\n", event->event_x, client->rect.width); if (!border_click) { printf("client. done.\n"); + xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time); + xcb_flush(conn); return 1; } @@ -195,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)"); @@ -221,7 +234,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_ nr &= XCB_EVENT_RESPONSE_TYPE_MASK; assert(nr >= 2); - /* Check if we need to escape this loop… */ + /* Check if we need to escape this loop */ if (nr == XCB_BUTTON_RELEASE) break; @@ -283,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; @@ -310,21 +327,30 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_ client = table_remove(byChild, e->window); printf("UnmapNotify for 0x%08x (received from 0x%08x): ", e->window, e->event); - if(client == NULL) { + if (client == NULL) { printf("not a managed window. Ignoring.\n"); return 0; } - - if (client->container->currently_focused == client) - client->container->currently_focused = NULL; - CIRCLEQ_REMOVE(&(client->container->clients), client, clients); + 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 = 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); xcb_reparent_window(c, client->child, root, 0, 0); xcb_destroy_window(c, client->frame); xcb_flush(c); table_remove(byParent, client->frame); + + cleanup_table(client->container->workspace); + free(client); render_layout(c); @@ -348,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; @@ -359,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; } @@ -384,7 +427,7 @@ int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message if (client == NULL) return 0; - /* Check if the fullscreen state should be toggled… */ + /* Check if the fullscreen state should be toggled */ if ((client->fullscreen && (event->data.data32[0] == _NET_WM_STATE_REMOVE || event->data.data32[0] == _NET_WM_STATE_TOGGLE)) ||