Merge pull request #2300 from emersion/override-redirect-updates

Handle xwayland override_redirect flag change
This commit is contained in:
Drew DeVault 2018-07-18 12:42:09 -07:00 committed by GitHub
commit 4931d0ddc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 49 deletions

View File

@ -83,7 +83,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
struct sway_container *container, bool warp); struct sway_container *container, bool warp);
void seat_set_focus_surface(struct sway_seat *seat, void seat_set_focus_surface(struct sway_seat *seat,
struct wlr_surface *surface); struct wlr_surface *surface, bool unfocus);
void seat_set_focus_layer(struct sway_seat *seat, void seat_set_focus_layer(struct sway_seat *seat,
struct wlr_layer_surface *layer); struct wlr_layer_surface *layer);

View File

@ -69,16 +69,11 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
surface->ly = xsurface->y; surface->ly = xsurface->y;
desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true);
if (!wlr_xwayland_surface_is_unmanaged(xsurface)) {
struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_seat *seat = input_manager_current_seat(input_manager);
struct wlr_xwayland *xwayland = struct wlr_xwayland *xwayland =
seat->input->server->xwayland.wlr_xwayland; seat->input->server->xwayland.wlr_xwayland;
wlr_xwayland_set_seat(xwayland, seat->wlr_seat); wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
seat_set_focus_surface(seat, xsurface->surface); seat_set_focus_surface(seat, xsurface->surface, false);
}
// TODO: we don't send surface enter/leave events to xwayland unmanaged
// surfaces, but xwayland doesn't support HiDPI anyway
} }
static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
@ -89,7 +84,6 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
wl_list_remove(&surface->link); wl_list_remove(&surface->link);
wl_list_remove(&surface->commit.link); wl_list_remove(&surface->commit.link);
if (!wlr_xwayland_surface_is_unmanaged(xsurface)) {
struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_seat *seat = input_manager_current_seat(input_manager);
if (seat->wlr_seat->keyboard_state.focused_surface == if (seat->wlr_seat->keyboard_state.focused_surface ==
xsurface->surface) { xsurface->surface) {
@ -102,7 +96,6 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
seat_set_focus(seat, previous); seat_set_focus(seat, previous);
} }
} }
}
} }
static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
@ -303,6 +296,27 @@ static void handle_commit(struct wl_listener *listener, void *data) {
} }
} }
static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, destroy);
struct sway_view *view = &xwayland_view->view;
if (view->surface) {
view_unmap(view);
wl_list_remove(&xwayland_view->commit.link);
}
wl_list_remove(&xwayland_view->destroy.link);
wl_list_remove(&xwayland_view->request_configure.link);
wl_list_remove(&xwayland_view->request_fullscreen.link);
wl_list_remove(&xwayland_view->set_title.link);
wl_list_remove(&xwayland_view->set_class.link);
wl_list_remove(&xwayland_view->set_window_type.link);
wl_list_remove(&xwayland_view->map.link);
wl_list_remove(&xwayland_view->unmap.link);
view_destroy(&xwayland_view->view);
}
static void handle_unmap(struct wl_listener *listener, void *data) { static void handle_unmap(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view = struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, unmap); wl_container_of(listener, xwayland_view, unmap);
@ -323,6 +337,15 @@ static void handle_map(struct wl_listener *listener, void *data) {
struct wlr_xwayland_surface *xsurface = data; struct wlr_xwayland_surface *xsurface = data;
struct sway_view *view = &xwayland_view->view; struct sway_view *view = &xwayland_view->view;
if (xsurface->override_redirect) {
// This window used not to have the override redirect flag and has it
// now. Switch to unmanaged.
handle_destroy(&xwayland_view->destroy, view);
struct sway_xwayland_unmanaged *unmanaged = create_unmanaged(xsurface);
unmanaged_handle_map(&unmanaged->map, xsurface);
return;
}
view->natural_width = xsurface->width; view->natural_width = xsurface->width;
view->natural_height = xsurface->height; view->natural_height = xsurface->height;
@ -344,27 +367,6 @@ static void handle_map(struct wl_listener *listener, void *data) {
transaction_commit_dirty(); transaction_commit_dirty();
} }
static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, destroy);
struct sway_view *view = &xwayland_view->view;
if (view->surface) {
view_unmap(view);
wl_list_remove(&xwayland_view->commit.link);
}
wl_list_remove(&xwayland_view->destroy.link);
wl_list_remove(&xwayland_view->request_configure.link);
wl_list_remove(&xwayland_view->request_fullscreen.link);
wl_list_remove(&xwayland_view->set_title.link);
wl_list_remove(&xwayland_view->set_class.link);
wl_list_remove(&xwayland_view->set_window_type.link);
wl_list_remove(&xwayland_view->map.link);
wl_list_remove(&xwayland_view->unmap.link);
view_destroy(&xwayland_view->view);
}
static void handle_request_configure(struct wl_listener *listener, void *data) { static void handle_request_configure(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view = struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, request_configure); wl_container_of(listener, xwayland_view, request_configure);
@ -445,8 +447,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
xwayland_surface); xwayland_surface);
struct wlr_xwayland_surface *xsurface = data; struct wlr_xwayland_surface *xsurface = data;
if (wlr_xwayland_surface_is_unmanaged(xsurface) || if (xsurface->override_redirect) {
xsurface->override_redirect) {
wlr_log(WLR_DEBUG, "New xwayland unmanaged surface"); wlr_log(WLR_DEBUG, "New xwayland unmanaged surface");
create_unmanaged(xsurface); create_unmanaged(xsurface);
return; return;

View File

@ -753,11 +753,11 @@ void seat_set_focus(struct sway_seat *seat,
} }
void seat_set_focus_surface(struct sway_seat *seat, void seat_set_focus_surface(struct sway_seat *seat,
struct wlr_surface *surface) { struct wlr_surface *surface, bool unfocus) {
if (seat->focused_layer != NULL) { if (seat->focused_layer != NULL) {
return; return;
} }
if (seat->has_focus) { if (seat->has_focus && unfocus) {
struct sway_container *focus = seat_get_focus(seat); struct sway_container *focus = seat_get_focus(seat);
seat_send_unfocus(focus, seat); seat_send_unfocus(focus, seat);
seat->has_focus = false; seat->has_focus = false;
@ -789,7 +789,7 @@ void seat_set_focus_layer(struct sway_seat *seat,
} else if (!layer || seat->focused_layer == layer) { } else if (!layer || seat->focused_layer == layer) {
return; return;
} }
seat_set_focus_surface(seat, layer->surface); seat_set_focus_surface(seat, layer->surface, true);
if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { if (layer->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
seat->focused_layer = layer; seat->focused_layer = layer;
} }