cleanups
This commit is contained in:
parent
8e5a831e27
commit
8959c5005f
|
@ -54,14 +54,14 @@ int handle_mapping_notify(void *ignored, xcb_connection_t *conn,
|
||||||
*/
|
*/
|
||||||
int handle_button_press(void *ignored, xcb_connection_t *conn,
|
int handle_button_press(void *ignored, xcb_connection_t *conn,
|
||||||
xcb_button_press_event_t *event);
|
xcb_button_press_event_t *event);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A new window appeared on the screen (=was mapped), so let’s manage it.
|
* A new window appeared on the screen (=was mapped), so let’s manage it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int handle_map_request(void *prophs, xcb_connection_t *conn,
|
int handle_map_request(void *prophs, xcb_connection_t *conn,
|
||||||
xcb_map_request_event_t *event);
|
xcb_map_request_event_t *event);
|
||||||
|
#if 0
|
||||||
/**
|
/**
|
||||||
* Configuration notifies are only handled because we need to set up ignore
|
* Configuration notifies are only handled because we need to set up ignore
|
||||||
* for the following enter notify events
|
* 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,
|
int handle_configure_request(void *prophs, xcb_connection_t *conn,
|
||||||
xcb_configure_request_event_t *event);
|
xcb_configure_request_event_t *event);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Our window decorations were unmapped. That means, the window will be killed
|
* Our window decorations were unmapped. That means, the window will be killed
|
||||||
* now, so we better clean up before.
|
* now, so we better clean up before.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event);
|
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
|
* A destroy notify event is sent when the window is not unmapped, but
|
||||||
* immediately destroyed (for example when starting a window and immediately
|
* 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_window_t window, xcb_atom_t atom,
|
||||||
xcb_get_property_reply_t *prop);
|
xcb_get_property_reply_t *prop);
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Expose event means we should redraw our windows (= title bar)
|
* Expose event means we should redraw our windows (= title bar)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int handle_expose_event(void *data, xcb_connection_t *conn,
|
int handle_expose_event(void *data, xcb_connection_t *conn,
|
||||||
xcb_expose_event_t *event);
|
xcb_expose_event_t *event);
|
||||||
|
#if 0
|
||||||
/**
|
/**
|
||||||
* Handle client messages (EWMH)
|
* Handle client messages (EWMH)
|
||||||
*
|
*
|
||||||
|
|
132
src/handlers.c
132
src/handlers.c
|
@ -253,6 +253,7 @@ int handle_mapping_notify(void *ignored, xcb_connection_t *conn, xcb_mapping_not
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* A new window appeared on the screen (=was mapped), so let’s manage it.
|
* A new window appeared on the screen (=was mapped), so let’s manage it.
|
||||||
*
|
*
|
||||||
|
@ -265,10 +266,10 @@ int handle_map_request(void *prophs, xcb_connection_t *conn, xcb_map_request_eve
|
||||||
DLOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence);
|
DLOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence);
|
||||||
add_ignore_event(event->sequence);
|
add_ignore_event(event->sequence);
|
||||||
|
|
||||||
manage_window(prophs, conn, event->window, cookie, false);
|
manage_window(event->window, cookie, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Configure requests are received when the application wants to resize windows on their own.
|
* 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Our window decorations were unmapped. That means, the window will be killed now,
|
* Our window decorations were unmapped. That means, the window will be killed
|
||||||
* so we better clean up before.
|
* now, so we better clean up before.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int handle_unmap_notify_event(void *data, xcb_connection_t *conn, xcb_unmap_notify_event_t *event) {
|
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);
|
DLOG("UnmapNotify for 0x%08x (received from 0x%08x)\n", event->window, event->event);
|
||||||
/* First, we need to check if the client is awaiting an unmap-request which
|
Con *con = con_by_window_id(event->window);
|
||||||
was generated by us reparenting the window. In that case, we just ignore it. */
|
if (con == NULL) {
|
||||||
if (client != NULL && client->awaiting_useless_unmap) {
|
LOG("Not a managed window, ignoring\n");
|
||||||
client->awaiting_useless_unmap = false;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLOG("event->window = %08x, event->event = %08x\n", event->window, event->event);
|
tree_close(con);
|
||||||
DLOG("UnmapNotify for 0x%08x (received from 0x%08x)\n", event->window, event->event);
|
tree_render();
|
||||||
|
x_push_changes(croot);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (client == NULL) {
|
if (client == NULL) {
|
||||||
DLOG("not a managed window. Ignoring.\n");
|
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;
|
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 */
|
/* 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_empty = SLIST_EMPTY(&(client->workspace->focus_stack));
|
||||||
bool workspace_focused = (c_ws == client->workspace);
|
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;
|
client->urgent = false;
|
||||||
workspace_update_urgent_flag(client->workspace);
|
workspace_update_urgent_flag(client->workspace);
|
||||||
|
|
||||||
FREE(client->window_class_instance);
|
|
||||||
FREE(client->window_class_class);
|
|
||||||
FREE(client->name);
|
|
||||||
free(client);
|
|
||||||
|
|
||||||
render_layout(conn);
|
render_layout(conn);
|
||||||
|
#endif
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* A destroy notify event is sent when the window is not unmapped, but
|
* A destroy notify event is sent when the window is not unmapped, but
|
||||||
* immediately destroyed (for example when starting a window and immediately
|
* immediately destroyed (for example when starting a window and immediately
|
||||||
|
@ -627,42 +572,35 @@ int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
/*
|
||||||
* Expose event means we should redraw our windows (= title bar)
|
* 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) {
|
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
|
Con *parent, *con;
|
||||||
skip all events but the last one */
|
|
||||||
|
/* 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)
|
if (event->count != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
DLOG("window = %08x\n", event->window);
|
DLOG("window = %08x\n", event->window);
|
||||||
|
|
||||||
Client *client = table_get(&by_parent, event->window);
|
if ((parent = con_by_frame_id(event->window)) == NULL) {
|
||||||
if (client == NULL) {
|
LOG("expose event for unknown window, ignoring\n");
|
||||||
/* 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* …or one of the bars? */
|
TAILQ_FOREACH(con, &(parent->nodes_head), nodes) {
|
||||||
Output *output;
|
LOG("expose for con %p / %s\n", con, con->name);
|
||||||
TAILQ_FOREACH(output, &outputs, outputs)
|
if (con->window)
|
||||||
if (output->bar == event->window)
|
x_draw_decoration(con);
|
||||||
render_layout(conn);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
xcb_flush(conn);
|
||||||
|
|
||||||
if (client->dock)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (container_mode(client->container, true) == MODE_DEFAULT)
|
#if 0
|
||||||
decorate_window(conn, client, client->frame, client->titlegc, 0, 0);
|
|
||||||
else {
|
else {
|
||||||
uint32_t background_color;
|
uint32_t background_color;
|
||||||
if (client->urgent)
|
if (client->urgent)
|
||||||
|
@ -696,8 +634,10 @@ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *
|
||||||
}
|
}
|
||||||
xcb_flush(conn);
|
xcb_flush(conn);
|
||||||
return 1;
|
return 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Handle client messages (EWMH)
|
* Handle client messages (EWMH)
|
||||||
*
|
*
|
||||||
|
|
52
src/nc.c
52
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) {
|
void parse_command(const char *command) {
|
||||||
printf("received command: %s\n", command);
|
printf("received command: %s\n", command);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue