1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2008-2011 Kristian Høgsberg
5// Copyright © 2010-2011 Intel Corporation
6// Copyright © 2012-2013 Collabora, Ltd.
7// Copyright © 2012, 2013 Intel Corporation
8// Copyright © 2015, 2016 Jan Arne Petersen
9// Copyright © 2017, 2018 Red Hat, Inc.
10// Copyright © 2018 Purism SPC
11//
12// Permission is hereby granted, free of charge, to any person obtaining a
13// copy of this software and associated documentation files (the "Software"),
14// to deal in the Software without restriction, including without limitation
15// the rights to use, copy, modify, merge, publish, distribute, sublicense,
16// and/or sell copies of the Software, and to permit persons to whom the
17// Software is furnished to do so, subject to the following conditions:
18//
19// The above copyright notice and this permission notice (including the next
20// paragraph) shall be included in all copies or substantial portions of the
21// Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30
31package inputmethod
32
33import (
34 "fmt"
35 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
36 "github.com/bnema/purego-libwayland/server"
37 "runtime"
38)
39
40var ZwpInputMethodV2Interface *server.Interface
41var ZwpInputPopupSurfaceV2Interface *server.Interface
42var ZwpInputMethodKeyboardGrabV2Interface *server.Interface
43var ZwpInputMethodManagerV2Interface *server.Interface
44
45func init() {
46 ZwpInputMethodV2Interface = &server.Interface{Name: "zwp_input_method_v2", Version: 1}
47 ZwpInputPopupSurfaceV2Interface = &server.Interface{Name: "zwp_input_popup_surface_v2", Version: 1}
48 ZwpInputMethodKeyboardGrabV2Interface = &server.Interface{Name: "zwp_input_method_keyboard_grab_v2", Version: 1}
49 ZwpInputMethodManagerV2Interface = &server.Interface{Name: "zwp_input_method_manager_v2", Version: 1}
50 ZwpInputMethodV2Interface.Requests = []server.Message{
51 {Name: "commit_string", Signature: "s", Types: []*server.Interface{nil}},
52 {Name: "set_preedit_string", Signature: "sii", Types: []*server.Interface{nil, nil, nil}},
53 {Name: "delete_surrounding_text", Signature: "uu", Types: []*server.Interface{nil, nil}},
54 {Name: "commit", Signature: "u", Types: []*server.Interface{nil}},
55 {Name: "get_input_popup_surface", Signature: "no", Types: []*server.Interface{ZwpInputPopupSurfaceV2Interface, wayland.SurfaceInterface}},
56 {Name: "grab_keyboard", Signature: "n", Types: []*server.Interface{ZwpInputMethodKeyboardGrabV2Interface}},
57 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
58 }
59 ZwpInputMethodV2Interface.Events = []server.Message{
60 {Name: "activate", Signature: "", Types: []*server.Interface{}},
61 {Name: "deactivate", Signature: "", Types: []*server.Interface{}},
62 {Name: "surrounding_text", Signature: "suu", Types: []*server.Interface{nil, nil, nil}},
63 {Name: "text_change_cause", Signature: "u", Types: []*server.Interface{nil}},
64 {Name: "content_type", Signature: "uu", Types: []*server.Interface{nil, nil}},
65 {Name: "done", Signature: "", Types: []*server.Interface{}},
66 {Name: "unavailable", Signature: "", Types: []*server.Interface{}},
67 }
68 ZwpInputPopupSurfaceV2Interface.Requests = []server.Message{
69 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
70 }
71 ZwpInputPopupSurfaceV2Interface.Events = []server.Message{
72 {Name: "text_input_rectangle", Signature: "iiii", Types: []*server.Interface{nil, nil, nil, nil}},
73 }
74 ZwpInputMethodKeyboardGrabV2Interface.Requests = []server.Message{
75 {Name: "release", Signature: "", Types: []*server.Interface{}},
76 }
77 ZwpInputMethodKeyboardGrabV2Interface.Events = []server.Message{
78 {Name: "keymap", Signature: "uhu", Types: []*server.Interface{nil, nil, nil}},
79 {Name: "key", Signature: "uuuu", Types: []*server.Interface{nil, nil, nil, nil}},
80 {Name: "modifiers", Signature: "uuuuu", Types: []*server.Interface{nil, nil, nil, nil, nil}},
81 {Name: "repeat_info", Signature: "ii", Types: []*server.Interface{nil, nil}},
82 }
83 ZwpInputMethodManagerV2Interface.Requests = []server.Message{
84 {Name: "get_input_method", Signature: "on", Types: []*server.Interface{wayland.SeatInterface, ZwpInputMethodV2Interface}},
85 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
86 }
87 ZwpInputMethodManagerV2Interface.Events = []server.Message{}
88 if err := server.NewInterfaces(ZwpInputMethodV2Interface, ZwpInputPopupSurfaceV2Interface, ZwpInputMethodKeyboardGrabV2Interface, ZwpInputMethodManagerV2Interface); err != nil {
89 panic(err)
90 }
91}
92
93// ZwpInputMethodV2 input method.
94type ZwpInputMethodV2 struct{ *server.Resource }
95
96func WrapZwpInputMethodV2(r *server.Resource) *ZwpInputMethodV2 {
97 if r == nil {
98 return nil
99 }
100 return &ZwpInputMethodV2{r}
101}
102
103const ZwpInputMethodV2RequestCommitString uint32 = 0
104const ZwpInputMethodV2RequestSetPreeditString uint32 = 1
105const ZwpInputMethodV2RequestDeleteSurroundingText uint32 = 2
106const ZwpInputMethodV2RequestCommit uint32 = 3
107const ZwpInputMethodV2RequestGetInputPopupSurface uint32 = 4
108const ZwpInputMethodV2RequestGrabKeyboard uint32 = 5
109const ZwpInputMethodV2RequestDestroy uint32 = 6
110const ZwpInputMethodV2EventActivate uint32 = 0
111const ZwpInputMethodV2EventDeactivate uint32 = 1
112const ZwpInputMethodV2EventSurroundingText uint32 = 2
113const ZwpInputMethodV2EventTextChangeCause uint32 = 3
114const ZwpInputMethodV2EventContentType uint32 = 4
115const ZwpInputMethodV2EventDone uint32 = 5
116const ZwpInputMethodV2EventUnavailable uint32 = 6
117
118// ZwpInputMethodV2Error .
119type ZwpInputMethodV2Error uint32
120
121const (
122 ZwpInputMethodV2ErrorRole ZwpInputMethodV2Error = 0
123)
124
125// ZwpInputMethodV2Handler handles zwp_input_method_v2 requests.
126type ZwpInputMethodV2Handler interface {
127 CommitString(self *ZwpInputMethodV2, text string)
128 SetPreeditString(self *ZwpInputMethodV2, text string, cursorBegin int32, cursorEnd int32)
129 DeleteSurroundingText(self *ZwpInputMethodV2, beforeLength uint32, afterLength uint32)
130 Commit(self *ZwpInputMethodV2, serial uint32)
131 GetInputPopupSurface(self *ZwpInputMethodV2, id uint32, surface *wayland.Surface)
132 GrabKeyboard(self *ZwpInputMethodV2, keyboard uint32)
133 Destroy(self *ZwpInputMethodV2)
134}
135
136func NewZwpInputMethodV2(c server.Client, version int32, id uint32, h ZwpInputMethodV2Handler) (*ZwpInputMethodV2, error) {
137 if h == nil {
138 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_method_v2")
139 }
140 var self *ZwpInputMethodV2
141 r, err := c.CreateResource(ZwpInputMethodV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
142 switch opcode {
143 case 0:
144 h.CommitString(self, args[0].String())
145 case 1:
146 h.SetPreeditString(self, args[0].String(), args[1].Int(), args[2].Int())
147 case 2:
148 h.DeleteSurroundingText(self, args[0].Uint(), args[1].Uint())
149 case 3:
150 h.Commit(self, args[0].Uint())
151 case 4:
152 h.GetInputPopupSurface(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
153 case 5:
154 h.GrabKeyboard(self, args[0].NewID())
155 case 6:
156 h.Destroy(self)
157 self.Destroy()
158 }
159 })
160 if err != nil {
161 return nil, err
162 }
163 self = WrapZwpInputMethodV2(r)
164 r.Data = self
165 return self, nil
166}
167
168// SendActivate input method has been requested.
169func (self *ZwpInputMethodV2) SendActivate() {
170 self.PostEvent(ZwpInputMethodV2EventActivate)
171}
172
173// SendDeactivate deactivate event.
174func (self *ZwpInputMethodV2) SendDeactivate() {
175 self.PostEvent(ZwpInputMethodV2EventDeactivate)
176}
177
178// SendSurroundingText surrounding text event.
179func (self *ZwpInputMethodV2) SendSurroundingText(text string, cursor uint32, anchor uint32) {
180 var p runtime.Pinner
181 defer p.Unpin()
182 self.PostEvent(ZwpInputMethodV2EventSurroundingText, server.String(&p, text, false), server.Uint(cursor), server.Uint(anchor))
183}
184
185// SendTextChangeCause indicates the cause of surrounding text change.
186func (self *ZwpInputMethodV2) SendTextChangeCause(cause uint32) {
187 self.PostEvent(ZwpInputMethodV2EventTextChangeCause, server.Uint(cause))
188}
189
190// SendContentType content purpose and hint.
191func (self *ZwpInputMethodV2) SendContentType(hint uint32, purpose uint32) {
192 self.PostEvent(ZwpInputMethodV2EventContentType, server.Uint(hint), server.Uint(purpose))
193}
194
195// SendDone apply state.
196func (self *ZwpInputMethodV2) SendDone() {
197 self.PostEvent(ZwpInputMethodV2EventDone)
198}
199
200// SendUnavailable input method unavailable.
201func (self *ZwpInputMethodV2) SendUnavailable() {
202 self.PostEvent(ZwpInputMethodV2EventUnavailable)
203}
204func NewZwpInputMethodV2Global(d *server.Display, version int32, bind server.BindFunc) error {
205 return d.CreateGlobal(ZwpInputMethodV2Interface, version, bind)
206}
207
208// ZwpInputPopupSurfaceV2 popup surface.
209type ZwpInputPopupSurfaceV2 struct{ *server.Resource }
210
211func WrapZwpInputPopupSurfaceV2(r *server.Resource) *ZwpInputPopupSurfaceV2 {
212 if r == nil {
213 return nil
214 }
215 return &ZwpInputPopupSurfaceV2{r}
216}
217
218const ZwpInputPopupSurfaceV2RequestDestroy uint32 = 0
219const ZwpInputPopupSurfaceV2EventTextInputRectangle uint32 = 0
220
221// ZwpInputPopupSurfaceV2Handler handles zwp_input_popup_surface_v2 requests.
222type ZwpInputPopupSurfaceV2Handler interface {
223 Destroy(self *ZwpInputPopupSurfaceV2)
224}
225
226func NewZwpInputPopupSurfaceV2(c server.Client, version int32, id uint32, h ZwpInputPopupSurfaceV2Handler) (*ZwpInputPopupSurfaceV2, error) {
227 if h == nil {
228 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_popup_surface_v2")
229 }
230 var self *ZwpInputPopupSurfaceV2
231 r, err := c.CreateResource(ZwpInputPopupSurfaceV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
232 switch opcode {
233 case 0:
234 h.Destroy(self)
235 self.Destroy()
236 }
237 })
238 if err != nil {
239 return nil, err
240 }
241 self = WrapZwpInputPopupSurfaceV2(r)
242 r.Data = self
243 return self, nil
244}
245
246// SendTextInputRectangle set text input area position.
247func (self *ZwpInputPopupSurfaceV2) SendTextInputRectangle(x int32, y int32, width int32, height int32) {
248 self.PostEvent(ZwpInputPopupSurfaceV2EventTextInputRectangle, server.Int(x), server.Int(y), server.Int(width), server.Int(height))
249}
250func NewZwpInputPopupSurfaceV2Global(d *server.Display, version int32, bind server.BindFunc) error {
251 return d.CreateGlobal(ZwpInputPopupSurfaceV2Interface, version, bind)
252}
253
254// ZwpInputMethodKeyboardGrabV2 keyboard grab.
255type ZwpInputMethodKeyboardGrabV2 struct{ *server.Resource }
256
257func WrapZwpInputMethodKeyboardGrabV2(r *server.Resource) *ZwpInputMethodKeyboardGrabV2 {
258 if r == nil {
259 return nil
260 }
261 return &ZwpInputMethodKeyboardGrabV2{r}
262}
263
264const ZwpInputMethodKeyboardGrabV2RequestRelease uint32 = 0
265const ZwpInputMethodKeyboardGrabV2EventKeymap uint32 = 0
266const ZwpInputMethodKeyboardGrabV2EventKey uint32 = 1
267const ZwpInputMethodKeyboardGrabV2EventModifiers uint32 = 2
268const ZwpInputMethodKeyboardGrabV2EventRepeatInfo uint32 = 3
269
270// ZwpInputMethodKeyboardGrabV2Handler handles zwp_input_method_keyboard_grab_v2 requests.
271type ZwpInputMethodKeyboardGrabV2Handler interface {
272 Release(self *ZwpInputMethodKeyboardGrabV2)
273}
274
275func NewZwpInputMethodKeyboardGrabV2(c server.Client, version int32, id uint32, h ZwpInputMethodKeyboardGrabV2Handler) (*ZwpInputMethodKeyboardGrabV2, error) {
276 if h == nil {
277 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_method_keyboard_grab_v2")
278 }
279 var self *ZwpInputMethodKeyboardGrabV2
280 r, err := c.CreateResource(ZwpInputMethodKeyboardGrabV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
281 switch opcode {
282 case 0:
283 h.Release(self)
284 self.Destroy()
285 }
286 })
287 if err != nil {
288 return nil, err
289 }
290 self = WrapZwpInputMethodKeyboardGrabV2(r)
291 r.Data = self
292 return self, nil
293}
294
295// SendKeymap keyboard mapping.
296func (self *ZwpInputMethodKeyboardGrabV2) SendKeymap(format uint32, fd int, size uint32) {
297 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventKeymap, server.Uint(format), server.Fd(fd), server.Uint(size))
298}
299
300// SendKey key event.
301func (self *ZwpInputMethodKeyboardGrabV2) SendKey(serial uint32, time uint32, key uint32, state uint32) {
302 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventKey, server.Uint(serial), server.Uint(time), server.Uint(key), server.Uint(state))
303}
304
305// SendModifiers modifier and group state.
306func (self *ZwpInputMethodKeyboardGrabV2) SendModifiers(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32) {
307 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventModifiers, server.Uint(serial), server.Uint(modsDepressed), server.Uint(modsLatched), server.Uint(modsLocked), server.Uint(group))
308}
309
310// SendRepeatInfo repeat rate and delay.
311func (self *ZwpInputMethodKeyboardGrabV2) SendRepeatInfo(rate int32, delay int32) {
312 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventRepeatInfo, server.Int(rate), server.Int(delay))
313}
314func NewZwpInputMethodKeyboardGrabV2Global(d *server.Display, version int32, bind server.BindFunc) error {
315 return d.CreateGlobal(ZwpInputMethodKeyboardGrabV2Interface, version, bind)
316}
317
318// ZwpInputMethodManagerV2 input method manager.
319type ZwpInputMethodManagerV2 struct{ *server.Resource }
320
321func WrapZwpInputMethodManagerV2(r *server.Resource) *ZwpInputMethodManagerV2 {
322 if r == nil {
323 return nil
324 }
325 return &ZwpInputMethodManagerV2{r}
326}
327
328const ZwpInputMethodManagerV2RequestGetInputMethod uint32 = 0
329const ZwpInputMethodManagerV2RequestDestroy uint32 = 1
330
331// ZwpInputMethodManagerV2Handler handles zwp_input_method_manager_v2 requests.
332type ZwpInputMethodManagerV2Handler interface {
333 GetInputMethod(self *ZwpInputMethodManagerV2, seat *wayland.Seat, inputMethod uint32)
334 Destroy(self *ZwpInputMethodManagerV2)
335}
336
337func NewZwpInputMethodManagerV2(c server.Client, version int32, id uint32, h ZwpInputMethodManagerV2Handler) (*ZwpInputMethodManagerV2, error) {
338 if h == nil {
339 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_method_manager_v2")
340 }
341 var self *ZwpInputMethodManagerV2
342 r, err := c.CreateResource(ZwpInputMethodManagerV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
343 switch opcode {
344 case 0:
345 h.GetInputMethod(self, wayland.WrapSeat(args[0].Resource()), args[1].NewID())
346 case 1:
347 h.Destroy(self)
348 self.Destroy()
349 }
350 })
351 if err != nil {
352 return nil, err
353 }
354 self = WrapZwpInputMethodManagerV2(r)
355 r.Data = self
356 return self, nil
357}
358func NewZwpInputMethodManagerV2Global(d *server.Display, version int32, bind server.BindFunc) error {
359 return d.CreateGlobal(ZwpInputMethodManagerV2Interface, version, bind)
360}
361func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
362 if v == nil {
363 return nil
364 }
365 return v.GetResource()
366}
367func (self *ZwpInputMethodV2) GetResource() *server.Resource {
368 if self == nil {
369 return nil
370 }
371 return self.Resource
372}
373func (self *ZwpInputPopupSurfaceV2) GetResource() *server.Resource {
374 if self == nil {
375 return nil
376 }
377 return self.Resource
378}
379func (self *ZwpInputMethodKeyboardGrabV2) GetResource() *server.Resource {
380 if self == nil {
381 return nil
382 }
383 return self.Resource
384}
385func (self *ZwpInputMethodManagerV2) GetResource() *server.Resource {
386 if self == nil {
387 return nil
388 }
389 return self.Resource
390}