diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-04-16 20:36:40 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-04-16 20:36:40 +1000 |
commit | 52420cc24d61db8d22cf0d391f1f84b37bf087d5 (patch) | |
tree | f975a3708c0d1562a8d2fcdceaed9a76aadbf1f4 /sway/tree | |
parent | dbc36935ee857375669e7ab3d0f20f1b5b098d23 (diff) |
Implement fullscreen.
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/layout.c | 18 | ||||
-rw-r--r-- | sway/tree/view.c | 40 |
2 files changed, 58 insertions, 0 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 0b637822..ae6db454 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -137,6 +137,21 @@ void container_move_to(struct sway_container *container, || container_has_anscestor(container, destination)) { return; } + + if (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); + } + struct sway_container *new_workspace = destination; + if (new_workspace->type != C_WORKSPACE) { + new_workspace = container_parent(new_workspace, C_WORKSPACE); + } + if (old_workspace != new_workspace) { + view_set_fullscreen(container->sway_view, false); + } + } + struct sway_container *old_parent = container_remove_child(container); container->width = container->height = 0; struct sway_container *new_parent; @@ -557,6 +572,9 @@ void arrange_windows(struct sway_container *container, return; case C_WORKSPACE: { + if (container->fullscreen) { + return; + } struct sway_container *output = container_parent(container, C_OUTPUT); struct wlr_box *area = &output->sway_output->usable_area; diff --git a/sway/tree/view.c b/sway/tree/view.c index 99b44720..b958233b 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -2,6 +2,7 @@ #include <wayland-server.h> #include <wlr/types/wlr_output_layout.h> #include "log.h" +#include "sway/ipc-server.h" #include "sway/output.h" #include "sway/tree/container.h" #include "sway/tree/layout.h" @@ -73,7 +74,46 @@ void view_set_activated(struct sway_view *view, bool activated) { } } +void view_set_fullscreen(struct sway_view *view, bool fullscreen) { + if (view->is_fullscreen == 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); + + if (view->impl->set_fullscreen) { + view->impl->set_fullscreen(view, 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; + } else { + view_configure(view, view->swayc->saved_x, view->swayc->saved_y, + view->saved_width, view->saved_height); + workspace->fullscreen = NULL; + } + + view->is_fullscreen = fullscreen; + output_damage_whole(output); + + arrange_windows(workspace, -1, -1); + + ipc_event_window(view->swayc, "fullscreen_mode"); +} + void view_close(struct sway_view *view) { + if (view->is_fullscreen) { + struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); + ws->fullscreen = NULL; + } + if (view->impl->close) { view->impl->close(view); } |