1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2021 Emmanuel Gil Peyrot
5// Copyright © 2022 Xaver Hugl
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice (including the next
15// paragraph) shall be included in all copies or substantial portions of the
16// Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24// DEALINGS IN THE SOFTWARE.
25
26package contenttype
27
28import (
29 "fmt"
30 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
31 "github.com/bnema/purego-libwayland/server"
32)
33
34var WpContentTypeManagerV1Interface *server.Interface
35var WpContentTypeV1Interface *server.Interface
36
37func init() {
38 WpContentTypeManagerV1Interface = &server.Interface{Name: "wp_content_type_manager_v1", Version: 1}
39 WpContentTypeV1Interface = &server.Interface{Name: "wp_content_type_v1", Version: 1}
40 WpContentTypeManagerV1Interface.Requests = []server.Message{
41 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
42 {Name: "get_surface_content_type", Signature: "no", Types: []*server.Interface{WpContentTypeV1Interface, wayland.SurfaceInterface}},
43 }
44 WpContentTypeManagerV1Interface.Events = []server.Message{}
45 WpContentTypeV1Interface.Requests = []server.Message{
46 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
47 {Name: "set_content_type", Signature: "u", Types: []*server.Interface{nil}},
48 }
49 WpContentTypeV1Interface.Events = []server.Message{}
50 if err := server.NewInterfaces(WpContentTypeManagerV1Interface, WpContentTypeV1Interface); err != nil {
51 panic(err)
52 }
53}
54
55// WpContentTypeManagerV1 surface content type manager.
56type WpContentTypeManagerV1 struct{ *server.Resource }
57
58func WrapWpContentTypeManagerV1(r *server.Resource) *WpContentTypeManagerV1 {
59 if r == nil {
60 return nil
61 }
62 return &WpContentTypeManagerV1{r}
63}
64
65const WpContentTypeManagerV1RequestDestroy uint32 = 0
66const WpContentTypeManagerV1RequestGetSurfaceContentType uint32 = 1
67
68// WpContentTypeManagerV1Error .
69type WpContentTypeManagerV1Error uint32
70
71const (
72 WpContentTypeManagerV1ErrorAlreadyConstructed WpContentTypeManagerV1Error = 0
73)
74
75// WpContentTypeManagerV1Handler handles wp_content_type_manager_v1 requests.
76type WpContentTypeManagerV1Handler interface {
77 Destroy(self *WpContentTypeManagerV1)
78 GetSurfaceContentType(self *WpContentTypeManagerV1, id uint32, surface *wayland.Surface)
79}
80
81func NewWpContentTypeManagerV1(c server.Client, version int32, id uint32, h WpContentTypeManagerV1Handler) (*WpContentTypeManagerV1, error) {
82 if h == nil {
83 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_content_type_manager_v1")
84 }
85 var self *WpContentTypeManagerV1
86 r, err := c.CreateResource(WpContentTypeManagerV1Interface, 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.GetSurfaceContentType(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
93 }
94 })
95 if err != nil {
96 return nil, err
97 }
98 self = WrapWpContentTypeManagerV1(r)
99 r.Data = self
100 return self, nil
101}
102func NewWpContentTypeManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
103 return d.CreateGlobal(WpContentTypeManagerV1Interface, version, bind)
104}
105
106// WpContentTypeV1 content type object for a surface.
107type WpContentTypeV1 struct{ *server.Resource }
108
109func WrapWpContentTypeV1(r *server.Resource) *WpContentTypeV1 {
110 if r == nil {
111 return nil
112 }
113 return &WpContentTypeV1{r}
114}
115
116const WpContentTypeV1RequestDestroy uint32 = 0
117const WpContentTypeV1RequestSetContentType uint32 = 1
118
119// WpContentTypeV1Type possible content types.
120type WpContentTypeV1Type uint32
121
122const (
123 WpContentTypeV1TypeNone WpContentTypeV1Type = 0
124 WpContentTypeV1TypePhoto WpContentTypeV1Type = 1
125 WpContentTypeV1TypeVideo WpContentTypeV1Type = 2
126 WpContentTypeV1TypeGame WpContentTypeV1Type = 3
127)
128
129// WpContentTypeV1Handler handles wp_content_type_v1 requests.
130type WpContentTypeV1Handler interface {
131 Destroy(self *WpContentTypeV1)
132 SetContentType(self *WpContentTypeV1, contentType uint32)
133}
134
135func NewWpContentTypeV1(c server.Client, version int32, id uint32, h WpContentTypeV1Handler) (*WpContentTypeV1, error) {
136 if h == nil {
137 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_content_type_v1")
138 }
139 var self *WpContentTypeV1
140 r, err := c.CreateResource(WpContentTypeV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
141 switch opcode {
142 case 0:
143 h.Destroy(self)
144 self.Destroy()
145 case 1:
146 h.SetContentType(self, args[0].Uint())
147 }
148 })
149 if err != nil {
150 return nil, err
151 }
152 self = WrapWpContentTypeV1(r)
153 r.Data = self
154 return self, nil
155}
156func NewWpContentTypeV1Global(d *server.Display, version int32, bind server.BindFunc) error {
157 return d.CreateGlobal(WpContentTypeV1Interface, version, bind)
158}
159func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
160 if v == nil {
161 return nil
162 }
163 return v.GetResource()
164}
165func (self *WpContentTypeManagerV1) GetResource() *server.Resource {
166 if self == nil {
167 return nil
168 }
169 return self.Resource
170}
171func (self *WpContentTypeV1) GetResource() *server.Resource {
172 if self == nil {
173 return nil
174 }
175 return self.Resource
176}