// Code generated by wlturbo-scanner. DO NOT EDIT. // Protocol: server_decoration // Source: server-decoration.xml // Upstream protocol copyright and license: // SPDX-FileCopyrightText: 2015 Martin Gräßlin // // SPDX-License-Identifier: LGPL-2.1-or-later package kdeserverdecoration import ( "sync" cross_wl_surface "github.com/bnema/wlturbo/protocol/core" "github.com/bnema/wlturbo/wl" ) // ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE is the mode None value. const ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE = 0 // ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT is the mode Client value. const ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT = 1 // ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER is the mode Server value. const ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER = 2 // ORG_KDE_KWIN_SERVER_DECORATION_MODE_NONE is the mode None value. const ORG_KDE_KWIN_SERVER_DECORATION_MODE_NONE = 0 // ORG_KDE_KWIN_SERVER_DECORATION_MODE_CLIENT is the mode Client value. const ORG_KDE_KWIN_SERVER_DECORATION_MODE_CLIENT = 1 // ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER is the mode Server value. const ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER = 2 // OrgKdeKwinServerDecorationManagerInterface is the protocol interface name. const OrgKdeKwinServerDecorationManagerInterface = "org_kde_kwin_server_decoration_manager" // OrgKdeKwinServerDecorationManager is the generated binding for org_kde_kwin_server_decoration_manager version 1. type OrgKdeKwinServerDecorationManager struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onDefaultMode []func(mode uint32) } // NewOrgKdeKwinServerDecorationManager returns an unbound OrgKdeKwinServerDecorationManager. func NewOrgKdeKwinServerDecorationManager(ctx *wl.Context) *OrgKdeKwinServerDecorationManager { obj := &OrgKdeKwinServerDecorationManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // When a client creates a server-side decoration object it indicates that it supports the protocol. The client is supposed to tell the server whether it wants server-side decorations or will provide client-side decorations. If the client does not create a server-side decoration object for a surface the server interprets this as lack of support for this protocol and considers it as client-side decorated. Nevertheless a client-side decorated surface should use this protocol to indicate to the server that it does not want a server-side deco. func (o *OrgKdeKwinServerDecorationManager) Create(surface *cross_wl_surface.Surface) (*OrgKdeKwinServerDecoration, error) { var arg1 wl.Object if surface != nil { arg1 = surface } child := &OrgKdeKwinServerDecoration{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "org_kde_kwin_server_decoration_manager.create", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // OnDefaultMode registers a handler for the default_mode 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 *OrgKdeKwinServerDecorationManager) OnDefaultMode(handler func(mode uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDefaultMode = append(o.onDefaultMode, handler) } // handlersForDefaultMode returns the handlers registered for default_mode, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OrgKdeKwinServerDecorationManager) handlersForDefaultMode() []func(mode uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDefaultMode } // EventSignature returns the declared event argument types in wire order. func (o *OrgKdeKwinServerDecorationManager) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true default: return "", false } } // Dispatch decodes one event on org_kde_kwin_server_decoration_manager and calls the registered handlers. func (o *OrgKdeKwinServerDecorationManager) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // default_mode mode := event.Uint32() for i, handler := range o.handlersForDefaultMode() { _ = i handler(mode) } default: } } // OrgKdeKwinServerDecorationInterface is the protocol interface name. const OrgKdeKwinServerDecorationInterface = "org_kde_kwin_server_decoration" // OrgKdeKwinServerDecoration is the generated binding for org_kde_kwin_server_decoration version 1. type OrgKdeKwinServerDecoration struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onMode []func(mode uint32) } // NewOrgKdeKwinServerDecoration returns an unbound OrgKdeKwinServerDecoration. func NewOrgKdeKwinServerDecoration(ctx *wl.Context) *OrgKdeKwinServerDecoration { obj := &OrgKdeKwinServerDecoration{} obj.SetContext(ctx) ctx.Register(obj) return obj } // release the server decoration object func (o *OrgKdeKwinServerDecoration) Release() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "org_kde_kwin_server_decoration.release", Destructor: true}); err != nil { return err } return nil } // The decoration mode the surface wants to use. func (o *OrgKdeKwinServerDecoration) RequestMode(mode uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "org_kde_kwin_server_decoration.request_mode"}, wl.ArgUint(mode)); err != nil { return err } return nil } // OnMode registers a handler for the mode 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 *OrgKdeKwinServerDecoration) OnMode(handler func(mode uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onMode = append(o.onMode, handler) } // handlersForMode returns the handlers registered for mode, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OrgKdeKwinServerDecoration) handlersForMode() []func(mode uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onMode } // EventSignature returns the declared event argument types in wire order. func (o *OrgKdeKwinServerDecoration) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true default: return "", false } } // Dispatch decodes one event on org_kde_kwin_server_decoration and calls the registered handlers. func (o *OrgKdeKwinServerDecoration) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // mode mode := event.Uint32() for i, handler := range o.handlersForMode() { _ = i handler(mode) } default: } }