// Code generated by wlbgen. DO NOT EDIT. // Protocol: tablet_v2 // Source: tablet-v2.xml // Upstream protocol copyright and license: // Copyright 2014 © Stephen "Lyude" Chandler Paul // Copyright 2015-2024 © Red Hat, Inc. // // 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 tablet import ( "sync" cross_wl_seat "github.com/bnema/go-wayland-bindings/client/wayland" cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // TYPE_PEN is the type pen value. const TYPE_PEN = 0x140 // TYPE_ERASER is the type eraser value. const TYPE_ERASER = 0x141 // TYPE_BRUSH is the type brush value. const TYPE_BRUSH = 0x142 // TYPE_PENCIL is the type pencil value. const TYPE_PENCIL = 0x143 // TYPE_AIRBRUSH is the type airbrush value. const TYPE_AIRBRUSH = 0x144 // TYPE_FINGER is the type finger value. const TYPE_FINGER = 0x145 // TYPE_MOUSE is the type mouse value. const TYPE_MOUSE = 0x146 // TYPE_LENS is the type lens value. const TYPE_LENS = 0x147 // CAPABILITY_TILT is the capability tilt value. const CAPABILITY_TILT = 1 // CAPABILITY_PRESSURE is the capability pressure value. const CAPABILITY_PRESSURE = 2 // CAPABILITY_DISTANCE is the capability distance value. const CAPABILITY_DISTANCE = 3 // CAPABILITY_ROTATION is the capability rotation value. const CAPABILITY_ROTATION = 4 // CAPABILITY_SLIDER is the capability slider value. const CAPABILITY_SLIDER = 5 // CAPABILITY_WHEEL is the capability wheel value. const CAPABILITY_WHEEL = 6 // ZWP_TABLET_TOOL_V2_BUTTON_STATE_RELEASED is the button_state released value. const ZWP_TABLET_TOOL_V2_BUTTON_STATE_RELEASED = 0 // ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED is the button_state pressed value. const ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED = 1 // ERROR_ROLE is the error role value. const ERROR_ROLE = 0 // BUSTYPE_USB is the bustype usb value. const BUSTYPE_USB = 3 // BUSTYPE_BLUETOOTH is the bustype bluetooth value. const BUSTYPE_BLUETOOTH = 5 // BUSTYPE_VIRTUAL is the bustype virtual value. const BUSTYPE_VIRTUAL = 6 // BUSTYPE_SERIAL is the bustype serial value. const BUSTYPE_SERIAL = 17 // BUSTYPE_I2C is the bustype i2c value. const BUSTYPE_I2C = 24 // ZWP_TABLET_PAD_RING_V2_SOURCE_FINGER is the source finger value. const ZWP_TABLET_PAD_RING_V2_SOURCE_FINGER = 1 // ZWP_TABLET_PAD_STRIP_V2_SOURCE_FINGER is the source finger value. const ZWP_TABLET_PAD_STRIP_V2_SOURCE_FINGER = 1 // ZWP_TABLET_PAD_V2_BUTTON_STATE_RELEASED is the button_state released value. const ZWP_TABLET_PAD_V2_BUTTON_STATE_RELEASED = 0 // ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED is the button_state pressed value. const ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED = 1 // TabletManagerInterface is the protocol interface name. const TabletManagerInterface = "zwp_tablet_manager_v2" // TabletManager is the generated binding for zwp_tablet_manager_v2 version 2. type TabletManager struct { wl.BaseProxy } // NewTabletManager returns an unbound TabletManager. func NewTabletManager(ctx *wl.Context) *TabletManager { obj := &TabletManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Get the zwp_tablet_seat_v2 object for the given seat. This object provides access to all graphics tablets in this seat. func (o *TabletManager) GetTabletSeat(seat *cross_wl_seat.Seat) (*TabletSeat, error) { var arg1 wl.Object if seat != nil { arg1 = seat } child := &TabletSeat{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_manager_v2.get_tablet_seat", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // Destroy the zwp_tablet_manager_v2 object. Objects created from this object are unaffected and should be destroyed separately. func (o *TabletManager) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_tablet_manager_v2.destroy", Destructor: true}); err != nil { return err } return nil } // EventSignature returns the declared event argument types in wire order. func (o *TabletManager) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zwp_tablet_manager_v2 and calls the registered handlers. func (o *TabletManager) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // TabletSeatInterface is the protocol interface name. const TabletSeatInterface = "zwp_tablet_seat_v2" // TabletSeat is the generated binding for zwp_tablet_seat_v2 version 2. type TabletSeat struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onTabletAdded []func(idObject *Tablet) onToolAdded []func(idObject *TabletTool) onPadAdded []func(idObject *TabletPad) } // NewTabletSeat returns an unbound TabletSeat. func NewTabletSeat(ctx *wl.Context) *TabletSeat { obj := &TabletSeat{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy the zwp_tablet_seat_v2 object. Objects created from this object are unaffected and should be destroyed separately. func (o *TabletSeat) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_seat_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnTabletAdded registers a handler for the tablet_added 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 *TabletSeat) OnTabletAdded(handler func(idObject *Tablet)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onTabletAdded = append(o.onTabletAdded, handler) } // handlersForTabletAdded returns the handlers registered for tablet_added, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletSeat) handlersForTabletAdded() []func(idObject *Tablet) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onTabletAdded } // OnToolAdded registers a handler for the tool_added 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 *TabletSeat) OnToolAdded(handler func(idObject *TabletTool)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onToolAdded = append(o.onToolAdded, handler) } // handlersForToolAdded returns the handlers registered for tool_added, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletSeat) handlersForToolAdded() []func(idObject *TabletTool) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onToolAdded } // OnPadAdded registers a handler for the pad_added 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 *TabletSeat) OnPadAdded(handler func(idObject *TabletPad)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPadAdded = append(o.onPadAdded, handler) } // handlersForPadAdded returns the handlers registered for pad_added, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletSeat) handlersForPadAdded() []func(idObject *TabletPad) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPadAdded } // EventSignature returns the declared event argument types in wire order. func (o *TabletSeat) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "new_id,", true case 1: return "new_id,", true case 2: return "new_id,", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_seat_v2 and calls the registered handlers. func (o *TabletSeat) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // tablet_added idID := event.Uint32() idObject := &Tablet{} idObject.SetContext(o.Context()) idObject.SetID(idID) idObject.SetVersion(o.Version()) o.Context().Register(idObject) for i, handler := range o.handlersForTabletAdded() { _ = i handler(idObject) } case 1: // tool_added idID := event.Uint32() idObject := &TabletTool{} idObject.SetContext(o.Context()) idObject.SetID(idID) idObject.SetVersion(o.Version()) o.Context().Register(idObject) for i, handler := range o.handlersForToolAdded() { _ = i handler(idObject) } case 2: // pad_added idID := event.Uint32() idObject := &TabletPad{} idObject.SetContext(o.Context()) idObject.SetID(idID) idObject.SetVersion(o.Version()) o.Context().Register(idObject) for i, handler := range o.handlersForPadAdded() { _ = i handler(idObject) } default: } } // TabletToolInterface is the protocol interface name. const TabletToolInterface = "zwp_tablet_tool_v2" // TabletTool is the generated binding for zwp_tablet_tool_v2 version 2. type TabletTool struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onType []func(toolType uint32) onHardwareSerial []func(hardwareSerialHi uint32, hardwareSerialLo uint32) onHardwareIdWacom []func(hardwareIdHi uint32, hardwareIdLo uint32) onCapability []func(capability uint32) onDone []func() onRemoved []func() onProximityIn []func(serial uint32, tabletID uint32, surfaceID uint32) onProximityOut []func() onDown []func(serial uint32) onUp []func() onMotion []func(x wl.Fixed, y wl.Fixed) onPressure []func(pressure uint32) onDistance []func(distance uint32) onTilt []func(tiltX wl.Fixed, tiltY wl.Fixed) onRotation []func(degrees wl.Fixed) onSlider []func(position int32) onWheel []func(degrees wl.Fixed, clicks int32) onButton []func(serial uint32, button uint32, state uint32) onFrame []func(time uint32) } // NewTabletTool returns an unbound TabletTool. func NewTabletTool(ctx *wl.Context) *TabletTool { obj := &TabletTool{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Sets the surface of the cursor used for this tool on the given tablet. This request only takes effect if the tool is in proximity of one of the requesting client's surfaces or the surface parameter is the current pointer surface. If there was a previous surface set with this request it is replaced. If surface is NULL, the cursor image is hidden. The parameters hotspot_x and hotspot_y define the position of the pointer surface relative to the pointer location. Its top-left corner is always at (x, y) - (hotspot_x, hotspot_y), where (x, y) are the coordinates of the pointer location, in surface-local coordinates. On surface.attach requests to the pointer surface, hotspot_x and hotspot_y are decremented by the x and y parameters passed to the request. Attach must be confirmed by wl_surface.commit as usual. The hotspot can also be updated by passing the currently set pointer surface to this request with new values for hotspot_x and hotspot_y. The current and pending input regions of the wl_surface are cleared, and wl_surface.set_input_region is ignored until the wl_surface is no longer used as the cursor. When the use as a cursor ends, the current and pending input regions become undefined, and the wl_surface is unmapped. This request gives the surface the role of a zwp_tablet_tool_v2 cursor. A surface may only ever be used as the cursor surface for one zwp_tablet_tool_v2. If the surface already has another role or has previously been used as cursor surface for a different tool, a protocol error is raised. func (o *TabletTool) SetCursor(serial uint32, surface *cross_wl_surface.Surface, hotspotX int32, hotspotY int32) error { var arg1 wl.Object if surface != nil { arg1 = surface } if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_tool_v2.set_cursor"}, wl.ArgUint(serial), wl.ArgObject(arg1), wl.ArgInt(hotspotX), wl.ArgInt(hotspotY)); err != nil { return err } return nil } // This destroys the client's resource for this tool object. func (o *TabletTool) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_tablet_tool_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnType registers a handler for the type 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 *TabletTool) OnType(handler func(toolType uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onType = append(o.onType, handler) } // handlersForType returns the handlers registered for type, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForType() []func(toolType uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onType } // OnHardwareSerial registers a handler for the hardware_serial 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 *TabletTool) OnHardwareSerial(handler func(hardwareSerialHi uint32, hardwareSerialLo uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onHardwareSerial = append(o.onHardwareSerial, handler) } // handlersForHardwareSerial returns the handlers registered for hardware_serial, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForHardwareSerial() []func(hardwareSerialHi uint32, hardwareSerialLo uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onHardwareSerial } // OnHardwareIdWacom registers a handler for the hardware_id_wacom 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 *TabletTool) OnHardwareIdWacom(handler func(hardwareIdHi uint32, hardwareIdLo uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onHardwareIdWacom = append(o.onHardwareIdWacom, handler) } // handlersForHardwareIdWacom returns the handlers registered for hardware_id_wacom, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForHardwareIdWacom() []func(hardwareIdHi uint32, hardwareIdLo uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onHardwareIdWacom } // OnCapability registers a handler for the capability 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 *TabletTool) OnCapability(handler func(capability uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onCapability = append(o.onCapability, handler) } // handlersForCapability returns the handlers registered for capability, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForCapability() []func(capability uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCapability } // OnDone registers a handler for the done 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 *TabletTool) OnDone(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDone = append(o.onDone, handler) } // handlersForDone returns the handlers registered for done, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForDone() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDone } // OnRemoved registers a handler for the removed 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 *TabletTool) OnRemoved(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onRemoved = append(o.onRemoved, handler) } // handlersForRemoved returns the handlers registered for removed, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForRemoved() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRemoved } // OnProximityIn registers a handler for the proximity_in 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 *TabletTool) OnProximityIn(handler func(serial uint32, tabletID uint32, surfaceID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onProximityIn = append(o.onProximityIn, handler) } // handlersForProximityIn returns the handlers registered for proximity_in, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForProximityIn() []func(serial uint32, tabletID uint32, surfaceID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onProximityIn } // OnProximityOut registers a handler for the proximity_out 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 *TabletTool) OnProximityOut(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onProximityOut = append(o.onProximityOut, handler) } // handlersForProximityOut returns the handlers registered for proximity_out, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForProximityOut() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onProximityOut } // OnDown registers a handler for the down 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 *TabletTool) OnDown(handler func(serial uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDown = append(o.onDown, handler) } // handlersForDown returns the handlers registered for down, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForDown() []func(serial uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDown } // OnUp registers a handler for the up 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 *TabletTool) OnUp(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onUp = append(o.onUp, handler) } // handlersForUp returns the handlers registered for up, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForUp() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onUp } // OnMotion registers a handler for the motion 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 *TabletTool) OnMotion(handler func(x wl.Fixed, y wl.Fixed)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onMotion = append(o.onMotion, handler) } // handlersForMotion returns the handlers registered for motion, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForMotion() []func(x wl.Fixed, y wl.Fixed) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onMotion } // OnPressure registers a handler for the pressure 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 *TabletTool) OnPressure(handler func(pressure uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPressure = append(o.onPressure, handler) } // handlersForPressure returns the handlers registered for pressure, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForPressure() []func(pressure uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPressure } // OnDistance registers a handler for the distance 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 *TabletTool) OnDistance(handler func(distance uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDistance = append(o.onDistance, handler) } // handlersForDistance returns the handlers registered for distance, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForDistance() []func(distance uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDistance } // OnTilt registers a handler for the tilt 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 *TabletTool) OnTilt(handler func(tiltX wl.Fixed, tiltY wl.Fixed)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onTilt = append(o.onTilt, handler) } // handlersForTilt returns the handlers registered for tilt, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForTilt() []func(tiltX wl.Fixed, tiltY wl.Fixed) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onTilt } // OnRotation registers a handler for the rotation 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 *TabletTool) OnRotation(handler func(degrees wl.Fixed)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onRotation = append(o.onRotation, handler) } // handlersForRotation returns the handlers registered for rotation, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForRotation() []func(degrees wl.Fixed) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRotation } // OnSlider registers a handler for the slider 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 *TabletTool) OnSlider(handler func(position int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSlider = append(o.onSlider, handler) } // handlersForSlider returns the handlers registered for slider, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForSlider() []func(position int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSlider } // OnWheel registers a handler for the wheel 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 *TabletTool) OnWheel(handler func(degrees wl.Fixed, clicks int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onWheel = append(o.onWheel, handler) } // handlersForWheel returns the handlers registered for wheel, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForWheel() []func(degrees wl.Fixed, clicks int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onWheel } // OnButton registers a handler for the button 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 *TabletTool) OnButton(handler func(serial uint32, button uint32, state uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onButton = append(o.onButton, handler) } // handlersForButton returns the handlers registered for button, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForButton() []func(serial uint32, button uint32, state uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onButton } // OnFrame registers a handler for the frame 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 *TabletTool) OnFrame(handler func(time uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFrame = append(o.onFrame, handler) } // handlersForFrame returns the handlers registered for frame, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletTool) handlersForFrame() []func(time uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFrame } // EventSignature returns the declared event argument types in wire order. func (o *TabletTool) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true case 1: return "uint,uint,", true case 2: return "uint,uint,", true case 3: return "uint,", true case 4: return "", true case 5: return "", true case 6: return "uint,object,object,", true case 7: return "", true case 8: return "uint,", true case 9: return "", true case 10: return "fixed,fixed,", true case 11: return "uint,", true case 12: return "uint,", true case 13: return "fixed,fixed,", true case 14: return "fixed,", true case 15: return "int,", true case 16: return "fixed,int,", true case 17: return "uint,uint,uint,", true case 18: return "uint,", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_tool_v2 and calls the registered handlers. func (o *TabletTool) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // type toolType := event.Uint32() for i, handler := range o.handlersForType() { _ = i handler(toolType) } case 1: // hardware_serial hardwareSerialHi := event.Uint32() hardwareSerialLo := event.Uint32() for i, handler := range o.handlersForHardwareSerial() { _ = i handler(hardwareSerialHi, hardwareSerialLo) } case 2: // hardware_id_wacom hardwareIdHi := event.Uint32() hardwareIdLo := event.Uint32() for i, handler := range o.handlersForHardwareIdWacom() { _ = i handler(hardwareIdHi, hardwareIdLo) } case 3: // capability capability := event.Uint32() for i, handler := range o.handlersForCapability() { _ = i handler(capability) } case 4: // done for i, handler := range o.handlersForDone() { _ = i handler() } case 5: // removed for i, handler := range o.handlersForRemoved() { _ = i handler() } case 6: // proximity_in serial := event.Uint32() tabletID := event.Uint32() surfaceID := event.Uint32() for i, handler := range o.handlersForProximityIn() { _ = i handler(serial, tabletID, surfaceID) } case 7: // proximity_out for i, handler := range o.handlersForProximityOut() { _ = i handler() } case 8: // down serial := event.Uint32() for i, handler := range o.handlersForDown() { _ = i handler(serial) } case 9: // up for i, handler := range o.handlersForUp() { _ = i handler() } case 10: // motion x := event.Fixed() y := event.Fixed() for i, handler := range o.handlersForMotion() { _ = i handler(x, y) } case 11: // pressure pressure := event.Uint32() for i, handler := range o.handlersForPressure() { _ = i handler(pressure) } case 12: // distance distance := event.Uint32() for i, handler := range o.handlersForDistance() { _ = i handler(distance) } case 13: // tilt tiltX := event.Fixed() tiltY := event.Fixed() for i, handler := range o.handlersForTilt() { _ = i handler(tiltX, tiltY) } case 14: // rotation degrees := event.Fixed() for i, handler := range o.handlersForRotation() { _ = i handler(degrees) } case 15: // slider position := event.Int32() for i, handler := range o.handlersForSlider() { _ = i handler(position) } case 16: // wheel degrees := event.Fixed() clicks := event.Int32() for i, handler := range o.handlersForWheel() { _ = i handler(degrees, clicks) } case 17: // button serial := event.Uint32() button := event.Uint32() state := event.Uint32() for i, handler := range o.handlersForButton() { _ = i handler(serial, button, state) } case 18: // frame time := event.Uint32() for i, handler := range o.handlersForFrame() { _ = i handler(time) } default: } } // TabletInterface is the protocol interface name. const TabletInterface = "zwp_tablet_v2" // Tablet is the generated binding for zwp_tablet_v2 version 2. type Tablet struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onName []func(name string) onId []func(vid uint32, pid uint32) onPath []func(path string) onDone []func() onRemoved []func() onBustype []func(bustype uint32) } // NewTablet returns an unbound Tablet. func NewTablet(ctx *wl.Context) *Tablet { obj := &Tablet{} obj.SetContext(ctx) ctx.Register(obj) return obj } // This destroys the client's resource for this tablet object. func (o *Tablet) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnName registers a handler for the name 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 *Tablet) OnName(handler func(name string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onName = append(o.onName, handler) } // handlersForName returns the handlers registered for name, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *Tablet) handlersForName() []func(name string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onName } // OnId registers a handler for the id 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 *Tablet) OnId(handler func(vid uint32, pid uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onId = append(o.onId, handler) } // handlersForId returns the handlers registered for id, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *Tablet) handlersForId() []func(vid uint32, pid uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onId } // OnPath registers a handler for the path 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 *Tablet) OnPath(handler func(path string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPath = append(o.onPath, handler) } // handlersForPath returns the handlers registered for path, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *Tablet) handlersForPath() []func(path string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPath } // OnDone registers a handler for the done 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 *Tablet) OnDone(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDone = append(o.onDone, handler) } // handlersForDone returns the handlers registered for done, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *Tablet) handlersForDone() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDone } // OnRemoved registers a handler for the removed 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 *Tablet) OnRemoved(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onRemoved = append(o.onRemoved, handler) } // handlersForRemoved returns the handlers registered for removed, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *Tablet) handlersForRemoved() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRemoved } // OnBustype registers a handler for the bustype 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 *Tablet) OnBustype(handler func(bustype uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onBustype = append(o.onBustype, handler) } // handlersForBustype returns the handlers registered for bustype, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *Tablet) handlersForBustype() []func(bustype uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onBustype } // EventSignature returns the declared event argument types in wire order. func (o *Tablet) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "string,", true case 1: return "uint,uint,", true case 2: return "string,", true case 3: return "", true case 4: return "", true case 5: return "uint,", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_v2 and calls the registered handlers. func (o *Tablet) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // name name := event.String() for i, handler := range o.handlersForName() { _ = i handler(name) } case 1: // id vid := event.Uint32() pid := event.Uint32() for i, handler := range o.handlersForId() { _ = i handler(vid, pid) } case 2: // path path := event.String() for i, handler := range o.handlersForPath() { _ = i handler(path) } case 3: // done for i, handler := range o.handlersForDone() { _ = i handler() } case 4: // removed for i, handler := range o.handlersForRemoved() { _ = i handler() } case 5: // bustype bustype := event.Uint32() for i, handler := range o.handlersForBustype() { _ = i handler(bustype) } default: } } // TabletPadRingInterface is the protocol interface name. const TabletPadRingInterface = "zwp_tablet_pad_ring_v2" // TabletPadRing is the generated binding for zwp_tablet_pad_ring_v2 version 2. type TabletPadRing struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onSource []func(source uint32) onAngle []func(degrees wl.Fixed) onStop []func() onFrame []func(time uint32) } // NewTabletPadRing returns an unbound TabletPadRing. func NewTabletPadRing(ctx *wl.Context) *TabletPadRing { obj := &TabletPadRing{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Request that the compositor use the provided feedback string associated with this ring. This request should be issued immediately after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding group is received, or whenever the ring is mapped to a different action. See zwp_tablet_pad_group_v2.mode_switch for more details. Clients are encouraged to provide context-aware descriptions for the actions associated with the ring; compositors may use this information to offer visual feedback about the button layout (eg. on-screen displays). The provided string 'description' is a UTF-8 encoded string to be associated with this ring, and is considered user-visible; general internationalization rules apply. The serial argument will be that of the last zwp_tablet_pad_group_v2.mode_switch event received for the group of this ring. Requests providing other serials than the most recent one will be ignored. func (o *TabletPadRing) SetFeedback(description string, serial uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_pad_ring_v2.set_feedback"}, wl.ArgString(description), wl.ArgUint(serial)); err != nil { return err } return nil } // This destroys the client's resource for this ring object. func (o *TabletPadRing) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_tablet_pad_ring_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnSource registers a handler for the source 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 *TabletPadRing) OnSource(handler func(source uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSource = append(o.onSource, handler) } // handlersForSource returns the handlers registered for source, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadRing) handlersForSource() []func(source uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSource } // OnAngle registers a handler for the angle 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 *TabletPadRing) OnAngle(handler func(degrees wl.Fixed)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onAngle = append(o.onAngle, handler) } // handlersForAngle returns the handlers registered for angle, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadRing) handlersForAngle() []func(degrees wl.Fixed) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onAngle } // OnStop registers a handler for the stop 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 *TabletPadRing) OnStop(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onStop = append(o.onStop, handler) } // handlersForStop returns the handlers registered for stop, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadRing) handlersForStop() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onStop } // OnFrame registers a handler for the frame 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 *TabletPadRing) OnFrame(handler func(time uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFrame = append(o.onFrame, handler) } // handlersForFrame returns the handlers registered for frame, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadRing) handlersForFrame() []func(time uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFrame } // EventSignature returns the declared event argument types in wire order. func (o *TabletPadRing) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true case 1: return "fixed,", true case 2: return "", true case 3: return "uint,", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_pad_ring_v2 and calls the registered handlers. func (o *TabletPadRing) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // source source := event.Uint32() for i, handler := range o.handlersForSource() { _ = i handler(source) } case 1: // angle degrees := event.Fixed() for i, handler := range o.handlersForAngle() { _ = i handler(degrees) } case 2: // stop for i, handler := range o.handlersForStop() { _ = i handler() } case 3: // frame time := event.Uint32() for i, handler := range o.handlersForFrame() { _ = i handler(time) } default: } } // TabletPadStripInterface is the protocol interface name. const TabletPadStripInterface = "zwp_tablet_pad_strip_v2" // TabletPadStrip is the generated binding for zwp_tablet_pad_strip_v2 version 2. type TabletPadStrip struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onSource []func(source uint32) onPosition []func(position uint32) onStop []func() onFrame []func(time uint32) } // NewTabletPadStrip returns an unbound TabletPadStrip. func NewTabletPadStrip(ctx *wl.Context) *TabletPadStrip { obj := &TabletPadStrip{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Requests the compositor to use the provided feedback string associated with this strip. This request should be issued immediately after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding group is received, or whenever the strip is mapped to a different action. See zwp_tablet_pad_group_v2.mode_switch for more details. Clients are encouraged to provide context-aware descriptions for the actions associated with the strip, and compositors may use this information to offer visual feedback about the button layout (eg. on-screen displays). The provided string 'description' is a UTF-8 encoded string to be associated with this ring, and is considered user-visible; general internationalization rules apply. The serial argument will be that of the last zwp_tablet_pad_group_v2.mode_switch event received for the group of this strip. Requests providing other serials than the most recent one will be ignored. func (o *TabletPadStrip) SetFeedback(description string, serial uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_pad_strip_v2.set_feedback"}, wl.ArgString(description), wl.ArgUint(serial)); err != nil { return err } return nil } // This destroys the client's resource for this strip object. func (o *TabletPadStrip) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_tablet_pad_strip_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnSource registers a handler for the source 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 *TabletPadStrip) OnSource(handler func(source uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSource = append(o.onSource, handler) } // handlersForSource returns the handlers registered for source, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadStrip) handlersForSource() []func(source uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSource } // OnPosition registers a handler for the position 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 *TabletPadStrip) OnPosition(handler func(position uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPosition = append(o.onPosition, handler) } // handlersForPosition returns the handlers registered for position, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadStrip) handlersForPosition() []func(position uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPosition } // OnStop registers a handler for the stop 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 *TabletPadStrip) OnStop(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onStop = append(o.onStop, handler) } // handlersForStop returns the handlers registered for stop, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadStrip) handlersForStop() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onStop } // OnFrame registers a handler for the frame 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 *TabletPadStrip) OnFrame(handler func(time uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFrame = append(o.onFrame, handler) } // handlersForFrame returns the handlers registered for frame, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadStrip) handlersForFrame() []func(time uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFrame } // EventSignature returns the declared event argument types in wire order. func (o *TabletPadStrip) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true case 1: return "uint,", true case 2: return "", true case 3: return "uint,", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_pad_strip_v2 and calls the registered handlers. func (o *TabletPadStrip) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // source source := event.Uint32() for i, handler := range o.handlersForSource() { _ = i handler(source) } case 1: // position position := event.Uint32() for i, handler := range o.handlersForPosition() { _ = i handler(position) } case 2: // stop for i, handler := range o.handlersForStop() { _ = i handler() } case 3: // frame time := event.Uint32() for i, handler := range o.handlersForFrame() { _ = i handler(time) } default: } } // TabletPadGroupInterface is the protocol interface name. const TabletPadGroupInterface = "zwp_tablet_pad_group_v2" // TabletPadGroup is the generated binding for zwp_tablet_pad_group_v2 version 2. type TabletPadGroup struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onButtons []func(buttons []byte) onRing []func(ringObject *TabletPadRing) onStrip []func(stripObject *TabletPadStrip) onModes []func(modes uint32) onDone []func() onModeSwitch []func(time uint32, serial uint32, mode uint32) onDial []func(dialObject *TabletPadDial) } // NewTabletPadGroup returns an unbound TabletPadGroup. func NewTabletPadGroup(ctx *wl.Context) *TabletPadGroup { obj := &TabletPadGroup{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy the zwp_tablet_pad_group_v2 object. Objects created from this object are unaffected and should be destroyed separately. func (o *TabletPadGroup) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_pad_group_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnButtons registers a handler for the buttons 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 *TabletPadGroup) OnButtons(handler func(buttons []byte)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onButtons = append(o.onButtons, handler) } // handlersForButtons returns the handlers registered for buttons, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadGroup) handlersForButtons() []func(buttons []byte) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onButtons } // OnRing registers a handler for the ring 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 *TabletPadGroup) OnRing(handler func(ringObject *TabletPadRing)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onRing = append(o.onRing, handler) } // handlersForRing returns the handlers registered for ring, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadGroup) handlersForRing() []func(ringObject *TabletPadRing) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRing } // OnStrip registers a handler for the strip 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 *TabletPadGroup) OnStrip(handler func(stripObject *TabletPadStrip)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onStrip = append(o.onStrip, handler) } // handlersForStrip returns the handlers registered for strip, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadGroup) handlersForStrip() []func(stripObject *TabletPadStrip) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onStrip } // OnModes registers a handler for the modes 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 *TabletPadGroup) OnModes(handler func(modes uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onModes = append(o.onModes, handler) } // handlersForModes returns the handlers registered for modes, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadGroup) handlersForModes() []func(modes uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onModes } // OnDone registers a handler for the done 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 *TabletPadGroup) OnDone(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDone = append(o.onDone, handler) } // handlersForDone returns the handlers registered for done, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadGroup) handlersForDone() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDone } // OnModeSwitch registers a handler for the mode_switch 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 *TabletPadGroup) OnModeSwitch(handler func(time uint32, serial uint32, mode uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onModeSwitch = append(o.onModeSwitch, handler) } // handlersForModeSwitch returns the handlers registered for mode_switch, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadGroup) handlersForModeSwitch() []func(time uint32, serial uint32, mode uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onModeSwitch } // OnDial registers a handler for the dial 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 *TabletPadGroup) OnDial(handler func(dialObject *TabletPadDial)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDial = append(o.onDial, handler) } // handlersForDial returns the handlers registered for dial, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadGroup) handlersForDial() []func(dialObject *TabletPadDial) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDial } // EventSignature returns the declared event argument types in wire order. func (o *TabletPadGroup) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "array,", true case 1: return "new_id,", true case 2: return "new_id,", true case 3: return "uint,", true case 4: return "", true case 5: return "uint,uint,uint,", true case 6: return "new_id,", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_pad_group_v2 and calls the registered handlers. func (o *TabletPadGroup) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // buttons buttons := event.Array() for i, handler := range o.handlersForButtons() { _ = i handler(buttons) } case 1: // ring ringID := event.Uint32() ringObject := &TabletPadRing{} ringObject.SetContext(o.Context()) ringObject.SetID(ringID) ringObject.SetVersion(o.Version()) o.Context().Register(ringObject) for i, handler := range o.handlersForRing() { _ = i handler(ringObject) } case 2: // strip stripID := event.Uint32() stripObject := &TabletPadStrip{} stripObject.SetContext(o.Context()) stripObject.SetID(stripID) stripObject.SetVersion(o.Version()) o.Context().Register(stripObject) for i, handler := range o.handlersForStrip() { _ = i handler(stripObject) } case 3: // modes modes := event.Uint32() for i, handler := range o.handlersForModes() { _ = i handler(modes) } case 4: // done for i, handler := range o.handlersForDone() { _ = i handler() } case 5: // mode_switch time := event.Uint32() serial := event.Uint32() mode := event.Uint32() for i, handler := range o.handlersForModeSwitch() { _ = i handler(time, serial, mode) } case 6: // dial dialID := event.Uint32() dialObject := &TabletPadDial{} dialObject.SetContext(o.Context()) dialObject.SetID(dialID) dialObject.SetVersion(o.Version()) o.Context().Register(dialObject) for i, handler := range o.handlersForDial() { _ = i handler(dialObject) } default: } } // TabletPadInterface is the protocol interface name. const TabletPadInterface = "zwp_tablet_pad_v2" // TabletPad is the generated binding for zwp_tablet_pad_v2 version 2. type TabletPad struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onGroup []func(padGroupObject *TabletPadGroup) onPath []func(path string) onButtons []func(buttons uint32) onDone []func() onButton []func(time uint32, button uint32, state uint32) onEnter []func(serial uint32, tabletID uint32, surfaceID uint32) onLeave []func(serial uint32, surfaceID uint32) onRemoved []func() } // NewTabletPad returns an unbound TabletPad. func NewTabletPad(ctx *wl.Context) *TabletPad { obj := &TabletPad{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Requests the compositor to use the provided feedback string associated with this button. This request should be issued immediately after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding group is received, or whenever a button is mapped to a different action. See zwp_tablet_pad_group_v2.mode_switch for more details. Clients are encouraged to provide context-aware descriptions for the actions associated with each button, and compositors may use this information to offer visual feedback on the button layout (e.g. on-screen displays). Button indices start at 0. Setting the feedback string on a button that is reserved by the compositor (i.e. not belonging to any zwp_tablet_pad_group_v2) does not generate an error but the compositor is free to ignore the request. The provided string 'description' is a UTF-8 encoded string to be associated with this ring, and is considered user-visible; general internationalization rules apply. The serial argument will be that of the last zwp_tablet_pad_group_v2.mode_switch event received for the group of this button. Requests providing other serials than the most recent one will be ignored. func (o *TabletPad) SetFeedback(button uint32, description string, serial uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_pad_v2.set_feedback"}, wl.ArgUint(button), wl.ArgString(description), wl.ArgUint(serial)); err != nil { return err } return nil } // Destroy the zwp_tablet_pad_v2 object. Objects created from this object are unaffected and should be destroyed separately. func (o *TabletPad) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_tablet_pad_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnGroup registers a handler for the group 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 *TabletPad) OnGroup(handler func(padGroupObject *TabletPadGroup)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onGroup = append(o.onGroup, handler) } // handlersForGroup returns the handlers registered for group, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForGroup() []func(padGroupObject *TabletPadGroup) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onGroup } // OnPath registers a handler for the path 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 *TabletPad) OnPath(handler func(path string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPath = append(o.onPath, handler) } // handlersForPath returns the handlers registered for path, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForPath() []func(path string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPath } // OnButtons registers a handler for the buttons 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 *TabletPad) OnButtons(handler func(buttons uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onButtons = append(o.onButtons, handler) } // handlersForButtons returns the handlers registered for buttons, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForButtons() []func(buttons uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onButtons } // OnDone registers a handler for the done 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 *TabletPad) OnDone(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDone = append(o.onDone, handler) } // handlersForDone returns the handlers registered for done, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForDone() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDone } // OnButton registers a handler for the button 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 *TabletPad) OnButton(handler func(time uint32, button uint32, state uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onButton = append(o.onButton, handler) } // handlersForButton returns the handlers registered for button, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForButton() []func(time uint32, button uint32, state uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onButton } // OnEnter registers a handler for the enter 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 *TabletPad) OnEnter(handler func(serial uint32, tabletID uint32, surfaceID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onEnter = append(o.onEnter, handler) } // handlersForEnter returns the handlers registered for enter, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForEnter() []func(serial uint32, tabletID uint32, surfaceID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onEnter } // OnLeave registers a handler for the leave 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 *TabletPad) OnLeave(handler func(serial uint32, surfaceID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onLeave = append(o.onLeave, handler) } // handlersForLeave returns the handlers registered for leave, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForLeave() []func(serial uint32, surfaceID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onLeave } // OnRemoved registers a handler for the removed 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 *TabletPad) OnRemoved(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onRemoved = append(o.onRemoved, handler) } // handlersForRemoved returns the handlers registered for removed, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPad) handlersForRemoved() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRemoved } // EventSignature returns the declared event argument types in wire order. func (o *TabletPad) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "new_id,", true case 1: return "string,", true case 2: return "uint,", true case 3: return "", true case 4: return "uint,uint,uint,", true case 5: return "uint,object,object,", true case 6: return "uint,object,", true case 7: return "", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_pad_v2 and calls the registered handlers. func (o *TabletPad) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // group padGroupID := event.Uint32() padGroupObject := &TabletPadGroup{} padGroupObject.SetContext(o.Context()) padGroupObject.SetID(padGroupID) padGroupObject.SetVersion(o.Version()) o.Context().Register(padGroupObject) for i, handler := range o.handlersForGroup() { _ = i handler(padGroupObject) } case 1: // path path := event.String() for i, handler := range o.handlersForPath() { _ = i handler(path) } case 2: // buttons buttons := event.Uint32() for i, handler := range o.handlersForButtons() { _ = i handler(buttons) } case 3: // done for i, handler := range o.handlersForDone() { _ = i handler() } case 4: // button time := event.Uint32() button := event.Uint32() state := event.Uint32() for i, handler := range o.handlersForButton() { _ = i handler(time, button, state) } case 5: // enter serial := event.Uint32() tabletID := event.Uint32() surfaceID := event.Uint32() for i, handler := range o.handlersForEnter() { _ = i handler(serial, tabletID, surfaceID) } case 6: // leave serial := event.Uint32() surfaceID := event.Uint32() for i, handler := range o.handlersForLeave() { _ = i handler(serial, surfaceID) } case 7: // removed for i, handler := range o.handlersForRemoved() { _ = i handler() } default: } } // TabletPadDialInterface is the protocol interface name. const TabletPadDialInterface = "zwp_tablet_pad_dial_v2" // TabletPadDial is the generated binding for zwp_tablet_pad_dial_v2 version 2. type TabletPadDial struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onDelta []func(value120 int32) onFrame []func(time uint32) } // NewTabletPadDial returns an unbound TabletPadDial. func NewTabletPadDial(ctx *wl.Context) *TabletPadDial { obj := &TabletPadDial{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Requests the compositor to use the provided feedback string associated with this dial. This request should be issued immediately after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding group is received, or whenever the dial is mapped to a different action. See zwp_tablet_pad_group_v2.mode_switch for more details. Clients are encouraged to provide context-aware descriptions for the actions associated with the dial, and compositors may use this information to offer visual feedback about the button layout (eg. on-screen displays). The provided string 'description' is a UTF-8 encoded string to be associated with this ring, and is considered user-visible; general internationalization rules apply. The serial argument will be that of the last zwp_tablet_pad_group_v2.mode_switch event received for the group of this dial. Requests providing other serials than the most recent one will be ignored. func (o *TabletPadDial) SetFeedback(description string, serial uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_tablet_pad_dial_v2.set_feedback"}, wl.ArgString(description), wl.ArgUint(serial)); err != nil { return err } return nil } // This destroys the client's resource for this dial object. func (o *TabletPadDial) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_tablet_pad_dial_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnDelta registers a handler for the delta 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 *TabletPadDial) OnDelta(handler func(value120 int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDelta = append(o.onDelta, handler) } // handlersForDelta returns the handlers registered for delta, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadDial) handlersForDelta() []func(value120 int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDelta } // OnFrame registers a handler for the frame 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 *TabletPadDial) OnFrame(handler func(time uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFrame = append(o.onFrame, handler) } // handlersForFrame returns the handlers registered for frame, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *TabletPadDial) handlersForFrame() []func(time uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFrame } // EventSignature returns the declared event argument types in wire order. func (o *TabletPadDial) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "int,", true case 1: return "uint,", true default: return "", false } } // Dispatch decodes one event on zwp_tablet_pad_dial_v2 and calls the registered handlers. func (o *TabletPadDial) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // delta value120 := event.Int32() for i, handler := range o.handlersForDelta() { _ = i handler(value120) } case 1: // frame time := event.Uint32() for i, handler := range o.handlersForFrame() { _ = i handler(time) } default: } }