1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2013-2014 Collabora, Ltd.
5//
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice (including the next
14// paragraph) shall be included in all copies or substantial portions of the
15// Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25package presentationtime
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var WpPresentationInterface *server.Interface
34var WpPresentationFeedbackInterface *server.Interface
35
36func init() {
37 WpPresentationInterface = &server.Interface{Name: "wp_presentation", Version: 2}
38 WpPresentationFeedbackInterface = &server.Interface{Name: "wp_presentation_feedback", Version: 2}
39 WpPresentationInterface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 {Name: "feedback", Signature: "on", Types: []*server.Interface{wayland.SurfaceInterface, WpPresentationFeedbackInterface}},
42 }
43 WpPresentationInterface.Events = []server.Message{
44 {Name: "clock_id", Signature: "u", Types: []*server.Interface{nil}},
45 }
46 WpPresentationFeedbackInterface.Requests = []server.Message{}
47 WpPresentationFeedbackInterface.Events = []server.Message{
48 {Name: "sync_output", Signature: "o", Types: []*server.Interface{wayland.OutputInterface}},
49 {Name: "presented", Signature: "uuuuuuu", Types: []*server.Interface{nil, nil, nil, nil, nil, nil, nil}},
50 {Name: "discarded", Signature: "", Types: []*server.Interface{}},
51 }
52 if err := server.NewInterfaces(WpPresentationInterface, WpPresentationFeedbackInterface); err != nil {
53 panic(err)
54 }
55}
56
57// WpPresentation timed presentation related wl_surface requests.
58type WpPresentation struct{ *server.Resource }
59
60func WrapWpPresentation(r *server.Resource) *WpPresentation {
61 if r == nil {
62 return nil
63 }
64 return &WpPresentation{r}
65}
66
67const WpPresentationRequestDestroy uint32 = 0
68const WpPresentationRequestFeedback uint32 = 1
69const WpPresentationEventClockId uint32 = 0
70
71// WpPresentationError fatal presentation errors.
72type WpPresentationError uint32
73
74const (
75 WpPresentationErrorInvalidTimestamp WpPresentationError = 0
76 WpPresentationErrorInvalidFlag WpPresentationError = 1
77)
78
79// WpPresentationHandler handles wp_presentation requests.
80type WpPresentationHandler interface {
81 Destroy(self *WpPresentation)
82 Feedback(self *WpPresentation, surface *wayland.Surface, callback uint32)
83}
84
85func NewWpPresentation(c server.Client, version int32, id uint32, h WpPresentationHandler) (*WpPresentation, error) {
86 if h == nil {
87 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_presentation")
88 }
89 var self *WpPresentation
90 r, err := c.CreateResource(WpPresentationInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
91 switch opcode {
92 case 0:
93 h.Destroy(self)
94 self.Destroy()
95 case 1:
96 h.Feedback(self, wayland.WrapSurface(args[0].Resource()), args[1].NewID())
97 }
98 })
99 if err != nil {
100 return nil, err
101 }
102 self = WrapWpPresentation(r)
103 r.Data = self
104 return self, nil
105}
106
107// SendClockId clock ID for timestamps.
108func (self *WpPresentation) SendClockId(clkId uint32) {
109 self.PostEvent(WpPresentationEventClockId, server.Uint(clkId))
110}
111func NewWpPresentationGlobal(d *server.Display, version int32, bind server.BindFunc) error {
112 return d.CreateGlobal(WpPresentationInterface, version, bind)
113}
114
115// WpPresentationFeedback presentation time feedback event.
116type WpPresentationFeedback struct{ *server.Resource }
117
118func WrapWpPresentationFeedback(r *server.Resource) *WpPresentationFeedback {
119 if r == nil {
120 return nil
121 }
122 return &WpPresentationFeedback{r}
123}
124
125const WpPresentationFeedbackEventSyncOutput uint32 = 0
126const WpPresentationFeedbackEventPresented uint32 = 1
127const WpPresentationFeedbackEventDiscarded uint32 = 2
128
129// WpPresentationFeedbackKind bitmask of flags in presented event (bitfield).
130type WpPresentationFeedbackKind uint32
131
132const (
133 WpPresentationFeedbackKindVsync WpPresentationFeedbackKind = 0x1
134 WpPresentationFeedbackKindHwClock WpPresentationFeedbackKind = 0x2
135 WpPresentationFeedbackKindHwCompletion WpPresentationFeedbackKind = 0x4
136 WpPresentationFeedbackKindZeroCopy WpPresentationFeedbackKind = 0x8
137)
138
139// WpPresentationFeedbackHandler handles wp_presentation_feedback requests.
140type WpPresentationFeedbackHandler interface {
141}
142
143func NewWpPresentationFeedback(c server.Client, version int32, id uint32, h WpPresentationFeedbackHandler) (*WpPresentationFeedback, error) {
144 var self *WpPresentationFeedback
145 r, err := c.CreateResource(WpPresentationFeedbackInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
146 switch opcode {
147 }
148 })
149 if err != nil {
150 return nil, err
151 }
152 self = WrapWpPresentationFeedback(r)
153 r.Data = self
154 return self, nil
155}
156
157// SendSyncOutput presentation synchronized to this output.
158func (self *WpPresentationFeedback) SendSyncOutput(output *wayland.Output) {
159 self.PostEvent(WpPresentationFeedbackEventSyncOutput, server.Object(resourceOf(output)))
160}
161
162// SendPresented the content update was displayed.
163func (self *WpPresentationFeedback) SendPresented(tvSecHi uint32, tvSecLo uint32, tvNsec uint32, refresh uint32, seqHi uint32, seqLo uint32, flags uint32) {
164 self.PostEvent(WpPresentationFeedbackEventPresented, server.Uint(tvSecHi), server.Uint(tvSecLo), server.Uint(tvNsec), server.Uint(refresh), server.Uint(seqHi), server.Uint(seqLo), server.Uint(flags))
165}
166
167// SendDiscarded the content update was not displayed.
168func (self *WpPresentationFeedback) SendDiscarded() {
169 self.PostEvent(WpPresentationFeedbackEventDiscarded)
170}
171func NewWpPresentationFeedbackGlobal(d *server.Display, version int32, bind server.BindFunc) error {
172 return d.CreateGlobal(WpPresentationFeedbackInterface, version, bind)
173}
174func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
175 if v == nil {
176 return nil
177 }
178 return v.GetResource()
179}
180func (self *WpPresentation) GetResource() *server.Resource {
181 if self == nil {
182 return nil
183 }
184 return self.Resource
185}
186func (self *WpPresentationFeedback) GetResource() *server.Resource {
187 if self == nil {
188 return nil
189 }
190 return self.Resource
191}