Client *get_last_focused_client(xcb_connection_t *conn, Container *container,
Client *exclude);
+/**
+ * Sends WM_TAKE_FOCUS to the client
+ *
+ */
+void take_focus(xcb_connection_t *conn, Client *client);
+
/**
* Sets the given client as focused by updating the data structures correctly,
* updating the X input focus and finally re-decorating both windows (to
REQUEST_ATOM(_NET_CURRENT_DESKTOP);
REQUEST_ATOM(_NET_ACTIVE_WINDOW);
REQUEST_ATOM(_NET_WORKAREA);
+ REQUEST_ATOM(WM_TAKE_FOCUS);
/* TODO: this has to be more beautiful somewhen */
int major, minor, error;
GET_ATOM(_NET_CURRENT_DESKTOP);
GET_ATOM(_NET_ACTIVE_WINDOW);
GET_ATOM(_NET_WORKAREA);
+ GET_ATOM(WM_TAKE_FOCUS);
xcb_property_set_handler(&prophs, atoms[_NET_WM_WINDOW_TYPE], UINT_MAX, handle_window_type, NULL);
/* TODO: In order to comply with EWMH, we have to watch _NET_WM_STRUT_PARTIAL */
}
if (new->container == CUR_CELL || client_is_floating(new)) {
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, new->child, XCB_CURRENT_TIME);
+ take_focus(conn, new);
ewmh_update_active_window(new->child);
}
}
return NULL;
}
+/*
+ * Sends WM_TAKE_FOCUS to the client
+ *
+ */
+void take_focus(xcb_connection_t *conn, Client *client) {
+ xcb_client_message_event_t ev;
+
+ memset(&ev, 0, sizeof(xcb_client_message_event_t));
+
+ ev.response_type = XCB_CLIENT_MESSAGE;
+ ev.window = client->child;
+ ev.type = atoms[WM_PROTOCOLS];
+ ev.format = 32;
+ ev.data.data32[0] = atoms[WM_TAKE_FOCUS];
+ ev.data.data32[1] = XCB_CURRENT_TIME;
+
+ DLOG("Sending WM_TAKE_FOCUS to the client\n");
+ xcb_send_event(conn, false, client->child, XCB_EVENT_MASK_NO_EVENT, (char*)&ev);
+}
/*
* Sets the given client as focused by updating the data structures correctly,
CLIENT_LOG(client);
/* Set focus to the entered window, and flush xcb buffer immediately */
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, client->child, XCB_CURRENT_TIME);
+ take_focus(conn, client);
ewmh_update_active_window(client->child);
//xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, 10, 10);