*
*/
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);
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;
*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;
}
}
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)");
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;
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;
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);
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;
*
*/
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;
}
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)) ||