1// Code generated by wlgen; DO NOT EDIT.
2package presentationtime
3
4import (
5 "fmt"
6 wayland "github.com/bnema/purego-libwayland/protocol/wayland"
7 "github.com/bnema/purego-libwayland/server"
8)
9
10var WpPresentationInterface *server.Interface
11var WpPresentationFeedbackInterface *server.Interface
12
13func init() {
14 WpPresentationInterface = &server.Interface{Name: "wp_presentation", Version: 2}
15 WpPresentationFeedbackInterface = &server.Interface{Name: "wp_presentation_feedback", Version: 2}
16 WpPresentationInterface.Requests = []server.Message{
17 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
18 {Name: "feedback", Signature: "on", Types: []*server.Interface{wayland.SurfaceInterface, WpPresentationFeedbackInterface}},
19 }
20 WpPresentationInterface.Events = []server.Message{
21 {Name: "clock_id", Signature: "u", Types: []*server.Interface{nil}},
22 }
23 WpPresentationFeedbackInterface.Requests = []server.Message{}
24 WpPresentationFeedbackInterface.Events = []server.Message{
25 {Name: "sync_output", Signature: "o", Types: []*server.Interface{wayland.OutputInterface}},
26 {Name: "presented", Signature: "uuuuuuu", Types: []*server.Interface{nil, nil, nil, nil, nil, nil, nil}},
27 {Name: "discarded", Signature: "", Types: []*server.Interface{}},
28 }
29 if err := server.NewInterfaces(WpPresentationInterface, WpPresentationFeedbackInterface); err != nil {
30 panic(err)
31 }
32}
33
34// WpPresentation timed presentation related wl_surface requests.
35type WpPresentation struct{ *server.Resource }
36
37func WrapWpPresentation(r *server.Resource) *WpPresentation {
38 if r == nil {
39 return nil
40 }
41 return &WpPresentation{r}
42}
43
44const WpPresentationRequestDestroy uint32 = 0
45const WpPresentationRequestFeedback uint32 = 1
46const WpPresentationEventClockId uint32 = 0
47
48// WpPresentationError fatal presentation errors.
49type WpPresentationError uint32
50
51const (
52 WpPresentationErrorInvalidTimestamp WpPresentationError = 0
53 WpPresentationErrorInvalidFlag WpPresentationError = 1
54)
55
56// WpPresentationHandler handles wp_presentation requests.
57type WpPresentationHandler interface {
58 Destroy(self *WpPresentation)
59 Feedback(self *WpPresentation, surface *wayland.Surface, callback uint32)
60}
61
62func NewWpPresentation(c server.Client, version int32, id uint32, h WpPresentationHandler) (*WpPresentation, error) {
63 if h == nil {
64 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_presentation")
65 }
66 var self *WpPresentation
67 r, err := c.CreateResource(WpPresentationInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
68 switch opcode {
69 case 0:
70 h.Destroy(self)
71 self.Destroy()
72 case 1:
73 h.Feedback(self, wayland.WrapSurface(args[0].Resource()), args[1].NewID())
74 }
75 })
76 if err != nil {
77 return nil, err
78 }
79 self = WrapWpPresentation(r)
80 r.Data = self
81 return self, nil
82}
83
84// SendClockId clock ID for timestamps.
85func (self *WpPresentation) SendClockId(clkId uint32) {
86 self.PostEvent(WpPresentationEventClockId, server.Uint(clkId))
87}
88func NewWpPresentationGlobal(d *server.Display, version int32, bind server.BindFunc) error {
89 return d.CreateGlobal(WpPresentationInterface, version, bind)
90}
91
92// WpPresentationFeedback presentation time feedback event.
93type WpPresentationFeedback struct{ *server.Resource }
94
95func WrapWpPresentationFeedback(r *server.Resource) *WpPresentationFeedback {
96 if r == nil {
97 return nil
98 }
99 return &WpPresentationFeedback{r}
100}
101
102const WpPresentationFeedbackEventSyncOutput uint32 = 0
103const WpPresentationFeedbackEventPresented uint32 = 1
104const WpPresentationFeedbackEventDiscarded uint32 = 2
105
106// WpPresentationFeedbackKind bitmask of flags in presented event (bitfield).
107type WpPresentationFeedbackKind uint32
108
109const (
110 WpPresentationFeedbackKindVsync WpPresentationFeedbackKind = 0x1
111 WpPresentationFeedbackKindHwClock WpPresentationFeedbackKind = 0x2
112 WpPresentationFeedbackKindHwCompletion WpPresentationFeedbackKind = 0x4
113 WpPresentationFeedbackKindZeroCopy WpPresentationFeedbackKind = 0x8
114)
115
116// WpPresentationFeedbackHandler handles wp_presentation_feedback requests.
117type WpPresentationFeedbackHandler interface {
118}
119
120func NewWpPresentationFeedback(c server.Client, version int32, id uint32, h WpPresentationFeedbackHandler) (*WpPresentationFeedback, error) {
121 var self *WpPresentationFeedback
122 r, err := c.CreateResource(WpPresentationFeedbackInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
123 switch opcode {
124 }
125 })
126 if err != nil {
127 return nil, err
128 }
129 self = WrapWpPresentationFeedback(r)
130 r.Data = self
131 return self, nil
132}
133
134// SendSyncOutput presentation synchronized to this output.
135func (self *WpPresentationFeedback) SendSyncOutput(output *wayland.Output) {
136 self.PostEvent(WpPresentationFeedbackEventSyncOutput, server.Object(resourceOf(output)))
137}
138
139// SendPresented the content update was displayed.
140func (self *WpPresentationFeedback) SendPresented(tvSecHi uint32, tvSecLo uint32, tvNsec uint32, refresh uint32, seqHi uint32, seqLo uint32, flags uint32) {
141 self.PostEvent(WpPresentationFeedbackEventPresented, server.Uint(tvSecHi), server.Uint(tvSecLo), server.Uint(tvNsec), server.Uint(refresh), server.Uint(seqHi), server.Uint(seqLo), server.Uint(flags))
142}
143
144// SendDiscarded the content update was not displayed.
145func (self *WpPresentationFeedback) SendDiscarded() {
146 self.PostEvent(WpPresentationFeedbackEventDiscarded)
147}
148func NewWpPresentationFeedbackGlobal(d *server.Display, version int32, bind server.BindFunc) error {
149 return d.CreateGlobal(WpPresentationFeedbackInterface, version, bind)
150}
151func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
152 if v == nil {
153 return nil
154 }
155 return v.GetResource()
156}
157func (self *WpPresentation) GetResource() *server.Resource {
158 if self == nil {
159 return nil
160 }
161 return self.Resource
162}
163func (self *WpPresentationFeedback) GetResource() *server.Resource {
164 if self == nil {
165 return nil
166 }
167 return self.Resource
168}