From 733993a651c71f7e2198d505960d6bbd31e0e107 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 18 Nov 2017 11:22:02 -0500 Subject: Move everything to sway/old/ --- sway/old/commands/fullscreen.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sway/old/commands/fullscreen.c (limited to 'sway/old/commands/fullscreen.c') diff --git a/sway/old/commands/fullscreen.c b/sway/old/commands/fullscreen.c new file mode 100644 index 00000000..bfff82f9 --- /dev/null +++ b/sway/old/commands/fullscreen.c @@ -0,0 +1,60 @@ +#include +#include +#include +#include "sway/commands.h" +#include "sway/container.h" +#include "sway/focus.h" +#include "sway/ipc-server.h" +#include "sway/layout.h" + +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, 0))) { + return error; + } + swayc_t *container = current_container; + if(container->type != C_VIEW){ + return cmd_results_new(CMD_INVALID, "fullscreen", "Only views can fullscreen"); + } + swayc_t *workspace = swayc_parent_by_type(container, C_WORKSPACE); + bool current = swayc_is_fullscreen(container); + wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current); + + if (container->is_floating) { + if (current) { + // set dimensions back to what they were before we fullscreened this + container->x = container->cached_geometry.origin.x; + container->y = container->cached_geometry.origin.y; + container->width = container->cached_geometry.size.w; + container->height = container->cached_geometry.size.h; + } else { + // cache dimensions so we can reset them after we "unfullscreen" this + struct wlc_geometry geo = { + .origin = { + .x = container->x, + .y = container->y + }, + .size = { + .w = container->width, + .h = container->height + } + }; + container->cached_geometry = geo; + } + } + + // Resize workspace if going from fullscreen -> notfullscreen + // otherwise just resize container + if (!current) { + arrange_windows(workspace, -1, -1); + workspace->fullscreen = container; + } else { + arrange_windows(container, -1, -1); + workspace->fullscreen = NULL; + } + ipc_event_window(container, "fullscreen_mode"); + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} -- cgit v1.2.3