1// Code generated by wlgen; DO NOT EDIT.
2package inputmethod
3
4import (
5 "fmt"
6 wayland "github.com/bnema/purego-libwayland/protocol/wayland"
7 "github.com/bnema/purego-libwayland/server"
8 "runtime"
9)
10
11var ZwpInputMethodV2Interface *server.Interface
12var ZwpInputPopupSurfaceV2Interface *server.Interface
13var ZwpInputMethodKeyboardGrabV2Interface *server.Interface
14var ZwpInputMethodManagerV2Interface *server.Interface
15
16func init() {
17 ZwpInputMethodV2Interface = &server.Interface{Name: "zwp_input_method_v2", Version: 1}
18 ZwpInputPopupSurfaceV2Interface = &server.Interface{Name: "zwp_input_popup_surface_v2", Version: 1}
19 ZwpInputMethodKeyboardGrabV2Interface = &server.Interface{Name: "zwp_input_method_keyboard_grab_v2", Version: 1}
20 ZwpInputMethodManagerV2Interface = &server.Interface{Name: "zwp_input_method_manager_v2", Version: 1}
21 ZwpInputMethodV2Interface.Requests = []server.Message{
22 {Name: "commit_string", Signature: "s", Types: []*server.Interface{nil}},
23 {Name: "set_preedit_string", Signature: "sii", Types: []*server.Interface{nil, nil, nil}},
24 {Name: "delete_surrounding_text", Signature: "uu", Types: []*server.Interface{nil, nil}},
25 {Name: "commit", Signature: "u", Types: []*server.Interface{nil}},
26 {Name: "get_input_popup_surface", Signature: "no", Types: []*server.Interface{ZwpInputPopupSurfaceV2Interface, wayland.SurfaceInterface}},
27 {Name: "grab_keyboard", Signature: "n", Types: []*server.Interface{ZwpInputMethodKeyboardGrabV2Interface}},
28 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
29 }
30 ZwpInputMethodV2Interface.Events = []server.Message{
31 {Name: "activate", Signature: "", Types: []*server.Interface{}},
32 {Name: "deactivate", Signature: "", Types: []*server.Interface{}},
33 {Name: "surrounding_text", Signature: "suu", Types: []*server.Interface{nil, nil, nil}},
34 {Name: "text_change_cause", Signature: "u", Types: []*server.Interface{nil}},
35 {Name: "content_type", Signature: "uu", Types: []*server.Interface{nil, nil}},
36 {Name: "done", Signature: "", Types: []*server.Interface{}},
37 {Name: "unavailable", Signature: "", Types: []*server.Interface{}},
38 }
39 ZwpInputPopupSurfaceV2Interface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 }
42 ZwpInputPopupSurfaceV2Interface.Events = []server.Message{
43 {Name: "text_input_rectangle", Signature: "iiii", Types: []*server.Interface{nil, nil, nil, nil}},
44 }
45 ZwpInputMethodKeyboardGrabV2Interface.Requests = []server.Message{
46 {Name: "release", Signature: "", Types: []*server.Interface{}},
47 }
48 ZwpInputMethodKeyboardGrabV2Interface.Events = []server.Message{
49 {Name: "keymap", Signature: "uhu", Types: []*server.Interface{nil, nil, nil}},
50 {Name: "key", Signature: "uuuu", Types: []*server.Interface{nil, nil, nil, nil}},
51 {Name: "modifiers", Signature: "uuuuu", Types: []*server.Interface{nil, nil, nil, nil, nil}},
52 {Name: "repeat_info", Signature: "ii", Types: []*server.Interface{nil, nil}},
53 }
54 ZwpInputMethodManagerV2Interface.Requests = []server.Message{
55 {Name: "get_input_method", Signature: "on", Types: []*server.Interface{wayland.SeatInterface, ZwpInputMethodV2Interface}},
56 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
57 }
58 ZwpInputMethodManagerV2Interface.Events = []server.Message{}
59 if err := server.NewInterfaces(ZwpInputMethodV2Interface, ZwpInputPopupSurfaceV2Interface, ZwpInputMethodKeyboardGrabV2Interface, ZwpInputMethodManagerV2Interface); err != nil {
60 panic(err)
61 }
62}
63
64// ZwpInputMethodV2 input method.
65type ZwpInputMethodV2 struct{ *server.Resource }
66
67func WrapZwpInputMethodV2(r *server.Resource) *ZwpInputMethodV2 {
68 if r == nil {
69 return nil
70 }
71 return &ZwpInputMethodV2{r}
72}
73
74const ZwpInputMethodV2RequestCommitString uint32 = 0
75const ZwpInputMethodV2RequestSetPreeditString uint32 = 1
76const ZwpInputMethodV2RequestDeleteSurroundingText uint32 = 2
77const ZwpInputMethodV2RequestCommit uint32 = 3
78const ZwpInputMethodV2RequestGetInputPopupSurface uint32 = 4
79const ZwpInputMethodV2RequestGrabKeyboard uint32 = 5
80const ZwpInputMethodV2RequestDestroy uint32 = 6
81const ZwpInputMethodV2EventActivate uint32 = 0
82const ZwpInputMethodV2EventDeactivate uint32 = 1
83const ZwpInputMethodV2EventSurroundingText uint32 = 2
84const ZwpInputMethodV2EventTextChangeCause uint32 = 3
85const ZwpInputMethodV2EventContentType uint32 = 4
86const ZwpInputMethodV2EventDone uint32 = 5
87const ZwpInputMethodV2EventUnavailable uint32 = 6
88
89// ZwpInputMethodV2Error .
90type ZwpInputMethodV2Error uint32
91
92const (
93 ZwpInputMethodV2ErrorRole ZwpInputMethodV2Error = 0
94)
95
96// ZwpInputMethodV2Handler handles zwp_input_method_v2 requests.
97type ZwpInputMethodV2Handler interface {
98 CommitString(self *ZwpInputMethodV2, text string)
99 SetPreeditString(self *ZwpInputMethodV2, text string, cursorBegin int32, cursorEnd int32)
100 DeleteSurroundingText(self *ZwpInputMethodV2, beforeLength uint32, afterLength uint32)
101 Commit(self *ZwpInputMethodV2, serial uint32)
102 GetInputPopupSurface(self *ZwpInputMethodV2, id uint32, surface *wayland.Surface)
103 GrabKeyboard(self *ZwpInputMethodV2, keyboard uint32)
104 Destroy(self *ZwpInputMethodV2)
105}
106
107func NewZwpInputMethodV2(c server.Client, version int32, id uint32, h ZwpInputMethodV2Handler) (*ZwpInputMethodV2, error) {
108 if h == nil {
109 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_method_v2")
110 }
111 var self *ZwpInputMethodV2
112 r, err := c.CreateResource(ZwpInputMethodV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
113 switch opcode {
114 case 0:
115 h.CommitString(self, args[0].String())
116 case 1:
117 h.SetPreeditString(self, args[0].String(), args[1].Int(), args[2].Int())
118 case 2:
119 h.DeleteSurroundingText(self, args[0].Uint(), args[1].Uint())
120 case 3:
121 h.Commit(self, args[0].Uint())
122 case 4:
123 h.GetInputPopupSurface(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
124 case 5:
125 h.GrabKeyboard(self, args[0].NewID())
126 case 6:
127 h.Destroy(self)
128 self.Destroy()
129 }
130 })
131 if err != nil {
132 return nil, err
133 }
134 self = WrapZwpInputMethodV2(r)
135 r.Data = self
136 return self, nil
137}
138
139// SendActivate input method has been requested.
140func (self *ZwpInputMethodV2) SendActivate() {
141 self.PostEvent(ZwpInputMethodV2EventActivate)
142}
143
144// SendDeactivate deactivate event.
145func (self *ZwpInputMethodV2) SendDeactivate() {
146 self.PostEvent(ZwpInputMethodV2EventDeactivate)
147}
148
149// SendSurroundingText surrounding text event.
150func (self *ZwpInputMethodV2) SendSurroundingText(text string, cursor uint32, anchor uint32) {
151 var p runtime.Pinner
152 defer p.Unpin()
153 self.PostEvent(ZwpInputMethodV2EventSurroundingText, server.String(&p, text, false), server.Uint(cursor), server.Uint(anchor))
154}
155
156// SendTextChangeCause indicates the cause of surrounding text change.
157func (self *ZwpInputMethodV2) SendTextChangeCause(cause uint32) {
158 self.PostEvent(ZwpInputMethodV2EventTextChangeCause, server.Uint(cause))
159}
160
161// SendContentType content purpose and hint.
162func (self *ZwpInputMethodV2) SendContentType(hint uint32, purpose uint32) {
163 self.PostEvent(ZwpInputMethodV2EventContentType, server.Uint(hint), server.Uint(purpose))
164}
165
166// SendDone apply state.
167func (self *ZwpInputMethodV2) SendDone() {
168 self.PostEvent(ZwpInputMethodV2EventDone)
169}
170
171// SendUnavailable input method unavailable.
172func (self *ZwpInputMethodV2) SendUnavailable() {
173 self.PostEvent(ZwpInputMethodV2EventUnavailable)
174}
175func NewZwpInputMethodV2Global(d *server.Display, version int32, bind server.BindFunc) error {
176 return d.CreateGlobal(ZwpInputMethodV2Interface, version, bind)
177}
178
179// ZwpInputPopupSurfaceV2 popup surface.
180type ZwpInputPopupSurfaceV2 struct{ *server.Resource }
181
182func WrapZwpInputPopupSurfaceV2(r *server.Resource) *ZwpInputPopupSurfaceV2 {
183 if r == nil {
184 return nil
185 }
186 return &ZwpInputPopupSurfaceV2{r}
187}
188
189const ZwpInputPopupSurfaceV2RequestDestroy uint32 = 0
190const ZwpInputPopupSurfaceV2EventTextInputRectangle uint32 = 0
191
192// ZwpInputPopupSurfaceV2Handler handles zwp_input_popup_surface_v2 requests.
193type ZwpInputPopupSurfaceV2Handler interface {
194 Destroy(self *ZwpInputPopupSurfaceV2)
195}
196
197func NewZwpInputPopupSurfaceV2(c server.Client, version int32, id uint32, h ZwpInputPopupSurfaceV2Handler) (*ZwpInputPopupSurfaceV2, error) {
198 if h == nil {
199 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_popup_surface_v2")
200 }
201 var self *ZwpInputPopupSurfaceV2
202 r, err := c.CreateResource(ZwpInputPopupSurfaceV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
203 switch opcode {
204 case 0:
205 h.Destroy(self)
206 self.Destroy()
207 }
208 })
209 if err != nil {
210 return nil, err
211 }
212 self = WrapZwpInputPopupSurfaceV2(r)
213 r.Data = self
214 return self, nil
215}
216
217// SendTextInputRectangle set text input area position.
218func (self *ZwpInputPopupSurfaceV2) SendTextInputRectangle(x int32, y int32, width int32, height int32) {
219 self.PostEvent(ZwpInputPopupSurfaceV2EventTextInputRectangle, server.Int(x), server.Int(y), server.Int(width), server.Int(height))
220}
221func NewZwpInputPopupSurfaceV2Global(d *server.Display, version int32, bind server.BindFunc) error {
222 return d.CreateGlobal(ZwpInputPopupSurfaceV2Interface, version, bind)
223}
224
225// ZwpInputMethodKeyboardGrabV2 keyboard grab.
226type ZwpInputMethodKeyboardGrabV2 struct{ *server.Resource }
227
228func WrapZwpInputMethodKeyboardGrabV2(r *server.Resource) *ZwpInputMethodKeyboardGrabV2 {
229 if r == nil {
230 return nil
231 }
232 return &ZwpInputMethodKeyboardGrabV2{r}
233}
234
235const ZwpInputMethodKeyboardGrabV2RequestRelease uint32 = 0
236const ZwpInputMethodKeyboardGrabV2EventKeymap uint32 = 0
237const ZwpInputMethodKeyboardGrabV2EventKey uint32 = 1
238const ZwpInputMethodKeyboardGrabV2EventModifiers uint32 = 2
239const ZwpInputMethodKeyboardGrabV2EventRepeatInfo uint32 = 3
240
241// ZwpInputMethodKeyboardGrabV2Handler handles zwp_input_method_keyboard_grab_v2 requests.
242type ZwpInputMethodKeyboardGrabV2Handler interface {
243 Release(self *ZwpInputMethodKeyboardGrabV2)
244}
245
246func NewZwpInputMethodKeyboardGrabV2(c server.Client, version int32, id uint32, h ZwpInputMethodKeyboardGrabV2Handler) (*ZwpInputMethodKeyboardGrabV2, error) {
247 if h == nil {
248 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_method_keyboard_grab_v2")
249 }
250 var self *ZwpInputMethodKeyboardGrabV2
251 r, err := c.CreateResource(ZwpInputMethodKeyboardGrabV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
252 switch opcode {
253 case 0:
254 h.Release(self)
255 self.Destroy()
256 }
257 })
258 if err != nil {
259 return nil, err
260 }
261 self = WrapZwpInputMethodKeyboardGrabV2(r)
262 r.Data = self
263 return self, nil
264}
265
266// SendKeymap keyboard mapping.
267func (self *ZwpInputMethodKeyboardGrabV2) SendKeymap(format uint32, fd int, size uint32) {
268 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventKeymap, server.Uint(format), server.Fd(fd), server.Uint(size))
269}
270
271// SendKey key event.
272func (self *ZwpInputMethodKeyboardGrabV2) SendKey(serial uint32, time uint32, key uint32, state uint32) {
273 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventKey, server.Uint(serial), server.Uint(time), server.Uint(key), server.Uint(state))
274}
275
276// SendModifiers modifier and group state.
277func (self *ZwpInputMethodKeyboardGrabV2) SendModifiers(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32) {
278 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventModifiers, server.Uint(serial), server.Uint(modsDepressed), server.Uint(modsLatched), server.Uint(modsLocked), server.Uint(group))
279}
280
281// SendRepeatInfo repeat rate and delay.
282func (self *ZwpInputMethodKeyboardGrabV2) SendRepeatInfo(rate int32, delay int32) {
283 self.PostEvent(ZwpInputMethodKeyboardGrabV2EventRepeatInfo, server.Int(rate), server.Int(delay))
284}
285func NewZwpInputMethodKeyboardGrabV2Global(d *server.Display, version int32, bind server.BindFunc) error {
286 return d.CreateGlobal(ZwpInputMethodKeyboardGrabV2Interface, version, bind)
287}
288
289// ZwpInputMethodManagerV2 input method manager.
290type ZwpInputMethodManagerV2 struct{ *server.Resource }
291
292func WrapZwpInputMethodManagerV2(r *server.Resource) *ZwpInputMethodManagerV2 {
293 if r == nil {
294 return nil
295 }
296 return &ZwpInputMethodManagerV2{r}
297}
298
299const ZwpInputMethodManagerV2RequestGetInputMethod uint32 = 0
300const ZwpInputMethodManagerV2RequestDestroy uint32 = 1
301
302// ZwpInputMethodManagerV2Handler handles zwp_input_method_manager_v2 requests.
303type ZwpInputMethodManagerV2Handler interface {
304 GetInputMethod(self *ZwpInputMethodManagerV2, seat *wayland.Seat, inputMethod uint32)
305 Destroy(self *ZwpInputMethodManagerV2)
306}
307
308func NewZwpInputMethodManagerV2(c server.Client, version int32, id uint32, h ZwpInputMethodManagerV2Handler) (*ZwpInputMethodManagerV2, error) {
309 if h == nil {
310 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_input_method_manager_v2")
311 }
312 var self *ZwpInputMethodManagerV2
313 r, err := c.CreateResource(ZwpInputMethodManagerV2Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
314 switch opcode {
315 case 0:
316 h.GetInputMethod(self, wayland.WrapSeat(args[0].Resource()), args[1].NewID())
317 case 1:
318 h.Destroy(self)
319 self.Destroy()
320 }
321 })
322 if err != nil {
323 return nil, err
324 }
325 self = WrapZwpInputMethodManagerV2(r)
326 r.Data = self
327 return self, nil
328}
329func NewZwpInputMethodManagerV2Global(d *server.Display, version int32, bind server.BindFunc) error {
330 return d.CreateGlobal(ZwpInputMethodManagerV2Interface, version, bind)
331}
332func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
333 if v == nil {
334 return nil
335 }
336 return v.GetResource()
337}
338func (self *ZwpInputMethodV2) GetResource() *server.Resource {
339 if self == nil {
340 return nil
341 }
342 return self.Resource
343}
344func (self *ZwpInputPopupSurfaceV2) GetResource() *server.Resource {
345 if self == nil {
346 return nil
347 }
348 return self.Resource
349}
350func (self *ZwpInputMethodKeyboardGrabV2) GetResource() *server.Resource {
351 if self == nil {
352 return nil
353 }
354 return self.Resource
355}
356func (self *ZwpInputMethodManagerV2) GetResource() *server.Resource {
357 if self == nil {
358 return nil
359 }
360 return self.Resource
361}