-
Notifications
You must be signed in to change notification settings - Fork 242
/
backdrop.lua
83 lines (75 loc) · 1.82 KB
/
backdrop.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
local wibox = require('wibox')
local gears = require('gears')
local awful = require('awful')
local function update_backdrop(w, c)
local cairo = require('lgi').cairo
local geo = c.screen.geometry
w.x = geo.x
w.y = geo.y
w.width = geo.width
w.height = geo.height
-- Create an image surface that is as large as the wibox
local shape = cairo.ImageSurface.create(cairo.Format.A1, geo.width, geo.height)
local cr = cairo.Context(shape)
-- Fill with "completely opaque"
cr.operator = 'SOURCE'
cr:set_source_rgba(1, 1, 1, 1)
cr:paint()
-- Remove the shape of the client
local c_geo = c:geometry()
local c_shape = gears.surface(c.shape_bounding)
cr:set_source_rgba(0, 0, 0, 0)
cr:mask_surface(c_shape, c_geo.x + c.border_width - geo.x, c_geo.y + c.border_width - geo.y)
c_shape:finish()
w.shape_bounding = shape._native
shape:finish()
w:draw()
end
local function backdrop(c)
local function update()
update_backdrop(c.backdrop, c)
end
if not c.backdrop then
c.backdrop = wibox {ontop = true, bg = '#00000054', type = 'splash'}
c.backdrop:buttons(
awful.util.table.join(
awful.button(
{},
1,
function()
c:kill()
end
)
)
)
c:connect_signal('property::geometry', update)
c:connect_signal(
'property::shape_client_bounding',
function()
gears.timer.delayed_call(update)
end
)
c:connect_signal(
'unmanage',
function()
c.backdrop.visible = false
end
)
c:connect_signal(
'property::shape_bounding',
function()
gears.timer.delayed_call(update)
end
)
end
update()
c.backdrop.visible = true
end
_G.client.connect_signal(
'manage',
function(c)
if c.drawBackdrop == true then
backdrop(c)
end
end
)