1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
5// Copyright © 2020 Carlos Garnacho <carlosg@gnome.org>
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice (including the next
15// paragraph) shall be included in all copies or substantial portions of the
16// Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24// DEALINGS IN THE SOFTWARE.
25
26package xdgactivation
27
28import (
29 "fmt"
30 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
31 "github.com/bnema/purego-libwayland/server"
32 "runtime"
33)
34
35var ActivationV1Interface *server.Interface
36var ActivationTokenV1Interface *server.Interface
37
38func init() {
39 ActivationV1Interface = &server.Interface{Name: "xdg_activation_v1", Version: 1}
40 ActivationTokenV1Interface = &server.Interface{Name: "xdg_activation_token_v1", Version: 1}
41 ActivationV1Interface.Requests = []server.Message{
42 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
43 {Name: "get_activation_token", Signature: "n", Types: []*server.Interface{ActivationTokenV1Interface}},
44 {Name: "activate", Signature: "so", Types: []*server.Interface{nil, wayland.SurfaceInterface}},
45 }
46 ActivationV1Interface.Events = []server.Message{}
47 ActivationTokenV1Interface.Requests = []server.Message{
48 {Name: "set_serial", Signature: "uo", Types: []*server.Interface{nil, wayland.SeatInterface}},
49 {Name: "set_app_id", Signature: "s", Types: []*server.Interface{nil}},
50 {Name: "set_surface", Signature: "o", Types: []*server.Interface{wayland.SurfaceInterface}},
51 {Name: "commit", Signature: "", Types: []*server.Interface{}},
52 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
53 }
54 ActivationTokenV1Interface.Events = []server.Message{
55 {Name: "done", Signature: "s", Types: []*server.Interface{nil}},
56 }
57 if err := server.NewInterfaces(ActivationV1Interface, ActivationTokenV1Interface); err != nil {
58 panic(err)
59 }
60}
61
62// ActivationV1 interface for activating surfaces.
63type ActivationV1 struct{ *server.Resource }
64
65func WrapActivationV1(r *server.Resource) *ActivationV1 {
66 if r == nil {
67 return nil
68 }
69 return &ActivationV1{r}
70}
71
72const ActivationV1RequestDestroy uint32 = 0
73const ActivationV1RequestGetActivationToken uint32 = 1
74const ActivationV1RequestActivate uint32 = 2
75
76// ActivationV1Handler handles xdg_activation_v1 requests.
77type ActivationV1Handler interface {
78 Destroy(self *ActivationV1)
79 GetActivationToken(self *ActivationV1, id uint32)
80 Activate(self *ActivationV1, token string, surface *wayland.Surface)
81}
82
83func NewActivationV1(c server.Client, version int32, id uint32, h ActivationV1Handler) (*ActivationV1, error) {
84 if h == nil {
85 return nil, fmt.Errorf("purego-libwayland: nil handler for xdg_activation_v1")
86 }
87 var self *ActivationV1
88 r, err := c.CreateResource(ActivationV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
89 switch opcode {
90 case 0:
91 h.Destroy(self)
92 self.Destroy()
93 case 1:
94 h.GetActivationToken(self, args[0].NewID())
95 case 2:
96 h.Activate(self, args[0].String(), wayland.WrapSurface(args[1].Resource()))
97 }
98 })
99 if err != nil {
100 return nil, err
101 }
102 self = WrapActivationV1(r)
103 r.Data = self
104 return self, nil
105}
106func NewActivationV1Global(d *server.Display, version int32, bind server.BindFunc) error {
107 return d.CreateGlobal(ActivationV1Interface, version, bind)
108}
109
110// ActivationTokenV1 an exported activation handle.
111type ActivationTokenV1 struct{ *server.Resource }
112
113func WrapActivationTokenV1(r *server.Resource) *ActivationTokenV1 {
114 if r == nil {
115 return nil
116 }
117 return &ActivationTokenV1{r}
118}
119
120const ActivationTokenV1RequestSetSerial uint32 = 0
121const ActivationTokenV1RequestSetAppId uint32 = 1
122const ActivationTokenV1RequestSetSurface uint32 = 2
123const ActivationTokenV1RequestCommit uint32 = 3
124const ActivationTokenV1RequestDestroy uint32 = 4
125const ActivationTokenV1EventDone uint32 = 0
126
127// ActivationTokenV1Error .
128type ActivationTokenV1Error uint32
129
130const (
131 ActivationTokenV1ErrorAlreadyUsed ActivationTokenV1Error = 0
132)
133
134// ActivationTokenV1Handler handles xdg_activation_token_v1 requests.
135type ActivationTokenV1Handler interface {
136 SetSerial(self *ActivationTokenV1, serial uint32, seat *wayland.Seat)
137 SetAppId(self *ActivationTokenV1, appId string)
138 SetSurface(self *ActivationTokenV1, surface *wayland.Surface)
139 Commit(self *ActivationTokenV1)
140 Destroy(self *ActivationTokenV1)
141}
142
143func NewActivationTokenV1(c server.Client, version int32, id uint32, h ActivationTokenV1Handler) (*ActivationTokenV1, error) {
144 if h == nil {
145 return nil, fmt.Errorf("purego-libwayland: nil handler for xdg_activation_token_v1")
146 }
147 var self *ActivationTokenV1
148 r, err := c.CreateResource(ActivationTokenV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
149 switch opcode {
150 case 0:
151 h.SetSerial(self, args[0].Uint(), wayland.WrapSeat(args[1].Resource()))
152 case 1:
153 h.SetAppId(self, args[0].String())
154 case 2:
155 h.SetSurface(self, wayland.WrapSurface(args[0].Resource()))
156 case 3:
157 h.Commit(self)
158 case 4:
159 h.Destroy(self)
160 self.Destroy()
161 }
162 })
163 if err != nil {
164 return nil, err
165 }
166 self = WrapActivationTokenV1(r)
167 r.Data = self
168 return self, nil
169}
170
171// SendDone the exported activation token.
172func (self *ActivationTokenV1) SendDone(token string) {
173 var p runtime.Pinner
174 defer p.Unpin()
175 self.PostEvent(ActivationTokenV1EventDone, server.String(&p, token, false))
176}
177func NewActivationTokenV1Global(d *server.Display, version int32, bind server.BindFunc) error {
178 return d.CreateGlobal(ActivationTokenV1Interface, version, bind)
179}
180func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
181 if v == nil {
182 return nil
183 }
184 return v.GetResource()
185}
186func (self *ActivationV1) GetResource() *server.Resource {
187 if self == nil {
188 return nil
189 }
190 return self.Resource
191}
192func (self *ActivationTokenV1) GetResource() *server.Resource {
193 if self == nil {
194 return nil
195 }
196 return self.Resource
197}