From 52420cc24d61db8d22cf0d391f1f84b37bf087d5 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 16 Apr 2018 20:36:40 +1000 Subject: Implement fullscreen. --- include/sway/tree/container.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/sway/tree/container.h') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 2a8b8aba..22bd7240 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -72,9 +72,13 @@ struct sway_container { // For C_OUTPUT, this is the output position in layout coordinates // For other types, this is the position in output-local coordinates double x, y; + double saved_x, saved_y; // does not include borders or gaps. double width, height; + // For C_WORKSPACE only + struct sway_view *fullscreen; + list_t *children; struct sway_container *parent; -- cgit v1.2.3 From bfd5834f4c1046c234ceaae212e65e045cd51460 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 17 Apr 2018 08:11:50 +1000 Subject: Feedback for fullscreen. --- include/sway/tree/container.h | 1 - include/sway/tree/view.h | 1 - sway/commands/fullscreen.c | 14 ++++---------- sway/desktop/output.c | 6 ++---- sway/desktop/xwayland.c | 12 ------------ sway/tree/layout.c | 2 +- sway/tree/view.c | 18 ++++++------------ 7 files changed, 13 insertions(+), 41 deletions(-) (limited to 'include/sway/tree/container.h') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 22bd7240..0283584b 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -72,7 +72,6 @@ struct sway_container { // For C_OUTPUT, this is the output position in layout coordinates // For other types, this is the position in output-local coordinates double x, y; - double saved_x, saved_y; // does not include borders or gaps. double width, height; diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 73d5f6c7..9dfd171f 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -42,7 +42,6 @@ struct sway_view { struct sway_container *swayc; // NULL for unmanaged views struct wlr_surface *surface; // NULL for unmapped views int width, height; - int saved_width, saved_height; bool is_fullscreen; union { diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index 3e256282..5a044aa8 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c @@ -8,12 +8,6 @@ // fullscreen toggle|enable|disable struct cmd_results *cmd_fullscreen(int argc, char **argv) { - struct cmd_results *error = NULL; - if (config->reading) return cmd_results_new(CMD_FAILURE, "fullscreen", "Can't be used in config file."); - if (!config->active) return cmd_results_new(CMD_FAILURE, "fullscreen", "Can only be used when sway is running."); - if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_LEAST, 1))) { - return error; - } struct sway_container *container = config->handler_context.current_container; if (container->type != C_VIEW) { @@ -23,15 +17,15 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { struct sway_view *view = container->sway_view; bool wants_fullscreen; - if (strcmp(argv[0], "enable") == 0) { + if (argc == 0 || strcmp(argv[0], "toggle") == 0) { + wants_fullscreen = !view->is_fullscreen; + } else if (strcmp(argv[0], "enable") == 0) { wants_fullscreen = true; } else if (strcmp(argv[0], "disable") == 0) { wants_fullscreen = false; - } else if (strcmp(argv[0], "toggle") == 0) { - wants_fullscreen = !view->is_fullscreen; } else { return cmd_results_new(CMD_INVALID, "fullscreen", - "Expected 'fullscreen '"); + "Expected 'fullscreen' or fullscreen '"); } view_set_fullscreen(view, wants_fullscreen); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index b86f20e8..dc2f6380 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -287,11 +287,9 @@ static void render_output(struct sway_output *output, struct timespec *when, render_container(output, workspace); render_unmanaged(output, &root_container.sway_root->xwayland_unmanaged); - - render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); - render_layer(output, - &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); } + render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); + render_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); renderer_end: if (root_container.sway_root->debug_tree) { diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 716d8882..963c5a0e 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -25,15 +25,6 @@ static void unmanaged_handle_request_configure(struct wl_listener *listener, ev->width, ev->height); } -static void unmanaged_handle_request_fullscreen(struct wl_listener *listener, - void *data) { - struct sway_xwayland_view *xwayland_view = - wl_container_of(listener, xwayland_view, request_fullscreen); - struct sway_view *view = &xwayland_view->view; - struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; - view_set_fullscreen(view, xsurface->fullscreen); -} - static void unmanaged_handle_commit(struct wl_listener *listener, void *data) { struct sway_xwayland_unmanaged *surface = wl_container_of(listener, surface, commit); @@ -115,9 +106,6 @@ static struct sway_xwayland_unmanaged *create_unmanaged( wl_signal_add(&xsurface->events.request_configure, &surface->request_configure); surface->request_configure.notify = unmanaged_handle_request_configure; - wl_signal_add(&xsurface->events.request_fullscreen, - &surface->request_fullscreen); - surface->request_fullscreen.notify = unmanaged_handle_request_fullscreen; wl_signal_add(&xsurface->events.map, &surface->map); surface->map.notify = unmanaged_handle_map; wl_signal_add(&xsurface->events.unmap, &surface->unmap); diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ae6db454..ad097f2e 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -138,7 +138,7 @@ void container_move_to(struct sway_container *container, return; } - if (container->sway_view->is_fullscreen) { + if (container->type == C_VIEW && container->sway_view->is_fullscreen) { struct sway_container *old_workspace = container; if (old_workspace->type != C_WORKSPACE) { old_workspace = container_parent(old_workspace, C_WORKSPACE); diff --git a/sway/tree/view.c b/sway/tree/view.c index b958233b..10285ad0 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -79,32 +79,26 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) { return; } - struct sway_container *container = container_parent(view->swayc, C_OUTPUT); - struct sway_output *output = container->sway_output; struct sway_container *workspace = container_parent(view->swayc, C_WORKSPACE); + struct sway_container *container = container_parent(workspace, C_OUTPUT); + struct sway_output *output = container->sway_output; if (view->impl->set_fullscreen) { view->impl->set_fullscreen(view, fullscreen); } + view->is_fullscreen = fullscreen; + if (fullscreen) { - view->swayc->saved_x = view->swayc->x; - view->swayc->saved_y = view->swayc->y; - view->saved_width = view->width; - view->saved_height = view->height; - view_configure(view, 0, 0, output->wlr_output->width, output->wlr_output->height); workspace->fullscreen = view; + view_configure(view, 0, 0, output->wlr_output->width, output->wlr_output->height); } else { - view_configure(view, view->swayc->saved_x, view->swayc->saved_y, - view->saved_width, view->saved_height); workspace->fullscreen = NULL; + arrange_windows(workspace, -1, -1); } - view->is_fullscreen = fullscreen; output_damage_whole(output); - arrange_windows(workspace, -1, -1); - ipc_event_window(view->swayc, "fullscreen_mode"); } -- cgit v1.2.3 From c685ef081f090d1e15428f55426e02f2274312d0 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 17 Apr 2018 09:31:34 +1000 Subject: Create sway_workspace struct. --- include/sway/tree/container.h | 5 ++--- include/sway/tree/workspace.h | 7 +++++++ sway/desktop/output.c | 5 +++-- sway/input/seat.c | 4 +++- sway/tree/container.c | 1 + sway/tree/layout.c | 18 +----------------- sway/tree/view.c | 7 ++++--- sway/tree/workspace.c | 7 +++++++ 8 files changed, 28 insertions(+), 26 deletions(-) (limited to 'include/sway/tree/container.h') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 0283584b..6efda72f 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -45,6 +45,7 @@ enum sway_container_border { struct sway_root; struct sway_output; +struct sway_workspace; struct sway_view; struct sway_container { @@ -52,6 +53,7 @@ struct sway_container { // TODO: Encapsulate state for other node types as well like C_CONTAINER struct sway_root *sway_root; struct sway_output *sway_output; + struct sway_workspace *sway_workspace; struct sway_view *sway_view; }; @@ -75,9 +77,6 @@ struct sway_container { // does not include borders or gaps. double width, height; - // For C_WORKSPACE only - struct sway_view *fullscreen; - list_t *children; struct sway_container *parent; diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 8d49fefb..35e1df3b 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -3,6 +3,13 @@ #include "sway/tree/container.h" +struct sway_view; + +struct sway_workspace { + struct sway_container *swayc; + struct sway_view *fullscreen; +}; + extern char *prev_workspace_name; char *workspace_next_name(const char *output_name); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index dc2f6380..74919ccd 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -22,6 +22,7 @@ #include "sway/tree/container.h" #include "sway/tree/layout.h" #include "sway/tree/view.h" +#include "sway/tree/workspace.h" struct sway_container *output_by_name(const char *name) { for (int i = 0; i < root_container.children->length; ++i) { @@ -275,9 +276,9 @@ static void render_output(struct sway_output *output, struct timespec *when, struct sway_container *workspace = output_get_active_workspace(output); - if (workspace->fullscreen) { + if (workspace->sway_workspace->fullscreen) { wlr_output_set_fullscreen_surface(wlr_output, - workspace->fullscreen->surface); + workspace->sway_workspace->fullscreen->surface); } else { wlr_output_set_fullscreen_surface(wlr_output, NULL); render_layer(output, diff --git a/sway/input/seat.c b/sway/input/seat.c index f60c43b5..23b7ef76 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -18,6 +18,7 @@ #include "sway/output.h" #include "sway/tree/container.h" #include "sway/tree/view.h" +#include "sway/tree/workspace.h" #include "log.h" static void seat_device_destroy(struct sway_seat_device *seat_device) { @@ -457,7 +458,8 @@ void seat_set_focus_warp(struct sway_seat *seat, new_workspace = container_parent(new_workspace, C_WORKSPACE); } - if (last_workspace == new_workspace && last_workspace->fullscreen + if (last_workspace == new_workspace + && last_workspace->sway_workspace->fullscreen && !container->sway_view->is_fullscreen) { return; } diff --git a/sway/tree/container.c b/sway/tree/container.c index c0067493..f14e9b9a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -197,6 +197,7 @@ static struct sway_container *container_workspace_destroy( } } + free(workspace->sway_workspace); _container_destroy(workspace); output_damage_whole(output->sway_output); diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ad097f2e..62219bb1 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -572,7 +572,7 @@ void arrange_windows(struct sway_container *container, return; case C_WORKSPACE: { - if (container->fullscreen) { + if (container->sway_workspace->fullscreen) { return; } struct sway_container *output = @@ -847,22 +847,6 @@ struct sway_container *container_get_in_direction( } } - // TODO WLR fullscreen - /* - if (container->type == C_VIEW && swayc_is_fullscreen(container)) { - wlr_log(L_DEBUG, "Moving from fullscreen view, skipping to output"); - container = container_parent(container, C_OUTPUT); - get_layout_center_position(container, &abs_pos); - struct sway_container *output = - swayc_adjacent_output(container, dir, &abs_pos, true); - return get_swayc_in_output_direction(output, dir); - } - if (container->type == C_WORKSPACE && container->fullscreen) { - sway_log(L_DEBUG, "Moving to fullscreen view"); - return container->fullscreen; - } - */ - struct sway_container *wrap_candidate = NULL; while (true) { bool can_move = false; diff --git a/sway/tree/view.c b/sway/tree/view.c index 10285ad0..e7a267ec 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -7,6 +7,7 @@ #include "sway/tree/container.h" #include "sway/tree/layout.h" #include "sway/tree/view.h" +#include "sway/tree/workspace.h" void view_init(struct sway_view *view, enum sway_view_type type, const struct sway_view_impl *impl) { @@ -90,10 +91,10 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) { view->is_fullscreen = fullscreen; if (fullscreen) { - workspace->fullscreen = view; + workspace->sway_workspace->fullscreen = view; view_configure(view, 0, 0, output->wlr_output->width, output->wlr_output->height); } else { - workspace->fullscreen = NULL; + workspace->sway_workspace->fullscreen = NULL; arrange_windows(workspace, -1, -1); } @@ -105,7 +106,7 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) { void view_close(struct sway_view *view) { if (view->is_fullscreen) { struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); - ws->fullscreen = NULL; + ws->sway_workspace->fullscreen = NULL; } if (view->impl->close) { diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 316f01e4..7f3c1903 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -59,6 +59,13 @@ struct sway_container *workspace_create(struct sway_container *output, workspace->layout = container_get_default_layout(output); workspace->workspace_layout = workspace->layout; + struct sway_workspace *swayws = calloc(1, sizeof(struct sway_workspace)); + if (!swayws) { + return NULL; + } + swayws->swayc = workspace; + workspace->sway_workspace = swayws; + container_add_child(output, workspace); container_sort_workspaces(output); container_create_notify(workspace); -- cgit v1.2.3