diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 111 |
1 files changed, 53 insertions, 58 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index c9c82405..658a94e8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -25,6 +25,7 @@ void view_init(struct sway_view *view, enum sway_view_type type, view->impl = impl; view->executed_criteria = create_list(); view->marks = create_list(); + view->instructions = create_list(); wl_signal_init(&view->events.unmap); } @@ -37,6 +38,11 @@ void view_destroy(struct sway_view *view) { view_unmap(view); } + if (!sway_assert(view->instructions->length == 0, + "Tried to destroy view with pending instructions")) { + return; + } + list_free(view->executed_criteria); for (int i = 0; i < view->marks->length; ++i) { @@ -44,6 +50,8 @@ void view_destroy(struct sway_view *view) { } list_free(view->marks); + list_free(view->instructions); + wlr_texture_destroy(view->marks_focused); wlr_texture_destroy(view->marks_focused_inactive); wlr_texture_destroy(view->marks_unfocused); @@ -119,29 +127,30 @@ const char *view_get_shell(struct sway_view *view) { return "unknown"; } -void view_configure(struct sway_view *view, double lx, double ly, int width, +uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, int height) { if (view->impl->configure) { - view->impl->configure(view, lx, ly, width, height); + return view->impl->configure(view, lx, ly, width, height); } + return 0; } -static void view_autoconfigure_floating(struct sway_view *view) { +void view_init_floating(struct sway_view *view) { struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); int max_width = ws->width * 0.6666; int max_height = ws->height * 0.6666; - int width = + view->width = view->natural_width > max_width ? max_width : view->natural_width; - int height = + view->height = view->natural_height > max_height ? max_height : view->natural_height; - int lx = ws->x + (ws->width - width) / 2; - int ly = ws->y + (ws->height - height) / 2; + view->x = ws->x + (ws->width - view->width) / 2; + view->y = ws->y + (ws->height - view->height) / 2; // If the view's border is B_NONE then these properties are ignored. view->border_top = view->border_bottom = true; view->border_left = view->border_right = true; - view_configure(view, lx, ly, width, height); + container_set_geometry_from_floating_view(view->swayc); } void view_autoconfigure(struct sway_view *view) { @@ -153,12 +162,14 @@ void view_autoconfigure(struct sway_view *view) { struct sway_container *output = container_parent(view->swayc, C_OUTPUT); if (view->is_fullscreen) { - view_configure(view, output->x, output->y, output->width, output->height); + view->x = output->x; + view->y = output->y; + view->width = output->width; + view->height = output->height; return; } if (container_is_floating(view->swayc)) { - view_autoconfigure_floating(view); return; } @@ -178,20 +189,22 @@ void view_autoconfigure(struct sway_view *view) { } } + struct sway_container *con = view->swayc; + view->border_top = view->border_bottom = true; view->border_left = view->border_right = true; if (config->hide_edge_borders == E_BOTH || config->hide_edge_borders == E_VERTICAL || (config->hide_edge_borders == E_SMART && !other_views)) { - view->border_left = view->swayc->x != ws->x; - int right_x = view->swayc->x + view->swayc->width; + view->border_left = con->x != ws->x; + int right_x = con->x + con->width; view->border_right = right_x != ws->x + ws->width; } if (config->hide_edge_borders == E_BOTH || config->hide_edge_borders == E_HORIZONTAL || (config->hide_edge_borders == E_SMART && !other_views)) { - view->border_top = view->swayc->y != ws->y; - int bottom_y = view->swayc->y + view->swayc->height; + view->border_top = con->y != ws->y; + int bottom_y = con->y + con->height; view->border_bottom = bottom_y != ws->y + ws->height; } @@ -202,45 +215,44 @@ void view_autoconfigure(struct sway_view *view) { // In a tabbed or stacked container, the swayc's y is the top of the title // area. We have to offset the surface y by the height of the title bar, and // disable any top border because we'll always have the title bar. - if (view->swayc->parent->layout == L_TABBED) { + if (con->parent->layout == L_TABBED) { y_offset = container_titlebar_height(); view->border_top = false; - } else if (view->swayc->parent->layout == L_STACKED) { - y_offset = container_titlebar_height() - * view->swayc->parent->children->length; + } else if (con->parent->layout == L_STACKED) { + y_offset = container_titlebar_height() * con->parent->children->length; view->border_top = false; } switch (view->border) { case B_NONE: - x = view->swayc->x; - y = view->swayc->y + y_offset; - width = view->swayc->width; - height = view->swayc->height - y_offset; + x = con->x; + y = con->y + y_offset; + width = con->width; + height = con->height - y_offset; break; case B_PIXEL: - x = view->swayc->x + view->border_thickness * view->border_left; - y = view->swayc->y + view->border_thickness * view->border_top + y_offset; - width = view->swayc->width + x = con->x + view->border_thickness * view->border_left; + y = con->y + view->border_thickness * view->border_top + y_offset; + width = con->width - view->border_thickness * view->border_left - view->border_thickness * view->border_right; - height = view->swayc->height - y_offset + height = con->height - y_offset - view->border_thickness * view->border_top - view->border_thickness * view->border_bottom; break; case B_NORMAL: // Height is: 1px border + 3px pad + title height + 3px pad + 1px border - x = view->swayc->x + view->border_thickness * view->border_left; - width = view->swayc->width + x = con->x + view->border_thickness * view->border_left; + width = con->width - view->border_thickness * view->border_left - view->border_thickness * view->border_right; if (y_offset) { - y = view->swayc->y + y_offset; - height = view->swayc->height - y_offset + y = con->y + y_offset; + height = con->height - y_offset - view->border_thickness * view->border_bottom; } else { - y = view->swayc->y + container_titlebar_height(); - height = view->swayc->height - container_titlebar_height() + y = con->y + container_titlebar_height(); + height = con->height - container_titlebar_height() - view->border_thickness * view->border_bottom; } break; @@ -248,7 +260,8 @@ void view_autoconfigure(struct sway_view *view) { view->x = x; view->y = y; - view_configure(view, x, y, width, height); + view->width = width; + view->height = height; } void view_set_activated(struct sway_view *view, bool activated) { @@ -257,8 +270,7 @@ void view_set_activated(struct sway_view *view, bool activated) { } } -// Set fullscreen, but without IPC events or arranging windows. -void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { +void view_set_fullscreen(struct sway_view *view, bool fullscreen) { if (view->is_fullscreen == fullscreen) { return; } @@ -304,27 +316,17 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { } else { workspace->sway_workspace->fullscreen = NULL; if (container_is_floating(view->swayc)) { - view_configure(view, view->saved_x, view->saved_y, - view->saved_width, view->saved_height); + view->x = view->saved_x; + view->y = view->saved_y; + view->width = view->saved_width; + view->height = view->saved_height; + container_set_geometry_from_floating_view(view->swayc); } else { view->swayc->width = view->swayc->saved_width; view->swayc->height = view->swayc->saved_height; - view_autoconfigure(view); } } -} -void view_set_fullscreen(struct sway_view *view, bool fullscreen) { - if (view->is_fullscreen == fullscreen) { - return; - } - - view_set_fullscreen_raw(view, fullscreen); - - struct sway_container *workspace = - container_parent(view->swayc, C_WORKSPACE); - arrange_workspace(workspace); - output_damage_whole(workspace->parent->sway_output); ipc_event_window(view->swayc, "fullscreen_mode"); } @@ -507,8 +509,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { if (view->impl->wants_floating && view->impl->wants_floating(view)) { container_set_floating(view->swayc, true); - } else { - arrange_children_of(cont->parent); } input_manager_set_focus(input_manager, cont); @@ -520,7 +520,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { container_notify_subtree_changed(view->swayc->parent); view_execute_criteria(view); - container_damage_whole(cont); view_handle_container_reparent(&view->container_reparent, NULL); } @@ -551,11 +550,7 @@ void view_unmap(struct sway_view *view) { view->title_format = NULL; } - if (parent->type == C_OUTPUT) { - arrange_output(parent); - } else { - arrange_children_of(parent); - } + arrange_and_commit(parent); } void view_update_position(struct sway_view *view, double lx, double ly) { |