diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 87 |
1 files changed, 57 insertions, 30 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 26ff1e8d..651a2be6 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -158,21 +158,19 @@ void view_autoconfigure(struct sway_view *view) { | |||
158 | 158 | ||
159 | view->border_top = view->border_bottom = true; | 159 | view->border_top = view->border_bottom = true; |
160 | view->border_left = view->border_right = true; | 160 | view->border_left = view->border_right = true; |
161 | if (view->swayc->layout != L_FLOATING) { | 161 | if (config->hide_edge_borders == E_BOTH |
162 | if (config->hide_edge_borders == E_BOTH | 162 | || config->hide_edge_borders == E_VERTICAL |
163 | || config->hide_edge_borders == E_VERTICAL | 163 | || (config->hide_edge_borders == E_SMART && !other_views)) { |
164 | || (config->hide_edge_borders == E_SMART && !other_views)) { | 164 | view->border_left = view->swayc->x != ws->x; |
165 | view->border_left = view->swayc->x != ws->x; | 165 | int right_x = view->swayc->x + view->swayc->width; |
166 | int right_x = view->swayc->x + view->swayc->width; | 166 | view->border_right = right_x != ws->x + ws->width; |
167 | view->border_right = right_x != ws->x + ws->width; | 167 | } |
168 | } | 168 | if (config->hide_edge_borders == E_BOTH |
169 | if (config->hide_edge_borders == E_BOTH | 169 | || config->hide_edge_borders == E_HORIZONTAL |
170 | || config->hide_edge_borders == E_HORIZONTAL | 170 | || (config->hide_edge_borders == E_SMART && !other_views)) { |
171 | || (config->hide_edge_borders == E_SMART && !other_views)) { | 171 | view->border_top = view->swayc->y != ws->y; |
172 | view->border_top = view->swayc->y != ws->y; | 172 | int bottom_y = view->swayc->y + view->swayc->height; |
173 | int bottom_y = view->swayc->y + view->swayc->height; | 173 | view->border_bottom = bottom_y != ws->y + ws->height; |
174 | view->border_bottom = bottom_y != ws->y + ws->height; | ||
175 | } | ||
176 | } | 174 | } |
177 | 175 | ||
178 | double x, y, width, height; | 176 | double x, y, width, height; |
@@ -184,11 +182,11 @@ void view_autoconfigure(struct sway_view *view) { | |||
184 | // disable any top border because we'll always have the title bar. | 182 | // disable any top border because we'll always have the title bar. |
185 | if (view->swayc->parent->layout == L_TABBED) { | 183 | if (view->swayc->parent->layout == L_TABBED) { |
186 | y_offset = container_titlebar_height(); | 184 | y_offset = container_titlebar_height(); |
187 | view->border_top = 0; | 185 | view->border_top = false; |
188 | } else if (view->swayc->parent->layout == L_STACKED) { | 186 | } else if (view->swayc->parent->layout == L_STACKED) { |
189 | y_offset = container_titlebar_height() | 187 | y_offset = container_titlebar_height() |
190 | * view->swayc->parent->children->length; | 188 | * view->swayc->parent->children->length; |
191 | view->border_top = 0; | 189 | view->border_top = false; |
192 | } | 190 | } |
193 | 191 | ||
194 | switch (view->border) { | 192 | switch (view->border) { |
@@ -237,6 +235,12 @@ void view_set_activated(struct sway_view *view, bool activated) { | |||
237 | } | 235 | } |
238 | } | 236 | } |
239 | 237 | ||
238 | void view_set_maximized(struct sway_view *view, bool maximized) { | ||
239 | if (view->impl->set_maximized) { | ||
240 | view->impl->set_maximized(view, maximized); | ||
241 | } | ||
242 | } | ||
243 | |||
240 | // Set fullscreen, but without IPC events or arranging windows. | 244 | // Set fullscreen, but without IPC events or arranging windows. |
241 | void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { | 245 | void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { |
242 | if (view->is_fullscreen == fullscreen) { | 246 | if (view->is_fullscreen == fullscreen) { |
@@ -452,6 +456,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
452 | // TODO: CT_ASSIGN_OUTPUT | 456 | // TODO: CT_ASSIGN_OUTPUT |
453 | } | 457 | } |
454 | } | 458 | } |
459 | // If we're about to launch the view into the floating container, then | ||
460 | // launch it as a tiled view in the root of the workspace instead. | ||
461 | if (focus->is_floating) { | ||
462 | focus = focus->parent->parent; | ||
463 | } | ||
455 | free(criterias); | 464 | free(criterias); |
456 | cont = container_view_create(focus, view); | 465 | cont = container_view_create(focus, view); |
457 | 466 | ||
@@ -468,7 +477,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
468 | wl_signal_add(&view->swayc->events.reparent, &view->container_reparent); | 477 | wl_signal_add(&view->swayc->events.reparent, &view->container_reparent); |
469 | view->container_reparent.notify = view_handle_container_reparent; | 478 | view->container_reparent.notify = view_handle_container_reparent; |
470 | 479 | ||
471 | arrange_children_of(cont->parent); | 480 | if (view->impl->wants_floating && view->impl->wants_floating(view)) { |
481 | container_set_floating(view->swayc, true); | ||
482 | } else { | ||
483 | arrange_children_of(cont->parent); | ||
484 | } | ||
485 | |||
472 | input_manager_set_focus(input_manager, cont); | 486 | input_manager_set_focus(input_manager, cont); |
473 | if (workspace) { | 487 | if (workspace) { |
474 | workspace_switch(workspace); | 488 | workspace_switch(workspace); |
@@ -516,16 +530,14 @@ void view_unmap(struct sway_view *view) { | |||
516 | } | 530 | } |
517 | } | 531 | } |
518 | 532 | ||
519 | void view_update_position(struct sway_view *view, double ox, double oy) { | 533 | void view_update_position(struct sway_view *view, double lx, double ly) { |
520 | if (view->swayc->x == ox && view->swayc->y == oy) { | 534 | if (!view->swayc->is_floating) { |
521 | return; | 535 | return; |
522 | } | 536 | } |
523 | |||
524 | // TODO: Only allow this if the view is floating (this function will only be | ||
525 | // called in response to wayland clients wanting to reposition themselves). | ||
526 | container_damage_whole(view->swayc); | 537 | container_damage_whole(view->swayc); |
527 | view->swayc->x = ox; | 538 | view->x = lx; |
528 | view->swayc->y = oy; | 539 | view->y = ly; |
540 | container_set_geometry_from_view(view->swayc); | ||
529 | container_damage_whole(view->swayc); | 541 | container_damage_whole(view->swayc); |
530 | } | 542 | } |
531 | 543 | ||
@@ -533,15 +545,15 @@ void view_update_size(struct sway_view *view, int width, int height) { | |||
533 | if (view->width == width && view->height == height) { | 545 | if (view->width == width && view->height == height) { |
534 | return; | 546 | return; |
535 | } | 547 | } |
536 | |||
537 | container_damage_whole(view->swayc); | 548 | container_damage_whole(view->swayc); |
538 | // Should we update the swayc width/height here too? | ||
539 | view->width = width; | 549 | view->width = width; |
540 | view->height = height; | 550 | view->height = height; |
551 | if (view->swayc->is_floating) { | ||
552 | container_set_geometry_from_view(view->swayc); | ||
553 | } | ||
541 | container_damage_whole(view->swayc); | 554 | container_damage_whole(view->swayc); |
542 | } | 555 | } |
543 | 556 | ||
544 | |||
545 | static void view_subsurface_create(struct sway_view *view, | 557 | static void view_subsurface_create(struct sway_view *view, |
546 | struct wlr_subsurface *subsurface) { | 558 | struct wlr_subsurface *subsurface) { |
547 | struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child)); | 559 | struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child)); |
@@ -888,6 +900,19 @@ bool view_is_visible(struct sway_view *view) { | |||
888 | if (!view->swayc) { | 900 | if (!view->swayc) { |
889 | return false; | 901 | return false; |
890 | } | 902 | } |
903 | struct sway_container *workspace = | ||
904 | container_parent(view->swayc, C_WORKSPACE); | ||
905 | // Determine if view is nested inside a floating container which is sticky. | ||
906 | // A simple floating view will have this ancestry: | ||
907 | // C_VIEW (is_floating=true) -> floating -> workspace | ||
908 | // A more complex ancestry could be: | ||
909 | // C_VIEW -> C_CONTAINER (tabbed and is_floating) -> floating -> workspace | ||
910 | struct sway_container *floater = view->swayc; | ||
911 | while (floater->parent->type != C_WORKSPACE | ||
912 | && floater->parent->parent->type != C_WORKSPACE) { | ||
913 | floater = floater->parent; | ||
914 | } | ||
915 | bool is_sticky = floater->is_floating && floater->is_sticky; | ||
891 | // Check view isn't in a tabbed or stacked container on an inactive tab | 916 | // Check view isn't in a tabbed or stacked container on an inactive tab |
892 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 917 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
893 | struct sway_container *container = view->swayc; | 918 | struct sway_container *container = view->swayc; |
@@ -901,10 +926,12 @@ bool view_is_visible(struct sway_view *view) { | |||
901 | container = container->parent; | 926 | container = container->parent; |
902 | } | 927 | } |
903 | // Check view isn't hidden by another fullscreen view | 928 | // Check view isn't hidden by another fullscreen view |
904 | struct sway_container *workspace = container; | ||
905 | if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) { | 929 | if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) { |
906 | return false; | 930 | return false; |
907 | } | 931 | } |
908 | // Check the workspace is visible | 932 | // Check the workspace is visible |
909 | return workspace_is_visible(workspace); | 933 | if (!is_sticky) { |
934 | return workspace_is_visible(workspace); | ||
935 | } | ||
936 | return true; | ||
910 | } | 937 | } |