-
Notifications
You must be signed in to change notification settings - Fork 242
/
decorate-client.lua
106 lines (89 loc) · 2.58 KB
/
decorate-client.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
local awful = require('awful')
local gears = require('gears')
local beautiful = require('beautiful')
local function renderClient(client, mode)
if client.skip_decoration or (client.rendering_mode == mode) then
return
end
client.rendering_mode = mode
client.floating = false
client.maximized = false
client.above = false
client.below = false
client.ontop = false
client.sticky = false
client.maximized_horizontal = false
client.maximized_vertical = false
if client.rendering_mode == 'maximized' then
client.border_width = 0
client.shape = function(cr, w, h)
gears.shape.rectangle(cr, w, h)
end
elseif client.rendering_mode == 'tiled' then
client.border_width = beautiful.border_width
client.shape = function(cr, w, h)
gears.shape.rounded_rect(cr, w, h, 8)
end
end
end
local changesOnScreenCalled = false
local function changesOnScreen(currentScreen)
local tagIsMax = currentScreen.selected_tag ~= nil and currentScreen.selected_tag.layout == awful.layout.suit.max
local clientsToManage = {}
for _, client in pairs(currentScreen.clients) do
if not client.skip_decoration and not client.hidden then
table.insert(clientsToManage, client)
end
end
if (tagIsMax or #clientsToManage == 1) then
currentScreen.client_mode = 'maximized'
else
currentScreen.client_mode = 'tiled'
end
for _, client in pairs(clientsToManage) do
renderClient(client, currentScreen.client_mode)
end
changesOnScreenCalled = false
end
function clientCallback(client)
if not changesOnScreenCalled then
if not client.skip_decoration and client.screen then
changesOnScreenCalled = true
local screen = client.screen
gears.timer.delayed_call(
function()
changesOnScreen(screen)
end
)
end
end
end
function tagCallback(tag)
if not changesOnScreenCalled then
if tag.screen then
changesOnScreenCalled = true
local screen = tag.screen
gears.timer.delayed_call(
function()
changesOnScreen(screen)
end
)
end
end
end
_G.client.connect_signal('manage', clientCallback)
_G.client.connect_signal('unmanage', clientCallback)
_G.client.connect_signal('property::hidden', clientCallback)
_G.client.connect_signal('property::minimized', clientCallback)
_G.client.connect_signal(
'property::fullscreen',
function(c)
if c.fullscreen then
renderClient(c, 'maximized')
else
clientCallback(c)
end
end
)
_G.tag.connect_signal('property::selected', tagCallback)
_G.tag.connect_signal('property::layout', tagCallback)