Fix some issue with the client preview for the tag and task preview widgets (#128)

This commit is contained in:
Kasper 2021-11-03 23:59:53 +02:00 committed by GitHub
parent 274df77bba
commit ab1a25e676
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 11 deletions

View File

@ -175,9 +175,22 @@ local enable = function(opts)
}) })
tag.connect_signal("property::selected", function(t) tag.connect_signal("property::selected", function(t)
for _, c in ipairs(t:clients()) do -- Awesome switches up tags on startup really fast it seems, probably depends on what rules you have set
c.prev_content = gears.surface.duplicate_surface(c.content) -- which can cause the c.content to not show the correct image
end gears.timer
{
timeout = 0.1,
call_now = false,
autostart = true,
single_shot = true,
callback = function()
if t.selected == true then
for _, c in ipairs(t:clients()) do
c.prev_content = gears.surface.duplicate_surface(c.content)
end
end
end
}
end) end)
awesome.connect_signal("bling::tag_preview::update", function(t) awesome.connect_signal("bling::tag_preview::update", function(t)

View File

@ -30,14 +30,24 @@ local function draw_widget(
end) then end) then
return return
end end
local content = gears.surface(c.content)
local cr = cairo.Context(content) local content = nil
local x, y, w, h = cr:clip_extents() if c.active then
local img = cairo.ImageSurface.create(cairo.Format.ARGB32, w - x, h - y) content = gears.surface(c.content)
cr = cairo.Context(img) elseif c.prev_content then
cr:set_source_surface(content, 0, 0) content = gears.surface(c.prev_content)
cr.operator = cairo.Operator.SOURCE end
cr:paint()
local img = nil
if content ~= nil then
local cr = cairo.Context(content)
local x, y, w, h = cr:clip_extents()
img = cairo.ImageSurface.create(cairo.Format.ARGB32, w - x, h - y)
cr = cairo.Context(img)
cr:set_source_surface(content, 0, 0)
cr.operator = cairo.Operator.SOURCE
cr:paint()
end
local widget = wibox.widget({ local widget = wibox.widget({
(widget_template or { (widget_template or {
@ -139,6 +149,25 @@ local enable = function(opts)
bg = "#00000000", bg = "#00000000",
}) })
tag.connect_signal("property::selected", function(t)
-- Awesome switches up tags on startup really fast it seems, probably depends on what rules you have set
-- which can cause the c.content to not show the correct image
gears.timer
{
timeout = 0.1,
call_now = false,
autostart = true,
single_shot = true,
callback = function()
if t.selected == true then
for _, c in ipairs(t:clients()) do
c.prev_content = gears.surface.duplicate_surface(c.content)
end
end
end
}
end)
awesome.connect_signal("bling::task_preview::visibility", function(s, v, c) awesome.connect_signal("bling::task_preview::visibility", function(s, v, c)
if v then if v then
-- Update task preview contents -- Update task preview contents