1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2013-2016 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 viewporter
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var WpViewporterInterface *server.Interface
34var WpViewportInterface *server.Interface
35
36func init() {
37 WpViewporterInterface = &server.Interface{Name: "wp_viewporter", Version: 1}
38 WpViewportInterface = &server.Interface{Name: "wp_viewport", Version: 1}
39 WpViewporterInterface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 {Name: "get_viewport", Signature: "no", Types: []*server.Interface{WpViewportInterface, wayland.SurfaceInterface}},
42 }
43 WpViewporterInterface.Events = []server.Message{}
44 WpViewportInterface.Requests = []server.Message{
45 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
46 {Name: "set_source", Signature: "ffff", Types: []*server.Interface{nil, nil, nil, nil}},
47 {Name: "set_destination", Signature: "ii", Types: []*server.Interface{nil, nil}},
48 }
49 WpViewportInterface.Events = []server.Message{}
50 if err := server.NewInterfaces(WpViewporterInterface, WpViewportInterface); err != nil {
51 panic(err)
52 }
53}
54
55// WpViewporter surface cropping and scaling.
56type WpViewporter struct{ *server.Resource }
57
58func WrapWpViewporter(r *server.Resource) *WpViewporter {
59 if r == nil {
60 return nil
61 }
62 return &WpViewporter{r}
63}
64
65const WpViewporterRequestDestroy uint32 = 0
66const WpViewporterRequestGetViewport uint32 = 1
67
68// WpViewporterError .
69type WpViewporterError uint32
70
71const (
72 WpViewporterErrorViewportExists WpViewporterError = 0
73)
74
75// WpViewporterHandler handles wp_viewporter requests.
76type WpViewporterHandler interface {
77 Destroy(self *WpViewporter)
78 GetViewport(self *WpViewporter, id uint32, surface *wayland.Surface)
79}
80
81func NewWpViewporter(c server.Client, version int32, id uint32, h WpViewporterHandler) (*WpViewporter, error) {
82 if h == nil {
83 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_viewporter")
84 }
85 var self *WpViewporter
86 r, err := c.CreateResource(WpViewporterInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
87 switch opcode {
88 case 0:
89 h.Destroy(self)
90 self.Destroy()
91 case 1:
92 h.GetViewport(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
93 }
94 })
95 if err != nil {
96 return nil, err
97 }
98 self = WrapWpViewporter(r)
99 r.Data = self
100 return self, nil
101}
102func NewWpViewporterGlobal(d *server.Display, version int32, bind server.BindFunc) error {
103 return d.CreateGlobal(WpViewporterInterface, version, bind)
104}
105
106// WpViewport crop and scale interface to a wl_surface.
107type WpViewport struct{ *server.Resource }
108
109func WrapWpViewport(r *server.Resource) *WpViewport {
110 if r == nil {
111 return nil
112 }
113 return &WpViewport{r}
114}
115
116const WpViewportRequestDestroy uint32 = 0
117const WpViewportRequestSetSource uint32 = 1
118const WpViewportRequestSetDestination uint32 = 2
119
120// WpViewportError .
121type WpViewportError uint32
122
123const (
124 WpViewportErrorBadValue WpViewportError = 0
125 WpViewportErrorBadSize WpViewportError = 1
126 WpViewportErrorOutOfBuffer WpViewportError = 2
127 WpViewportErrorNoSurface WpViewportError = 3
128)
129
130// WpViewportHandler handles wp_viewport requests.
131type WpViewportHandler interface {
132 Destroy(self *WpViewport)
133 SetSource(self *WpViewport, x server.Fixed, y server.Fixed, width server.Fixed, height server.Fixed)
134 SetDestination(self *WpViewport, width int32, height int32)
135}
136
137func NewWpViewport(c server.Client, version int32, id uint32, h WpViewportHandler) (*WpViewport, error) {
138 if h == nil {
139 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_viewport")
140 }
141 var self *WpViewport
142 r, err := c.CreateResource(WpViewportInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
143 switch opcode {
144 case 0:
145 h.Destroy(self)
146 self.Destroy()
147 case 1:
148 h.SetSource(self, args[0].Fixed(), args[1].Fixed(), args[2].Fixed(), args[3].Fixed())
149 case 2:
150 h.SetDestination(self, args[0].Int(), args[1].Int())
151 }
152 })
153 if err != nil {
154 return nil, err
155 }
156 self = WrapWpViewport(r)
157 r.Data = self
158 return self, nil
159}
160func NewWpViewportGlobal(d *server.Display, version int32, bind server.BindFunc) error {
161 return d.CreateGlobal(WpViewportInterface, version, bind)
162}
163func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
164 if v == nil {
165 return nil
166 }
167 return v.GetResource()
168}
169func (self *WpViewporter) GetResource() *server.Resource {
170 if self == nil {
171 return nil
172 }
173 return self.Resource
174}
175func (self *WpViewport) GetResource() *server.Resource {
176 if self == nil {
177 return nil
178 }
179 return self.Resource
180}