-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathroot_panel.go
117 lines (106 loc) · 3.06 KB
/
root_panel.go
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
package main
import (
"github.com/ziutek/mdtwm/xgb_patched"
)
const rightButtonEventMask = xgb.EventMaskButtonPress |
xgb.EventMaskButtonRelease | xgb.EventMaskPointerMotion
// Box for root window
type RootPanel struct {
commonBox
checkWindow Window
}
func NewRootPanel() *RootPanel {
var p RootPanel
p.init(
Window(screen.Root),
xgb.EventMaskSubstructureNotify| // For override-redirect windows
xgb.EventMaskSubstructureRedirect,
)
p.width = int16(screen.WidthInPixels)
p.height = int16(screen.HeightInPixels)
p.w.ChangeAttrs(xgb.CWCursor, uint32(cfg.DefaultCursor))
p.SetClass(cfg.Instance, cfg.Class)
p.SetName("mdtwm root")
// Create infrastructure for check of existence of active WM
p.checkWindow = NewWindow(p.Window(), Geometry{0, 0, 1, 1, 0},
xgb.WindowClassInputOutput, 0)
p.checkWindow.ChangeProp(xgb.PropModeReplace, AtomNetWmName,
AtomUtf8String, p.Name())
p.checkWindow.ChangeProp(xgb.PropModeReplace, AtomNetSupportingWmCheck,
xgb.AtomWindow, p.checkWindow)
p.w.ChangeProp(xgb.PropModeReplace, AtomNetSupportingWmCheck,
xgb.AtomWindow, p.checkWindow)
// Supported WM properties
p.w.ChangeProp(
xgb.PropModeReplace, AtomNetSupported, xgb.AtomAtom,
[]xgb.Id{
AtomNetSupportingWmCheck,
AtomNetWmName,
AtomNetWmDesktop,
AtomNetNumberOfDesktops,
AtomNetCurrentDesktop,
AtomNetWmStateModal,
AtomNetWmStateHidden,
AtomNetActiveWindow,
AtomNetWmStrut,
},
)
p.w.DeleteProp(AtomNetVirtualRoots) // clear for future append
// Grab right mouse buttons for WM actions
p.w.GrabButton(
true, // Needed for EnterNotify events during grab
rightButtonEventMask,
xgb.GrabModeAsync, xgb.GrabModeAsync,
xgb.WindowNone, cfg.DefaultCursor, 3,
cfg.ModMask,
)
p.w.GrabButton(
true,
rightButtonEventMask,
xgb.GrabModeAsync, xgb.GrabModeAsync,
xgb.WindowNone, cfg.DefaultCursor, 3,
cfg.ModMask|xgb.ModMask2,
)
// Grab keys for WM actions
for k, _ := range cfg.Keys {
// For cfg.ModMask
p.w.GrabKey(true, cfg.ModMask, keySymToCode[k], xgb.GrabModeAsync,
xgb.GrabModeAsync)
// For cfg.ModMask + NumLock
p.w.GrabKey(true, cfg.ModMask|xgb.ModMask2, keySymToCode[k],
xgb.GrabModeAsync, xgb.GrabModeAsync)
}
return &p
}
func (p *RootPanel) Geometry() Geometry {
return Geometry{
X: p.x, Y: p.y,
W: p.width, H: p.height,
}
}
func (p *RootPanel) SetPosSize(x, y, width, height int16) {
l.Panic("Can't request a geometry change of root window")
}
func (p *RootPanel) SetFocus(f bool, t xgb.Timestamp) {
return
}
// Inserts a box into panel
func (p *RootPanel) Append(b Box) {
b.SetParent(p)
p.children.PushBack(b)
b.SetPosSize(p.x, p.y, p.width, p.height)
b.SetName("mdtwm desktop")
b.Window().Map()
// Update desktops properties
p.w.ChangeProp(xgb.PropModeReplace, AtomNetNumberOfDesktops,
xgb.AtomCardinal, uint32(p.children.Len()))
p.w.ChangeProp(xgb.PropModeAppend, AtomNetVirtualRoots, xgb.AtomWindow,
b.Window())
}
func (p *RootPanel) InsertNextTo(b, mark Box, x, y int16) {
// TODO: Proper implementation needed.
panic("Unimplemented.")
}
func (p *RootPanel) Remove(b Box) {
p.children.Remove(b)
}