aboutsummaryrefslogtreecommitdiff
path: root/xwayland/xwm.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-10-24 10:04:33 -0400
committerTony Crisci <tony@dubstepdish.com>2017-10-24 10:04:33 -0400
commit79978383ba8fc894117947c80fc9d8cd78782fee (patch)
tree3947a4f28bde3c64285d3d5d1b99feb9bbf185ab /xwayland/xwm.c
parent03bd34e826f01e35b4e23d9555d45924f12dadfa (diff)
xwm: net active window
Diffstat (limited to 'xwayland/xwm.c')
-rw-r--r--xwayland/xwm.c63
1 files changed, 45 insertions, 18 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 5d349253..bd485eb1 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -620,8 +620,8 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) {
static void create_surface_handler(struct wl_listener *listener, void *data) {
struct wlr_surface *surface = data;
- struct wlr_xwm *xwm = wl_container_of(listener, xwm,
- surface_create_listener);
+ struct wlr_xwm *xwm =
+ wl_container_of(listener, xwm, surface_create_listener);
if (wl_resource_get_client(surface->resource) != xwm->xwayland->client) {
return;
}
@@ -639,28 +639,55 @@ static void create_surface_handler(struct wl_listener *listener, void *data) {
}
}
-void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland,
+static void xwm_set_net_active_window(struct wlr_xwm *xwm,
+ xcb_window_t window) {
+ xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE,
+ xwm->screen->root, xwm->atoms[_NET_ACTIVE_WINDOW],
+ xwm->atoms[WINDOW], 32, 1, &window);
+}
+
+static void xwm_send_focus_window(struct wlr_xwm *xwm,
struct wlr_xwayland_surface *surface) {
- struct wlr_xwm *xwm = wlr_xwayland->xwm;
if (surface) {
- xcb_client_message_event_t m = {0};
- m.response_type = XCB_CLIENT_MESSAGE;
- m.format = 32;
- m.window = surface->window_id;
- m.type = xwm->atoms[WM_PROTOCOLS];
- m.data.data32[0] = xwm->atoms[WM_TAKE_FOCUS];
- m.data.data32[1] = XCB_TIME_CURRENT_TIME;
- xcb_send_event_checked(xwm->xcb_conn, 0, surface->window_id,
- XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&m);
- xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT,
+ xcb_client_message_event_t client_message;
+ client_message.response_type = XCB_CLIENT_MESSAGE;
+ client_message.format = 32;
+ client_message.window = surface->window_id;
+ client_message.type = xwm->atoms[WM_PROTOCOLS];
+ client_message.data.data32[0] = xwm->atoms[WM_TAKE_FOCUS];
+ client_message.data.data32[1] = XCB_TIME_CURRENT_TIME;
+
+ xcb_send_event(xwm->xcb_conn, 0, surface->window_id,
+ XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&client_message);
+
+ xcb_set_input_focus(xwm->xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT,
surface->window_id, XCB_CURRENT_TIME);
+
+ uint32_t values[1];
+ values[0] = XCB_STACK_MODE_ABOVE;
xcb_configure_window_checked(xwm->xcb_conn, surface->window_id,
- XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){XCB_STACK_MODE_ABOVE});
+ XCB_CONFIG_WINDOW_STACK_MODE, values);
} else {
- wlr_log(L_DEBUG, "Deactivating xwayland");
- xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_NONE,
- -1, XCB_CURRENT_TIME);
+ xcb_set_input_focus_checked(xwm->xcb_conn,
+ XCB_INPUT_FOCUS_POINTER_ROOT,
+ XCB_NONE, XCB_CURRENT_TIME);
}
+}
+
+void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland,
+ struct wlr_xwayland_surface *surface) {
+ struct wlr_xwm *xwm = wlr_xwayland->xwm;
+
+ if (surface) {
+ xwm_set_net_active_window(xwm, surface->window_id);
+ } else {
+ xwm_set_net_active_window(xwm, XCB_WINDOW_NONE);
+ }
+
+ xwm_send_focus_window(xwm, surface);
+
+ xwm->focus_surface = surface;
+
xcb_flush(xwm->xcb_conn);
}