1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2021 Xaver Hugl
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 tearingcontrol
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var WpTearingControlManagerV1Interface *server.Interface
34var WpTearingControlV1Interface *server.Interface
35
36func init() {
37 WpTearingControlManagerV1Interface = &server.Interface{Name: "wp_tearing_control_manager_v1", Version: 1}
38 WpTearingControlV1Interface = &server.Interface{Name: "wp_tearing_control_v1", Version: 1}
39 WpTearingControlManagerV1Interface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 {Name: "get_tearing_control", Signature: "no", Types: []*server.Interface{WpTearingControlV1Interface, wayland.SurfaceInterface}},
42 }
43 WpTearingControlManagerV1Interface.Events = []server.Message{}
44 WpTearingControlV1Interface.Requests = []server.Message{
45 {Name: "set_presentation_hint", Signature: "u", Types: []*server.Interface{nil}},
46 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
47 }
48 WpTearingControlV1Interface.Events = []server.Message{}
49 if err := server.NewInterfaces(WpTearingControlManagerV1Interface, WpTearingControlV1Interface); err != nil {
50 panic(err)
51 }
52}
53
54// WpTearingControlManagerV1 protocol for tearing control.
55type WpTearingControlManagerV1 struct{ *server.Resource }
56
57func WrapWpTearingControlManagerV1(r *server.Resource) *WpTearingControlManagerV1 {
58 if r == nil {
59 return nil
60 }
61 return &WpTearingControlManagerV1{r}
62}
63
64const WpTearingControlManagerV1RequestDestroy uint32 = 0
65const WpTearingControlManagerV1RequestGetTearingControl uint32 = 1
66
67// WpTearingControlManagerV1Error .
68type WpTearingControlManagerV1Error uint32
69
70const (
71 WpTearingControlManagerV1ErrorTearingControlExists WpTearingControlManagerV1Error = 0
72)
73
74// WpTearingControlManagerV1Handler handles wp_tearing_control_manager_v1 requests.
75type WpTearingControlManagerV1Handler interface {
76 Destroy(self *WpTearingControlManagerV1)
77 GetTearingControl(self *WpTearingControlManagerV1, id uint32, surface *wayland.Surface)
78}
79
80func NewWpTearingControlManagerV1(c server.Client, version int32, id uint32, h WpTearingControlManagerV1Handler) (*WpTearingControlManagerV1, error) {
81 if h == nil {
82 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_tearing_control_manager_v1")
83 }
84 var self *WpTearingControlManagerV1
85 r, err := c.CreateResource(WpTearingControlManagerV1Interface, 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.GetTearingControl(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
92 }
93 })
94 if err != nil {
95 return nil, err
96 }
97 self = WrapWpTearingControlManagerV1(r)
98 r.Data = self
99 return self, nil
100}
101func NewWpTearingControlManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
102 return d.CreateGlobal(WpTearingControlManagerV1Interface, version, bind)
103}
104
105// WpTearingControlV1 per-surface tearing control interface.
106type WpTearingControlV1 struct{ *server.Resource }
107
108func WrapWpTearingControlV1(r *server.Resource) *WpTearingControlV1 {
109 if r == nil {
110 return nil
111 }
112 return &WpTearingControlV1{r}
113}
114
115const WpTearingControlV1RequestSetPresentationHint uint32 = 0
116const WpTearingControlV1RequestDestroy uint32 = 1
117
118// WpTearingControlV1PresentationHint presentation hint values.
119type WpTearingControlV1PresentationHint uint32
120
121const (
122 WpTearingControlV1PresentationHintVsync WpTearingControlV1PresentationHint = 0
123 WpTearingControlV1PresentationHintAsync WpTearingControlV1PresentationHint = 1
124)
125
126// WpTearingControlV1Handler handles wp_tearing_control_v1 requests.
127type WpTearingControlV1Handler interface {
128 SetPresentationHint(self *WpTearingControlV1, hint uint32)
129 Destroy(self *WpTearingControlV1)
130}
131
132func NewWpTearingControlV1(c server.Client, version int32, id uint32, h WpTearingControlV1Handler) (*WpTearingControlV1, error) {
133 if h == nil {
134 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_tearing_control_v1")
135 }
136 var self *WpTearingControlV1
137 r, err := c.CreateResource(WpTearingControlV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
138 switch opcode {
139 case 0:
140 h.SetPresentationHint(self, args[0].Uint())
141 case 1:
142 h.Destroy(self)
143 self.Destroy()
144 }
145 })
146 if err != nil {
147 return nil, err
148 }
149 self = WrapWpTearingControlV1(r)
150 r.Data = self
151 return self, nil
152}
153func NewWpTearingControlV1Global(d *server.Display, version int32, bind server.BindFunc) error {
154 return d.CreateGlobal(WpTearingControlV1Interface, version, bind)
155}
156func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
157 if v == nil {
158 return nil
159 }
160 return v.GetResource()
161}
162func (self *WpTearingControlManagerV1) GetResource() *server.Resource {
163 if self == nil {
164 return nil
165 }
166 return self.Resource
167}
168func (self *WpTearingControlV1) GetResource() *server.Resource {
169 if self == nil {
170 return nil
171 }
172 return self.Resource
173}