// Code generated by wlbgen. DO NOT EDIT. // Protocol: ext_idle_notify_v1 // Source: ext-idle-notify-v1.xml // Upstream protocol copyright and license: // Copyright © 2015 Martin Gräßlin // Copyright © 2022 Simon Ser // // 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 extidlenotify import ( "sync" cross_wl_seat "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // ExtIdleNotifierInterface is the protocol interface name. const ExtIdleNotifierInterface = "ext_idle_notifier_v1" // ExtIdleNotifier is the generated binding for ext_idle_notifier_v1 version 2. type ExtIdleNotifier struct { wl.BaseProxy } // NewExtIdleNotifier returns an unbound ExtIdleNotifier. func NewExtIdleNotifier(ctx *wl.Context) *ExtIdleNotifier { obj := &ExtIdleNotifier{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy the manager object. All objects created via this interface remain valid. func (o *ExtIdleNotifier) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_idle_notifier_v1.destroy", Destructor: true}); err != nil { return err } return nil } // Create a new idle notification object. The notification object has a minimum timeout duration and is tied to a seat. The client will be notified if the seat is inactive for at least the provided timeout. See ext_idle_notification_v1 for more details. A zero timeout is valid and means the client wants to be notified as soon as possible when the seat is inactive. func (o *ExtIdleNotifier) GetIdleNotification(timeout uint32, seat *cross_wl_seat.Seat) (*ExtIdleNotification, error) { var arg2 wl.Object if seat != nil { arg2 = seat } child := &ExtIdleNotification{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_idle_notifier_v1.get_idle_notification", Child: child}, wl.ArgObject(child), wl.ArgUint(timeout), wl.ArgObject(arg2)); err != nil { return nil, err } return child, nil } // Create a new idle notification object to track input from the user, such as keyboard and mouse movement. Because this object is meant to track user input alone, it ignores idle inhibitors. The notification object has a minimum timeout duration and is tied to a seat. The client will be notified if the seat is inactive for at least the provided timeout. See ext_idle_notification_v1 for more details. A zero timeout is valid and means the client wants to be notified as soon as possible when the seat is inactive. func (o *ExtIdleNotifier) GetInputIdleNotification(timeout uint32, seat *cross_wl_seat.Seat) (*ExtIdleNotification, error) { var arg2 wl.Object if seat != nil { arg2 = seat } child := &ExtIdleNotification{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "ext_idle_notifier_v1.get_input_idle_notification", Since: 2, Child: child}, wl.ArgObject(child), wl.ArgUint(timeout), wl.ArgObject(arg2)); err != nil { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *ExtIdleNotifier) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on ext_idle_notifier_v1 and calls the registered handlers. func (o *ExtIdleNotifier) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // ExtIdleNotificationInterface is the protocol interface name. const ExtIdleNotificationInterface = "ext_idle_notification_v1" // ExtIdleNotification is the generated binding for ext_idle_notification_v1 version 2. type ExtIdleNotification struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onIdled []func() onResumed []func() } // NewExtIdleNotification returns an unbound ExtIdleNotification. func NewExtIdleNotification(ctx *wl.Context) *ExtIdleNotification { obj := &ExtIdleNotification{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroy the notification object. func (o *ExtIdleNotification) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_idle_notification_v1.destroy", Destructor: true}); err != nil { return err } return nil } // OnIdled registers a handler for the idled 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 *ExtIdleNotification) OnIdled(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onIdled = append(o.onIdled, handler) } // handlersForIdled returns the handlers registered for idled, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtIdleNotification) handlersForIdled() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onIdled } // OnResumed registers a handler for the resumed 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 *ExtIdleNotification) OnResumed(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onResumed = append(o.onResumed, handler) } // handlersForResumed returns the handlers registered for resumed, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtIdleNotification) handlersForResumed() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onResumed } // EventSignature returns the declared event argument types in wire order. func (o *ExtIdleNotification) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "", true case 1: return "", true default: return "", false } } // Dispatch decodes one event on ext_idle_notification_v1 and calls the registered handlers. func (o *ExtIdleNotification) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // idled for i, handler := range o.handlersForIdled() { _ = i handler() } case 1: // resumed for i, handler := range o.handlersForResumed() { _ = i handler() } default: } }