1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: wlr_layer_shell_unstable_v1
3// Source: wlr-layer-shell-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2017 Drew DeVault
7//
8// Permission to use, copy, modify, distribute, and sell this
9// software and its documentation for any purpose is hereby granted
10// without fee, provided that the above copyright notice appear in
11// all copies and that both that copyright notice and this permission
12// notice appear in supporting documentation, and that the name of
13// the copyright holders not be used in advertising or publicity
14// pertaining to distribution of the software without specific,
15// written prior permission. The copyright holders make no
16// representations about the suitability of this software for any
17// purpose. It is provided "as is" without express or implied
18// warranty.
19//
20// THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
21// SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
22// FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23// SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
25// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
27// THIS SOFTWARE.
28
29package wlrlayershell
30
31import (
32 "sync"
33
34 cross_wl_output "github.com/bnema/go-wayland-bindings/client/wayland"
35 cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland"
36 cross_xdg_popup "github.com/bnema/go-wayland-bindings/client/xdgshell"
37 "github.com/bnema/wlturbo/wl"
38)
39
40// ERROR_ROLE is the error role value.
41const ERROR_ROLE = 0
42
43// ERROR_INVALID_LAYER is the error invalid_layer value.
44const ERROR_INVALID_LAYER = 1
45
46// ERROR_ALREADY_CONSTRUCTED is the error already_constructed value.
47const ERROR_ALREADY_CONSTRUCTED = 2
48
49// LAYER_BACKGROUND is the layer background value.
50const LAYER_BACKGROUND = 0
51
52// LAYER_BOTTOM is the layer bottom value.
53const LAYER_BOTTOM = 1
54
55// LAYER_TOP is the layer top value.
56const LAYER_TOP = 2
57
58// LAYER_OVERLAY is the layer overlay value.
59const LAYER_OVERLAY = 3
60
61// KEYBOARD_INTERACTIVITY_NONE is the keyboard_interactivity none value.
62const KEYBOARD_INTERACTIVITY_NONE = 0
63
64// KEYBOARD_INTERACTIVITY_EXCLUSIVE is the keyboard_interactivity exclusive value.
65const KEYBOARD_INTERACTIVITY_EXCLUSIVE = 1
66
67// KEYBOARD_INTERACTIVITY_ON_DEMAND is the keyboard_interactivity on_demand value.
68const KEYBOARD_INTERACTIVITY_ON_DEMAND = 2
69
70// ERROR_INVALID_SURFACE_STATE is the error invalid_surface_state value.
71const ERROR_INVALID_SURFACE_STATE = 0
72
73// ERROR_INVALID_SIZE is the error invalid_size value.
74const ERROR_INVALID_SIZE = 1
75
76// ERROR_INVALID_ANCHOR is the error invalid_anchor value.
77const ERROR_INVALID_ANCHOR = 2
78
79// ERROR_INVALID_KEYBOARD_INTERACTIVITY is the error invalid_keyboard_interactivity value.
80const ERROR_INVALID_KEYBOARD_INTERACTIVITY = 3
81
82// ERROR_INVALID_EXCLUSIVE_EDGE is the error invalid_exclusive_edge value.
83const ERROR_INVALID_EXCLUSIVE_EDGE = 4
84
85// ANCHOR_TOP is the anchor top value.
86const ANCHOR_TOP = 1
87
88// ANCHOR_BOTTOM is the anchor bottom value.
89const ANCHOR_BOTTOM = 2
90
91// ANCHOR_LEFT is the anchor left value.
92const ANCHOR_LEFT = 4
93
94// ANCHOR_RIGHT is the anchor right value.
95const ANCHOR_RIGHT = 8
96
97// LayerShellInterface is the protocol interface name.
98const LayerShellInterface = "zwlr_layer_shell_v1"
99
100// LayerShell is the generated binding for zwlr_layer_shell_v1 version 5.
101type LayerShell struct {
102 wl.BaseProxy
103}
104
105// NewLayerShell returns an unbound LayerShell.
106func NewLayerShell(ctx *wl.Context) *LayerShell {
107 obj := &LayerShell{}
108 obj.SetContext(ctx)
109 ctx.Register(obj)
110 return obj
111}
112
113// 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.
114func (o *LayerShell) GetLayerSurface(surface *cross_wl_surface.Surface, output *cross_wl_output.Output, layer uint32, namespace string) (*LayerSurface, error) {
115 var arg1 wl.Object
116 if surface != nil {
117 arg1 = surface
118 }
119 var arg2 wl.Object
120 if output != nil {
121 arg2 = output
122 }
123 child := &LayerSurface{}
124 child.SetContext(o.Context())
125 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_layer_shell_v1.get_layer_surface", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgObject(arg2), wl.ArgUint(layer), wl.ArgString(namespace)); err != nil {
126 return nil, err
127 }
128 return child, nil
129}
130
131// 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.
132func (o *LayerShell) Destroy() error {
133 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_layer_shell_v1.destroy", Since: 3, Destructor: true}); err != nil {
134 return err
135 }
136 return nil
137}
138
139// EventSignature returns the declared event argument types in wire order.
140func (o *LayerShell) EventSignature(opcode uint16) (string, bool) {
141 switch opcode {
142 default:
143 return "", false
144 }
145}
146
147// Dispatch decodes one event on zwlr_layer_shell_v1 and calls the registered handlers.
148func (o *LayerShell) Dispatch(event *wl.Event) {
149 switch event.Opcode {
150 default:
151 }
152}
153
154// LayerSurfaceInterface is the protocol interface name.
155const LayerSurfaceInterface = "zwlr_layer_surface_v1"
156
157// LayerSurface is the generated binding for zwlr_layer_surface_v1 version 5.
158type LayerSurface struct {
159 wl.BaseProxy
160 // handlersMu guards the handler slices: a client may register or replace
161 // handlers while another goroutine dispatches events.
162 handlersMu sync.Mutex
163 onConfigure []func(serial uint32, width uint32, height uint32)
164 onClosed []func()
165}
166
167// NewLayerSurface returns an unbound LayerSurface.
168func NewLayerSurface(ctx *wl.Context) *LayerSurface {
169 obj := &LayerSurface{}
170 obj.SetContext(ctx)
171 ctx.Register(obj)
172 return obj
173}
174
175// 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.
176func (o *LayerSurface) SetSize(width uint32, height uint32) error {
177 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_layer_surface_v1.set_size"}, wl.ArgUint(width), wl.ArgUint(height)); err != nil {
178 return err
179 }
180 return nil
181}
182
183// 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.
184func (o *LayerSurface) SetAnchor(anchor uint32) error {
185 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_layer_surface_v1.set_anchor"}, wl.ArgUint(anchor)); err != nil {
186 return err
187 }
188 return nil
189}
190
191// 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.
192func (o *LayerSurface) SetExclusiveZone(zone int32) error {
193 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_layer_surface_v1.set_exclusive_zone"}, wl.ArgInt(zone)); err != nil {
194 return err
195 }
196 return nil
197}
198
199// 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.
200func (o *LayerSurface) SetMargin(top int32, right int32, bottom int32, left int32) error {
201 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwlr_layer_surface_v1.set_margin"}, wl.ArgInt(top), wl.ArgInt(right), wl.ArgInt(bottom), wl.ArgInt(left)); err != nil {
202 return err
203 }
204 return nil
205}
206
207// 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.
208func (o *LayerSurface) SetKeyboardInteractivity(keyboardInteractivity uint32) error {
209 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "zwlr_layer_surface_v1.set_keyboard_interactivity"}, wl.ArgUint(keyboardInteractivity)); err != nil {
210 return err
211 }
212 return nil
213}
214
215// 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.
216func (o *LayerSurface) GetPopup(popup *cross_xdg_popup.XdgPopup) error {
217 var arg0 wl.Object
218 if popup != nil {
219 arg0 = popup
220 }
221 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "zwlr_layer_surface_v1.get_popup"}, wl.ArgObject(arg0)); err != nil {
222 return err
223 }
224 return nil
225}
226
227// 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.
228func (o *LayerSurface) AckConfigure(serial uint32) error {
229 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 6, Name: "zwlr_layer_surface_v1.ack_configure"}, wl.ArgUint(serial)); err != nil {
230 return err
231 }
232 return nil
233}
234
235// This request destroys the layer surface.
236func (o *LayerSurface) Destroy() error {
237 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 7, Name: "zwlr_layer_surface_v1.destroy", Destructor: true}); err != nil {
238 return err
239 }
240 return nil
241}
242
243// Change the layer that the surface is rendered on. Layer is double-buffered, see wl_surface.commit.
244func (o *LayerSurface) SetLayer(layer uint32) error {
245 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 8, Name: "zwlr_layer_surface_v1.set_layer", Since: 2}, wl.ArgUint(layer)); err != nil {
246 return err
247 }
248 return nil
249}
250
251// 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.
252func (o *LayerSurface) SetExclusiveEdge(edge uint32) error {
253 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 9, Name: "zwlr_layer_surface_v1.set_exclusive_edge", Since: 5}, wl.ArgUint(edge)); err != nil {
254 return err
255 }
256 return nil
257}
258
259// OnConfigure registers a handler for the configure event.
260//
261// Handlers are appended, so a second call adds another handler rather than
262// replacing the first. Registration is safe while another goroutine dispatches.
263func (o *LayerSurface) OnConfigure(handler func(serial uint32, width uint32, height uint32)) {
264 if handler == nil {
265 return
266 }
267 o.handlersMu.Lock()
268 defer o.handlersMu.Unlock()
269 o.onConfigure = append(o.onConfigure, handler)
270}
271
272// handlersForConfigure returns the handlers registered for configure, taken
273// under the lock so a handler may register another handler while events are
274// being dispatched.
275func (o *LayerSurface) handlersForConfigure() []func(serial uint32, width uint32, height uint32) {
276 o.handlersMu.Lock()
277 defer o.handlersMu.Unlock()
278 return o.onConfigure
279}
280
281// OnClosed registers a handler for the closed event.
282//
283// Handlers are appended, so a second call adds another handler rather than
284// replacing the first. Registration is safe while another goroutine dispatches.
285func (o *LayerSurface) OnClosed(handler func()) {
286 if handler == nil {
287 return
288 }
289 o.handlersMu.Lock()
290 defer o.handlersMu.Unlock()
291 o.onClosed = append(o.onClosed, handler)
292}
293
294// handlersForClosed returns the handlers registered for closed, taken
295// under the lock so a handler may register another handler while events are
296// being dispatched.
297func (o *LayerSurface) handlersForClosed() []func() {
298 o.handlersMu.Lock()
299 defer o.handlersMu.Unlock()
300 return o.onClosed
301}
302
303// EventSignature returns the declared event argument types in wire order.
304func (o *LayerSurface) EventSignature(opcode uint16) (string, bool) {
305 switch opcode {
306 case 0:
307 return "uint,uint,uint,", true
308 case 1:
309 return "", true
310 default:
311 return "", false
312 }
313}
314
315// Dispatch decodes one event on zwlr_layer_surface_v1 and calls the registered handlers.
316func (o *LayerSurface) Dispatch(event *wl.Event) {
317 switch event.Opcode {
318 case 0: // configure
319 serial := event.Uint32()
320 width := event.Uint32()
321 height := event.Uint32()
322
323 for i, handler := range o.handlersForConfigure() {
324 _ = i
325 handler(serial, width, height)
326 }
327 case 1: // closed
328
329 for i, handler := range o.handlersForClosed() {
330 _ = i
331 handler()
332 }
333 default:
334 }
335}