From e677c5b204971af00d71f9a50a89206d01b46a36 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Mon, 2 Apr 2018 08:45:37 -0400 Subject: rename seat functions --- sway/tree/container.c | 2 +- sway/tree/layout.c | 8 ++++---- sway/tree/workspace.c | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'sway/tree') diff --git a/sway/tree/container.c b/sway/tree/container.c index 746dbf1f..2d752862 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -144,7 +144,7 @@ struct sway_container *container_output_create( struct sway_seat *seat = NULL; wl_list_for_each(seat, &input_manager->seats, link) { if (!seat->has_focus) { - sway_seat_set_focus(seat, ws); + seat_set_focus(seat, ws); } } diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ce0682dc..0a766b22 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -404,7 +404,7 @@ static struct sway_container *get_swayc_in_output_direction( return NULL; } - struct sway_container *ws = sway_seat_get_focus_inactive(seat, output); + struct sway_container *ws = seat_get_focus_inactive(seat, output); if (ws->type != C_WORKSPACE) { ws = container_parent(ws, C_WORKSPACE); } @@ -425,7 +425,7 @@ static struct sway_container *get_swayc_in_output_direction( case MOVE_UP: case MOVE_DOWN: { struct sway_container *focused = - sway_seat_get_focus_inactive(seat, ws); + seat_get_focus_inactive(seat, ws); if (focused && focused->parent) { struct sway_container *parent = focused->parent; if (parent->layout == L_VERT) { @@ -509,7 +509,7 @@ static struct sway_container *get_swayc_in_direction_under( struct sway_container *container, enum movement_direction dir, struct sway_seat *seat, struct sway_container *limit) { if (dir == MOVE_CHILD) { - return sway_seat_get_focus_inactive(seat, container); + return seat_get_focus_inactive(seat, container); } struct sway_container *parent = container->parent; @@ -589,7 +589,7 @@ static struct sway_container *get_swayc_in_direction_under( } if (next->children && next->children->length) { // TODO consider floating children as well - return sway_seat_get_focus_inactive(seat, next); + return seat_get_focus_inactive(seat, next); } else { return next; } diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index c629f1f1..c47bab33 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -158,7 +158,7 @@ static bool _workspace_by_name(struct sway_container *view, void *data) { struct sway_container *workspace_by_name(const char *name) { struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *current_workspace = NULL, *current_output = NULL; - struct sway_container *focus = sway_seat_get_focus(seat); + struct sway_container *focus = seat_get_focus(seat); if (focus) { current_workspace = container_parent(focus, C_WORKSPACE); current_output = container_parent(focus, C_OUTPUT); @@ -200,7 +200,7 @@ struct sway_container *workspace_create(const char *name) { // Otherwise create a new one struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *focus = - sway_seat_get_focus_inactive(seat, &root_container); + seat_get_focus_inactive(seat, &root_container); parent = focus; parent = container_parent(parent, C_OUTPUT); struct sway_container *new_ws = container_workspace_create(parent, name); @@ -260,7 +260,7 @@ struct sway_container *workspace_output_prev_next_impl( } struct sway_seat *seat = input_manager_current_seat(input_manager); - struct sway_container *focus = sway_seat_get_focus_inactive(seat, output); + struct sway_container *focus = seat_get_focus_inactive(seat, output); struct sway_container *workspace = (focus->type == C_WORKSPACE ? focus : container_parent(focus, C_WORKSPACE)); @@ -345,7 +345,7 @@ bool workspace_switch(struct sway_container *workspace) { } struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *focus = - sway_seat_get_focus_inactive(seat, &root_container); + seat_get_focus_inactive(seat, &root_container); if (!seat || !focus) { return false; } @@ -376,11 +376,11 @@ bool workspace_switch(struct sway_container *workspace) { wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); - struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace); + struct sway_container *next = seat_get_focus_inactive(seat, workspace); if (next == NULL) { next = workspace; } - sway_seat_set_focus(seat, next); + seat_set_focus(seat, next); struct sway_container *output = container_parent(workspace, C_OUTPUT); arrange_windows(output, -1, -1); return true; @@ -389,7 +389,7 @@ bool workspace_switch(struct sway_container *workspace) { bool workspace_is_visible(struct sway_container *ws) { struct sway_container *output = container_parent(ws, C_OUTPUT); struct sway_seat *seat = input_manager_current_seat(input_manager); - struct sway_container *focus = sway_seat_get_focus_inactive(seat, output); + struct sway_container *focus = seat_get_focus_inactive(seat, output); if (focus->type != C_WORKSPACE) { focus = container_parent(focus, C_WORKSPACE); } -- cgit v1.2.3 From c507727ad240b978c6e09e3aa9238080ca9a1c81 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 2 Apr 2018 11:53:56 -0400 Subject: Fix use-after-free with block hotspots --- common/pango.c | 9 ++++++++- sway/tree/layout.c | 4 ++-- swaybar/i3bar.c | 4 +--- swaybar/render.c | 5 +++-- 4 files changed, 14 insertions(+), 8 deletions(-) (limited to 'sway/tree') diff --git a/common/pango.c b/common/pango.c index 2ae7883c..658d2876 100644 --- a/common/pango.c +++ b/common/pango.c @@ -6,6 +6,7 @@ #include #include #include +#include "log.h" PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, const char *text, int32_t scale, bool markup) { @@ -13,7 +14,13 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, PangoAttrList *attrs; if (markup) { char *buf; - pango_parse_markup(text, -1, 0, &attrs, &buf, NULL, NULL); + GError *error = NULL; + if (!sway_assert(pango_parse_markup( + text, -1, 0, &attrs, &buf, NULL, &error), + "pango_parse_markup '%s' -> error %s", text, + error ? error->message : NULL)) { + return NULL; + } pango_layout_set_markup(layout, buf, -1); free(buf); } else { diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ce0682dc..e8363660 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -248,8 +248,8 @@ void arrange_windows(struct sway_container *container, struct wlr_box *area = &output->sway_output->usable_area; wlr_log(L_DEBUG, "Usable area for ws: %dx%d@%d,%d", area->width, area->height, area->x, area->y); - container->width = area->width; - container->height = area->height; + container->width = width = area->width; + container->height = height = area->height; container->x = x = area->x; container->y = y = area->y; wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index 5e98c4aa..46459e24 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c @@ -30,9 +30,7 @@ static bool i3bar_parse_json(struct status_line *status, const char *text) { status_error(status, "[failed to parse i3bar json]"); return false; } - if (json_object_array_length(results) < 1) { - return true; - } + wlr_log(L_DEBUG, "Got i3bar json: '%s'", text); for (size_t i = 0; i < json_object_array_length(results); ++i) { json_object *full_text, *short_text, *color, *min_width, *align, *urgent; json_object *name, *instance, *separator, *separator_block_width; diff --git a/swaybar/render.c b/swaybar/render.c index a5039a2e..a62e1d01 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -153,7 +153,7 @@ static uint32_t render_status_block(cairo_t *cairo, hotspot->width = width; hotspot->height = height; hotspot->callback = block_hotspot_callback; - hotspot->destroy = free; + hotspot->destroy = NULL; hotspot->data = block; wl_list_insert(&output->hotspots, &hotspot->link); @@ -227,9 +227,9 @@ static uint32_t render_status_line_i3bar(cairo_t *cairo, struct swaybar_config *config, struct swaybar_output *output, struct status_line *status, bool focused, double *x, uint32_t width, uint32_t height) { - struct i3bar_block *block; uint32_t max_height = 0; bool edge = true; + struct i3bar_block *block; wl_list_for_each_reverse(block, &status->blocks, link) { uint32_t h = render_status_block(cairo, config, output, block, x, height, focused, edge); @@ -376,6 +376,7 @@ static uint32_t render_workspace_button(cairo_t *cairo, static uint32_t render_to_cairo(cairo_t *cairo, struct swaybar *bar, struct swaybar_output *output) { struct swaybar_config *config = bar->config; + wlr_log(L_DEBUG, "output %p", output); cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); if (output->focused) { -- cgit v1.2.3