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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
-- Test configuration for decoration and window state controls
-- This file demonstrates the cross-platform decoration and tiling/floating functionality
print("Loading decoration and window state test configuration...")
-- Global decoration settings
srd.set("general.decorations_enabled", true)
srd.set("general.border_width", 3)
srd.set("general.border_color", "#2e3440")
-- Keybindings for decoration and window state controls
srd.bind("Mod4+d", function()
-- Toggle decorations for focused window
local window = srd.window.focused()
if window then
local current = srd.window.get_decorations(window.id)
srd.window.set_decorations(window.id, not current)
print("Toggled decorations for window " .. window.id)
end
end)
srd.bind("Mod4+b", function()
-- Toggle border color for focused window
local window = srd.window.focused()
if window then
srd.window.set_border_color(window.id, 255, 0, 0) -- Red border
print("Set red border for window " .. window.id)
end
end)
srd.bind("Mod4+n", function()
-- Toggle border color back to normal
local window = srd.window.focused()
if window then
srd.window.set_border_color(window.id, 46, 52, 64) -- Default color
print("Reset border color for window " .. window.id)
end
end)
srd.bind("Mod4+w", function()
-- Toggle border width
local window = srd.window.focused()
if window then
srd.window.set_border_width(window.id, 8) -- Thick border
print("Set thick border for window " .. window.id)
end
end)
srd.bind("Mod4+s", function()
-- Reset border width
local window = srd.window.focused()
if window then
srd.window.set_border_width(window.id, 3) -- Normal border
print("Reset border width for window " .. window.id)
end
end)
-- Window state controls
srd.bind("Mod4+f", function()
-- Toggle floating state for focused window
local window = srd.window.focused()
if window then
srd.window.toggle_floating(window.id)
local floating = srd.window.is_floating(window.id)
print("Window " .. window.id .. " floating: " .. tostring(floating))
end
end)
srd.bind("Mod4+t", function()
-- Set window to tiling mode
local window = srd.window.focused()
if window then
srd.window.set_floating(window.id, false)
print("Set window " .. window.id .. " to tiling mode")
end
end)
srd.bind("Mod4+l", function()
-- Set window to floating mode
local window = srd.window.focused()
if window then
srd.window.set_floating(window.id, true)
print("Set window " .. window.id .. " to floating mode")
end
end)
-- Layout switching with decoration awareness
srd.bind("Mod4+1", function()
srd.layout.set("tiling")
print("Switched to tiling layout")
end)
srd.bind("Mod4+2", function()
srd.layout.set("dynamic")
print("Switched to dynamic layout")
end)
srd.bind("Mod4+3", function()
srd.layout.set("floating")
print("Switched to floating layout")
end)
-- Test function to apply decorations to all windows
function apply_test_decorations()
print("Applying test decorations to all windows...")
-- This would iterate through all windows in a real implementation
-- For now, we'll just demonstrate the API
-- Example: Apply red border to window with ID "1"
srd.window.set_border_color("1", 255, 0, 0)
srd.window.set_border_width("1", 5)
-- Example: Apply blue border to window with ID "2"
srd.window.set_border_color("2", 0, 0, 255)
srd.window.set_border_width("2", 3)
-- Example: Disable decorations for window with ID "3"
srd.window.set_decorations("3", false)
print("Test decorations applied")
end
-- Call the test function
apply_test_decorations()
print("Decoration and window state test configuration loaded successfully!")
|