aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-28 11:26:14 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-28 11:26:14 +1000
commit167c2e1aa99aa8011e169b0fb61c47953cc9a5f6 (patch)
treef312cac40cd542964f62d8b7ed53d44bb13dea37 /sway/tree/view.c
parentMerge pull request #1866 from ggreer/swaybar-cmd-sh (diff)
downloadsway-167c2e1aa99aa8011e169b0fb61c47953cc9a5f6.tar.gz
sway-167c2e1aa99aa8011e169b0fb61c47953cc9a5f6.tar.zst
sway-167c2e1aa99aa8011e169b0fb61c47953cc9a5f6.zip
Refactor arrange_windows()
Replaces arrange_windows() with arrange_root(), arrange_output(), arrange_workspace() and arrange_children_of(). Also makes fullscreen views save and restore their dimensions, which allows it to preserve any custom resize and is also a requirement for floating views once they are implemented.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 3eeb1d97..e0aa6c0c 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -7,6 +7,7 @@
7#include "sway/ipc-server.h" 7#include "sway/ipc-server.h"
8#include "sway/output.h" 8#include "sway/output.h"
9#include "sway/input/seat.h" 9#include "sway/input/seat.h"
10#include "sway/tree/arrange.h"
10#include "sway/tree/container.h" 11#include "sway/tree/container.h"
11#include "sway/tree/layout.h" 12#include "sway/tree/layout.h"
12#include "sway/tree/view.h" 13#include "sway/tree/view.h"
@@ -78,14 +79,14 @@ void view_set_activated(struct sway_view *view, bool activated) {
78 } 79 }
79} 80}
80 81
81void view_set_fullscreen(struct sway_view *view, bool fullscreen) { 82// Set fullscreen, but without IPC events or arranging windows.
83void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
82 if (view->is_fullscreen == fullscreen) { 84 if (view->is_fullscreen == fullscreen) {
83 return; 85 return;
84 } 86 }
85 87
86 struct sway_container *workspace = container_parent(view->swayc, C_WORKSPACE); 88 struct sway_container *workspace =
87 struct sway_container *container = container_parent(workspace, C_OUTPUT); 89 container_parent(view->swayc, C_WORKSPACE);
88 struct sway_output *output = container->sway_output;
89 90
90 if (view->impl->set_fullscreen) { 91 if (view->impl->set_fullscreen) {
91 view->impl->set_fullscreen(view, fullscreen); 92 view->impl->set_fullscreen(view, fullscreen);
@@ -98,6 +99,8 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
98 view_set_fullscreen(workspace->sway_workspace->fullscreen, false); 99 view_set_fullscreen(workspace->sway_workspace->fullscreen, false);
99 } 100 }
100 workspace->sway_workspace->fullscreen = view; 101 workspace->sway_workspace->fullscreen = view;
102 view->swayc->saved_width = view->swayc->width;
103 view->swayc->saved_height = view->swayc->height;
101 104
102 struct sway_seat *seat; 105 struct sway_seat *seat;
103 struct sway_container *focus, *focus_ws; 106 struct sway_container *focus, *focus_ws;
@@ -114,11 +117,22 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
114 } 117 }
115 } else { 118 } else {
116 workspace->sway_workspace->fullscreen = NULL; 119 workspace->sway_workspace->fullscreen = NULL;
120 view->swayc->width = view->swayc->saved_width;
121 view->swayc->height = view->swayc->saved_height;
117 } 122 }
123}
118 124
119 arrange_windows(workspace, -1, -1); 125void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
120 output_damage_whole(output); 126 if (view->is_fullscreen == fullscreen) {
127 return;
128 }
121 129
130 view_set_fullscreen_raw(view, fullscreen);
131
132 struct sway_container *workspace =
133 container_parent(view->swayc, C_WORKSPACE);
134 arrange_workspace(workspace);
135 output_damage_whole(workspace->parent->sway_output);
122 ipc_event_window(view->swayc, "fullscreen_mode"); 136 ipc_event_window(view->swayc, "fullscreen_mode");
123} 137}
124 138
@@ -257,7 +271,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
257 wl_signal_add(&view->swayc->events.reparent, &view->container_reparent); 271 wl_signal_add(&view->swayc->events.reparent, &view->container_reparent);
258 view->container_reparent.notify = view_handle_container_reparent; 272 view->container_reparent.notify = view_handle_container_reparent;
259 273
260 arrange_windows(cont->parent, -1, -1); 274 arrange_children_of(cont->parent);
261 input_manager_set_focus(input_manager, cont); 275 input_manager_set_focus(input_manager, cont);
262 276
263 view_damage(view, true); 277 view_damage(view, true);
@@ -288,7 +302,7 @@ void view_unmap(struct sway_view *view) {
288 view->swayc = NULL; 302 view->swayc = NULL;
289 view->surface = NULL; 303 view->surface = NULL;
290 304
291 arrange_windows(parent, -1, -1); 305 arrange_children_of(parent);
292} 306}
293 307
294void view_update_position(struct sway_view *view, double ox, double oy) { 308void view_update_position(struct sway_view *view, double ox, double oy) {