diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index cf6f5b54..d9c721f5 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -21,6 +21,7 @@ #include "sway/tree/arrange.h" #include "sway/tree/view.h" #include "sway/tree/workspace.h" +#include "list.h" #include "log.h" #include "stringop.h" @@ -67,8 +68,7 @@ void container_destroy(struct sway_container *con) { list_free(con->current.children); list_free(con->outputs); - list_foreach(con->marks, free); - list_free(con->marks); + list_free_items_and_destroy(con->marks); wlr_texture_destroy(con->marks_focused); wlr_texture_destroy(con->marks_focused_inactive); wlr_texture_destroy(con->marks_unfocused); @@ -453,19 +453,26 @@ static void update_title_texture(struct sway_container *con, int width = 0; int height = con->title_height * scale; - cairo_t *c = cairo_create(NULL); + // We must use a non-nil cairo_t for cairo_set_font_options to work. + // Therefore, we cannot use cairo_create(NULL). + cairo_surface_t *dummy_surface = cairo_image_surface_create( + CAIRO_FORMAT_ARGB32, 0, 0); + cairo_t *c = cairo_create(dummy_surface); + cairo_set_antialias(c, CAIRO_ANTIALIAS_BEST); + cairo_font_options_t *fo = cairo_font_options_create(); + cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL); + cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_subpixel_order(fo, to_cairo_subpixel_order(output->wlr_output->subpixel)); + cairo_set_font_options(c, fo); get_text_size(c, config->font, &width, NULL, NULL, scale, config->pango_markup, "%s", con->formatted_title); + cairo_surface_destroy(dummy_surface); cairo_destroy(c); cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, width, height); cairo_t *cairo = cairo_create(surface); cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST); - cairo_font_options_t *fo = cairo_font_options_create(); - cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL); - cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL); - cairo_font_options_set_subpixel_order(fo, to_cairo_subpixel_order(output->wlr_output->subpixel)); cairo_set_font_options(cairo, fo); cairo_font_options_destroy(fo); cairo_set_source_rgba(cairo, class->background[0], class->background[1], @@ -594,7 +601,7 @@ void container_update_representation(struct sway_container *con) { } size_t container_titlebar_height(void) { - return config->font_height + TITLEBAR_V_PADDING * 2; + return config->font_height + config->titlebar_v_padding * 2; } void container_init_floating(struct sway_container *con) { @@ -857,15 +864,7 @@ bool container_has_urgent_child(struct sway_container *container) { void container_end_mouse_operation(struct sway_container *container) { struct sway_seat *seat; wl_list_for_each(seat, &server.input->seats, link) { - if (seat->op_container == container) { - seat->op_target_node = NULL; // ensure tiling move doesn't apply - seat_end_mouse_operation(seat); - } - // If the user is doing a tiling drag over this container, - // keep the operation active but unset the target container. - if (seat->op_target_node == &container->node) { - seat->op_target_node = NULL; - } + seatop_unref(seat, container); } } @@ -979,7 +978,7 @@ void container_discover_outputs(struct sway_container *con) { output_get_box(output, &output_box); struct wlr_box intersection; bool intersects = - wlr_box_intersection(&con_box, &output_box, &intersection); + wlr_box_intersection(&intersection, &con_box, &output_box); int index = list_find(con->outputs, output); if (intersects && index == -1) { @@ -1267,7 +1266,9 @@ bool container_find_and_unmark(char *mark) { } void container_clear_marks(struct sway_container *con) { - list_foreach(con->marks, free); + for (int i = 0; i < con->marks->length; ++i) { + free(con->marks->items[i]); + } con->marks->length = 0; ipc_event_window(con, "mark"); } @@ -1375,3 +1376,16 @@ void container_update_marks_textures(struct sway_container *con) { &config->border_colors.urgent); container_damage_whole(con); } + +void container_raise_floating(struct sway_container *con) { + // Bring container to front by putting it at the end of the floating list. + struct sway_container *floater = con; + while (floater->parent) { + floater = floater->parent; + } + if (container_is_floating(floater)) { + list_move_to_end(floater->workspace->floating, floater); + node_set_dirty(&floater->workspace->node); + } +} + |