diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 120 |
1 files changed, 31 insertions, 89 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 950494d8..7bf7325a 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -236,7 +236,12 @@ void view_autoconfigure(struct sway_view *view) { view->border_top = false; } - switch (view->border) { + enum sway_container_border border = view->border; + if (view->using_csd) { + border = B_NONE; + } + + switch (border) { case B_NONE: x = con->x; y = con->y + y_offset; @@ -364,48 +369,6 @@ static void view_handle_surface_new_subsurface(struct wl_listener *listener, view_subsurface_create(view, subsurface); } -static void surface_send_enter_iterator(struct wlr_surface *surface, - int x, int y, void *data) { - struct wlr_output *wlr_output = data; - wlr_surface_send_enter(surface, wlr_output); -} - -static void surface_send_leave_iterator(struct wlr_surface *surface, - int x, int y, void *data) { - struct wlr_output *wlr_output = data; - wlr_surface_send_leave(surface, wlr_output); -} - -static void view_handle_container_reparent(struct wl_listener *listener, - void *data) { - struct sway_view *view = - wl_container_of(listener, view, container_reparent); - struct sway_container *old_parent = data; - - struct sway_container *old_output = old_parent; - if (old_output != NULL && old_output->type != C_OUTPUT) { - old_output = container_parent(old_output, C_OUTPUT); - } - - struct sway_container *new_output = view->swayc->parent; - if (new_output != NULL && new_output->type != C_OUTPUT) { - new_output = container_parent(new_output, C_OUTPUT); - } - - if (old_output == new_output) { - return; - } - - if (old_output != NULL) { - view_for_each_surface(view, surface_send_leave_iterator, - old_output->sway_output->wlr_output); - } - if (new_output != NULL) { - view_for_each_surface(view, surface_send_enter_iterator, - new_output->sway_output->wlr_output); - } -} - static bool view_has_executed_criteria(struct sway_view *view, struct criteria *criteria) { for (int i = 0; i < view->executed_criteria->length; ++i) { @@ -450,12 +413,22 @@ static struct sway_container *select_workspace(struct sway_view *view) { // Check if there's any `assign` criteria for the view list_t *criterias = criteria_for_view(view, - CT_ASSIGN_WORKSPACE | CT_ASSIGN_OUTPUT); + CT_ASSIGN_WORKSPACE | CT_ASSIGN_WORKSPACE_NUMBER | CT_ASSIGN_OUTPUT); struct sway_container *ws = NULL; for (int i = 0; i < criterias->length; ++i) { struct criteria *criteria = criterias->items[i]; - if (criteria->type == CT_ASSIGN_WORKSPACE) { - ws = workspace_by_name(criteria->target); + if (criteria->type == CT_ASSIGN_OUTPUT) { + struct sway_container *output = output_by_name(criteria->target); + if (output) { + ws = seat_get_active_child(seat, output); + break; + } + } else { + // CT_ASSIGN_WORKSPACE(_NUMBER) + ws = criteria->type == CT_ASSIGN_WORKSPACE_NUMBER ? + workspace_by_number(criteria->target) : + workspace_by_name(criteria->target); + if (!ws) { if (strcasecmp(criteria->target, "back_and_forth") == 0) { if (prev_workspace_name) { @@ -466,13 +439,6 @@ static struct sway_container *select_workspace(struct sway_view *view) { } } break; - } else { - // CT_ASSIGN_OUTPUT - struct sway_container *output = output_by_name(criteria->target); - if (output) { - ws = seat_get_active_child(seat, output); - break; - } } } list_free(criterias); @@ -528,7 +494,7 @@ static bool should_focus(struct sway_view *view) { struct sway_container *parent = view->swayc->parent; if (parent->type == C_WORKSPACE && prev_focus == parent) { size_t num_children = parent->children->length + - parent->sway_workspace->floating->children->length; + parent->sway_workspace->floating->length; if (num_children == 1) { return true; } @@ -554,7 +520,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { // If we're about to launch the view into the floating container, then // launch it as a tiled view in the root of the workspace instead. if (container_is_floating(target_sibling)) { - target_sibling = target_sibling->parent->parent; + target_sibling = target_sibling->parent; } view->swayc = container_view_create(target_sibling, view); @@ -564,9 +530,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { &view->surface_new_subsurface); view->surface_new_subsurface.notify = view_handle_surface_new_subsurface; - wl_signal_add(&view->swayc->events.reparent, &view->container_reparent); - view->container_reparent.notify = view_handle_container_reparent; - if (view->impl->wants_floating && view->impl->wants_floating(view)) { view->border = config->floating_border; view->border_thickness = config->floating_border_thickness; @@ -584,15 +547,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { view_update_title(view, false); container_notify_subtree_changed(view->swayc->parent); view_execute_criteria(view); - - view_handle_container_reparent(&view->container_reparent, NULL); } void view_unmap(struct sway_view *view) { wl_signal_emit(&view->events.unmap, view); wl_list_remove(&view->surface_new_subsurface.link); - wl_list_remove(&view->container_reparent.link); if (view->urgent_timer) { wl_event_source_remove(view->urgent_timer); @@ -615,34 +575,16 @@ void view_unmap(struct sway_view *view) { view->surface = NULL; } -void view_update_position(struct sway_view *view, double lx, double ly) { - if (view->x == lx && view->y == ly) { - return; - } - container_damage_whole(view->swayc); - view->x = lx; - view->y = ly; - view->swayc->current.view_x = lx; - view->swayc->current.view_y = ly; - if (container_is_floating(view->swayc)) { - container_set_geometry_from_floating_view(view->swayc); - } - container_damage_whole(view->swayc); -} - void view_update_size(struct sway_view *view, int width, int height) { - if (view->width == width && view->height == height) { + if (!sway_assert(container_is_floating(view->swayc), + "Expected a floating container")) { return; } - container_damage_whole(view->swayc); view->width = width; view->height = height; view->swayc->current.view_width = width; view->swayc->current.view_height = height; - if (container_is_floating(view->swayc)) { - container_set_geometry_from_floating_view(view->swayc); - } - container_damage_whole(view->swayc); + container_set_geometry_from_floating_view(view->swayc); } static void view_subsurface_create(struct sway_view *view, @@ -899,8 +841,8 @@ static bool find_by_mark_iterator(struct sway_container *con, } struct sway_view *view_find_mark(char *mark) { - struct sway_container *container = container_find(&root_container, - find_by_mark_iterator, mark); + struct sway_container *container = root_find_container( + find_by_mark_iterator, mark); if (!container) { return NULL; } @@ -908,7 +850,7 @@ struct sway_view *view_find_mark(char *mark) { } bool view_find_and_unmark(char *mark) { - struct sway_container *container = container_find(&root_container, + struct sway_container *container = root_find_container( find_by_mark_iterator, mark); if (!container) { return false; @@ -952,7 +894,7 @@ void view_add_mark(struct sway_view *view, char *mark) { static void update_marks_texture(struct sway_view *view, struct wlr_texture **texture, struct border_colors *class) { - struct sway_container *output = container_parent(view->swayc, C_OUTPUT); + struct sway_output *output = container_get_effective_output(view->swayc); if (!output) { return; } @@ -988,7 +930,7 @@ static void update_marks_texture(struct sway_view *view, } free(part); - double scale = output->sway_output->wlr_output->scale; + double scale = output->wlr_output->scale; int width = 0; int height = view->swayc->title_height * scale; @@ -1014,7 +956,7 @@ static void update_marks_texture(struct sway_view *view, unsigned char *data = cairo_image_surface_get_data(surface); int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); struct wlr_renderer *renderer = wlr_backend_get_renderer( - output->sway_output->wlr_output->backend); + output->wlr_output->backend); *texture = wlr_texture_from_pixels( renderer, WL_SHM_FORMAT_ARGB8888, stride, width, height, data); cairo_surface_destroy(surface); @@ -1061,7 +1003,7 @@ bool view_is_visible(struct sway_view *view) { // Check view isn't in a tabbed or stacked container on an inactive tab struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *container = view->swayc; - while (container->type != C_WORKSPACE && container->layout != L_FLOATING) { + while (container->type != C_WORKSPACE) { if (container->parent->layout == L_TABBED || container->parent->layout == L_STACKED) { if (seat_get_active_child(seat, container->parent) != container) { |