1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: input_method_unstable_v2
3// Source: input-method-unstable-v2.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2008-2011 Kristian Høgsberg
7// Copyright © 2010-2011 Intel Corporation
8// Copyright © 2012-2013 Collabora, Ltd.
9// Copyright © 2012, 2013 Intel Corporation
10// Copyright © 2015, 2016 Jan Arne Petersen
11// Copyright © 2017, 2018 Red Hat, Inc.
12// Copyright © 2018 Purism SPC
13//
14// Permission is hereby granted, free of charge, to any person obtaining a
15// copy of this software and associated documentation files (the "Software"),
16// to deal in the Software without restriction, including without limitation
17// the rights to use, copy, modify, merge, publish, distribute, sublicense,
18// and/or sell copies of the Software, and to permit persons to whom the
19// Software is furnished to do so, subject to the following conditions:
20//
21// The above copyright notice and this permission notice (including the next
22// paragraph) shall be included in all copies or substantial portions of the
23// Software.
24//
25// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31// DEALINGS IN THE SOFTWARE.
32
33package inputmethod
34
35import (
36 "sync"
37
38 cross_wl_seat "github.com/bnema/go-wayland-bindings/client/wayland"
39 cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland"
40 "github.com/bnema/wlturbo/wl"
41)
42
43// ERROR_ROLE is the error role value.
44const ERROR_ROLE = 0
45
46// InputMethodInterface is the protocol interface name.
47const InputMethodInterface = "zwp_input_method_v2"
48
49// InputMethod is the generated binding for zwp_input_method_v2 version 1.
50type InputMethod struct {
51 wl.BaseProxy
52 // handlersMu guards the handler slices: a client may register or replace
53 // handlers while another goroutine dispatches events.
54 handlersMu sync.Mutex
55 onActivate []func()
56 onDeactivate []func()
57 onSurroundingText []func(text string, cursor uint32, anchor uint32)
58 onTextChangeCause []func(cause uint32)
59 onContentType []func(hint uint32, purpose uint32)
60 onDone []func()
61 onUnavailable []func()
62}
63
64// NewInputMethod returns an unbound InputMethod.
65func NewInputMethod(ctx *wl.Context) *InputMethod {
66 obj := &InputMethod{}
67 obj.SetContext(ctx)
68 ctx.Register(obj)
69 return obj
70}
71
72// Send the commit string text for insertion to the application. Inserts a string at current cursor position (see commit event sequence). The string to commit could be either just a single character after a key press or the result of some composing. The argument text is a buffer containing the string to insert. There is a maximum length of wayland messages, so text can not be longer than 4000 bytes. Values set with this event are double-buffered. They must be applied and reset to initial on the next zwp_text_input_v3.commit request. The initial value of text is an empty string.
73func (o *InputMethod) CommitString(text string) error {
74 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_input_method_v2.commit_string"}, wl.ArgString(text)); err != nil {
75 return err
76 }
77 return nil
78}
79
80// Send the pre-edit string text to the application text input. Place a new composing text (pre-edit) at the current cursor position. Any previously set composing text must be removed. Any previously existing selected text must be removed. The cursor is moved to a new position within the preedit string. The argument text is a buffer containing the preedit string. There is a maximum length of wayland messages, so text can not be longer than 4000 bytes. The arguments cursor_begin and cursor_end are counted in bytes relative to the beginning of the submitted string buffer. Cursor should be hidden by the text input when both are equal to -1. cursor_begin indicates the beginning of the cursor. cursor_end indicates the end of the cursor. It may be equal or different than cursor_begin. Values set with this event are double-buffered. They must be applied on the next zwp_input_method_v2.commit event. The initial value of text is an empty string. The initial value of cursor_begin, and cursor_end are both 0.
81func (o *InputMethod) SetPreeditString(text string, cursorBegin int32, cursorEnd int32) error {
82 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_input_method_v2.set_preedit_string"}, wl.ArgString(text), wl.ArgInt(cursorBegin), wl.ArgInt(cursorEnd)); err != nil {
83 return err
84 }
85 return nil
86}
87
88// Remove the surrounding text. before_length and after_length are the number of bytes before and after the current cursor index (excluding the preedit text) to delete. If any preedit text is present, it is replaced with the cursor for the purpose of this event. In effect before_length is counted from the beginning of preedit text, and after_length from its end (see commit event sequence). Values set with this event are double-buffered. They must be applied and reset to initial on the next zwp_input_method_v2.commit request. The initial values of both before_length and after_length are 0.
89func (o *InputMethod) DeleteSurroundingText(beforeLength uint32, afterLength uint32) error {
90 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_input_method_v2.delete_surrounding_text"}, wl.ArgUint(beforeLength), wl.ArgUint(afterLength)); err != nil {
91 return err
92 }
93 return nil
94}
95
96// Apply state changes from commit_string, set_preedit_string and delete_surrounding_text requests. The state relating to these events is double-buffered, and each one modifies the pending state. This request replaces the current state with the pending state. The connected text input is expected to proceed by evaluating the changes in the following order: 1. Replace existing preedit string with the cursor. 2. Delete requested surrounding text. 3. Insert commit string with the cursor at its end. 4. Calculate surrounding text to send. 5. Insert new preedit text in cursor position. 6. Place cursor inside preedit text. The serial number reflects the last state of the zwp_input_method_v2 object known to the client. The value of the serial argument must be equal to the number of done events already issued by that object. When the compositor receives a commit request with a serial different than the number of past done events, it must proceed as normal, except it should not change the current state of the zwp_input_method_v2 object.
97func (o *InputMethod) Commit(serial uint32) error {
98 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwp_input_method_v2.commit"}, wl.ArgUint(serial)); err != nil {
99 return err
100 }
101 return nil
102}
103
104// Creates a new zwp_input_popup_surface_v2 object wrapping a given surface. The surface gets assigned the "input_popup" role. If the surface already has an assigned role, the compositor must issue a protocol error.
105func (o *InputMethod) GetInputPopupSurface(surface *cross_wl_surface.Surface) (*InputPopupSurface, error) {
106 var arg1 wl.Object
107 if surface != nil {
108 arg1 = surface
109 }
110 child := &InputPopupSurface{}
111 child.SetContext(o.Context())
112 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "zwp_input_method_v2.get_input_popup_surface", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
113 return nil, err
114 }
115 return child, nil
116}
117
118// Allow an input method to receive hardware keyboard input and process key events to generate text events (with pre-edit) over the wire. This allows input methods which compose multiple key events for inputting text like it is done for CJK languages. The compositor should send all keyboard events on the seat to the grab holder via the returned wl_keyboard object. Nevertheless, the compositor may decide not to forward any particular event. The compositor must not further process any event after it has been forwarded to the grab holder. Releasing the resulting wl_keyboard object releases the grab.
119func (o *InputMethod) GrabKeyboard() (*InputMethodKeyboardGrab, error) {
120 child := &InputMethodKeyboardGrab{}
121 child.SetContext(o.Context())
122 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "zwp_input_method_v2.grab_keyboard", Child: child}, wl.ArgObject(child)); err != nil {
123 return nil, err
124 }
125 return child, nil
126}
127
128// Destroys the zwp_text_input_v2 object and any associated child objects, i.e. zwp_input_popup_surface_v2 and zwp_input_method_keyboard_grab_v2.
129func (o *InputMethod) Destroy() error {
130 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 6, Name: "zwp_input_method_v2.destroy", Destructor: true}); err != nil {
131 return err
132 }
133 return nil
134}
135
136// OnActivate registers a handler for the activate event.
137//
138// Handlers are appended, so a second call adds another handler rather than
139// replacing the first. Registration is safe while another goroutine dispatches.
140func (o *InputMethod) OnActivate(handler func()) {
141 if handler == nil {
142 return
143 }
144 o.handlersMu.Lock()
145 defer o.handlersMu.Unlock()
146 o.onActivate = append(o.onActivate, handler)
147}
148
149// handlersForActivate returns the handlers registered for activate, taken
150// under the lock so a handler may register another handler while events are
151// being dispatched.
152func (o *InputMethod) handlersForActivate() []func() {
153 o.handlersMu.Lock()
154 defer o.handlersMu.Unlock()
155 return o.onActivate
156}
157
158// OnDeactivate registers a handler for the deactivate event.
159//
160// Handlers are appended, so a second call adds another handler rather than
161// replacing the first. Registration is safe while another goroutine dispatches.
162func (o *InputMethod) OnDeactivate(handler func()) {
163 if handler == nil {
164 return
165 }
166 o.handlersMu.Lock()
167 defer o.handlersMu.Unlock()
168 o.onDeactivate = append(o.onDeactivate, handler)
169}
170
171// handlersForDeactivate returns the handlers registered for deactivate, taken
172// under the lock so a handler may register another handler while events are
173// being dispatched.
174func (o *InputMethod) handlersForDeactivate() []func() {
175 o.handlersMu.Lock()
176 defer o.handlersMu.Unlock()
177 return o.onDeactivate
178}
179
180// OnSurroundingText registers a handler for the surrounding_text event.
181//
182// Handlers are appended, so a second call adds another handler rather than
183// replacing the first. Registration is safe while another goroutine dispatches.
184func (o *InputMethod) OnSurroundingText(handler func(text string, cursor uint32, anchor uint32)) {
185 if handler == nil {
186 return
187 }
188 o.handlersMu.Lock()
189 defer o.handlersMu.Unlock()
190 o.onSurroundingText = append(o.onSurroundingText, handler)
191}
192
193// handlersForSurroundingText returns the handlers registered for surrounding_text, taken
194// under the lock so a handler may register another handler while events are
195// being dispatched.
196func (o *InputMethod) handlersForSurroundingText() []func(text string, cursor uint32, anchor uint32) {
197 o.handlersMu.Lock()
198 defer o.handlersMu.Unlock()
199 return o.onSurroundingText
200}
201
202// OnTextChangeCause registers a handler for the text_change_cause event.
203//
204// Handlers are appended, so a second call adds another handler rather than
205// replacing the first. Registration is safe while another goroutine dispatches.
206func (o *InputMethod) OnTextChangeCause(handler func(cause uint32)) {
207 if handler == nil {
208 return
209 }
210 o.handlersMu.Lock()
211 defer o.handlersMu.Unlock()
212 o.onTextChangeCause = append(o.onTextChangeCause, handler)
213}
214
215// handlersForTextChangeCause returns the handlers registered for text_change_cause, taken
216// under the lock so a handler may register another handler while events are
217// being dispatched.
218func (o *InputMethod) handlersForTextChangeCause() []func(cause uint32) {
219 o.handlersMu.Lock()
220 defer o.handlersMu.Unlock()
221 return o.onTextChangeCause
222}
223
224// OnContentType registers a handler for the content_type event.
225//
226// Handlers are appended, so a second call adds another handler rather than
227// replacing the first. Registration is safe while another goroutine dispatches.
228func (o *InputMethod) OnContentType(handler func(hint uint32, purpose uint32)) {
229 if handler == nil {
230 return
231 }
232 o.handlersMu.Lock()
233 defer o.handlersMu.Unlock()
234 o.onContentType = append(o.onContentType, handler)
235}
236
237// handlersForContentType returns the handlers registered for content_type, taken
238// under the lock so a handler may register another handler while events are
239// being dispatched.
240func (o *InputMethod) handlersForContentType() []func(hint uint32, purpose uint32) {
241 o.handlersMu.Lock()
242 defer o.handlersMu.Unlock()
243 return o.onContentType
244}
245
246// OnDone registers a handler for the done event.
247//
248// Handlers are appended, so a second call adds another handler rather than
249// replacing the first. Registration is safe while another goroutine dispatches.
250func (o *InputMethod) OnDone(handler func()) {
251 if handler == nil {
252 return
253 }
254 o.handlersMu.Lock()
255 defer o.handlersMu.Unlock()
256 o.onDone = append(o.onDone, handler)
257}
258
259// handlersForDone returns the handlers registered for done, taken
260// under the lock so a handler may register another handler while events are
261// being dispatched.
262func (o *InputMethod) handlersForDone() []func() {
263 o.handlersMu.Lock()
264 defer o.handlersMu.Unlock()
265 return o.onDone
266}
267
268// OnUnavailable registers a handler for the unavailable event.
269//
270// Handlers are appended, so a second call adds another handler rather than
271// replacing the first. Registration is safe while another goroutine dispatches.
272func (o *InputMethod) OnUnavailable(handler func()) {
273 if handler == nil {
274 return
275 }
276 o.handlersMu.Lock()
277 defer o.handlersMu.Unlock()
278 o.onUnavailable = append(o.onUnavailable, handler)
279}
280
281// handlersForUnavailable returns the handlers registered for unavailable, taken
282// under the lock so a handler may register another handler while events are
283// being dispatched.
284func (o *InputMethod) handlersForUnavailable() []func() {
285 o.handlersMu.Lock()
286 defer o.handlersMu.Unlock()
287 return o.onUnavailable
288}
289
290// EventSignature returns the declared event argument types in wire order.
291func (o *InputMethod) EventSignature(opcode uint16) (string, bool) {
292 switch opcode {
293 case 0:
294 return "", true
295 case 1:
296 return "", true
297 case 2:
298 return "string,uint,uint,", true
299 case 3:
300 return "uint,", true
301 case 4:
302 return "uint,uint,", true
303 case 5:
304 return "", true
305 case 6:
306 return "", true
307 default:
308 return "", false
309 }
310}
311
312// Dispatch decodes one event on zwp_input_method_v2 and calls the registered handlers.
313func (o *InputMethod) Dispatch(event *wl.Event) {
314 switch event.Opcode {
315 case 0: // activate
316
317 for i, handler := range o.handlersForActivate() {
318 _ = i
319 handler()
320 }
321 case 1: // deactivate
322
323 for i, handler := range o.handlersForDeactivate() {
324 _ = i
325 handler()
326 }
327 case 2: // surrounding_text
328 text := event.String()
329 cursor := event.Uint32()
330 anchor := event.Uint32()
331
332 for i, handler := range o.handlersForSurroundingText() {
333 _ = i
334 handler(text, cursor, anchor)
335 }
336 case 3: // text_change_cause
337 cause := event.Uint32()
338
339 for i, handler := range o.handlersForTextChangeCause() {
340 _ = i
341 handler(cause)
342 }
343 case 4: // content_type
344 hint := event.Uint32()
345 purpose := event.Uint32()
346
347 for i, handler := range o.handlersForContentType() {
348 _ = i
349 handler(hint, purpose)
350 }
351 case 5: // done
352
353 for i, handler := range o.handlersForDone() {
354 _ = i
355 handler()
356 }
357 case 6: // unavailable
358
359 for i, handler := range o.handlersForUnavailable() {
360 _ = i
361 handler()
362 }
363 default:
364 }
365}
366
367// InputPopupSurfaceInterface is the protocol interface name.
368const InputPopupSurfaceInterface = "zwp_input_popup_surface_v2"
369
370// InputPopupSurface is the generated binding for zwp_input_popup_surface_v2 version 1.
371type InputPopupSurface struct {
372 wl.BaseProxy
373 // handlersMu guards the handler slices: a client may register or replace
374 // handlers while another goroutine dispatches events.
375 handlersMu sync.Mutex
376 onTextInputRectangle []func(x int32, y int32, width int32, height int32)
377}
378
379// NewInputPopupSurface returns an unbound InputPopupSurface.
380func NewInputPopupSurface(ctx *wl.Context) *InputPopupSurface {
381 obj := &InputPopupSurface{}
382 obj.SetContext(ctx)
383 ctx.Register(obj)
384 return obj
385}
386func (o *InputPopupSurface) Destroy() error {
387 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_input_popup_surface_v2.destroy", Destructor: true}); err != nil {
388 return err
389 }
390 return nil
391}
392
393// OnTextInputRectangle registers a handler for the text_input_rectangle event.
394//
395// Handlers are appended, so a second call adds another handler rather than
396// replacing the first. Registration is safe while another goroutine dispatches.
397func (o *InputPopupSurface) OnTextInputRectangle(handler func(x int32, y int32, width int32, height int32)) {
398 if handler == nil {
399 return
400 }
401 o.handlersMu.Lock()
402 defer o.handlersMu.Unlock()
403 o.onTextInputRectangle = append(o.onTextInputRectangle, handler)
404}
405
406// handlersForTextInputRectangle returns the handlers registered for text_input_rectangle, taken
407// under the lock so a handler may register another handler while events are
408// being dispatched.
409func (o *InputPopupSurface) handlersForTextInputRectangle() []func(x int32, y int32, width int32, height int32) {
410 o.handlersMu.Lock()
411 defer o.handlersMu.Unlock()
412 return o.onTextInputRectangle
413}
414
415// EventSignature returns the declared event argument types in wire order.
416func (o *InputPopupSurface) EventSignature(opcode uint16) (string, bool) {
417 switch opcode {
418 case 0:
419 return "int,int,int,int,", true
420 default:
421 return "", false
422 }
423}
424
425// Dispatch decodes one event on zwp_input_popup_surface_v2 and calls the registered handlers.
426func (o *InputPopupSurface) Dispatch(event *wl.Event) {
427 switch event.Opcode {
428 case 0: // text_input_rectangle
429 x := event.Int32()
430 y := event.Int32()
431 width := event.Int32()
432 height := event.Int32()
433
434 for i, handler := range o.handlersForTextInputRectangle() {
435 _ = i
436 handler(x, y, width, height)
437 }
438 default:
439 }
440}
441
442// InputMethodKeyboardGrabInterface is the protocol interface name.
443const InputMethodKeyboardGrabInterface = "zwp_input_method_keyboard_grab_v2"
444
445// InputMethodKeyboardGrab is the generated binding for zwp_input_method_keyboard_grab_v2 version 1.
446type InputMethodKeyboardGrab struct {
447 wl.BaseProxy
448 // handlersMu guards the handler slices: a client may register or replace
449 // handlers while another goroutine dispatches events.
450 handlersMu sync.Mutex
451 onKeymap []func(format uint32, fd *wl.OwnedFD, size uint32)
452 onKey []func(serial uint32, time uint32, key uint32, state uint32)
453 onModifiers []func(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32)
454 onRepeatInfo []func(rate int32, delay int32)
455}
456
457// NewInputMethodKeyboardGrab returns an unbound InputMethodKeyboardGrab.
458func NewInputMethodKeyboardGrab(ctx *wl.Context) *InputMethodKeyboardGrab {
459 obj := &InputMethodKeyboardGrab{}
460 obj.SetContext(ctx)
461 ctx.Register(obj)
462 return obj
463}
464
465// release the grab object
466func (o *InputMethodKeyboardGrab) Release() error {
467 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_input_method_keyboard_grab_v2.release", Destructor: true}); err != nil {
468 return err
469 }
470 return nil
471}
472
473// OnKeymap registers a handler for the keymap event.
474//
475// Handlers are appended, so a second call adds another handler rather than
476// replacing the first. Registration is safe while another goroutine dispatches.
477func (o *InputMethodKeyboardGrab) OnKeymap(handler func(format uint32, fd *wl.OwnedFD, size uint32)) {
478 if handler == nil {
479 return
480 }
481 o.handlersMu.Lock()
482 defer o.handlersMu.Unlock()
483 o.onKeymap = append(o.onKeymap, handler)
484}
485
486// handlersForKeymap returns the handlers registered for keymap, taken
487// under the lock so a handler may register another handler while events are
488// being dispatched.
489func (o *InputMethodKeyboardGrab) handlersForKeymap() []func(format uint32, fd *wl.OwnedFD, size uint32) {
490 o.handlersMu.Lock()
491 defer o.handlersMu.Unlock()
492 return o.onKeymap
493}
494
495// OnKey registers a handler for the key event.
496//
497// Handlers are appended, so a second call adds another handler rather than
498// replacing the first. Registration is safe while another goroutine dispatches.
499func (o *InputMethodKeyboardGrab) OnKey(handler func(serial uint32, time uint32, key uint32, state uint32)) {
500 if handler == nil {
501 return
502 }
503 o.handlersMu.Lock()
504 defer o.handlersMu.Unlock()
505 o.onKey = append(o.onKey, handler)
506}
507
508// handlersForKey returns the handlers registered for key, taken
509// under the lock so a handler may register another handler while events are
510// being dispatched.
511func (o *InputMethodKeyboardGrab) handlersForKey() []func(serial uint32, time uint32, key uint32, state uint32) {
512 o.handlersMu.Lock()
513 defer o.handlersMu.Unlock()
514 return o.onKey
515}
516
517// OnModifiers registers a handler for the modifiers event.
518//
519// Handlers are appended, so a second call adds another handler rather than
520// replacing the first. Registration is safe while another goroutine dispatches.
521func (o *InputMethodKeyboardGrab) OnModifiers(handler func(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32)) {
522 if handler == nil {
523 return
524 }
525 o.handlersMu.Lock()
526 defer o.handlersMu.Unlock()
527 o.onModifiers = append(o.onModifiers, handler)
528}
529
530// handlersForModifiers returns the handlers registered for modifiers, taken
531// under the lock so a handler may register another handler while events are
532// being dispatched.
533func (o *InputMethodKeyboardGrab) handlersForModifiers() []func(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32) {
534 o.handlersMu.Lock()
535 defer o.handlersMu.Unlock()
536 return o.onModifiers
537}
538
539// OnRepeatInfo registers a handler for the repeat_info event.
540//
541// Handlers are appended, so a second call adds another handler rather than
542// replacing the first. Registration is safe while another goroutine dispatches.
543func (o *InputMethodKeyboardGrab) OnRepeatInfo(handler func(rate int32, delay int32)) {
544 if handler == nil {
545 return
546 }
547 o.handlersMu.Lock()
548 defer o.handlersMu.Unlock()
549 o.onRepeatInfo = append(o.onRepeatInfo, handler)
550}
551
552// handlersForRepeatInfo returns the handlers registered for repeat_info, taken
553// under the lock so a handler may register another handler while events are
554// being dispatched.
555func (o *InputMethodKeyboardGrab) handlersForRepeatInfo() []func(rate int32, delay int32) {
556 o.handlersMu.Lock()
557 defer o.handlersMu.Unlock()
558 return o.onRepeatInfo
559}
560
561// EventSignature returns the declared event argument types in wire order.
562func (o *InputMethodKeyboardGrab) EventSignature(opcode uint16) (string, bool) {
563 switch opcode {
564 case 0:
565 return "uint,fd,uint,", true
566 case 1:
567 return "uint,uint,uint,uint,", true
568 case 2:
569 return "uint,uint,uint,uint,uint,", true
570 case 3:
571 return "int,int,", true
572 default:
573 return "", false
574 }
575}
576
577// Dispatch decodes one event on zwp_input_method_keyboard_grab_v2 and calls the registered handlers.
578func (o *InputMethodKeyboardGrab) Dispatch(event *wl.Event) {
579 switch event.Opcode {
580 case 0: // keymap
581 format := event.Uint32()
582 fd := event.FD()
583 size := event.Uint32()
584 ownedfd := fd
585 defer ownedfd.Close()
586
587 for i, handler := range o.handlersForKeymap() {
588 if i > 0 {
589 fd = nil
590 }
591 handler(format, fd, size)
592 }
593 case 1: // key
594 serial := event.Uint32()
595 time := event.Uint32()
596 key := event.Uint32()
597 state := event.Uint32()
598
599 for i, handler := range o.handlersForKey() {
600 _ = i
601 handler(serial, time, key, state)
602 }
603 case 2: // modifiers
604 serial := event.Uint32()
605 modsDepressed := event.Uint32()
606 modsLatched := event.Uint32()
607 modsLocked := event.Uint32()
608 group := event.Uint32()
609
610 for i, handler := range o.handlersForModifiers() {
611 _ = i
612 handler(serial, modsDepressed, modsLatched, modsLocked, group)
613 }
614 case 3: // repeat_info
615 rate := event.Int32()
616 delay := event.Int32()
617
618 for i, handler := range o.handlersForRepeatInfo() {
619 _ = i
620 handler(rate, delay)
621 }
622 default:
623 }
624}
625
626// InputMethodManagerInterface is the protocol interface name.
627const InputMethodManagerInterface = "zwp_input_method_manager_v2"
628
629// InputMethodManager is the generated binding for zwp_input_method_manager_v2 version 1.
630type InputMethodManager struct {
631 wl.BaseProxy
632}
633
634// NewInputMethodManager returns an unbound InputMethodManager.
635func NewInputMethodManager(ctx *wl.Context) *InputMethodManager {
636 obj := &InputMethodManager{}
637 obj.SetContext(ctx)
638 ctx.Register(obj)
639 return obj
640}
641
642// Request a new input zwp_input_method_v2 object associated with a given seat.
643func (o *InputMethodManager) GetInputMethod(seat *cross_wl_seat.Seat) (*InputMethod, error) {
644 var arg0 wl.Object
645 if seat != nil {
646 arg0 = seat
647 }
648 child := &InputMethod{}
649 child.SetContext(o.Context())
650 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_input_method_manager_v2.get_input_method", Child: child}, wl.ArgObject(arg0), wl.ArgObject(child)); err != nil {
651 return nil, err
652 }
653 return child, nil
654}
655
656// Destroys the zwp_input_method_manager_v2 object. The zwp_input_method_v2 objects originating from it remain valid.
657func (o *InputMethodManager) Destroy() error {
658 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_input_method_manager_v2.destroy", Destructor: true}); err != nil {
659 return err
660 }
661 return nil
662}
663
664// EventSignature returns the declared event argument types in wire order.
665func (o *InputMethodManager) EventSignature(opcode uint16) (string, bool) {
666 switch opcode {
667 default:
668 return "", false
669 }
670}
671
672// Dispatch decodes one event on zwp_input_method_manager_v2 and calls the registered handlers.
673func (o *InputMethodManager) Dispatch(event *wl.Event) {
674 switch event.Opcode {
675 default:
676 }
677}