diff --git a/bin/xsecurelock-saver b/bin/xsecurelock-saver index 4721727..24fe52f 100755 --- a/bin/xsecurelock-saver +++ b/bin/xsecurelock-saver @@ -43,18 +43,22 @@ def on_win_realize(widget, ctx): def on_win_draw(widget, cctx, ctx): """Draw background image.""" + x, y = ctx.position + wwidth, wheight = widget.get_size() + scale = widget.get_scale_factor() + bg = None + + if ctx.background: + bg = ctx.background.new_subpixbuf( + x * scale, y * scale, wwidth * scale, wheight * scale + ) + cctx.set_operator(cairo.OPERATOR_SOURCE) - if not ctx.background: + if not bg: cctx.set_source_rgba(0, 0, 0, 1) cctx.paint() return - x, y = ctx.position - wwidth, wheight = widget.get_size() - scale = widget.get_scale_factor() - bg = ctx.background.new_subpixbuf( - x * scale, y * scale, wwidth * scale, wheight * scale - ) cctx.save() cctx.scale(1 / scale, 1 / scale) Gdk.cairo_set_source_pixbuf(cctx, bg, 0, 0) diff --git a/bin/xss-dimmer b/bin/xss-dimmer index 391127f..d4cd681 100755 --- a/bin/xss-dimmer +++ b/bin/xss-dimmer @@ -52,13 +52,15 @@ def on_draw(widget, event, options, background, start): cctx = event # Background + scale = widget.get_scale_factor() + bg = None + if background: + bg = background.new_subpixbuf(x, y, wwidth * scale, wheight * scale) cctx.set_operator(cairo.OPERATOR_SOURCE) - if not background: + if not bg: cctx.set_source_rgba(0, 0, 0, opacity) cctx.paint() else: - scale = widget.get_scale_factor() - bg = background.new_subpixbuf(x, y, wwidth * scale, wheight * scale) cctx.save() cctx.scale(1 / scale, 1 / scale) Gdk.cairo_set_source_pixbuf(cctx, bg, 0, 0)