Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagebox: add proper svg resizing #3802

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/wibox/widget/imagebox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ function imagebox:draw(ctx, cr, width, height)

local w, h = self._private.default.width, self._private.default.height

local RsvgRect = Rsvg.Rectangle {x = 0, y = 0, width = w, height = h}
Crylia marked this conversation as resolved.
Show resolved Hide resolved
local svg_surf = cairo.ImageSurface(cairo.Format.ARGB32, w, h)

if self._private.resize then
-- That's for the "fit" policy.
local aspects = {
Expand Down Expand Up @@ -233,7 +236,12 @@ function imagebox:draw(ctx, cr, width, height)
cr:clip(self._private.clip_shape(cr, w*aspects.w, h*aspects.h, unpack(self._private.clip_args)))
end

cr:scale(aspects.w, aspects.h)
if self._private.handle then
RsvgRect = Rsvg.Rectangle {x = 0, y = 0, width = w*aspects.w, height = h*aspects.h }
svg_surf = cairo.ImageSurface(cairo.Format.ARGB32, w*aspects.w, h*aspects.h)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the stacktrace from the failed test actually pointing to this line, but anyway you got the idea :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you marked thread as resolved but test is still failing on this line: https://github.com/awesomeWM/awesome/actions/runs/6042238743/job/16477140356?pr=3802

else
cr:scale(aspects.w, aspects.h)
end
else
if self._private.halign == "center" then
translate.x = math.floor((width - w)/2)
Expand All @@ -256,7 +264,8 @@ function imagebox:draw(ctx, cr, width, height)
end

if self._private.handle then
self._private.handle:render_cairo(cr)
cr:set_source_surface(svg_surf, 0, 0)
Elv13 marked this conversation as resolved.
Show resolved Hide resolved
self._private.handle:render_document(cr, RsvgRect)
else
cr:set_source_surface(self._private.image, 0, 0)

Expand Down