summaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c58
1 files changed, 5 insertions, 53 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e641544e..8f54cc11 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -168,55 +168,6 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
168 return 0; 168 return 0;
169} 169}
170 170
171void view_init_floating(struct sway_view *view) {
172 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
173 int min_width, min_height;
174 int max_width, max_height;
175
176 if (config->floating_minimum_width == -1) { // no minimum
177 min_width = 0;
178 } else if (config->floating_minimum_width == 0) { // automatic
179 min_width = 75;
180 } else {
181 min_width = config->floating_minimum_width;
182 }
183
184 if (config->floating_minimum_height == -1) { // no minimum
185 min_height = 0;
186 } else if (config->floating_minimum_height == 0) { // automatic
187 min_height = 50;
188 } else {
189 min_height = config->floating_minimum_height;
190 }
191
192 if (config->floating_maximum_width == -1) { // no maximum
193 max_width = INT_MAX;
194 } else if (config->floating_maximum_width == 0) { // automatic
195 max_width = ws->width * 0.6666;
196 } else {
197 max_width = config->floating_maximum_width;
198 }
199
200 if (config->floating_maximum_height == -1) { // no maximum
201 max_height = INT_MAX;
202 } else if (config->floating_maximum_height == 0) { // automatic
203 max_height = ws->height * 0.6666;
204 } else {
205 max_height = config->floating_maximum_height;
206 }
207
208 view->width = fmax(min_width, fmin(view->natural_width, max_width));
209 view->height = fmax(min_height, fmin(view->natural_height, max_height));
210 view->x = ws->x + (ws->width - view->width) / 2;
211 view->y = ws->y + (ws->height - view->height) / 2;
212
213 // If the view's border is B_NONE then these properties are ignored.
214 view->border_top = view->border_bottom = true;
215 view->border_left = view->border_right = true;
216
217 container_set_geometry_from_floating_view(view->swayc);
218}
219
220void view_autoconfigure(struct sway_view *view) { 171void view_autoconfigure(struct sway_view *view) {
221 if (!sway_assert(view->swayc, 172 if (!sway_assert(view->swayc,
222 "Called view_autoconfigure() on a view without a swayc")) { 173 "Called view_autoconfigure() on a view without a swayc")) {
@@ -626,10 +577,8 @@ void view_unmap(struct sway_view *view) {
626 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 577 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
627 578
628 struct sway_container *parent; 579 struct sway_container *parent;
629 if (view->swayc->is_fullscreen) { 580 if (container_is_fullscreen_or_child(view->swayc)) {
630 ws->sway_workspace->fullscreen = NULL;
631 parent = container_destroy(view->swayc); 581 parent = container_destroy(view->swayc);
632
633 arrange_windows(ws->parent); 582 arrange_windows(ws->parent);
634 } else { 583 } else {
635 parent = container_destroy(view->swayc); 584 parent = container_destroy(view->swayc);
@@ -1050,11 +999,14 @@ void view_update_marks_textures(struct sway_view *view) {
1050} 999}
1051 1000
1052bool view_is_visible(struct sway_view *view) { 1001bool view_is_visible(struct sway_view *view) {
1053 if (!view->swayc || view->swayc->destroying || !view->swayc->parent) { 1002 if (!view->swayc || view->swayc->destroying) {
1054 return false; 1003 return false;
1055 } 1004 }
1056 struct sway_container *workspace = 1005 struct sway_container *workspace =
1057 container_parent(view->swayc, C_WORKSPACE); 1006 container_parent(view->swayc, C_WORKSPACE);
1007 if (!workspace) {
1008 return false;
1009 }
1058 // Determine if view is nested inside a floating container which is sticky. 1010 // Determine if view is nested inside a floating container which is sticky.
1059 // A simple floating view will have this ancestry: 1011 // A simple floating view will have this ancestry:
1060 // C_VIEW -> floating -> workspace 1012 // C_VIEW -> floating -> workspace