// Code generated by wlbgen. DO NOT EDIT. // Protocol: fullscreen_shell_unstable_v1 // Source: fullscreen-shell-unstable-v1.xml // Upstream protocol copyright and license: // Copyright © 2016 Yong Bakos // Copyright © 2015 Jason Ekstrand // Copyright © 2015 Jonas Ådahl // // 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 fullscreenshell import ( "sync" cross_wl_output "github.com/bnema/go-wayland-bindings/client/wayland" cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // CAPABILITY_ARBITRARY_MODES is the capability arbitrary_modes value. const CAPABILITY_ARBITRARY_MODES = 1 // CAPABILITY_CURSOR_PLANE is the capability cursor_plane value. const CAPABILITY_CURSOR_PLANE = 2 // PRESENT_METHOD_DEFAULT is the present_method default value. const PRESENT_METHOD_DEFAULT = 0 // PRESENT_METHOD_CENTER is the present_method center value. const PRESENT_METHOD_CENTER = 1 // PRESENT_METHOD_ZOOM is the present_method zoom value. const PRESENT_METHOD_ZOOM = 2 // PRESENT_METHOD_ZOOM_CROP is the present_method zoom_crop value. const PRESENT_METHOD_ZOOM_CROP = 3 // PRESENT_METHOD_STRETCH is the present_method stretch value. const PRESENT_METHOD_STRETCH = 4 // ERROR_INVALID_METHOD is the error invalid_method value. const ERROR_INVALID_METHOD = 0 // ERROR_ROLE is the error role value. const ERROR_ROLE = 1 // FullscreenShellInterface is the protocol interface name. const FullscreenShellInterface = "zwp_fullscreen_shell_v1" // FullscreenShell is the generated binding for zwp_fullscreen_shell_v1 version 1. type FullscreenShell struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onCapability []func(capability uint32) } // NewFullscreenShell returns an unbound FullscreenShell. func NewFullscreenShell(ctx *wl.Context) *FullscreenShell { obj := &FullscreenShell{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Release the binding from the wl_fullscreen_shell interface. This destroys the server-side object and frees this binding. If the client binds to wl_fullscreen_shell multiple times, it may wish to free some of those bindings. func (o *FullscreenShell) Release() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_fullscreen_shell_v1.release", Destructor: true}); err != nil { return err } return nil } // Present a surface on the given output. If the output is null, the compositor will present the surface on whatever display (or displays) it thinks best. In particular, this may replace any or all surfaces currently presented so it should not be used in combination with placing surfaces on specific outputs. The method parameter is a hint to the compositor for how the surface is to be presented. In particular, it tells the compositor how to handle a size mismatch between the presented surface and the output. The compositor is free to ignore this parameter. The "zoom", "zoom_crop", and "stretch" methods imply a scaling operation on the surface. This will override any kind of output scaling, so the buffer_scale property of the surface is effectively ignored. This request gives the surface the role of a fullscreen shell surface. If the surface already has another role, it raises a role protocol error. func (o *FullscreenShell) PresentSurface(surface *cross_wl_surface.Surface, method uint32, output *cross_wl_output.Output) error { var arg0 wl.Object if surface != nil { arg0 = surface } var arg2 wl.Object if output != nil { arg2 = output } if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_fullscreen_shell_v1.present_surface"}, wl.ArgObject(arg0), wl.ArgUint(method), wl.ArgObject(arg2)); err != nil { return err } return nil } // Presents a surface on the given output for a particular mode. If the current size of the output differs from that of the surface, the compositor will attempt to change the size of the output to match the surface. The result of the mode-switch operation will be returned via the provided wl_fullscreen_shell_mode_feedback object. If the current output mode matches the one requested or if the compositor successfully switches the mode to match the surface, then the mode_successful event will be sent and the output will contain the contents of the given surface. If the compositor cannot match the output size to the surface size, the mode_failed will be sent and the output will contain the contents of the previously presented surface (if any). If another surface is presented on the given output before either of these has a chance to happen, the present_cancelled event will be sent. Due to race conditions and other issues unknown to the client, no mode-switch operation is guaranteed to succeed. However, if the mode is one advertised by wl_output.mode or if the compositor advertises the ARBITRARY_MODES capability, then the client should expect that the mode-switch operation will usually succeed. If the size of the presented surface changes, the resulting output is undefined. The compositor may attempt to change the output mode to compensate. However, there is no guarantee that a suitable mode will be found and the client has no way to be notified of success or failure. The framerate parameter specifies the desired framerate for the output in mHz. The compositor is free to ignore this parameter. A value of 0 indicates that the client has no preference. If the value of wl_output.scale differs from wl_surface.buffer_scale, then the compositor may choose a mode that matches either the buffer size or the surface size. In either case, the surface will fill the output. This request gives the surface the role of a fullscreen shell surface. If the surface already has another role, it raises a role protocol error. func (o *FullscreenShell) PresentSurfaceForMode(surface *cross_wl_surface.Surface, output *cross_wl_output.Output, framerate int32) (*FullscreenShellModeFeedback, error) { var arg0 wl.Object if surface != nil { arg0 = surface } var arg1 wl.Object if output != nil { arg1 = output } child := &FullscreenShellModeFeedback{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_fullscreen_shell_v1.present_surface_for_mode", Child: child}, wl.ArgObject(arg0), wl.ArgObject(arg1), wl.ArgInt(framerate), wl.ArgObject(child)); err != nil { return nil, err } return child, nil } // OnCapability registers a handler for the capability 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 *FullscreenShell) OnCapability(handler func(capability uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onCapability = append(o.onCapability, handler) } // handlersForCapability returns the handlers registered for capability, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *FullscreenShell) handlersForCapability() []func(capability uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCapability } // EventSignature returns the declared event argument types in wire order. func (o *FullscreenShell) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true default: return "", false } } // Dispatch decodes one event on zwp_fullscreen_shell_v1 and calls the registered handlers. func (o *FullscreenShell) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // capability capability := event.Uint32() for i, handler := range o.handlersForCapability() { _ = i handler(capability) } default: } } // FullscreenShellModeFeedbackInterface is the protocol interface name. const FullscreenShellModeFeedbackInterface = "zwp_fullscreen_shell_mode_feedback_v1" // FullscreenShellModeFeedback is the generated binding for zwp_fullscreen_shell_mode_feedback_v1 version 1. type FullscreenShellModeFeedback struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onModeSuccessful []func() onModeFailed []func() onPresentCancelled []func() } // NewFullscreenShellModeFeedback returns an unbound FullscreenShellModeFeedback. func NewFullscreenShellModeFeedback(ctx *wl.Context) *FullscreenShellModeFeedback { obj := &FullscreenShellModeFeedback{} obj.SetContext(ctx) ctx.Register(obj) return obj } // OnModeSuccessful registers a handler for the mode_successful 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 *FullscreenShellModeFeedback) OnModeSuccessful(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onModeSuccessful = append(o.onModeSuccessful, handler) } // handlersForModeSuccessful returns the handlers registered for mode_successful, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *FullscreenShellModeFeedback) handlersForModeSuccessful() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onModeSuccessful } // OnModeFailed registers a handler for the mode_failed 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 *FullscreenShellModeFeedback) OnModeFailed(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onModeFailed = append(o.onModeFailed, handler) } // handlersForModeFailed returns the handlers registered for mode_failed, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *FullscreenShellModeFeedback) handlersForModeFailed() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onModeFailed } // OnPresentCancelled registers a handler for the present_cancelled 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 *FullscreenShellModeFeedback) OnPresentCancelled(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPresentCancelled = append(o.onPresentCancelled, handler) } // handlersForPresentCancelled returns the handlers registered for present_cancelled, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *FullscreenShellModeFeedback) handlersForPresentCancelled() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPresentCancelled } // EventSignature returns the declared event argument types in wire order. func (o *FullscreenShellModeFeedback) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "", true case 1: return "", true case 2: return "", true default: return "", false } } // Dispatch decodes one event on zwp_fullscreen_shell_mode_feedback_v1 and calls the registered handlers. func (o *FullscreenShellModeFeedback) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // mode_successful for i, handler := range o.handlersForModeSuccessful() { _ = i handler() } o.Context().Unregister(o) case 1: // mode_failed for i, handler := range o.handlersForModeFailed() { _ = i handler() } o.Context().Unregister(o) case 2: // present_cancelled for i, handler := range o.handlersForPresentCancelled() { _ = i handler() } o.Context().Unregister(o) default: } }