// Code generated by wlbgen. DO NOT EDIT. // Protocol: ext_workspace_v1 // Source: ext-workspace-v1.xml // Upstream protocol copyright and license: // Copyright © 2019 Christopher Billington // Copyright © 2020 Ilia Bozhinov // Copyright © 2022 Victoria Brekenfeld // // Permission to use, copy, modify, distribute, and sell this // software and its documentation for any purpose is hereby granted // without fee, provided that the above copyright notice appear in // all copies and that both that copyright notice and this permission // notice appear in supporting documentation, and that the name of // the copyright holders not be used in advertising or publicity // pertaining to distribution of the software without specific, // written prior permission. The copyright holders make no // representations about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. // // THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS // SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY // SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, // ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF // THIS SOFTWARE. package extworkspace import ( "sync" "github.com/bnema/wlturbo/wl" ) // GROUP_CAPABILITIES_CREATE_WORKSPACE is the group_capabilities create_workspace value. const GROUP_CAPABILITIES_CREATE_WORKSPACE = 1 // STATE_ACTIVE is the state active value. const STATE_ACTIVE = 1 // STATE_URGENT is the state urgent value. const STATE_URGENT = 2 // STATE_HIDDEN is the state hidden value. const STATE_HIDDEN = 4 // WORKSPACE_CAPABILITIES_ACTIVATE is the workspace_capabilities activate value. const WORKSPACE_CAPABILITIES_ACTIVATE = 1 // WORKSPACE_CAPABILITIES_DEACTIVATE is the workspace_capabilities deactivate value. const WORKSPACE_CAPABILITIES_DEACTIVATE = 2 // WORKSPACE_CAPABILITIES_REMOVE is the workspace_capabilities remove value. const WORKSPACE_CAPABILITIES_REMOVE = 4 // WORKSPACE_CAPABILITIES_ASSIGN is the workspace_capabilities assign value. const WORKSPACE_CAPABILITIES_ASSIGN = 8 // ExtWorkspaceManagerInterface is the protocol interface name. const ExtWorkspaceManagerInterface = "ext_workspace_manager_v1" // ExtWorkspaceManager is the generated binding for ext_workspace_manager_v1 version 1. type ExtWorkspaceManager struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onWorkspaceGroup []func(workspaceGroupObject *ExtWorkspaceGroupHandle) onWorkspace []func(workspaceObject *ExtWorkspaceHandle) onDone []func() onFinished []func() } // NewExtWorkspaceManager returns an unbound ExtWorkspaceManager. func NewExtWorkspaceManager(ctx *wl.Context) *ExtWorkspaceManager { obj := &ExtWorkspaceManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // The client must send this request after it has finished sending other requests. The compositor must process a series of requests preceding a commit request atomically. This allows changes to the workspace properties to be seen as atomic, even if they happen via multiple events, and even if they involve multiple ext_workspace_handle_v1 objects, for example, deactivating one workspace and activating another. func (o *ExtWorkspaceManager) Commit() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_workspace_manager_v1.commit"}); err != nil { return err } return nil } // Indicates the client no longer wishes to receive events for new workspace groups. However the compositor may emit further workspace events, until the finished event is emitted. The compositor is expected to send the finished event eventually once the stop request has been processed. The client must not send any requests after this one, doing so will raise a wl_display invalid_object error. func (o *ExtWorkspaceManager) Stop() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_workspace_manager_v1.stop"}); err != nil { return err } return nil } // OnWorkspaceGroup registers a handler for the workspace_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 *ExtWorkspaceManager) OnWorkspaceGroup(handler func(workspaceGroupObject *ExtWorkspaceGroupHandle)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onWorkspaceGroup = append(o.onWorkspaceGroup, handler) } // handlersForWorkspaceGroup returns the handlers registered for workspace_group, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceManager) handlersForWorkspaceGroup() []func(workspaceGroupObject *ExtWorkspaceGroupHandle) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onWorkspaceGroup } // OnWorkspace registers a handler for the workspace 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 *ExtWorkspaceManager) OnWorkspace(handler func(workspaceObject *ExtWorkspaceHandle)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onWorkspace = append(o.onWorkspace, handler) } // handlersForWorkspace returns the handlers registered for workspace, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceManager) handlersForWorkspace() []func(workspaceObject *ExtWorkspaceHandle) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onWorkspace } // 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 *ExtWorkspaceManager) 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 *ExtWorkspaceManager) handlersForDone() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDone } // OnFinished registers a handler for the finished 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 *ExtWorkspaceManager) OnFinished(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFinished = append(o.onFinished, handler) } // handlersForFinished returns the handlers registered for finished, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceManager) handlersForFinished() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFinished } // EventSignature returns the declared event argument types in wire order. func (o *ExtWorkspaceManager) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "new_id,", true case 1: return "new_id,", true case 2: return "", true case 3: return "", true default: return "", false } } // Dispatch decodes one event on ext_workspace_manager_v1 and calls the registered handlers. func (o *ExtWorkspaceManager) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // workspace_group workspaceGroupID := event.Uint32() workspaceGroupObject := &ExtWorkspaceGroupHandle{} workspaceGroupObject.SetContext(o.Context()) workspaceGroupObject.SetID(workspaceGroupID) workspaceGroupObject.SetVersion(o.Version()) o.Context().Register(workspaceGroupObject) for i, handler := range o.handlersForWorkspaceGroup() { _ = i handler(workspaceGroupObject) } case 1: // workspace workspaceID := event.Uint32() workspaceObject := &ExtWorkspaceHandle{} workspaceObject.SetContext(o.Context()) workspaceObject.SetID(workspaceID) workspaceObject.SetVersion(o.Version()) o.Context().Register(workspaceObject) for i, handler := range o.handlersForWorkspace() { _ = i handler(workspaceObject) } case 2: // done for i, handler := range o.handlersForDone() { _ = i handler() } case 3: // finished for i, handler := range o.handlersForFinished() { _ = i handler() } o.Context().Unregister(o) default: } } // ExtWorkspaceGroupHandleInterface is the protocol interface name. const ExtWorkspaceGroupHandleInterface = "ext_workspace_group_handle_v1" // ExtWorkspaceGroupHandle is the generated binding for ext_workspace_group_handle_v1 version 1. type ExtWorkspaceGroupHandle struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onCapabilities []func(capabilities uint32) onOutputEnter []func(outputID uint32) onOutputLeave []func(outputID uint32) onWorkspaceEnter []func(workspaceID uint32) onWorkspaceLeave []func(workspaceID uint32) onRemoved []func() } // NewExtWorkspaceGroupHandle returns an unbound ExtWorkspaceGroupHandle. func NewExtWorkspaceGroupHandle(ctx *wl.Context) *ExtWorkspaceGroupHandle { obj := &ExtWorkspaceGroupHandle{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Request that the compositor create a new workspace with the given name and assign it to this group. There is no guarantee that the compositor will create a new workspace, or that the created workspace will have the provided name. func (o *ExtWorkspaceGroupHandle) CreateWorkspace(workspace string) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_workspace_group_handle_v1.create_workspace"}, wl.ArgString(workspace)); err != nil { return err } return nil } // Destroys the ext_workspace_group_handle_v1 object. This request should be send either when the client does not want to use the workspace group object any more or after the removed event to finalize the destruction of the object. func (o *ExtWorkspaceGroupHandle) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_workspace_group_handle_v1.destroy", Destructor: true}); err != nil { return err } return nil } // OnCapabilities registers a handler for the capabilities 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 *ExtWorkspaceGroupHandle) OnCapabilities(handler func(capabilities uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onCapabilities = append(o.onCapabilities, handler) } // handlersForCapabilities returns the handlers registered for capabilities, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceGroupHandle) handlersForCapabilities() []func(capabilities uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCapabilities } // OnOutputEnter registers a handler for the output_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 *ExtWorkspaceGroupHandle) OnOutputEnter(handler func(outputID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onOutputEnter = append(o.onOutputEnter, handler) } // handlersForOutputEnter returns the handlers registered for output_enter, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceGroupHandle) handlersForOutputEnter() []func(outputID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onOutputEnter } // OnOutputLeave registers a handler for the output_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 *ExtWorkspaceGroupHandle) OnOutputLeave(handler func(outputID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onOutputLeave = append(o.onOutputLeave, handler) } // handlersForOutputLeave returns the handlers registered for output_leave, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceGroupHandle) handlersForOutputLeave() []func(outputID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onOutputLeave } // OnWorkspaceEnter registers a handler for the workspace_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 *ExtWorkspaceGroupHandle) OnWorkspaceEnter(handler func(workspaceID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onWorkspaceEnter = append(o.onWorkspaceEnter, handler) } // handlersForWorkspaceEnter returns the handlers registered for workspace_enter, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceGroupHandle) handlersForWorkspaceEnter() []func(workspaceID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onWorkspaceEnter } // OnWorkspaceLeave registers a handler for the workspace_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 *ExtWorkspaceGroupHandle) OnWorkspaceLeave(handler func(workspaceID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onWorkspaceLeave = append(o.onWorkspaceLeave, handler) } // handlersForWorkspaceLeave returns the handlers registered for workspace_leave, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceGroupHandle) handlersForWorkspaceLeave() []func(workspaceID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onWorkspaceLeave } // 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 *ExtWorkspaceGroupHandle) 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 *ExtWorkspaceGroupHandle) handlersForRemoved() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRemoved } // EventSignature returns the declared event argument types in wire order. func (o *ExtWorkspaceGroupHandle) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true case 1: return "object,", true case 2: return "object,", true case 3: return "object,", true case 4: return "object,", true case 5: return "", true default: return "", false } } // Dispatch decodes one event on ext_workspace_group_handle_v1 and calls the registered handlers. func (o *ExtWorkspaceGroupHandle) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // capabilities capabilities := event.Uint32() for i, handler := range o.handlersForCapabilities() { _ = i handler(capabilities) } case 1: // output_enter outputID := event.Uint32() for i, handler := range o.handlersForOutputEnter() { _ = i handler(outputID) } case 2: // output_leave outputID := event.Uint32() for i, handler := range o.handlersForOutputLeave() { _ = i handler(outputID) } case 3: // workspace_enter workspaceID := event.Uint32() for i, handler := range o.handlersForWorkspaceEnter() { _ = i handler(workspaceID) } case 4: // workspace_leave workspaceID := event.Uint32() for i, handler := range o.handlersForWorkspaceLeave() { _ = i handler(workspaceID) } case 5: // removed for i, handler := range o.handlersForRemoved() { _ = i handler() } default: } } // ExtWorkspaceHandleInterface is the protocol interface name. const ExtWorkspaceHandleInterface = "ext_workspace_handle_v1" // ExtWorkspaceHandle is the generated binding for ext_workspace_handle_v1 version 1. type ExtWorkspaceHandle struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onId []func(id string) onName []func(name string) onCoordinates []func(coordinates []byte) onState []func(state uint32) onCapabilities []func(capabilities uint32) onRemoved []func() } // NewExtWorkspaceHandle returns an unbound ExtWorkspaceHandle. func NewExtWorkspaceHandle(ctx *wl.Context) *ExtWorkspaceHandle { obj := &ExtWorkspaceHandle{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Destroys the ext_workspace_handle_v1 object. This request should be made either when the client does not want to use the workspace object any more or after the remove event to finalize the destruction of the object. func (o *ExtWorkspaceHandle) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_workspace_handle_v1.destroy", Destructor: true}); err != nil { return err } return nil } // Request that this workspace be activated. There is no guarantee the workspace will be actually activated, and behaviour may be compositor-dependent. For example, activating a workspace may or may not deactivate all other workspaces in the same group. func (o *ExtWorkspaceHandle) Activate() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_workspace_handle_v1.activate"}); err != nil { return err } return nil } // Request that this workspace be deactivated. There is no guarantee the workspace will be actually deactivated. func (o *ExtWorkspaceHandle) Deactivate() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "ext_workspace_handle_v1.deactivate"}); err != nil { return err } return nil } // Requests that this workspace is assigned to the given workspace group. There is no guarantee the workspace will be assigned. func (o *ExtWorkspaceHandle) Assign(workspaceGroup *ExtWorkspaceGroupHandle) error { var arg0 wl.Object if workspaceGroup != nil { arg0 = workspaceGroup } if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "ext_workspace_handle_v1.assign"}, wl.ArgObject(arg0)); err != nil { return err } return nil } // Request that this workspace be removed. There is no guarantee the workspace will be actually removed. func (o *ExtWorkspaceHandle) Remove() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "ext_workspace_handle_v1.remove"}); err != nil { return err } return nil } // 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 *ExtWorkspaceHandle) OnId(handler func(id string)) { 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 *ExtWorkspaceHandle) handlersForId() []func(id string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onId } // 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 *ExtWorkspaceHandle) 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 *ExtWorkspaceHandle) handlersForName() []func(name string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onName } // OnCoordinates registers a handler for the coordinates 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 *ExtWorkspaceHandle) OnCoordinates(handler func(coordinates []byte)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onCoordinates = append(o.onCoordinates, handler) } // handlersForCoordinates returns the handlers registered for coordinates, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceHandle) handlersForCoordinates() []func(coordinates []byte) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCoordinates } // OnState registers a handler for the state 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 *ExtWorkspaceHandle) OnState(handler func(state uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onState = append(o.onState, handler) } // handlersForState returns the handlers registered for state, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceHandle) handlersForState() []func(state uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onState } // OnCapabilities registers a handler for the capabilities 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 *ExtWorkspaceHandle) OnCapabilities(handler func(capabilities uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onCapabilities = append(o.onCapabilities, handler) } // handlersForCapabilities returns the handlers registered for capabilities, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtWorkspaceHandle) handlersForCapabilities() []func(capabilities uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCapabilities } // 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 *ExtWorkspaceHandle) 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 *ExtWorkspaceHandle) handlersForRemoved() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRemoved } // EventSignature returns the declared event argument types in wire order. func (o *ExtWorkspaceHandle) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "string,", true case 1: return "string,", true case 2: return "array,", true case 3: return "uint,", true case 4: return "uint,", true case 5: return "", true default: return "", false } } // Dispatch decodes one event on ext_workspace_handle_v1 and calls the registered handlers. func (o *ExtWorkspaceHandle) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // id id := event.String() for i, handler := range o.handlersForId() { _ = i handler(id) } case 1: // name name := event.String() for i, handler := range o.handlersForName() { _ = i handler(name) } case 2: // coordinates coordinates := event.Array() for i, handler := range o.handlersForCoordinates() { _ = i handler(coordinates) } case 3: // state state := event.Uint32() for i, handler := range o.handlersForState() { _ = i handler(state) } case 4: // capabilities capabilities := event.Uint32() for i, handler := range o.handlersForCapabilities() { _ = i handler(capabilities) } case 5: // removed for i, handler := range o.handlersForRemoved() { _ = i handler() } default: } }