From: Michael Stapelberg Date: Tue, 13 Apr 2010 17:33:40 +0000 (+0200) Subject: cleanups X-Git-Tag: tree-pr1~265 X-Git-Url: https://git.sur5r.net/?p=i3%2Fi3;a=commitdiff_plain;h=8959c5005f77258613a203f5edb7dcbfc239036c cleanups --- diff --git a/include/handlers.h b/include/handlers.h index a691b35a..c35defe7 100644 --- a/include/handlers.h +++ b/include/handlers.h @@ -54,14 +54,14 @@ int handle_mapping_notify(void *ignored, xcb_connection_t *conn, */ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event); - +#endif /** * A new window appeared on the screen (=was mapped), so let’s manage it. * */ int handle_map_request(void *prophs, xcb_connection_t *conn, xcb_map_request_event_t *event); - +#if 0 /** * Configuration notifies are only handled because we need to set up ignore * for the following enter notify events @@ -87,14 +87,14 @@ int handle_screen_change(void *prophs, xcb_connection_t *conn, */ int handle_configure_request(void *prophs, xcb_connection_t *conn, xcb_configure_request_event_t *event); - +#endif /** * Our window decorations were unmapped. That means, the window will be killed * now, so we better clean up before. * */ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event); - +#if 0 /** * A destroy notify event is sent when the window is not unmapped, but * immediately destroyed (for example when starting a window and immediately @@ -134,14 +134,14 @@ int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop); - +#endif /** * Expose event means we should redraw our windows (= title bar) * */ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *event); - +#if 0 /** * Handle client messages (EWMH) * diff --git a/src/handlers.c b/src/handlers.c index 80f1e669..11cbc37c 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -253,22 +253,23 @@ int handle_mapping_notify(void *ignored, xcb_connection_t *conn, xcb_mapping_not return 0; } +#endif /* * A new window appeared on the screen (=was mapped), so let’s manage it. * */ int handle_map_request(void *prophs, xcb_connection_t *conn, xcb_map_request_event_t *event) { - xcb_get_window_attributes_cookie_t cookie; + xcb_get_window_attributes_cookie_t cookie; - cookie = xcb_get_window_attributes_unchecked(conn, event->window); + cookie = xcb_get_window_attributes_unchecked(conn, event->window); - DLOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence); - add_ignore_event(event->sequence); + DLOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence); + add_ignore_event(event->sequence); - manage_window(prophs, conn, event->window, cookie, false); - return 1; + manage_window(event->window, cookie, false); + return 1; } - +#if 0 /* * Configure requests are received when the application wants to resize windows on their own. * @@ -437,27 +438,30 @@ int handle_screen_change(void *prophs, xcb_connection_t *conn, return 1; } +#endif /* - * Our window decorations were unmapped. That means, the window will be killed now, - * so we better clean up before. + * Our window decorations were unmapped. That means, the window will be killed + * now, so we better clean up before. * */ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event) { - xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; - add_ignore_event(event->sequence); + //add_ignore_event(event->sequence); - Client *client = table_get(&by_child, event->window); - /* First, we need to check if the client is awaiting an unmap-request which - was generated by us reparenting the window. In that case, we just ignore it. */ - if (client != NULL && client->awaiting_useless_unmap) { - client->awaiting_useless_unmap = false; - return 1; - } + DLOG("UnmapNotify for 0x%08x (received from 0x%08x)\n", event->window, event->event); + Con *con = con_by_window_id(event->window); + if (con == NULL) { + LOG("Not a managed window, ignoring\n"); + return 1; + } + + tree_close(con); + tree_render(); + x_push_changes(croot); + return 1; - DLOG("event->window = %08x, event->event = %08x\n", event->window, event->event); - DLOG("UnmapNotify for 0x%08x (received from 0x%08x)\n", event->window, event->event); +#if 0 if (client == NULL) { DLOG("not a managed window. Ignoring.\n"); @@ -469,52 +473,10 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti return 0; } +#endif - client = table_remove(&by_child, event->window); - - /* If this was the fullscreen client, we need to unset it */ - if (client->fullscreen) - client->workspace->fullscreen_client = NULL; - - /* Clients without a container are either floating or dock windows */ - if (client->container != NULL) { - Container *con = client->container; - - /* Remove the client from the list of clients */ - client_remove_from_container(conn, client, con, true); - - /* Set focus to the last focused client in this container */ - con->currently_focused = get_last_focused_client(conn, con, NULL); - - /* Only if this is the active container, we need to really change focus */ - if ((con->currently_focused != NULL) && ((con == CUR_CELL) || client->fullscreen)) - set_focus(conn, con->currently_focused, true); - } else if (client_is_floating(client)) { - DLOG("Removing from floating clients\n"); - TAILQ_REMOVE(&(client->workspace->floating_clients), client, floating_clients); - SLIST_REMOVE(&(client->workspace->focus_stack), client, Client, focus_clients); - } - - if (client->dock) { - DLOG("Removing from dock clients\n"); - SLIST_REMOVE(&(client->workspace->output->dock_clients), client, Client, dock_clients); - } - - DLOG("child of 0x%08x.\n", client->frame); - xcb_reparent_window(conn, client->child, root, 0, 0); - - client_unmap(conn, client); - - xcb_destroy_window(conn, client->frame); - xcb_flush(conn); - table_remove(&by_parent, client->frame); - - if (client->container != NULL) { - Workspace *workspace = client->container->workspace; - cleanup_table(conn, workspace); - fix_colrowspan(conn, workspace); - } +#if 0 /* Let’s see how many clients there are left on the workspace to delete it if it’s empty */ bool workspace_empty = SLIST_EMPTY(&(client->workspace->focus_stack)); bool workspace_focused = (c_ws == client->workspace); @@ -533,30 +495,13 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_noti client->urgent = false; workspace_update_urgent_flag(client->workspace); - FREE(client->window_class_instance); - FREE(client->window_class_class); - FREE(client->name); - free(client); - render_layout(conn); - - /* Ensure the focus is set to the next client in the focus stack or to - * the screen itself (if we do not focus the screen, it can happen that - * the focus is "nowhere" and thus keypress events will not be received - * by i3, thus the user cannot use any hotkeys). */ - if (workspace_focused) { - if (to_focus != NULL) - set_focus(conn, to_focus, true); - else { - DLOG("Restoring focus to root screen\n"); - xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME); - xcb_flush(conn); - } - } +#endif return 1; } +#if 0 /* * A destroy notify event is sent when the window is not unmapped, but * immediately destroyed (for example when starting a window and immediately @@ -627,77 +572,72 @@ int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state, return 0; } -#if 0 /* * Expose event means we should redraw our windows (= title bar) * */ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *event) { - /* event->count is the number of minimum remaining expose events for this window, so we - skip all events but the last one */ - if (event->count != 0) - return 1; - DLOG("window = %08x\n", event->window); + Con *parent, *con; - Client *client = table_get(&by_parent, event->window); - 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 == event->window) { - render_container(conn, stack_win->container); - return 1; - } - - /* …or one of the bars? */ - Output *output; - TAILQ_FOREACH(output, &outputs, outputs) - if (output->bar == event->window) - render_layout(conn); - return 1; - } + /* event->count is the number of minimum remaining expose events for this + * window, so we skip all events but the last one */ + if (event->count != 0) + return 1; - if (client->dock) - return 1; + DLOG("window = %08x\n", event->window); - if (container_mode(client->container, true) == MODE_DEFAULT) - decorate_window(conn, client, client->frame, client->titlegc, 0, 0); - else { - uint32_t background_color; - if (client->urgent) - background_color = config.client.urgent.background; - /* Distinguish if the window is currently focused… */ - else if (CUR_CELL != NULL && CUR_CELL->currently_focused == client) - background_color = config.client.focused.background; - /* …or if it is the focused window in a not focused container */ - else background_color = config.client.focused_inactive.background; - - /* Set foreground color to current focused color, line width to 2 */ - uint32_t values[] = {background_color, 2}; - xcb_change_gc(conn, client->titlegc, XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH, values); - - /* Draw the border, the ±1 is for line width = 2 */ - xcb_point_t points[] = {{1, 0}, /* left upper edge */ - {1, client->rect.height-1}, /* left bottom edge */ - {client->rect.width-1, client->rect.height-1}, /* right bottom edge */ - {client->rect.width-1, 0}}; /* right upper edge */ - xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, client->frame, client->titlegc, 4, points); - - /* Draw a black background */ - xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000")); - if (client->titlebar_position == TITLEBAR_OFF && !client->borderless) { - xcb_rectangle_t crect = {1, 0, client->rect.width - (1 + 1), client->rect.height - 1}; - xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect); - } else { - xcb_rectangle_t crect = {2, 0, client->rect.width - (2 + 2), client->rect.height - 2}; - xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect); - } - } - xcb_flush(conn); + if ((parent = con_by_frame_id(event->window)) == NULL) { + LOG("expose event for unknown window, ignoring\n"); return 1; + } + + TAILQ_FOREACH(con, &(parent->nodes_head), nodes) { + LOG("expose for con %p / %s\n", con, con->name); + if (con->window) + x_draw_decoration(con); + } + xcb_flush(conn); + + return 1; + +#if 0 + else { + uint32_t background_color; + if (client->urgent) + background_color = config.client.urgent.background; + /* Distinguish if the window is currently focused… */ + else if (CUR_CELL != NULL && CUR_CELL->currently_focused == client) + background_color = config.client.focused.background; + /* …or if it is the focused window in a not focused container */ + else background_color = config.client.focused_inactive.background; + + /* Set foreground color to current focused color, line width to 2 */ + uint32_t values[] = {background_color, 2}; + xcb_change_gc(conn, client->titlegc, XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH, values); + + /* Draw the border, the ±1 is for line width = 2 */ + xcb_point_t points[] = {{1, 0}, /* left upper edge */ + {1, client->rect.height-1}, /* left bottom edge */ + {client->rect.width-1, client->rect.height-1}, /* right bottom edge */ + {client->rect.width-1, 0}}; /* right upper edge */ + xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, client->frame, client->titlegc, 4, points); + + /* Draw a black background */ + xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000")); + if (client->titlebar_position == TITLEBAR_OFF && !client->borderless) { + xcb_rectangle_t crect = {1, 0, client->rect.width - (1 + 1), client->rect.height - 1}; + xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect); + } else { + xcb_rectangle_t crect = {2, 0, client->rect.width - (2 + 2), client->rect.height - 2}; + xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect); + } + } + xcb_flush(conn); + return 1; +#endif } +#if 0 /* * Handle client messages (EWMH) * diff --git a/src/nc.c b/src/nc.c index 68646c87..44a43461 100644 --- a/src/nc.c +++ b/src/nc.c @@ -62,58 +62,6 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) { } } -int handle_map_request(void *unused, xcb_connection_t *conn, xcb_map_request_event_t *event) { - xcb_get_window_attributes_cookie_t cookie; - - cookie = xcb_get_window_attributes_unchecked(conn, event->window); - - LOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence); - //add_ignore_event(event->sequence); - - manage_window(event->window, cookie, false); - return 1; -} - - -int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event) { - LOG("unmap event for 0x%08x\n", event->window); - Con *con = con_by_window_id(event->window); - if (con == NULL) { - LOG("Not a managed window, ignoring\n"); - return 1; - } - - tree_close(con); - tree_render(); - return 1; -} - -int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *event) { - Con *parent, *con; - - /* event->count is the number of minimum remaining expose events for this window, so we - skip all events but the last one */ - if (event->count != 0) - return 1; - LOG("expose-event, window = %08x\n", event->window); - - if ((parent = con_by_frame_id(event->window)) == NULL) { - LOG("expose event for unknown window, ignoring\n"); - return 1; - } - - TAILQ_FOREACH(con, &(parent->nodes_head), nodes) { - LOG("expose for con %p / %s\n", con, con->name); - if (con->window) - x_draw_decoration(con); - } - xcb_flush(conn); - - return 1; -} - - - void parse_command(const char *command) { printf("received command: %s\n", command);