xdg-output-unstable-v1_generated.go RawHistoryFolder
1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: xdg_output_unstable_v1
3// Source: xdg-output-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2017 Red Hat Inc.
7//
8// Permission is hereby granted, free of charge, to any person obtaining a
9// copy of this software and associated documentation files (the "Software"),
10// to deal in the Software without restriction, including without limitation
11// the rights to use, copy, modify, merge, publish, distribute, sublicense,
12// and/or sell copies of the Software, and to permit persons to whom the
13// Software is furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice (including the next
16// paragraph) shall be included in all copies or substantial portions of the
17// Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25// DEALINGS IN THE SOFTWARE.
26
27package xdgoutput
28
29import (
30 "sync"
31
32 cross_wl_output "github.com/bnema/wlturbo/protocol/core"
33 "github.com/bnema/wlturbo/wl"
34)
35
36// ZxdgOutputManagerInterface is the protocol interface name.
37const ZxdgOutputManagerInterface = "zxdg_output_manager_v1"
38
39// ZxdgOutputManager is the generated binding for zxdg_output_manager_v1 version 3.
40type ZxdgOutputManager struct {
41 wl.BaseProxy
42}
43
44// NewZxdgOutputManager returns an unbound ZxdgOutputManager.
45func NewZxdgOutputManager(ctx *wl.Context) *ZxdgOutputManager {
46 obj := &ZxdgOutputManager{}
47 obj.SetContext(ctx)
48 ctx.Register(obj)
49 return obj
50}
51
52// Using this request a client can tell the server that it is not going to use the xdg_output_manager object anymore. Any objects already created through this instance are not affected.
53func (o *ZxdgOutputManager) Destroy() error {
54 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zxdg_output_manager_v1.destroy", Destructor: true}); err != nil {
55 return err
56 }
57 return nil
58}
59
60// This creates a new xdg_output object for the given wl_output.
61func (o *ZxdgOutputManager) GetXdgOutput(output *cross_wl_output.Output) (*ZxdgOutput, error) {
62 var arg1 wl.Object
63 if output != nil {
64 arg1 = output
65 }
66 child := &ZxdgOutput{}
67 child.SetContext(o.Context())
68 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zxdg_output_manager_v1.get_xdg_output", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
69 return nil, err
70 }
71 return child, nil
72}
73
74// EventSignature returns the declared event argument types in wire order.
75func (o *ZxdgOutputManager) EventSignature(opcode uint16) (string, bool) {
76 switch opcode {
77 default:
78 return "", false
79 }
80}
81
82// Dispatch decodes one event on zxdg_output_manager_v1 and calls the registered handlers.
83func (o *ZxdgOutputManager) Dispatch(event *wl.Event) {
84 switch event.Opcode {
85 default:
86 }
87}
88
89// ZxdgOutputInterface is the protocol interface name.
90const ZxdgOutputInterface = "zxdg_output_v1"
91
92// ZxdgOutput is the generated binding for zxdg_output_v1 version 3.
93type ZxdgOutput struct {
94 wl.BaseProxy
95 // handlersMu guards the handler slices: a client may register or replace
96 // handlers while another goroutine dispatches events.
97 handlersMu sync.Mutex
98 onLogicalPosition []func(x int32, y int32)
99 onLogicalSize []func(width int32, height int32)
100 onDone []func()
101 onName []func(name string)
102 onDescription []func(description string)
103}
104
105// NewZxdgOutput returns an unbound ZxdgOutput.
106func NewZxdgOutput(ctx *wl.Context) *ZxdgOutput {
107 obj := &ZxdgOutput{}
108 obj.SetContext(ctx)
109 ctx.Register(obj)
110 return obj
111}
112
113// Using this request a client can tell the server that it is not going to use the xdg_output object anymore.
114func (o *ZxdgOutput) Destroy() error {
115 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zxdg_output_v1.destroy", Destructor: true}); err != nil {
116 return err
117 }
118 return nil
119}
120
121// OnLogicalPosition registers a handler for the logical_position event.
122//
123// Handlers are appended, so a second call adds another handler rather than
124// replacing the first. Registration is safe while another goroutine dispatches.
125func (o *ZxdgOutput) OnLogicalPosition(handler func(x int32, y int32)) {
126 if handler == nil {
127 return
128 }
129 o.handlersMu.Lock()
130 defer o.handlersMu.Unlock()
131 o.onLogicalPosition = append(o.onLogicalPosition, handler)
132}
133
134// handlersForLogicalPosition returns the handlers registered for logical_position, taken
135// under the lock so a handler may register another handler while events are
136// being dispatched.
137func (o *ZxdgOutput) handlersForLogicalPosition() []func(x int32, y int32) {
138 o.handlersMu.Lock()
139 defer o.handlersMu.Unlock()
140 return o.onLogicalPosition
141}
142
143// OnLogicalSize registers a handler for the logical_size event.
144//
145// Handlers are appended, so a second call adds another handler rather than
146// replacing the first. Registration is safe while another goroutine dispatches.
147func (o *ZxdgOutput) OnLogicalSize(handler func(width int32, height int32)) {
148 if handler == nil {
149 return
150 }
151 o.handlersMu.Lock()
152 defer o.handlersMu.Unlock()
153 o.onLogicalSize = append(o.onLogicalSize, handler)
154}
155
156// handlersForLogicalSize returns the handlers registered for logical_size, taken
157// under the lock so a handler may register another handler while events are
158// being dispatched.
159func (o *ZxdgOutput) handlersForLogicalSize() []func(width int32, height int32) {
160 o.handlersMu.Lock()
161 defer o.handlersMu.Unlock()
162 return o.onLogicalSize
163}
164
165// OnDone registers a handler for the done event.
166//
167// Handlers are appended, so a second call adds another handler rather than
168// replacing the first. Registration is safe while another goroutine dispatches.
169func (o *ZxdgOutput) OnDone(handler func()) {
170 if handler == nil {
171 return
172 }
173 o.handlersMu.Lock()
174 defer o.handlersMu.Unlock()
175 o.onDone = append(o.onDone, handler)
176}
177
178// handlersForDone returns the handlers registered for done, taken
179// under the lock so a handler may register another handler while events are
180// being dispatched.
181func (o *ZxdgOutput) handlersForDone() []func() {
182 o.handlersMu.Lock()
183 defer o.handlersMu.Unlock()
184 return o.onDone
185}
186
187// OnName registers a handler for the name event.
188//
189// Handlers are appended, so a second call adds another handler rather than
190// replacing the first. Registration is safe while another goroutine dispatches.
191func (o *ZxdgOutput) OnName(handler func(name string)) {
192 if handler == nil {
193 return
194 }
195 o.handlersMu.Lock()
196 defer o.handlersMu.Unlock()
197 o.onName = append(o.onName, handler)
198}
199
200// handlersForName returns the handlers registered for name, taken
201// under the lock so a handler may register another handler while events are
202// being dispatched.
203func (o *ZxdgOutput) handlersForName() []func(name string) {
204 o.handlersMu.Lock()
205 defer o.handlersMu.Unlock()
206 return o.onName
207}
208
209// OnDescription registers a handler for the description event.
210//
211// Handlers are appended, so a second call adds another handler rather than
212// replacing the first. Registration is safe while another goroutine dispatches.
213func (o *ZxdgOutput) OnDescription(handler func(description string)) {
214 if handler == nil {
215 return
216 }
217 o.handlersMu.Lock()
218 defer o.handlersMu.Unlock()
219 o.onDescription = append(o.onDescription, handler)
220}
221
222// handlersForDescription returns the handlers registered for description, taken
223// under the lock so a handler may register another handler while events are
224// being dispatched.
225func (o *ZxdgOutput) handlersForDescription() []func(description string) {
226 o.handlersMu.Lock()
227 defer o.handlersMu.Unlock()
228 return o.onDescription
229}
230
231// EventSignature returns the declared event argument types in wire order.
232func (o *ZxdgOutput) EventSignature(opcode uint16) (string, bool) {
233 switch opcode {
234 case 0:
235 return "int,int,", true
236 case 1:
237 return "int,int,", true
238 case 2:
239 return "", true
240 case 3:
241 return "string,", true
242 case 4:
243 return "string,", true
244 default:
245 return "", false
246 }
247}
248
249// Dispatch decodes one event on zxdg_output_v1 and calls the registered handlers.
250func (o *ZxdgOutput) Dispatch(event *wl.Event) {
251 switch event.Opcode {
252 case 0: // logical_position
253 x := event.Int32()
254 y := event.Int32()
255
256 for i, handler := range o.handlersForLogicalPosition() {
257 _ = i
258 handler(x, y)
259 }
260 case 1: // logical_size
261 width := event.Int32()
262 height := event.Int32()
263
264 for i, handler := range o.handlersForLogicalSize() {
265 _ = i
266 handler(width, height)
267 }
268 case 2: // done
269
270 for i, handler := range o.handlersForDone() {
271 _ = i
272 handler()
273 }
274 case 3: // name
275 name := event.String()
276
277 for i, handler := range o.handlersForName() {
278 _ = i
279 handler(name)
280 }
281 case 4: // description
282 description := event.String()
283
284 for i, handler := range o.handlersForDescription() {
285 _ = i
286 handler(description)
287 }
288 default:
289 }
290}