Merge branch 'librsvg-deprecations'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Closes #45
authored by Daniel Eklöf · committed by Daniel Eklöf · parents 4640878, f8000c9 · Browse files · 2 files·+58 added−57 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+58 added−57 removed
- other:+58 added−57 removed
Provenance
- Commit
1abbb16- Tree
368dd75- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent 1
4640878- Parent 2
f8000c9
2 files changed+58 added−57 removed
modified:CHANGELOG.md+6 added
21 unmodified lines2223242526272829303132333435155 unmodified linesExpand all21 unmodified lines
### Deprecated### Removed### Fixed
* Removed usage of deprecated function `rsvg_handle_get_dimensions()` when building against recent versions of librsvg (https://codeberg.org/dnkl/fuzzel/issues/45).
### Security### Contributors
155 unmodified linesExpand allmodified:render.c+52 added-57 removed
305 unmodified lines306 /* If currently selected item has a scalable icon, and if307 * there's "enough" free space, render a large308 * representation of the icon */309 310+ const double size = min(buf->height * 0.618, buf->width * 0.618);311+ const double img_x = (buf->width - size) / 2.;312+ const double img_y = first_row + (buf->height - size) / 2.;313+314+ const double list_end = first_row + match_count * row_height;315+310- if (match->application->icon.type == ICON_SVG) {316+ if (match->application->icon.type == ICON_SVG && img_y > list_end) {317 #if defined(FUZZEL_ENABLE_SVG)318 RsvgHandle *svg = match->application->icon.svg;319+320+ cairo_save(buf->cairo);321+ cairo_set_operator(buf->cairo, CAIRO_OPERATOR_ATOP);322+323+#if LIBRSVG_CHECK_VERSION(2, 46, 0)324+ if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS) {325+ const RsvgRectangle viewport = {326+ .x = img_x,327+ .y = img_y,328+ .width = size,329+ .height = size,330+ };331+ rsvg_handle_render_document(svg, buf->cairo, &viewport, NULL);332+ }333+#else334 RsvgDimensionData dim;335 rsvg_handle_get_dimensions(svg, &dim);336 316- const double max_height = buf->height * 0.618;317- const double max_width = buf->width * 0.618;318-319- const double scale_x = max_width / dim.width;320- const double scale_y = max_height / dim.height;337+ const double scale_x = size / dim.width;338+ const double scale_y = size / dim.height;339 const double scale = scale_x < scale_y ? scale_x : scale_y;340 341 const double height = dim.height * scale;342 const double width = dim.width * scale;343 326- const double img_x = (buf->width - width) / 2.;327- const double img_y = first_row + (buf->height - height) / 2.;344+ cairo_rectangle(buf->cairo, img_x, img_y, height, width);345+ cairo_clip(buf->cairo);346 329- double list_end = first_row + match_count * row_height;347+ /* Translate + scale. Note: order matters! */348+ cairo_translate(buf->cairo, img_x, img_y);349+ cairo_scale(buf->cairo, scale, scale);350 331- if (img_y > list_end) {332-333- cairo_save(buf->cairo);334- cairo_set_operator(buf->cairo, CAIRO_OPERATOR_ATOP);335-336- cairo_rectangle(buf->cairo, img_x, img_y, height, width);337- cairo_clip(buf->cairo);338-339-#if LIBRSVG_CHECK_VERSION(2, 46, 0)340- if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS) {341- RsvgRectangle viewport = {342- .x = img_x,343- .y = img_y,344- .width = width,345- .height = height,346- };347- rsvg_handle_render_document(svg, buf->cairo, &viewport, NULL);348- }349-#else350- /* Translate + scale. Note: order matters! */351- cairo_translate(buf->cairo, img_x, img_y);352- cairo_scale(buf->cairo, scale, scale);353-354- if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS)355- rsvg_handle_render_cairo(svg, buf->cairo);351+ if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS)352+ rsvg_handle_render_cairo(svg, buf->cairo);353 #endif357- cairo_restore(buf->cairo);358- }354+ cairo_restore(buf->cairo);355 #endif /* FUZZEL_ENABLE_SVG */356 }357 358 pixman_color_t sc = rgba2pixman(render->options.selection_color);86 unmodified lines445 }446 447 case ICON_SVG: {448 #if defined(FUZZEL_ENABLE_SVG)453- RsvgDimensionData dim;454- rsvg_handle_get_dimensions(icon->svg, &dim);455-456- double height = render->icon_height;457- double scale = height / dim.height;458-459- double img_x = cur_x;460- double img_y = first_row + i * row_height + (row_height - height) / 2;461- double img_width = dim.width * scale;462- double img_height = dim.height * scale;463-449 cairo_save(buf->cairo);450 cairo_set_operator(buf->cairo, CAIRO_OPERATOR_OVER);451 467- cairo_rectangle(buf->cairo, img_x, img_y, img_width, img_height);468- cairo_clip(buf->cairo);452+ double size = render->icon_height;453+ double img_x = cur_x;454+ double img_y = first_row + i * row_height + (row_height - size) / 2;455 456 #if LIBRSVG_CHECK_VERSION(2, 46, 0)457 if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS) {472- RsvgRectangle viewport = {473- .x = cur_x,474- .y = first_row + i * row_height + (row_height - height) / 2,475- .width = img_width,476- .height = img_height,458+ const RsvgRectangle viewport = {459+ .x = img_x,460+ .y = img_y,461+ .width = size,462+ .height = size,463 };464 rsvg_handle_render_document(icon->svg, buf->cairo, &viewport, NULL);465 }466 #else467+ RsvgDimensionData dim;468+ rsvg_handle_get_dimensions(icon->svg, &dim);469+470+ double scale = size / dim.height;471+472+ double img_width = dim.width * scale;473+ double img_height = dim.height * scale;474+475+ cairo_rectangle(buf->cairo, img_x, img_y, img_width, img_height);476+ cairo_clip(buf->cairo);477+478 /* Translate + scale. Note: order matters! */482- cairo_translate(483- buf->cairo, cur_x,484- first_row + i * row_height + (row_height - height) / 2);479+ cairo_translate(buf->cairo, img_x, img_y);480 cairo_scale(buf->cairo, scale, scale);481 482 if (cairo_status(buf->cairo) == CAIRO_STATUS_SUCCESS)483 rsvg_handle_render_cairo(icon->svg, buf->cairo);125 unmodified lines