Skip to content

Commit

Permalink
xwayland: listen to request_activate event
Browse files Browse the repository at this point in the history
When REAPER submenu is closed `XCB_CLIENT_MESSAGE` with type
`NET_ACTIVE_WINDOW` is sent to set focus to parent menu.

Closes: #6324
  • Loading branch information
yrhki authored and emersion committed Jan 31, 2022
1 parent 518e18a commit 69b4302
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sway/tree/view.h
Expand Up @@ -169,6 +169,7 @@ struct sway_xwayland_unmanaged {

int lx, ly;

struct wl_listener request_activate;
struct wl_listener request_configure;
struct wl_listener request_fullscreen;
struct wl_listener commit;
Expand Down
17 changes: 17 additions & 0 deletions sway/desktop/xwayland.c
Expand Up @@ -121,6 +121,20 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
}
}

static void unmanaged_handle_request_activate(struct wl_listener *listener, void *data) {
struct wlr_xwayland_surface *xsurface = data;
if (!xsurface->mapped) {
return;
}
struct sway_seat *seat = input_manager_current_seat();
struct sway_container *focus = seat_get_focused_container(seat);
if (focus && focus->view && focus->view->pid != xsurface->pid) {
return;
}

seat_set_focus_surface(seat, xsurface->surface, false);
}

static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
struct sway_xwayland_unmanaged *surface =
wl_container_of(listener, surface, destroy);
Expand All @@ -129,6 +143,7 @@ static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&surface->unmap.link);
wl_list_remove(&surface->destroy.link);
wl_list_remove(&surface->override_redirect.link);
wl_list_remove(&surface->request_activate.link);
free(surface);
}

Expand Down Expand Up @@ -176,6 +191,8 @@ static struct sway_xwayland_unmanaged *create_unmanaged(
surface->destroy.notify = unmanaged_handle_destroy;
wl_signal_add(&xsurface->events.set_override_redirect, &surface->override_redirect);
surface->override_redirect.notify = unmanaged_handle_override_redirect;
wl_signal_add(&xsurface->events.request_activate, &surface->request_activate);
surface->request_activate.notify = unmanaged_handle_request_activate;

return surface;
}
Expand Down

0 comments on commit 69b4302

Please sign in to comment.