aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index dbf803c6..658a94e8 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -135,22 +135,22 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
135 return 0; 135 return 0;
136} 136}
137 137
138static void view_autoconfigure_floating(struct sway_view *view) { 138void view_init_floating(struct sway_view *view) {
139 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 139 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
140 int max_width = ws->width * 0.6666; 140 int max_width = ws->width * 0.6666;
141 int max_height = ws->height * 0.6666; 141 int max_height = ws->height * 0.6666;
142 int width = 142 view->width =
143 view->natural_width > max_width ? max_width : view->natural_width; 143 view->natural_width > max_width ? max_width : view->natural_width;
144 int height = 144 view->height =
145 view->natural_height > max_height ? max_height : view->natural_height; 145 view->natural_height > max_height ? max_height : view->natural_height;
146 int lx = ws->x + (ws->width - width) / 2; 146 view->x = ws->x + (ws->width - view->width) / 2;
147 int ly = ws->y + (ws->height - height) / 2; 147 view->y = ws->y + (ws->height - view->height) / 2;
148 148
149 // If the view's border is B_NONE then these properties are ignored. 149 // If the view's border is B_NONE then these properties are ignored.
150 view->border_top = view->border_bottom = true; 150 view->border_top = view->border_bottom = true;
151 view->border_left = view->border_right = true; 151 view->border_left = view->border_right = true;
152 152
153 view_configure(view, lx, ly, width, height); 153 container_set_geometry_from_floating_view(view->swayc);
154} 154}
155 155
156void view_autoconfigure(struct sway_view *view) { 156void view_autoconfigure(struct sway_view *view) {
@@ -162,12 +162,14 @@ void view_autoconfigure(struct sway_view *view) {
162 struct sway_container *output = container_parent(view->swayc, C_OUTPUT); 162 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
163 163
164 if (view->is_fullscreen) { 164 if (view->is_fullscreen) {
165 view_configure(view, output->x, output->y, output->width, output->height); 165 view->x = output->x;
166 view->y = output->y;
167 view->width = output->width;
168 view->height = output->height;
166 return; 169 return;
167 } 170 }
168 171
169 if (container_is_floating(view->swayc)) { 172 if (container_is_floating(view->swayc)) {
170 view_autoconfigure_floating(view);
171 return; 173 return;
172 } 174 }
173 175
@@ -268,8 +270,7 @@ void view_set_activated(struct sway_view *view, bool activated) {
268 } 270 }
269} 271}
270 272
271// Set fullscreen, but without IPC events or arranging windows. 273void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
272void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
273 if (view->is_fullscreen == fullscreen) { 274 if (view->is_fullscreen == fullscreen) {
274 return; 275 return;
275 } 276 }
@@ -315,26 +316,17 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) {
315 } else { 316 } else {
316 workspace->sway_workspace->fullscreen = NULL; 317 workspace->sway_workspace->fullscreen = NULL;
317 if (container_is_floating(view->swayc)) { 318 if (container_is_floating(view->swayc)) {
318 view_configure(view, view->saved_x, view->saved_y, 319 view->x = view->saved_x;
319 view->saved_width, view->saved_height); 320 view->y = view->saved_y;
321 view->width = view->saved_width;
322 view->height = view->saved_height;
323 container_set_geometry_from_floating_view(view->swayc);
320 } else { 324 } else {
321 view->swayc->width = view->swayc->saved_width; 325 view->swayc->width = view->swayc->saved_width;
322 view->swayc->height = view->swayc->saved_height; 326 view->swayc->height = view->swayc->saved_height;
323 } 327 }
324 } 328 }
325}
326
327void view_set_fullscreen(struct sway_view *view, bool fullscreen) {
328 if (view->is_fullscreen == fullscreen) {
329 return;
330 }
331 329
332 view_set_fullscreen_raw(view, fullscreen);
333
334 struct sway_container *workspace =
335 container_parent(view->swayc, C_WORKSPACE);
336 arrange_workspace(workspace);
337 output_damage_whole(workspace->parent->sway_output);
338 ipc_event_window(view->swayc, "fullscreen_mode"); 330 ipc_event_window(view->swayc, "fullscreen_mode");
339} 331}
340 332
@@ -517,8 +509,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
517 509
518 if (view->impl->wants_floating && view->impl->wants_floating(view)) { 510 if (view->impl->wants_floating && view->impl->wants_floating(view)) {
519 container_set_floating(view->swayc, true); 511 container_set_floating(view->swayc, true);
520 } else {
521 arrange_children_of(cont->parent);
522 } 512 }
523 513
524 input_manager_set_focus(input_manager, cont); 514 input_manager_set_focus(input_manager, cont);
@@ -530,7 +520,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
530 container_notify_subtree_changed(view->swayc->parent); 520 container_notify_subtree_changed(view->swayc->parent);
531 view_execute_criteria(view); 521 view_execute_criteria(view);
532 522
533 container_damage_whole(cont);
534 view_handle_container_reparent(&view->container_reparent, NULL); 523 view_handle_container_reparent(&view->container_reparent, NULL);
535} 524}
536 525
@@ -561,11 +550,7 @@ void view_unmap(struct sway_view *view) {
561 view->title_format = NULL; 550 view->title_format = NULL;
562 } 551 }
563 552
564 if (parent->type == C_OUTPUT) { 553 arrange_and_commit(parent);
565 arrange_output(parent);
566 } else {
567 arrange_children_of(parent);
568 }
569} 554}
570 555
571void view_update_position(struct sway_view *view, double lx, double ly) { 556void view_update_position(struct sway_view *view, double lx, double ly) {