1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2023 Valve Corporation
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 committiming
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var WpCommitTimingManagerV1Interface *server.Interface
34var WpCommitTimerV1Interface *server.Interface
35
36func init() {
37 WpCommitTimingManagerV1Interface = &server.Interface{Name: "wp_commit_timing_manager_v1", Version: 1}
38 WpCommitTimerV1Interface = &server.Interface{Name: "wp_commit_timer_v1", Version: 1}
39 WpCommitTimingManagerV1Interface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 {Name: "get_timer", Signature: "no", Types: []*server.Interface{WpCommitTimerV1Interface, wayland.SurfaceInterface}},
42 }
43 WpCommitTimingManagerV1Interface.Events = []server.Message{}
44 WpCommitTimerV1Interface.Requests = []server.Message{
45 {Name: "set_timestamp", Signature: "uuu", Types: []*server.Interface{nil, nil, nil}},
46 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
47 }
48 WpCommitTimerV1Interface.Events = []server.Message{}
49 if err := server.NewInterfaces(WpCommitTimingManagerV1Interface, WpCommitTimerV1Interface); err != nil {
50 panic(err)
51 }
52}
53
54// WpCommitTimingManagerV1 commit timing.
55type WpCommitTimingManagerV1 struct{ *server.Resource }
56
57func WrapWpCommitTimingManagerV1(r *server.Resource) *WpCommitTimingManagerV1 {
58 if r == nil {
59 return nil
60 }
61 return &WpCommitTimingManagerV1{r}
62}
63
64const WpCommitTimingManagerV1RequestDestroy uint32 = 0
65const WpCommitTimingManagerV1RequestGetTimer uint32 = 1
66
67// WpCommitTimingManagerV1Error .
68type WpCommitTimingManagerV1Error uint32
69
70const (
71 WpCommitTimingManagerV1ErrorCommitTimerExists WpCommitTimingManagerV1Error = 0
72)
73
74// WpCommitTimingManagerV1Handler handles wp_commit_timing_manager_v1 requests.
75type WpCommitTimingManagerV1Handler interface {
76 Destroy(self *WpCommitTimingManagerV1)
77 GetTimer(self *WpCommitTimingManagerV1, id uint32, surface *wayland.Surface)
78}
79
80func NewWpCommitTimingManagerV1(c server.Client, version int32, id uint32, h WpCommitTimingManagerV1Handler) (*WpCommitTimingManagerV1, error) {
81 if h == nil {
82 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_commit_timing_manager_v1")
83 }
84 var self *WpCommitTimingManagerV1
85 r, err := c.CreateResource(WpCommitTimingManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
86 switch opcode {
87 case 0:
88 h.Destroy(self)
89 self.Destroy()
90 case 1:
91 h.GetTimer(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
92 }
93 })
94 if err != nil {
95 return nil, err
96 }
97 self = WrapWpCommitTimingManagerV1(r)
98 r.Data = self
99 return self, nil
100}
101func NewWpCommitTimingManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
102 return d.CreateGlobal(WpCommitTimingManagerV1Interface, version, bind)
103}
104
105// WpCommitTimerV1 Surface commit timer.
106type WpCommitTimerV1 struct{ *server.Resource }
107
108func WrapWpCommitTimerV1(r *server.Resource) *WpCommitTimerV1 {
109 if r == nil {
110 return nil
111 }
112 return &WpCommitTimerV1{r}
113}
114
115const WpCommitTimerV1RequestSetTimestamp uint32 = 0
116const WpCommitTimerV1RequestDestroy uint32 = 1
117
118// WpCommitTimerV1Error .
119type WpCommitTimerV1Error uint32
120
121const (
122 WpCommitTimerV1ErrorInvalidTimestamp WpCommitTimerV1Error = 0
123 WpCommitTimerV1ErrorTimestampExists WpCommitTimerV1Error = 1
124 WpCommitTimerV1ErrorSurfaceDestroyed WpCommitTimerV1Error = 2
125)
126
127// WpCommitTimerV1Handler handles wp_commit_timer_v1 requests.
128type WpCommitTimerV1Handler interface {
129 SetTimestamp(self *WpCommitTimerV1, tvSecHi uint32, tvSecLo uint32, tvNsec uint32)
130 Destroy(self *WpCommitTimerV1)
131}
132
133func NewWpCommitTimerV1(c server.Client, version int32, id uint32, h WpCommitTimerV1Handler) (*WpCommitTimerV1, error) {
134 if h == nil {
135 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_commit_timer_v1")
136 }
137 var self *WpCommitTimerV1
138 r, err := c.CreateResource(WpCommitTimerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
139 switch opcode {
140 case 0:
141 h.SetTimestamp(self, args[0].Uint(), args[1].Uint(), args[2].Uint())
142 case 1:
143 h.Destroy(self)
144 self.Destroy()
145 }
146 })
147 if err != nil {
148 return nil, err
149 }
150 self = WrapWpCommitTimerV1(r)
151 r.Data = self
152 return self, nil
153}
154func NewWpCommitTimerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
155 return d.CreateGlobal(WpCommitTimerV1Interface, version, bind)
156}
157func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
158 if v == nil {
159 return nil
160 }
161 return v.GetResource()
162}
163func (self *WpCommitTimingManagerV1) GetResource() *server.Resource {
164 if self == nil {
165 return nil
166 }
167 return self.Resource
168}
169func (self *WpCommitTimerV1) GetResource() *server.Resource {
170 if self == nil {
171 return nil
172 }
173 return self.Resource
174}