aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-25 11:15:43 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commit13a4b0512e25b8da6e16ca1286f8b62fcc24c5cc (patch)
tree5e03717e41e4af7282995b15b0938a6f07c4c74d /sway/tree/view.c
parentRespect view's border config for floating containers (diff)
downloadsway-13a4b0512e25b8da6e16ca1286f8b62fcc24c5cc.tar.gz
sway-13a4b0512e25b8da6e16ca1286f8b62fcc24c5cc.tar.zst
sway-13a4b0512e25b8da6e16ca1286f8b62fcc24c5cc.zip
Fix unfullscreening a floating view
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 8548d9b8..65961dd9 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -126,6 +126,23 @@ void view_configure(struct sway_view *view, double ox, double oy, int width,
126 } 126 }
127} 127}
128 128
129static void view_autoconfigure_floating(struct sway_view *view) {
130 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
131 int max_width = ws->width * 0.6666;
132 int max_height = ws->height * 0.6666;
133 int width =
134 view->natural_width > max_width ? max_width : view->natural_width;
135 int height =
136 view->natural_height > max_height ? max_height : view->natural_height;
137 struct sway_container *output = ws->parent;
138 int lx = output->x + (ws->width - width) / 2;
139 int ly = output->y + (ws->height - height) / 2;
140
141 view->border_left = view->border_right = view->border_bottom = true;
142 view_set_maximized(view, false);
143 view_configure(view, lx, ly, width, height);
144}
145
129void view_autoconfigure(struct sway_view *view) { 146void view_autoconfigure(struct sway_view *view) {
130 if (!sway_assert(view->swayc, 147 if (!sway_assert(view->swayc,
131 "Called view_autoconfigure() on a view without a swayc")) { 148 "Called view_autoconfigure() on a view without a swayc")) {
@@ -140,6 +157,11 @@ void view_autoconfigure(struct sway_view *view) {
140 return; 157 return;
141 } 158 }
142 159
160 if (container_is_floating(view->swayc)) {
161 view_autoconfigure_floating(view);
162 return;
163 }
164
143 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 165 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
144 166
145 int other_views = 0; 167 int other_views = 0;
@@ -261,6 +283,8 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
261 view_set_fullscreen(workspace->sway_workspace->fullscreen, false); 283 view_set_fullscreen(workspace->sway_workspace->fullscreen, false);
262 } 284 }
263 workspace->sway_workspace->fullscreen = view; 285 workspace->sway_workspace->fullscreen = view;
286 view->swayc->saved_x = view->swayc->x;
287 view->swayc->saved_y = view->swayc->y;
264 view->swayc->saved_width = view->swayc->width; 288 view->swayc->saved_width = view->swayc->width;
265 view->swayc->saved_height = view->swayc->height; 289 view->swayc->saved_height = view->swayc->height;
266 290
@@ -283,6 +307,11 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
283 workspace->sway_workspace->fullscreen = NULL; 307 workspace->sway_workspace->fullscreen = NULL;
284 view->swayc->width = view->swayc->saved_width; 308 view->swayc->width = view->swayc->saved_width;
285 view->swayc->height = view->swayc->saved_height; 309 view->swayc->height = view->swayc->saved_height;
310 if (container_is_floating(view->swayc)) {
311 view->swayc->x = view->swayc->saved_x;
312 view->swayc->y = view->swayc->saved_y;
313 view_autoconfigure(view);
314 }
286 } 315 }
287} 316}
288 317