Skip to content

Commit

Permalink
Fix some issue with the client preview for the tag and task preview w…
Browse files Browse the repository at this point in the history
…idgets (BlingCorp#128)
  • Loading branch information
Kasper24 authored Nov 3, 2021
1 parent 274df77 commit ab1a25e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
19 changes: 16 additions & 3 deletions widget/tag_preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,22 @@ local enable = function(opts)
})

tag.connect_signal("property::selected", function(t)
for _, c in ipairs(t:clients()) do
c.prev_content = gears.surface.duplicate_surface(c.content)
end
-- 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::tag_preview::update", function(t)
Expand Down
45 changes: 37 additions & 8 deletions widget/task_preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,24 @@ local function draw_widget(
end) then
return
end
local content = gears.surface(c.content)
local cr = cairo.Context(content)
local x, y, w, h = cr:clip_extents()
local 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()

local content = nil
if c.active then
content = gears.surface(c.content)
elseif c.prev_content then
content = gears.surface(c.prev_content)
end

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({
(widget_template or {
Expand Down Expand Up @@ -139,6 +149,25 @@ local enable = function(opts)
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)
if v then
-- Update task preview contents
Expand Down

0 comments on commit ab1a25e

Please sign in to comment.