Skip to content

Commit

Permalink
wibox.hierarchy:draw: Clear paths after .draw (awesomeWM#2805)
Browse files Browse the repository at this point in the history
Cairo's save/restore methods handle all properties except for the
current path. The path is just left as-is.

A widget's draw method could create some path without consuming it. This
path would then interfere with random things later which did not expect
a path to already exist.

This commits adds calls to cairo_new_path() in the relevant positions to
clean things up.

This not only applies to a widget's draw method, but also
{before,after}_draw_{child,children}. However, these methods could (for
whatever reason) create paths that are to be consumed in one of the
other methods. To keep this working, the path is only cleared after all
of these methods ran.

I do not expect this commit to break anything, because a widget cannot
really assume much about what widget is drawn after it. Especially so,
because partial redraws could mean that some later widget is skipped and
not redrawn.

This should fix the issue reported at
awesomeWM#2804.

Signed-off-by: Uli Schlachter <[email protected]>
  • Loading branch information
psychon authored and Elv13 committed Jul 3, 2019
1 parent fe37eeb commit d4cb8dc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/wibox/hierarchy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ function hierarchy:draw(context, cr)
cr:clip()
call(widget.draw)
cr:restore()
-- Clear any path that the widget might have left
cr:new_path()

-- Draw its children (We already clipped to the draw extents above)
call(widget.before_draw_children)
Expand All @@ -359,6 +361,8 @@ function hierarchy:draw(context, cr)
call(widget.after_draw_child, i, wi:get_widget())
end
call(widget.after_draw_children)
-- Clear any path that the widget might have left
cr:new_path()

-- Apply opacity
if opacity ~= 1 then
Expand Down

0 comments on commit d4cb8dc

Please sign in to comment.