wlr-layer-shell-unstable-v1_generated.go RawHistoryFolder
1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: wlr_layer_shell_unstable_v1
3// Source: wlr-layer-shell-unstable-v1.xml
4
5package layershell
6
7import (
8 "sync"
9
10 cross_wl_output "github.com/bnema/wlturbo/protocol/core"
11 cross_wl_surface "github.com/bnema/wlturbo/protocol/core"
12 cross_xdg_popup "github.com/bnema/wlturbo/protocol/xdgshell"
13 "github.com/bnema/wlturbo/wl"
14)
15
16// ERROR_ROLE is the error role value.
17const ERROR_ROLE = 0
18
19// ERROR_INVALID_LAYER is the error invalid_layer value.
20const ERROR_INVALID_LAYER = 1
21
22// ERROR_ALREADY_CONSTRUCTED is the error already_constructed value.
23const ERROR_ALREADY_CONSTRUCTED = 2
24
25// LAYER_BACKGROUND is the layer background value.
26const LAYER_BACKGROUND = 0
27
28// LAYER_BOTTOM is the layer bottom value.
29const LAYER_BOTTOM = 1
30
31// LAYER_TOP is the layer top value.
32const LAYER_TOP = 2
33
34// LAYER_OVERLAY is the layer overlay value.
35const LAYER_OVERLAY = 3
36
37// KEYBOARD_INTERACTIVITY_NONE is the keyboard_interactivity none value.
38const KEYBOARD_INTERACTIVITY_NONE = 0
39
40// KEYBOARD_INTERACTIVITY_EXCLUSIVE is the keyboard_interactivity exclusive value.
41const KEYBOARD_INTERACTIVITY_EXCLUSIVE = 1
42
43// KEYBOARD_INTERACTIVITY_ON_DEMAND is the keyboard_interactivity on_demand value.
44const KEYBOARD_INTERACTIVITY_ON_DEMAND = 2
45
46// ERROR_INVALID_SURFACE_STATE is the error invalid_surface_state value.
47const ERROR_INVALID_SURFACE_STATE = 0
48
49// ERROR_INVALID_SIZE is the error invalid_size value.
50const ERROR_INVALID_SIZE = 1
51
52// ERROR_INVALID_ANCHOR is the error invalid_anchor value.
53const ERROR_INVALID_ANCHOR = 2
54
55// ERROR_INVALID_KEYBOARD_INTERACTIVITY is the error invalid_keyboard_interactivity value.
56const ERROR_INVALID_KEYBOARD_INTERACTIVITY = 3
57
58// ERROR_INVALID_EXCLUSIVE_EDGE is the error invalid_exclusive_edge value.
59const ERROR_INVALID_EXCLUSIVE_EDGE = 4
60
61// ANCHOR_TOP is the anchor top value.
62const ANCHOR_TOP = 1
63
64// ANCHOR_BOTTOM is the anchor bottom value.
65const ANCHOR_BOTTOM = 2
66
67// ANCHOR_LEFT is the anchor left value.
68const ANCHOR_LEFT = 4
69
70// ANCHOR_RIGHT is the anchor right value.
71const ANCHOR_RIGHT = 8
72
73// LayerShellInterface is the protocol interface name.
74const LayerShellInterface = "zwlr_layer_shell_v1"
75
76// LayerShell is the generated binding for zwlr_layer_shell_v1 version 5.
77type LayerShell struct {
78 wl.BaseProxy
79}
80
81// NewLayerShell returns an unbound LayerShell.
82func NewLayerShell(ctx *wl.Context) *LayerShell {
83 obj := &LayerShell{}
84 obj.SetContext(ctx)
85 ctx.Register(obj)
86 return obj
87}
88
89// Create a layer surface for an existing surface. This assigns the role of layer_surface, or raises a protocol error if another role is already assigned. Creating a layer surface from a wl_surface which has a buffer attached or committed is a client error, and any attempts by a client to attach or manipulate a buffer prior to the first layer_surface.configure call must also be treated as errors. After creating a layer_surface object and setting it up, the client must perform an initial commit without any buffer attached. The compositor will reply with a layer_surface.configure event. The client must acknowledge it and is then allowed to attach a buffer to map the surface. You may pass NULL for output to allow the compositor to decide which output to use. Generally this will be the one that the user most recently interacted with. Clients can specify a namespace that defines the purpose of the layer surface.
90func (o *LayerShell) GetLayerSurface(surface *cross_wl_surface.Surface, output *cross_wl_output.Output, layer uint32, namespace string) (*LayerSurface, error) {
91 var arg1 wl.Object
92 if surface != nil {
93 arg1 = surface
94 }
95 var arg2 wl.Object
96 if output != nil {
97 arg2 = output
98 }
99 child := &LayerSurface{}
100 child.SetContext(o.Context())
101 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_layer_shell_v1.get_layer_surface", Child: child}, child, arg1, arg2, layer, namespace); err != nil {
102 return nil, err
103 }
104 return child, nil
105}
106
107// This request indicates that the client will not use the layer_shell object any more. Objects that have been created through this instance are not affected.
108func (o *LayerShell) Destroy() error {
109 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_layer_shell_v1.destroy", Since: 3, Destructor: true}); err != nil {
110 return err
111 }
112 return nil
113}
114
115// EventSignature returns the declared event argument types in wire order.
116func (o *LayerShell) EventSignature(opcode uint16) (string, bool) {
117 switch opcode {
118 default:
119 return "", false
120 }
121}
122
123// Dispatch decodes one event on zwlr_layer_shell_v1 and calls the registered handlers.
124func (o *LayerShell) Dispatch(event *wl.Event) {
125 switch event.Opcode {
126 default:
127 }
128}
129
130// LayerSurfaceInterface is the protocol interface name.
131const LayerSurfaceInterface = "zwlr_layer_surface_v1"
132
133// LayerSurface is the generated binding for zwlr_layer_surface_v1 version 5.
134type LayerSurface struct {
135 wl.BaseProxy
136 // handlersMu guards the handler slices: a client may register or replace
137 // handlers while another goroutine dispatches events.
138 handlersMu sync.Mutex
139 onConfigure []func(serial uint32, width uint32, height uint32)
140 onClosed []func()
141}
142
143// NewLayerSurface returns an unbound LayerSurface.
144func NewLayerSurface(ctx *wl.Context) *LayerSurface {
145 obj := &LayerSurface{}
146 obj.SetContext(ctx)
147 ctx.Register(obj)
148 return obj
149}
150
151// Sets the size of the surface in surface-local coordinates. The compositor will display the surface centered with respect to its anchors. If you pass 0 for either value, the compositor will assign it and inform you of the assignment in the configure event. You must set your anchor to opposite edges in the dimensions you omit; not doing so is a protocol error. Both values are 0 by default. Size is double-buffered, see wl_surface.commit.
152func (o *LayerSurface) SetSize(width uint32, height uint32) error {
153 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_layer_surface_v1.set_size"}, width, height); err != nil {
154 return err
155 }
156 return nil
157}
158
159// Requests that the compositor anchor the surface to the specified edges and corners. If two orthogonal edges are specified (e.g. 'top' and 'left'), then the anchor point will be the intersection of the edges (e.g. the top left corner of the output); otherwise the anchor point will be centered on that edge, or in the center if none is specified. Anchor is double-buffered, see wl_surface.commit.
160func (o *LayerSurface) SetAnchor(anchor uint32) error {
161 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_layer_surface_v1.set_anchor"}, anchor); err != nil {
162 return err
163 }
164 return nil
165}
166
167// Requests that the compositor avoids occluding an area with other surfaces. The compositor's use of this information is implementation-dependent - do not assume that this region will not actually be occluded. A positive value is only meaningful if the surface is anchored to one edge or an edge and both perpendicular edges. If the surface is not anchored, anchored to only two perpendicular edges (a corner), anchored to only two parallel edges or anchored to all edges, a positive value will be treated the same as zero. A positive zone is the distance from the edge in surface-local coordinates to consider exclusive. Surfaces that do not wish to have an exclusive zone may instead specify how they should interact with surfaces that do. If set to zero, the surface indicates that it would like to be moved to avoid occluding surfaces with a positive exclusive zone. If set to -1, the surface indicates that it would not like to be moved to accommodate for other surfaces, and the compositor should extend it all the way to the edges it is anchored to. For example, a panel might set its exclusive zone to 10, so that maximized shell surfaces are not shown on top of it. A notification might set its exclusive zone to 0, so that it is moved to avoid occluding the panel, but shell surfaces are shown underneath it. A wallpaper or lock screen might set their exclusive zone to -1, so that they stretch below or over the panel. The default value is 0. Exclusive zone is double-buffered, see wl_surface.commit.
168func (o *LayerSurface) SetExclusiveZone(zone int32) error {
169 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_layer_surface_v1.set_exclusive_zone"}, zone); err != nil {
170 return err
171 }
172 return nil
173}
174
175// Requests that the surface be placed some distance away from the anchor point on the output, in surface-local coordinates. Setting this value for edges you are not anchored to has no effect. The exclusive zone includes the margin. Margin is double-buffered, see wl_surface.commit.
176func (o *LayerSurface) SetMargin(top int32, right int32, bottom int32, left int32) error {
177 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 3, Name: "zwlr_layer_surface_v1.set_margin"}, top, right, bottom, left); err != nil {
178 return err
179 }
180 return nil
181}
182
183// Set how keyboard events are delivered to this surface. By default, layer shell surfaces do not receive keyboard events; this request can be used to change this. This setting is inherited by child surfaces set by the get_popup request. Layer surfaces receive pointer, touch, and tablet events normally. If you do not want to receive them, set the input region on your surface to an empty region. Keyboard interactivity is double-buffered, see wl_surface.commit.
184func (o *LayerSurface) SetKeyboardInteractivity(keyboardInteractivity uint32) error {
185 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 4, Name: "zwlr_layer_surface_v1.set_keyboard_interactivity"}, keyboardInteractivity); err != nil {
186 return err
187 }
188 return nil
189}
190
191// This assigns an xdg_popup's parent to this layer_surface. This popup should have been created via xdg_surface::get_popup with the parent set to NULL, and this request must be invoked before committing the popup's initial state. See the documentation of xdg_popup for more details about what an xdg_popup is and how it is used.
192func (o *LayerSurface) GetPopup(popup *cross_xdg_popup.XdgPopup) error {
193 var arg0 wl.Object
194 if popup != nil {
195 arg0 = popup
196 }
197 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 5, Name: "zwlr_layer_surface_v1.get_popup"}, arg0); err != nil {
198 return err
199 }
200 return nil
201}
202
203// When a configure event is received, if a client commits the surface in response to the configure event, then the client must make an ack_configure request sometime before the commit request, passing along the serial of the configure event. If the client receives multiple configure events before it can respond to one, it only has to ack the last configure event. A client is not required to commit immediately after sending an ack_configure request - it may even ack_configure several times before its next surface commit. A client may send multiple ack_configure requests before committing, but only the last request sent before a commit indicates which configure event the client really is responding to.
204func (o *LayerSurface) AckConfigure(serial uint32) error {
205 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 6, Name: "zwlr_layer_surface_v1.ack_configure"}, serial); err != nil {
206 return err
207 }
208 return nil
209}
210
211// This request destroys the layer surface.
212func (o *LayerSurface) Destroy() error {
213 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 7, Name: "zwlr_layer_surface_v1.destroy", Destructor: true}); err != nil {
214 return err
215 }
216 return nil
217}
218
219// Change the layer that the surface is rendered on. Layer is double-buffered, see wl_surface.commit.
220func (o *LayerSurface) SetLayer(layer uint32) error {
221 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 8, Name: "zwlr_layer_surface_v1.set_layer", Since: 2}, layer); err != nil {
222 return err
223 }
224 return nil
225}
226
227// Requests an edge for the exclusive zone to apply. The exclusive edge will be automatically deduced from anchor points when possible, but when the surface is anchored to a corner, it will be necessary to set it explicitly to disambiguate, as it is not possible to deduce which one of the two corner edges should be used. The edge must be one the surface is anchored to, otherwise the invalid_exclusive_edge protocol error will be raised.
228func (o *LayerSurface) SetExclusiveEdge(edge uint32) error {
229 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 9, Name: "zwlr_layer_surface_v1.set_exclusive_edge", Since: 5}, edge); err != nil {
230 return err
231 }
232 return nil
233}
234
235// OnConfigure registers a handler for the configure event.
236//
237// Handlers are appended, so a second call adds another handler rather than
238// replacing the first. Registration is safe while another goroutine dispatches.
239func (o *LayerSurface) OnConfigure(handler func(serial uint32, width uint32, height uint32)) {
240 if handler == nil {
241 return
242 }
243 o.handlersMu.Lock()
244 defer o.handlersMu.Unlock()
245 o.onConfigure = append(o.onConfigure, handler)
246}
247
248// handlersForConfigure returns the handlers registered for configure, taken
249// under the lock so a handler may register another handler while events are
250// being dispatched.
251func (o *LayerSurface) handlersForConfigure() []func(serial uint32, width uint32, height uint32) {
252 o.handlersMu.Lock()
253 defer o.handlersMu.Unlock()
254 return o.onConfigure
255}
256
257// OnClosed registers a handler for the closed event.
258//
259// Handlers are appended, so a second call adds another handler rather than
260// replacing the first. Registration is safe while another goroutine dispatches.
261func (o *LayerSurface) OnClosed(handler func()) {
262 if handler == nil {
263 return
264 }
265 o.handlersMu.Lock()
266 defer o.handlersMu.Unlock()
267 o.onClosed = append(o.onClosed, handler)
268}
269
270// handlersForClosed returns the handlers registered for closed, taken
271// under the lock so a handler may register another handler while events are
272// being dispatched.
273func (o *LayerSurface) handlersForClosed() []func() {
274 o.handlersMu.Lock()
275 defer o.handlersMu.Unlock()
276 return o.onClosed
277}
278
279// EventSignature returns the declared event argument types in wire order.
280func (o *LayerSurface) EventSignature(opcode uint16) (string, bool) {
281 switch opcode {
282 case 0:
283 return "uint,uint,uint,", true
284 case 1:
285 return "", true
286 default:
287 return "", false
288 }
289}
290
291// Dispatch decodes one event on zwlr_layer_surface_v1 and calls the registered handlers.
292func (o *LayerSurface) Dispatch(event *wl.Event) {
293 switch event.Opcode {
294 case 0: // configure
295 serial := event.Uint32()
296 width := event.Uint32()
297 height := event.Uint32()
298
299 for i, handler := range o.handlersForConfigure() {
300 _ = i
301 handler(serial, width, height)
302 }
303 case 1: // closed
304
305 for i, handler := range o.handlersForClosed() {
306 _ = i
307 handler()
308 }
309 default:
310 }
311}