Skip to content

Commit

Permalink
Fix X11 clients getting stuck minimized
Browse files Browse the repository at this point in the history
Usually it should be enough to simply not grant a client's
minimize request, however some applications (Steam, fullscreen
games in Wine) don't wait for the compositor and minimize anyway,
getting them stuck in an unrecoverable state.
Restoring them immediately lead to heavy flickering when unfocused
on my test application (Earth Defense Force 5 via Steam), so it's
preferable to grant their request without actually minimizing and
then restoring them once they are in focus again.
  • Loading branch information
junglerobba committed Jul 21, 2020
1 parent 7c7afa3 commit 83401f1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/sway/tree/view.h
Expand Up @@ -147,6 +147,7 @@ struct sway_xwayland_view {
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_maximize;
struct wl_listener request_minimize;
struct wl_listener request_configure;
struct wl_listener request_fullscreen;
struct wl_listener request_activate;
Expand Down
24 changes: 24 additions & 0 deletions sway/desktop/xwayland.c
Expand Up @@ -508,6 +508,26 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
transaction_commit_dirty();
}

static void handle_request_minimize(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, request_minimize);
struct sway_view *view = &xwayland_view->view;
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
if (!xsurface->mapped) {
return;
}

struct wlr_xwayland_minimize_event *e = data;
struct sway_seat *seat = input_manager_current_seat();
bool focused =
seat->wlr_seat->keyboard_state.focused_surface == xsurface->surface;
if (!focused && e->minimize) {
wlr_xwayland_surface_set_minimized(xsurface, true);
} else {
wlr_xwayland_surface_set_minimized(xsurface, false);
}
}

static void handle_request_move(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, request_move);
Expand Down Expand Up @@ -653,6 +673,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
&xwayland_view->request_fullscreen);
xwayland_view->request_fullscreen.notify = handle_request_fullscreen;

wl_signal_add(&xsurface->events.request_minimize,
&xwayland_view->request_minimize);
xwayland_view->request_minimize.notify = handle_request_minimize;

wl_signal_add(&xsurface->events.request_activate,
&xwayland_view->request_activate);
xwayland_view->request_activate.notify = handle_request_activate;
Expand Down
9 changes: 9 additions & 0 deletions sway/input/seat.c
Expand Up @@ -1197,6 +1197,15 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
// the workspace needs to be arranged
arrange_workspace(new_workspace);
}

#if HAVE_XWAYLAND
// Some X11 clients minimize without waiting for the compositor to allow it
if (container && container->view && container->view->type == SWAY_VIEW_XWAYLAND
&& container->view->wlr_xwayland_surface->minimized) {
wlr_xwayland_surface_set_minimized(
container->view->wlr_xwayland_surface, false);
}
#endif
}

void seat_set_focus_container(struct sway_seat *seat,
Expand Down

0 comments on commit 83401f1

Please sign in to comment.