// Code generated by wlbgen. DO NOT EDIT. // Protocol: presentation_time // Source: presentation-time.xml // Upstream protocol copyright and license: // Copyright © 2013-2014 Collabora, Ltd. // // 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 presentationtime import ( "sync" cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // ERROR_INVALID_TIMESTAMP is the error invalid_timestamp value. const ERROR_INVALID_TIMESTAMP = 0 // ERROR_INVALID_FLAG is the error invalid_flag value. const ERROR_INVALID_FLAG = 1 // KIND_VSYNC is the kind vsync value. const KIND_VSYNC = 0x1 // KIND_HW_CLOCK is the kind hw_clock value. const KIND_HW_CLOCK = 0x2 // KIND_HW_COMPLETION is the kind hw_completion value. const KIND_HW_COMPLETION = 0x4 // KIND_ZERO_COPY is the kind zero_copy value. const KIND_ZERO_COPY = 0x8 // WpPresentationInterface is the protocol interface name. const WpPresentationInterface = "wp_presentation" // WpPresentation is the generated binding for wp_presentation version 2. type WpPresentation struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onClockId []func(clkId uint32) } // NewWpPresentation returns an unbound WpPresentation. func NewWpPresentation(ctx *wl.Context) *WpPresentation { obj := &WpPresentation{} 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 *WpPresentation) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_presentation.destroy", Destructor: true}); err != nil { return err } return nil } // Request presentation feedback for the current content submission on the given surface. This creates a new presentation_feedback object, which will deliver the feedback information once. If multiple presentation_feedback objects are created for the same submission, they will all deliver the same information. For details on what information is returned, see the presentation_feedback interface. func (o *WpPresentation) Feedback(surface *cross_wl_surface.Surface) (*WpPresentationFeedback, error) { var arg0 wl.Object if surface != nil { arg0 = surface } child := &WpPresentationFeedback{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_presentation.feedback", Child: child}, wl.ArgObject(arg0), wl.ArgObject(child)); err != nil { return nil, err } return child, nil } // OnClockId registers a handler for the clock_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 *WpPresentation) OnClockId(handler func(clkId uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onClockId = append(o.onClockId, handler) } // handlersForClockId returns the handlers registered for clock_id, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *WpPresentation) handlersForClockId() []func(clkId uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onClockId } // EventSignature returns the declared event argument types in wire order. func (o *WpPresentation) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true default: return "", false } } // Dispatch decodes one event on wp_presentation and calls the registered handlers. func (o *WpPresentation) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // clock_id clkId := event.Uint32() for i, handler := range o.handlersForClockId() { _ = i handler(clkId) } default: } } // WpPresentationFeedbackInterface is the protocol interface name. const WpPresentationFeedbackInterface = "wp_presentation_feedback" // WpPresentationFeedback is the generated binding for wp_presentation_feedback version 2. type WpPresentationFeedback struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onSyncOutput []func(outputID uint32) onPresented []func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32, refresh uint32, seqHi uint32, seqLo uint32, flags uint32) onDiscarded []func() } // NewWpPresentationFeedback returns an unbound WpPresentationFeedback. func NewWpPresentationFeedback(ctx *wl.Context) *WpPresentationFeedback { obj := &WpPresentationFeedback{} obj.SetContext(ctx) ctx.Register(obj) return obj } // OnSyncOutput registers a handler for the sync_output 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 *WpPresentationFeedback) OnSyncOutput(handler func(outputID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSyncOutput = append(o.onSyncOutput, handler) } // handlersForSyncOutput returns the handlers registered for sync_output, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *WpPresentationFeedback) handlersForSyncOutput() []func(outputID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSyncOutput } // OnPresented registers a handler for the presented 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 *WpPresentationFeedback) OnPresented(handler func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32, refresh uint32, seqHi uint32, seqLo uint32, flags uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPresented = append(o.onPresented, handler) } // handlersForPresented returns the handlers registered for presented, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *WpPresentationFeedback) handlersForPresented() []func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32, refresh uint32, seqHi uint32, seqLo uint32, flags uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPresented } // OnDiscarded registers a handler for the discarded 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 *WpPresentationFeedback) OnDiscarded(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDiscarded = append(o.onDiscarded, handler) } // handlersForDiscarded returns the handlers registered for discarded, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *WpPresentationFeedback) handlersForDiscarded() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDiscarded } // EventSignature returns the declared event argument types in wire order. func (o *WpPresentationFeedback) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "object,", true case 1: return "uint,uint,uint,uint,uint,uint,uint,", true case 2: return "", true default: return "", false } } // Dispatch decodes one event on wp_presentation_feedback and calls the registered handlers. func (o *WpPresentationFeedback) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // sync_output outputID := event.Uint32() for i, handler := range o.handlersForSyncOutput() { _ = i handler(outputID) } case 1: // presented tvSecHi := event.Uint32() tvSecLo := event.Uint32() tvNsec := event.Uint32() refresh := event.Uint32() seqHi := event.Uint32() seqLo := event.Uint32() flags := event.Uint32() for i, handler := range o.handlersForPresented() { _ = i handler(tvSecHi, tvSecLo, tvNsec, refresh, seqHi, seqLo, flags) } o.Context().Unregister(o) case 2: // discarded for i, handler := range o.handlersForDiscarded() { _ = i handler() } o.Context().Unregister(o) default: } }