1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: xdg_activation_v1
3// Source: xdg-activation-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
7// Copyright © 2020 Carlos Garnacho <carlosg@gnome.org>
8//
9// Permission is hereby granted, free of charge, to any person obtaining a
10// copy of this software and associated documentation files (the "Software"),
11// to deal in the Software without restriction, including without limitation
12// the rights to use, copy, modify, merge, publish, distribute, sublicense,
13// and/or sell copies of the Software, and to permit persons to whom the
14// Software is furnished to do so, subject to the following conditions:
15//
16// The above copyright notice and this permission notice (including the next
17// paragraph) shall be included in all copies or substantial portions of the
18// Software.
19//
20// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26// DEALINGS IN THE SOFTWARE.
27
28package xdgactivation
29
30import (
31 "sync"
32
33 cross_wl_seat "github.com/bnema/wlturbo/protocol/core"
34 cross_wl_surface "github.com/bnema/wlturbo/protocol/core"
35 "github.com/bnema/wlturbo/wl"
36)
37
38// ERROR_ALREADY_USED is the error already_used value.
39const ERROR_ALREADY_USED = 0
40
41// XdgActivationInterface is the protocol interface name.
42const XdgActivationInterface = "xdg_activation_v1"
43
44// XdgActivation is the generated binding for xdg_activation_v1 version 1.
45type XdgActivation struct {
46 wl.BaseProxy
47}
48
49// NewXdgActivation returns an unbound XdgActivation.
50func NewXdgActivation(ctx *wl.Context) *XdgActivation {
51 obj := &XdgActivation{}
52 obj.SetContext(ctx)
53 ctx.Register(obj)
54 return obj
55}
56
57// Notify the compositor that the xdg_activation object will no longer be used. The child objects created via this interface are unaffected and should be destroyed separately.
58func (o *XdgActivation) Destroy() error {
59 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "xdg_activation_v1.destroy", Destructor: true}); err != nil {
60 return err
61 }
62 return nil
63}
64
65// Creates an xdg_activation_token_v1 object that will provide the initiating client with a unique token for this activation. This token should be offered to the clients to be activated.
66func (o *XdgActivation) GetActivationToken() (*XdgActivationToken, error) {
67 child := &XdgActivationToken{}
68 child.SetContext(o.Context())
69 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "xdg_activation_v1.get_activation_token", Child: child}, wl.ArgObject(child)); err != nil {
70 return nil, err
71 }
72 return child, nil
73}
74
75// Requests surface activation. It's up to the compositor to display this information as desired, for example by placing the surface above the rest. The compositor may know who requested this by checking the activation token and might decide not to follow through with the activation if it's considered unwanted. Compositors can ignore unknown activation tokens when an invalid token is passed.
76func (o *XdgActivation) Activate(token string, surface *cross_wl_surface.Surface) error {
77 var arg1 wl.Object
78 if surface != nil {
79 arg1 = surface
80 }
81 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "xdg_activation_v1.activate"}, wl.ArgString(token), wl.ArgObject(arg1)); err != nil {
82 return err
83 }
84 return nil
85}
86
87// EventSignature returns the declared event argument types in wire order.
88func (o *XdgActivation) EventSignature(opcode uint16) (string, bool) {
89 switch opcode {
90 default:
91 return "", false
92 }
93}
94
95// Dispatch decodes one event on xdg_activation_v1 and calls the registered handlers.
96func (o *XdgActivation) Dispatch(event *wl.Event) {
97 switch event.Opcode {
98 default:
99 }
100}
101
102// XdgActivationTokenInterface is the protocol interface name.
103const XdgActivationTokenInterface = "xdg_activation_token_v1"
104
105// XdgActivationToken is the generated binding for xdg_activation_token_v1 version 1.
106type XdgActivationToken struct {
107 wl.BaseProxy
108 // handlersMu guards the handler slices: a client may register or replace
109 // handlers while another goroutine dispatches events.
110 handlersMu sync.Mutex
111 onDone []func(token string)
112}
113
114// NewXdgActivationToken returns an unbound XdgActivationToken.
115func NewXdgActivationToken(ctx *wl.Context) *XdgActivationToken {
116 obj := &XdgActivationToken{}
117 obj.SetContext(ctx)
118 ctx.Register(obj)
119 return obj
120}
121
122// Provides information about the seat and serial event that requested the token. The serial can come from an input or focus event. For instance, if a click triggers the launch of a third-party client, the launcher client should send a set_serial request with the serial and seat from the wl_pointer.button event. Some compositors might refuse to activate toplevels when the token doesn't have a valid and recent enough event serial. Must be sent before commit. This information is optional.
123func (o *XdgActivationToken) SetSerial(serial uint32, seat *cross_wl_seat.Seat) error {
124 var arg1 wl.Object
125 if seat != nil {
126 arg1 = seat
127 }
128 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "xdg_activation_token_v1.set_serial"}, wl.ArgUint(serial), wl.ArgObject(arg1)); err != nil {
129 return err
130 }
131 return nil
132}
133
134// The requesting client can specify an app_id to associate the token being created with it. Must be sent before commit. This information is optional.
135func (o *XdgActivationToken) SetAppId(appId string) error {
136 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "xdg_activation_token_v1.set_app_id"}, wl.ArgString(appId)); err != nil {
137 return err
138 }
139 return nil
140}
141
142// This request sets the surface requesting the activation. Note, this is different from the surface that will be activated. Some compositors might refuse to activate toplevels when the token doesn't have a requesting surface. Must be sent before commit. This information is optional.
143func (o *XdgActivationToken) SetSurface(surface *cross_wl_surface.Surface) error {
144 var arg0 wl.Object
145 if surface != nil {
146 arg0 = surface
147 }
148 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "xdg_activation_token_v1.set_surface"}, wl.ArgObject(arg0)); err != nil {
149 return err
150 }
151 return nil
152}
153
154// Requests an activation token based on the different parameters that have been offered through set_serial, set_surface and set_app_id.
155func (o *XdgActivationToken) Commit() error {
156 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "xdg_activation_token_v1.commit"}); err != nil {
157 return err
158 }
159 return nil
160}
161
162// Notify the compositor that the xdg_activation_token_v1 object will no longer be used. The received token stays valid.
163func (o *XdgActivationToken) Destroy() error {
164 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "xdg_activation_token_v1.destroy", Destructor: true}); err != nil {
165 return err
166 }
167 return nil
168}
169
170// OnDone registers a handler for the done event.
171//
172// Handlers are appended, so a second call adds another handler rather than
173// replacing the first. Registration is safe while another goroutine dispatches.
174func (o *XdgActivationToken) OnDone(handler func(token string)) {
175 if handler == nil {
176 return
177 }
178 o.handlersMu.Lock()
179 defer o.handlersMu.Unlock()
180 o.onDone = append(o.onDone, handler)
181}
182
183// handlersForDone returns the handlers registered for done, taken
184// under the lock so a handler may register another handler while events are
185// being dispatched.
186func (o *XdgActivationToken) handlersForDone() []func(token string) {
187 o.handlersMu.Lock()
188 defer o.handlersMu.Unlock()
189 return o.onDone
190}
191
192// EventSignature returns the declared event argument types in wire order.
193func (o *XdgActivationToken) EventSignature(opcode uint16) (string, bool) {
194 switch opcode {
195 case 0:
196 return "string,", true
197 default:
198 return "", false
199 }
200}
201
202// Dispatch decodes one event on xdg_activation_token_v1 and calls the registered handlers.
203func (o *XdgActivationToken) Dispatch(event *wl.Event) {
204 switch event.Opcode {
205 case 0: // done
206 token := event.String()
207
208 for i, handler := range o.handlersForDone() {
209 _ = i
210 handler(token)
211 }
212 default:
213 }
214}