Deactivate xwayland when focus leaves there

This commit is contained in:
Drew DeVault 2017-10-06 09:34:22 -04:00
parent 4d7ff3cb48
commit 528f000a7a
3 changed files with 25 additions and 14 deletions

View file

@ -137,11 +137,14 @@ static void set_view_focus(struct roots_input *input,
size_t index = 0; size_t index = 0;
for (size_t i = 0; i < desktop->views->length; ++i) { for (size_t i = 0; i < desktop->views->length; ++i) {
struct roots_view *_view = desktop->views->items[i]; struct roots_view *_view = desktop->views->items[i];
view_activate(_view, _view == view); if (_view != view) {
view_activate(_view, false);
}
if (view == _view) { if (view == _view) {
index = i; index = i;
} }
} }
view_activate(view, true);
// TODO: list_swap // TODO: list_swap
list_del(desktop->views, index); list_del(desktop->views, index);
list_add(desktop->views, view); list_add(desktop->views, view);

View file

@ -42,6 +42,8 @@ static void activate(struct roots_view *view, bool active) {
if (active) { if (active) {
wlr_xwayland_surface_activate(view->desktop->xwayland, wlr_xwayland_surface_activate(view->desktop->xwayland,
view->xwayland_surface); view->xwayland_surface);
} else {
wlr_xwayland_surface_activate(view->desktop->xwayland, NULL);
} }
} }

View file

@ -705,19 +705,25 @@ static void xcb_init_wm(struct wlr_xwm *xwm) {
void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland, void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland,
struct wlr_xwayland_surface *surface) { struct wlr_xwayland_surface *surface) {
struct wlr_xwm *xwm = wlr_xwayland->xwm; struct wlr_xwm *xwm = wlr_xwayland->xwm;
xcb_client_message_event_t m = {0}; if (surface) {
m.response_type = XCB_CLIENT_MESSAGE; xcb_client_message_event_t m = {0};
m.format = 32; m.response_type = XCB_CLIENT_MESSAGE;
m.window = surface->window_id; m.format = 32;
m.type = xwm->atoms[WM_PROTOCOLS]; m.window = surface->window_id;
m.data.data32[0] = xwm->atoms[WM_TAKE_FOCUS]; m.type = xwm->atoms[WM_PROTOCOLS];
m.data.data32[1] = XCB_TIME_CURRENT_TIME; m.data.data32[0] = xwm->atoms[WM_TAKE_FOCUS];
xcb_send_event_checked(xwm->xcb_conn, 0, surface->window_id, m.data.data32[1] = XCB_TIME_CURRENT_TIME;
XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&m); xcb_send_event_checked(xwm->xcb_conn, 0, surface->window_id,
xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&m);
surface->window_id, XCB_CURRENT_TIME); xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT,
xcb_configure_window_checked(xwm->xcb_conn, surface->window_id, surface->window_id, XCB_CURRENT_TIME);
XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){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});
} else {
wlr_log(L_DEBUG, "Deactivating xwayland");
xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_NONE,
-1, XCB_CURRENT_TIME);
}
xcb_flush(xwm->xcb_conn); xcb_flush(xwm->xcb_conn);
} }