keyboardshortcutsinhibit_generated.go RawHistoryFolder
1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: keyboard_shortcuts_inhibit_unstable_v1
3// Source: keyboard-shortcuts-inhibit-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2017 Red Hat Inc.
7//
8// Permission is hereby granted, free of charge, to any person obtaining a
9// copy of this software and associated documentation files (the "Software"),
10// to deal in the Software without restriction, including without limitation
11// the rights to use, copy, modify, merge, publish, distribute, sublicense,
12// and/or sell copies of the Software, and to permit persons to whom the
13// Software is furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice (including the next
16// paragraph) shall be included in all copies or substantial portions of the
17// Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25// DEALINGS IN THE SOFTWARE.
26
27package keyboardshortcutsinhibit
28
29import (
30 "sync"
31
32 cross_wl_seat "github.com/bnema/go-wayland-bindings/client/wayland"
33 cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland"
34 "github.com/bnema/wlturbo/wl"
35)
36
37// ERROR_ALREADY_INHIBITED is the error already_inhibited value.
38const ERROR_ALREADY_INHIBITED = 0
39
40// KeyboardShortcutsInhibitManagerInterface is the protocol interface name.
41const KeyboardShortcutsInhibitManagerInterface = "zwp_keyboard_shortcuts_inhibit_manager_v1"
42
43// KeyboardShortcutsInhibitManager is the generated binding for zwp_keyboard_shortcuts_inhibit_manager_v1 version 1.
44type KeyboardShortcutsInhibitManager struct {
45 wl.BaseProxy
46}
47
48// NewKeyboardShortcutsInhibitManager returns an unbound KeyboardShortcutsInhibitManager.
49func NewKeyboardShortcutsInhibitManager(ctx *wl.Context) *KeyboardShortcutsInhibitManager {
50 obj := &KeyboardShortcutsInhibitManager{}
51 obj.SetContext(ctx)
52 ctx.Register(obj)
53 return obj
54}
55
56// Destroy the keyboard shortcuts inhibitor manager.
57func (o *KeyboardShortcutsInhibitManager) Destroy() error {
58 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_keyboard_shortcuts_inhibit_manager_v1.destroy", Destructor: true}); err != nil {
59 return err
60 }
61 return nil
62}
63
64// Create a new keyboard shortcuts inhibitor object associated with the given surface for the given seat. If shortcuts are already inhibited for the specified seat and surface, a protocol error "already_inhibited" is raised by the compositor.
65func (o *KeyboardShortcutsInhibitManager) InhibitShortcuts(surface *cross_wl_surface.Surface, seat *cross_wl_seat.Seat) (*KeyboardShortcutsInhibitor, error) {
66 var arg1 wl.Object
67 if surface != nil {
68 arg1 = surface
69 }
70 var arg2 wl.Object
71 if seat != nil {
72 arg2 = seat
73 }
74 child := &KeyboardShortcutsInhibitor{}
75 child.SetContext(o.Context())
76 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_keyboard_shortcuts_inhibit_manager_v1.inhibit_shortcuts", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgObject(arg2)); err != nil {
77 return nil, err
78 }
79 return child, nil
80}
81
82// EventSignature returns the declared event argument types in wire order.
83func (o *KeyboardShortcutsInhibitManager) EventSignature(opcode uint16) (string, bool) {
84 switch opcode {
85 default:
86 return "", false
87 }
88}
89
90// Dispatch decodes one event on zwp_keyboard_shortcuts_inhibit_manager_v1 and calls the registered handlers.
91func (o *KeyboardShortcutsInhibitManager) Dispatch(event *wl.Event) {
92 switch event.Opcode {
93 default:
94 }
95}
96
97// KeyboardShortcutsInhibitorInterface is the protocol interface name.
98const KeyboardShortcutsInhibitorInterface = "zwp_keyboard_shortcuts_inhibitor_v1"
99
100// KeyboardShortcutsInhibitor is the generated binding for zwp_keyboard_shortcuts_inhibitor_v1 version 1.
101type KeyboardShortcutsInhibitor struct {
102 wl.BaseProxy
103 // handlersMu guards the handler slices: a client may register or replace
104 // handlers while another goroutine dispatches events.
105 handlersMu sync.Mutex
106 onActive []func()
107 onInactive []func()
108}
109
110// NewKeyboardShortcutsInhibitor returns an unbound KeyboardShortcutsInhibitor.
111func NewKeyboardShortcutsInhibitor(ctx *wl.Context) *KeyboardShortcutsInhibitor {
112 obj := &KeyboardShortcutsInhibitor{}
113 obj.SetContext(ctx)
114 ctx.Register(obj)
115 return obj
116}
117
118// Remove the keyboard shortcuts inhibitor from the associated wl_surface.
119func (o *KeyboardShortcutsInhibitor) Destroy() error {
120 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_keyboard_shortcuts_inhibitor_v1.destroy", Destructor: true}); err != nil {
121 return err
122 }
123 return nil
124}
125
126// OnActive registers a handler for the active event.
127//
128// Handlers are appended, so a second call adds another handler rather than
129// replacing the first. Registration is safe while another goroutine dispatches.
130func (o *KeyboardShortcutsInhibitor) OnActive(handler func()) {
131 if handler == nil {
132 return
133 }
134 o.handlersMu.Lock()
135 defer o.handlersMu.Unlock()
136 o.onActive = append(o.onActive, handler)
137}
138
139// handlersForActive returns the handlers registered for active, taken
140// under the lock so a handler may register another handler while events are
141// being dispatched.
142func (o *KeyboardShortcutsInhibitor) handlersForActive() []func() {
143 o.handlersMu.Lock()
144 defer o.handlersMu.Unlock()
145 return o.onActive
146}
147
148// OnInactive registers a handler for the inactive event.
149//
150// Handlers are appended, so a second call adds another handler rather than
151// replacing the first. Registration is safe while another goroutine dispatches.
152func (o *KeyboardShortcutsInhibitor) OnInactive(handler func()) {
153 if handler == nil {
154 return
155 }
156 o.handlersMu.Lock()
157 defer o.handlersMu.Unlock()
158 o.onInactive = append(o.onInactive, handler)
159}
160
161// handlersForInactive returns the handlers registered for inactive, taken
162// under the lock so a handler may register another handler while events are
163// being dispatched.
164func (o *KeyboardShortcutsInhibitor) handlersForInactive() []func() {
165 o.handlersMu.Lock()
166 defer o.handlersMu.Unlock()
167 return o.onInactive
168}
169
170// EventSignature returns the declared event argument types in wire order.
171func (o *KeyboardShortcutsInhibitor) EventSignature(opcode uint16) (string, bool) {
172 switch opcode {
173 case 0:
174 return "", true
175 case 1:
176 return "", true
177 default:
178 return "", false
179 }
180}
181
182// Dispatch decodes one event on zwp_keyboard_shortcuts_inhibitor_v1 and calls the registered handlers.
183func (o *KeyboardShortcutsInhibitor) Dispatch(event *wl.Event) {
184 switch event.Opcode {
185 case 0: // active
186
187 for i, handler := range o.handlersForActive() {
188 _ = i
189 handler()
190 }
191 case 1: // inactive
192
193 for i, handler := range o.handlersForInactive() {
194 _ = i
195 handler()
196 }
197 default:
198 }
199}