// Code generated by wlbgen. DO NOT EDIT. // Protocol: input_timestamps_unstable_v1 // Source: input-timestamps-unstable-v1.xml // Upstream protocol copyright and license: // Copyright © 2017 Collabora, Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice (including the next // paragraph) shall be included in all copies or substantial portions of the // Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. package inputtimestamps import ( "sync" cross_wl_keyboard "github.com/bnema/go-wayland-bindings/client/wayland" cross_wl_pointer "github.com/bnema/go-wayland-bindings/client/wayland" cross_wl_touch "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // InputTimestampsManagerInterface is the protocol interface name. const InputTimestampsManagerInterface = "zwp_input_timestamps_manager_v1" // InputTimestampsManager is the generated binding for zwp_input_timestamps_manager_v1 version 1. type InputTimestampsManager struct { wl.BaseProxy } // NewInputTimestampsManager returns an unbound InputTimestampsManager. func NewInputTimestampsManager(ctx *wl.Context) *InputTimestampsManager { obj := &InputTimestampsManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Informs the server that the client will no longer be using this protocol object. Existing objects created by this object are not affected. func (o *InputTimestampsManager) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_input_timestamps_manager_v1.destroy", Destructor: true}); err != nil { return err } return nil } // Creates a new input timestamps object that represents a subscription to high-resolution timestamp events for all wl_keyboard events that carry a timestamp. If the associated wl_keyboard object is invalidated, either through client action (e.g. release) or server-side changes, the input timestamps object becomes inert and the client should destroy it by calling zwp_input_timestamps_v1.destroy. func (o *InputTimestampsManager) GetKeyboardTimestamps(keyboard *cross_wl_keyboard.Keyboard) (*InputTimestamps, error) { var arg1 wl.Object if keyboard != nil { arg1 = keyboard } child := &InputTimestamps{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_input_timestamps_manager_v1.get_keyboard_timestamps", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // Creates a new input timestamps object that represents a subscription to high-resolution timestamp events for all wl_pointer events that carry a timestamp. If the associated wl_pointer object is invalidated, either through client action (e.g. release) or server-side changes, the input timestamps object becomes inert and the client should destroy it by calling zwp_input_timestamps_v1.destroy. func (o *InputTimestampsManager) GetPointerTimestamps(pointer *cross_wl_pointer.Pointer) (*InputTimestamps, error) { var arg1 wl.Object if pointer != nil { arg1 = pointer } child := &InputTimestamps{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_input_timestamps_manager_v1.get_pointer_timestamps", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // Creates a new input timestamps object that represents a subscription to high-resolution timestamp events for all wl_touch events that carry a timestamp. If the associated wl_touch object becomes invalid, either through client action (e.g. release) or server-side changes, the input timestamps object becomes inert and the client should destroy it by calling zwp_input_timestamps_v1.destroy. func (o *InputTimestampsManager) GetTouchTimestamps(touch *cross_wl_touch.Touch) (*InputTimestamps, error) { var arg1 wl.Object if touch != nil { arg1 = touch } child := &InputTimestamps{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwp_input_timestamps_manager_v1.get_touch_timestamps", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *InputTimestampsManager) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zwp_input_timestamps_manager_v1 and calls the registered handlers. func (o *InputTimestampsManager) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // InputTimestampsInterface is the protocol interface name. const InputTimestampsInterface = "zwp_input_timestamps_v1" // InputTimestamps is the generated binding for zwp_input_timestamps_v1 version 1. type InputTimestamps struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onTimestamp []func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32) } // NewInputTimestamps returns an unbound InputTimestamps. func NewInputTimestamps(ctx *wl.Context) *InputTimestamps { obj := &InputTimestamps{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Informs the server that the client will no longer be using this protocol object. After the server processes the request, no more timestamp events will be emitted. func (o *InputTimestamps) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_input_timestamps_v1.destroy", Destructor: true}); err != nil { return err } return nil } // OnTimestamp registers a handler for the timestamp event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *InputTimestamps) OnTimestamp(handler func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onTimestamp = append(o.onTimestamp, handler) } // handlersForTimestamp returns the handlers registered for timestamp, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *InputTimestamps) handlersForTimestamp() []func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onTimestamp } // EventSignature returns the declared event argument types in wire order. func (o *InputTimestamps) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,uint,uint,", true default: return "", false } } // Dispatch decodes one event on zwp_input_timestamps_v1 and calls the registered handlers. func (o *InputTimestamps) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // timestamp tvSecHi := event.Uint32() tvSecLo := event.Uint32() tvNsec := event.Uint32() for i, handler := range o.handlersForTimestamp() { _ = i handler(tvSecHi, tvSecLo, tvNsec) } default: } }