// Code generated by wlbgen. DO NOT EDIT. // Protocol: xdg_foreign_unstable_v2 // Source: xdg-foreign-unstable-v2.xml // Upstream protocol copyright and license: // Copyright © 2015-2016 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 xdgforeign import ( "sync" cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // ZXDG_EXPORTER_V2_ERROR_INVALID_SURFACE is the error invalid_surface value. const ZXDG_EXPORTER_V2_ERROR_INVALID_SURFACE = 0 // ZXDG_IMPORTED_V2_ERROR_INVALID_SURFACE is the error invalid_surface value. const ZXDG_IMPORTED_V2_ERROR_INVALID_SURFACE = 0 // ZxdgExporterInterface is the protocol interface name. const ZxdgExporterInterface = "zxdg_exporter_v2" // ZxdgExporter is the generated binding for zxdg_exporter_v2 version 1. type ZxdgExporter struct { wl.BaseProxy } // NewZxdgExporter returns an unbound ZxdgExporter. func NewZxdgExporter(ctx *wl.Context) *ZxdgExporter { obj := &ZxdgExporter{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Notify the compositor that the xdg_exporter object will no longer be used. func (o *ZxdgExporter) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zxdg_exporter_v2.destroy", Destructor: true}); err != nil { return err } return nil } // The export_toplevel request exports the passed surface so that it can later be imported via xdg_importer. When called, a new xdg_exported object will be created and xdg_exported.handle will be sent immediately. See the corresponding interface and event for details. A surface may be exported multiple times, and each exported handle may be used to create an xdg_imported multiple times. Only xdg_toplevel equivalent surfaces may be exported, otherwise an invalid_surface protocol error is sent. func (o *ZxdgExporter) ExportToplevel(surface *cross_wl_surface.Surface) (*ZxdgExported, error) { var arg1 wl.Object if surface != nil { arg1 = surface } child := &ZxdgExported{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zxdg_exporter_v2.export_toplevel", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *ZxdgExporter) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zxdg_exporter_v2 and calls the registered handlers. func (o *ZxdgExporter) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // ZxdgImporterInterface is the protocol interface name. const ZxdgImporterInterface = "zxdg_importer_v2" // ZxdgImporter is the generated binding for zxdg_importer_v2 version 1. type ZxdgImporter struct { wl.BaseProxy } // NewZxdgImporter returns an unbound ZxdgImporter. func NewZxdgImporter(ctx *wl.Context) *ZxdgImporter { obj := &ZxdgImporter{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Notify the compositor that the xdg_importer object will no longer be used. func (o *ZxdgImporter) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zxdg_importer_v2.destroy", Destructor: true}); err != nil { return err } return nil } // The import_toplevel request imports a surface from any client given a handle retrieved by exporting said surface using xdg_exporter.export_toplevel. When called, a new xdg_imported object will be created. This new object represents the imported surface, and the importing client can manipulate its relationship using it. See xdg_imported for details. func (o *ZxdgImporter) ImportToplevel(handle string) (*ZxdgImported, error) { child := &ZxdgImported{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zxdg_importer_v2.import_toplevel", Child: child}, wl.ArgObject(child), wl.ArgString(handle)); err != nil { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *ZxdgImporter) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zxdg_importer_v2 and calls the registered handlers. func (o *ZxdgImporter) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // ZxdgExportedInterface is the protocol interface name. const ZxdgExportedInterface = "zxdg_exported_v2" // ZxdgExported is the generated binding for zxdg_exported_v2 version 1. type ZxdgExported struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onHandle []func(handle string) } // NewZxdgExported returns an unbound ZxdgExported. func NewZxdgExported(ctx *wl.Context) *ZxdgExported { obj := &ZxdgExported{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Revoke the previously exported surface. This invalidates any relationship the importer may have set up using the xdg_imported created given the handle sent via xdg_exported.handle. func (o *ZxdgExported) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zxdg_exported_v2.destroy", Destructor: true}); err != nil { return err } return nil } // OnHandle registers a handler for the handle 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 *ZxdgExported) OnHandle(handler func(handle string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onHandle = append(o.onHandle, handler) } // handlersForHandle returns the handlers registered for handle, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ZxdgExported) handlersForHandle() []func(handle string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onHandle } // EventSignature returns the declared event argument types in wire order. func (o *ZxdgExported) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "string,", true default: return "", false } } // Dispatch decodes one event on zxdg_exported_v2 and calls the registered handlers. func (o *ZxdgExported) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // handle handle := event.String() for i, handler := range o.handlersForHandle() { _ = i handler(handle) } default: } } // ZxdgImportedInterface is the protocol interface name. const ZxdgImportedInterface = "zxdg_imported_v2" // ZxdgImported is the generated binding for zxdg_imported_v2 version 1. type ZxdgImported struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onDestroyed []func() } // NewZxdgImported returns an unbound ZxdgImported. func NewZxdgImported(ctx *wl.Context) *ZxdgImported { obj := &ZxdgImported{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Notify the compositor that it will no longer use the xdg_imported object. Any relationship that may have been set up will at this point be invalidated. func (o *ZxdgImported) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zxdg_imported_v2.destroy", Destructor: true}); err != nil { return err } return nil } // Set the imported surface as the parent of some surface of the client. The passed surface must be an xdg_toplevel equivalent, otherwise an invalid_surface protocol error is sent. Calling this function sets up a surface to surface relation with the same stacking and positioning semantics as xdg_toplevel.set_parent. func (o *ZxdgImported) SetParentOf(surface *cross_wl_surface.Surface) error { var arg0 wl.Object if surface != nil { arg0 = surface } if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zxdg_imported_v2.set_parent_of"}, wl.ArgObject(arg0)); err != nil { return err } return nil } // OnDestroyed registers a handler for the destroyed 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 *ZxdgImported) OnDestroyed(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDestroyed = append(o.onDestroyed, handler) } // handlersForDestroyed returns the handlers registered for destroyed, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ZxdgImported) handlersForDestroyed() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDestroyed } // EventSignature returns the declared event argument types in wire order. func (o *ZxdgImported) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "", true default: return "", false } } // Dispatch decodes one event on zxdg_imported_v2 and calls the registered handlers. func (o *ZxdgImported) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // destroyed for i, handler := range o.handlersForDestroyed() { _ = i handler() } default: } }