mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-19 08:58:18 +02:00
xss-dimmer/xsecurelock: handle case where background is too small
This commit is contained in:
parent
de2c9879bc
commit
76dfac0d99
2 changed files with 16 additions and 10 deletions
|
@ -43,18 +43,22 @@ def on_win_realize(widget, ctx):
|
||||||
|
|
||||||
def on_win_draw(widget, cctx, ctx):
|
def on_win_draw(widget, cctx, ctx):
|
||||||
"""Draw background image."""
|
"""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)
|
cctx.set_operator(cairo.OPERATOR_SOURCE)
|
||||||
if not ctx.background:
|
if not bg:
|
||||||
cctx.set_source_rgba(0, 0, 0, 1)
|
cctx.set_source_rgba(0, 0, 0, 1)
|
||||||
cctx.paint()
|
cctx.paint()
|
||||||
return
|
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.save()
|
||||||
cctx.scale(1 / scale, 1 / scale)
|
cctx.scale(1 / scale, 1 / scale)
|
||||||
Gdk.cairo_set_source_pixbuf(cctx, bg, 0, 0)
|
Gdk.cairo_set_source_pixbuf(cctx, bg, 0, 0)
|
||||||
|
|
|
@ -52,13 +52,15 @@ def on_draw(widget, event, options, background, start):
|
||||||
cctx = event
|
cctx = event
|
||||||
|
|
||||||
# Background
|
# 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)
|
cctx.set_operator(cairo.OPERATOR_SOURCE)
|
||||||
if not background:
|
if not bg:
|
||||||
cctx.set_source_rgba(0, 0, 0, opacity)
|
cctx.set_source_rgba(0, 0, 0, opacity)
|
||||||
cctx.paint()
|
cctx.paint()
|
||||||
else:
|
else:
|
||||||
scale = widget.get_scale_factor()
|
|
||||||
bg = background.new_subpixbuf(x, y, wwidth * scale, wheight * scale)
|
|
||||||
cctx.save()
|
cctx.save()
|
||||||
cctx.scale(1 / scale, 1 / scale)
|
cctx.scale(1 / scale, 1 / scale)
|
||||||
Gdk.cairo_set_source_pixbuf(cctx, bg, 0, 0)
|
Gdk.cairo_set_source_pixbuf(cctx, bg, 0, 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue