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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0.0)
project(awesome C)
project(awesome_crylia C)

# Require an out-of-source build. We generate an awesomerc.lua in the build dir
# from the one in the source dir and this does not work otherwise.
Expand Down
2 changes: 1 addition & 1 deletion awesomeConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(PROJECT_AWE_NAME awesome)
set(PROJECT_AWE_NAME awesome_crylia)

# If ${SOURCE_DIR} is a git repository VERSION is set to
# `git describe` later.
Expand Down
17 changes: 15 additions & 2 deletions lib/wibox/widget/imagebox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ function imagebox:draw(ctx, cr, width, height)

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

local svg_surf

if self._private.resize then
-- That's for the "fit" policy.
local aspects = {
Expand Down Expand Up @@ -233,7 +235,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
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

self._private.handle:render_document(cr, Rsvg.Rectangle {x = 0, y = 0, width = w*aspects.w, height = h*aspects.h})
else
cr:scale(aspects.w, aspects.h)
end
else
if self._private.halign == "center" then
translate.x = math.floor((width - w)/2)
Expand All @@ -253,10 +260,16 @@ function imagebox:draw(ctx, cr, width, height)
if self._private.clip_shape then
cr:clip(self._private.clip_shape(cr, w, h, unpack(self._private.clip_args)))
end

if self._private.handle then
-- Translation is not needed in the new surface
svg_surf = cairo.ImageSurface(cairo.Format.ARGB32, 0, 0)
self._private.handle:render_document(cr, Rsvg.Rectangle {x = 0, y = 0, width = w, height = h})
end
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
else
cr:set_source_surface(self._private.image, 0, 0)

Expand Down
Loading