// Code generated by wlbgen. DO NOT EDIT. // Protocol: ext_background_effect_v1 // Source: ext-background-effect-v1.xml // Upstream protocol copyright and license: // Copyright (C) 2015 Martin Gräßlin // Copyright (C) 2015 Marco Martin // Copyright (C) 2020 Vlad Zahorodnii // Copyright (C) 2024 Xaver Hugl // // 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 extbackgroundeffect import ( "sync" cross_wl_region "github.com/bnema/go-wayland-bindings/client/wayland" cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // ERROR_BACKGROUND_EFFECT_EXISTS is the error background_effect_exists value. const ERROR_BACKGROUND_EFFECT_EXISTS = 0 // CAPABILITY_BLUR is the capability blur value. const CAPABILITY_BLUR = 1 // ERROR_SURFACE_DESTROYED is the error surface_destroyed value. const ERROR_SURFACE_DESTROYED = 0 // ExtBackgroundEffectManagerInterface is the protocol interface name. const ExtBackgroundEffectManagerInterface = "ext_background_effect_manager_v1" // ExtBackgroundEffectManager is the generated binding for ext_background_effect_manager_v1 version 1. type ExtBackgroundEffectManager 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(flags uint32) } // NewExtBackgroundEffectManager returns an unbound ExtBackgroundEffectManager. func NewExtBackgroundEffectManager(ctx *wl.Context) *ExtBackgroundEffectManager { obj := &ExtBackgroundEffectManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Informs the server that the client will no longer be using this protocol object. Existing objects created by this object are not affected. func (o *ExtBackgroundEffectManager) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_background_effect_manager_v1.destroy", Destructor: true}); err != nil { return err } return nil } // Instantiate an interface extension for the given wl_surface to add effects like blur for the background behind it. If the given wl_surface already has a ext_background_effect_surface_v1 object associated, the background_effect_exists protocol error will be raised. func (o *ExtBackgroundEffectManager) GetBackgroundEffect(surface *cross_wl_surface.Surface) (*ExtBackgroundEffectSurface, error) { var arg1 wl.Object if surface != nil { arg1 = surface } child := &ExtBackgroundEffectSurface{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_background_effect_manager_v1.get_background_effect", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, 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 *ExtBackgroundEffectManager) OnCapabilities(handler func(flags 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 *ExtBackgroundEffectManager) handlersForCapabilities() []func(flags uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCapabilities } // EventSignature returns the declared event argument types in wire order. func (o *ExtBackgroundEffectManager) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true default: return "", false } } // Dispatch decodes one event on ext_background_effect_manager_v1 and calls the registered handlers. func (o *ExtBackgroundEffectManager) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // capabilities flags := event.Uint32() for i, handler := range o.handlersForCapabilities() { _ = i handler(flags) } default: } } // ExtBackgroundEffectSurfaceInterface is the protocol interface name. const ExtBackgroundEffectSurfaceInterface = "ext_background_effect_surface_v1" // ExtBackgroundEffectSurface is the generated binding for ext_background_effect_surface_v1 version 1. type ExtBackgroundEffectSurface struct { wl.BaseProxy } // NewExtBackgroundEffectSurface returns an unbound ExtBackgroundEffectSurface. func NewExtBackgroundEffectSurface(ctx *wl.Context) *ExtBackgroundEffectSurface { obj := &ExtBackgroundEffectSurface{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Informs the server that the client will no longer be using this protocol object. The effect regions will be removed on the next commit. func (o *ExtBackgroundEffectSurface) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_background_effect_surface_v1.destroy", Destructor: true}); err != nil { return err } return nil } // This request sets the region of the surface that will have its background blurred. The blur region is specified in the surface-local coordinates, and clipped by the compositor to the surface size. The initial value for the blur region is empty. Setting the pending blur region has copy semantics, and the wl_region object can be destroyed immediately. A NULL wl_region removes the effect. The blur region is double-buffered state, and will be applied on the next wl_surface.commit. The blur algorithm is subject to compositor policies. If the associated surface has been destroyed, the surface_destroyed error will be raised. func (o *ExtBackgroundEffectSurface) SetBlurRegion(region *cross_wl_region.Region) error { var arg0 wl.Object if region != nil { arg0 = region } if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_background_effect_surface_v1.set_blur_region"}, wl.ArgObject(arg0)); err != nil { return err } return nil } // EventSignature returns the declared event argument types in wire order. func (o *ExtBackgroundEffectSurface) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on ext_background_effect_surface_v1 and calls the registered handlers. func (o *ExtBackgroundEffectSurface) Dispatch(event *wl.Event) { switch event.Opcode { default: } }