-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathview.go
198 lines (164 loc) · 5.9 KB
/
view.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package wlc
/*
#cgo LDFLAGS: -lwlc
#include <stdlib.h>
#include <wlc/wlc.h>
*/
import "C"
import "unsafe"
// View is a wlc_handle describing a view object in wlc.
type View C.wlc_handle
// Focus focuses view.
func (v View) Focus() {
C.wlc_view_focus(C.wlc_handle(v))
}
// ViewUnfocus unfocuses all views.
func ViewUnfocus() {
C.wlc_view_focus(0)
}
// Close closes view.
func (v View) Close() {
C.wlc_view_close(C.wlc_handle(v))
}
// GetOutput gets output of view.
func (v View) GetOutput() Output {
return Output(C.wlc_view_get_output(C.wlc_handle(v)))
}
// SetOutput sets output for view. Alternatively output.SetViews() can be used.
func (v View) SetOutput(output Output) {
C.wlc_view_set_output(C.wlc_handle(v), C.wlc_handle(output))
}
// SendToBack sends view behind everything.
func (v View) SendToBack() {
C.wlc_view_send_to_back(C.wlc_handle(v))
}
// SendBelow sends view below another view.
func (v View) SendBelow(other View) {
C.wlc_view_send_below(C.wlc_handle(v), C.wlc_handle(other))
}
// BringAbove brings view above another view.
func (v View) BringAbove(other View) {
C.wlc_view_bring_above(C.wlc_handle(v), C.wlc_handle(other))
}
// BringToFront brings view to front of everything.
func (v View) BringToFront() {
C.wlc_view_bring_to_front(C.wlc_handle(v))
}
// GetMask gets current visibility bitmask.
func (v View) GetMask() uint32 {
return uint32(C.wlc_view_get_mask(C.wlc_handle(v)))
}
// SetMask sets visibility bitmask.
func (v View) SetMask(mask uint32) {
C.wlc_view_set_mask(C.wlc_handle(v), C.uint32_t(mask))
}
// GetGeometry gets current geometry (what the client sees).
func (v View) GetGeometry() *Geometry {
cgeometry := C.wlc_view_get_geometry(C.wlc_handle(v))
return geometryCtoGo(&Geometry{}, cgeometry)
}
// PositionerGetSize gets size requested by positioner, as defined in xdg-shell
// v6.
func (v View) PositionerGetSize() *Size {
csize := C.wlc_view_positioner_get_size(C.wlc_handle(v))
return sizeCtoGo(csize)
}
// PositionerGetAnchorRect gets anchor rectangle requested by positioner, as
// defined in xdg-shell v6.
// Returns nil if view has no valid positioner.
func (v View) PositionerGetAnchorRect() *Geometry {
cgeometry := C.wlc_view_positioner_get_anchor_rect(C.wlc_handle(v))
return geometryCtoGo(&Geometry{}, cgeometry)
}
// PositionerGetOffset gets offset requested by positioner, as defined in
// xdg-shell v6.
// Returns NULL if view has no valid positioner, or default value (0, 0) if
// positioner has no offset set.
func (v View) PositionerGetOffset() *Point {
cpoint := C.wlc_view_positioner_get_offset(C.wlc_handle(v))
return pointCtoGo(cpoint)
}
// PositionerGetAnchor gets anchor requested by positioner, as defined in
// xdg-shell v6.
// Returns default value WLC_BIT_ANCHOR_NONE if view has no valid positioner or
// if positioner has no anchor set.
func (v View) PositionerGetAnchor() PositionerAnchorBit {
return PositionerAnchorBit(C.wlc_view_positioner_get_anchor(C.wlc_handle(v)))
}
// PositionerGetGravity gets anchor requested by positioner, as defined in
// xdg-shell v6.
// Returns default value WLC_BIT_GRAVITY_NONE if view has no valid positioner
// or if positioner has no gravity set.
func (v View) PositionerGetGravity() PositionerGravityBit {
return PositionerGravityBit(C.wlc_view_positioner_get_gravity(C.wlc_handle(v)))
}
// PositionerGetConstraintAdjustment gets constraint adjustment requested by
// positioner, as defined in xdg-shell v6.
// Returns default value WLC_BIT_CONSTRAINT_ADJUSTMENT_NONE if view has no
// valid positioner or if positioner has no constraint adjustment set.
func (v View) PositionerGetConstraintAdjustment() PositionerConstraintAdjustmentBit {
return PositionerConstraintAdjustmentBit(
C.wlc_view_positioner_get_constraint_adjustment(C.wlc_handle(v)),
)
}
// GetVisibleGeometry gets current visible geometry (what wlc displays).
func (v View) GetVisibleGeometry() Geometry {
cgeometry := C.struct_wlc_geometry{}
C.wlc_view_get_visible_geometry(C.wlc_handle(v), &cgeometry)
return *geometryCtoGo(&Geometry{}, &cgeometry)
}
// SetGeometry sets geometry. Set edges if the geometry change is caused by
// interactive resize.
func (v View) SetGeometry(edges uint32, geometry Geometry) {
cgeometry := geometry.c()
defer C.free(unsafe.Pointer(cgeometry))
C.wlc_view_set_geometry(C.wlc_handle(v), C.uint32_t(edges), cgeometry)
}
// GetType gets type bitfield for view.
func (v View) GetType() uint32 {
return uint32(C.wlc_view_get_type(C.wlc_handle(v)))
}
// SetType sets type bit. TOggle indicates whether it is set or not.
func (v View) SetType(typ ViewTypeBit, toggle bool) {
C.wlc_view_set_type(C.wlc_handle(v), uint32(typ), C._Bool(toggle))
}
// GetState gets current state bitfield.
func (v View) GetState() uint32 {
return uint32(C.wlc_view_get_state(C.wlc_handle(v)))
}
// SetState sets state bit. Toggle indicates whether it is set or not.
func (v View) SetState(state ViewStateBit, toggle bool) {
C.wlc_view_set_state(C.wlc_handle(v), uint32(state), C._Bool(toggle))
}
// GetParent gets parent view.
func (v View) GetParent() View {
return View(C.wlc_view_get_parent(C.wlc_handle(v)))
}
// SetParent sets parent view.
func (v View) SetParent(parent View) {
C.wlc_view_set_parent(C.wlc_handle(v), C.wlc_handle(parent))
}
// Title gets title.
func (v View) Title() string {
ctitle := C.wlc_view_get_title(C.wlc_handle(v))
return C.GoString(ctitle)
}
// Instance gets instance (shell-surface only).
func (v View) Instance() string {
cinstance := C.wlc_view_get_instance(C.wlc_handle(v))
return C.GoString(cinstance)
}
// GetClass gets class. (shell-surface only).
func (v View) GetClass() string {
cclass := C.wlc_view_get_class(C.wlc_handle(v))
return C.GoString(cclass)
}
// GetAppID gets app id. (xdg-surface only).
func (v View) GetAppID() string {
capp := C.wlc_view_get_app_id(C.wlc_handle(v))
return C.GoString(capp)
}
// GetPID gets pid of program owning the view.
func (v View) GetPID() int {
return int(C.wlc_view_get_pid(C.wlc_handle(v)))
}