Skip to content

Commit

Permalink
Honor output for xdg_toplevel_set_fullscreen
Browse files Browse the repository at this point in the history
This honors the fullscreen output request for
`xdg_toplevel_set_fullscreen` and `zxdg_toplevel_v6_set_fullscreen`.

If the request was sent before mapping, the fullscreen output request
will be retrieved from the client_pending state for the toplevel. The
output will be passed to `view_map` and if there is a workspace on the
output, the view will be placed on that workspace.

If the request comes in after being mapped, the view will be moved to
the workspace on the output (if there is one) before becoming
fullscreen.
  • Loading branch information
RedSoxFan authored and ddevault committed Apr 11, 2019
1 parent e0324fc commit 1952261
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/sway/tree/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void view_destroy(struct sway_view *view);
void view_begin_destroy(struct sway_view *view);

void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
bool fullscreen, bool decoration);
bool fullscreen, struct wlr_output *fullscreen_output, bool decoration);

void view_unmap(struct sway_view *view);

Expand Down
16 changes: 15 additions & 1 deletion sway/desktop/xdg_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
return;
}

if (e->fullscreen && e->output && e->output->data) {
struct sway_output *output = e->output->data;
struct sway_workspace *ws = output_get_active_workspace(output);
if (ws && !container_is_scratchpad_hidden(view->container)) {
if (container_is_floating(view->container)) {
workspace_add_floating(ws, view->container);
} else {
workspace_add_tiling(ws, view->container);
}
}
}

container_set_fullscreen(view->container, e->fullscreen);

arrange_root();
Expand Down Expand Up @@ -417,7 +429,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
}

view_map(view, view->wlr_xdg_surface->surface,
xdg_surface->toplevel->client_pending.fullscreen, csd);
xdg_surface->toplevel->client_pending.fullscreen,
xdg_surface->toplevel->client_pending.fullscreen_output,
csd);

transaction_commit_dirty();

Expand Down
16 changes: 15 additions & 1 deletion sway/desktop/xdg_shell_v6.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
return;
}

if (e->fullscreen && e->output && e->output->data) {
struct sway_output *output = e->output->data;
struct sway_workspace *ws = output_get_active_workspace(output);
if (ws && !container_is_scratchpad_hidden(view->container)) {
if (container_is_floating(view->container)) {
workspace_add_floating(ws, view->container);
} else {
workspace_add_tiling(ws, view->container);
}
}
}

container_set_fullscreen(view->container, e->fullscreen);

arrange_root();
Expand Down Expand Up @@ -411,7 +423,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
== WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;

view_map(view, view->wlr_xdg_surface_v6->surface,
xdg_surface->toplevel->client_pending.fullscreen, csd);
xdg_surface->toplevel->client_pending.fullscreen,
xdg_surface->toplevel->client_pending.fullscreen_output,
csd);

transaction_commit_dirty();

Expand Down
2 changes: 1 addition & 1 deletion sway/desktop/xwayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
xwayland_view->commit.notify = handle_commit;

// Put it back into the tree
view_map(view, xsurface->surface, xsurface->fullscreen, false);
view_map(view, xsurface->surface, xsurface->fullscreen, NULL, false);

transaction_commit_dirty();
}
Expand Down
16 changes: 14 additions & 2 deletions sway/tree/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,14 +561,26 @@ static bool should_focus(struct sway_view *view) {
}

void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
bool fullscreen, bool decoration) {
bool fullscreen, struct wlr_output *fullscreen_output,
bool decoration) {
if (!sway_assert(view->surface == NULL, "cannot map mapped view")) {
return;
}
view->surface = wlr_surface;

// If there is a request to be opened fullscreen on a specific output, try
// to honor that request. Otherwise, fallback to assigns, pid mappings,
// focused workspace, etc
struct sway_workspace *ws = NULL;
if (fullscreen_output && fullscreen_output->data) {
struct sway_output *output = fullscreen_output->data;
ws = output_get_active_workspace(output);
}
if (!ws) {
ws = select_workspace(view);
}

struct sway_seat *seat = input_manager_current_seat();
struct sway_workspace *ws = select_workspace(view);
struct sway_node *node = seat_get_focus_inactive(seat, &ws->node);
struct sway_container *target_sibling = node->type == N_CONTAINER ?
node->sway_container : NULL;
Expand Down

0 comments on commit 1952261

Please sign in to comment.