1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2022 Joshua Ashton
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 xwaylandshell
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var XwaylandShellV1Interface *server.Interface
34var XwaylandSurfaceV1Interface *server.Interface
35
36func init() {
37 XwaylandShellV1Interface = &server.Interface{Name: "xwayland_shell_v1", Version: 1}
38 XwaylandSurfaceV1Interface = &server.Interface{Name: "xwayland_surface_v1", Version: 1}
39 XwaylandShellV1Interface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 {Name: "get_xwayland_surface", Signature: "no", Types: []*server.Interface{XwaylandSurfaceV1Interface, wayland.SurfaceInterface}},
42 }
43 XwaylandShellV1Interface.Events = []server.Message{}
44 XwaylandSurfaceV1Interface.Requests = []server.Message{
45 {Name: "set_serial", Signature: "uu", Types: []*server.Interface{nil, nil}},
46 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
47 }
48 XwaylandSurfaceV1Interface.Events = []server.Message{}
49 if err := server.NewInterfaces(XwaylandShellV1Interface, XwaylandSurfaceV1Interface); err != nil {
50 panic(err)
51 }
52}
53
54// XwaylandShellV1 context object for Xwayland shell.
55type XwaylandShellV1 struct{ *server.Resource }
56
57func WrapXwaylandShellV1(r *server.Resource) *XwaylandShellV1 {
58 if r == nil {
59 return nil
60 }
61 return &XwaylandShellV1{r}
62}
63
64const XwaylandShellV1RequestDestroy uint32 = 0
65const XwaylandShellV1RequestGetXwaylandSurface uint32 = 1
66
67// XwaylandShellV1Error .
68type XwaylandShellV1Error uint32
69
70const (
71 XwaylandShellV1ErrorRole XwaylandShellV1Error = 0
72)
73
74// XwaylandShellV1Handler handles xwayland_shell_v1 requests.
75type XwaylandShellV1Handler interface {
76 Destroy(self *XwaylandShellV1)
77 GetXwaylandSurface(self *XwaylandShellV1, id uint32, surface *wayland.Surface)
78}
79
80func NewXwaylandShellV1(c server.Client, version int32, id uint32, h XwaylandShellV1Handler) (*XwaylandShellV1, error) {
81 if h == nil {
82 return nil, fmt.Errorf("purego-libwayland: nil handler for xwayland_shell_v1")
83 }
84 var self *XwaylandShellV1
85 r, err := c.CreateResource(XwaylandShellV1Interface, 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.GetXwaylandSurface(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
92 }
93 })
94 if err != nil {
95 return nil, err
96 }
97 self = WrapXwaylandShellV1(r)
98 r.Data = self
99 return self, nil
100}
101func NewXwaylandShellV1Global(d *server.Display, version int32, bind server.BindFunc) error {
102 return d.CreateGlobal(XwaylandShellV1Interface, version, bind)
103}
104
105// XwaylandSurfaceV1 interface for associating Xwayland windows to wl_surfaces.
106type XwaylandSurfaceV1 struct{ *server.Resource }
107
108func WrapXwaylandSurfaceV1(r *server.Resource) *XwaylandSurfaceV1 {
109 if r == nil {
110 return nil
111 }
112 return &XwaylandSurfaceV1{r}
113}
114
115const XwaylandSurfaceV1RequestSetSerial uint32 = 0
116const XwaylandSurfaceV1RequestDestroy uint32 = 1
117
118// XwaylandSurfaceV1Error .
119type XwaylandSurfaceV1Error uint32
120
121const (
122 XwaylandSurfaceV1ErrorAlreadyAssociated XwaylandSurfaceV1Error = 0
123 XwaylandSurfaceV1ErrorInvalidSerial XwaylandSurfaceV1Error = 1
124)
125
126// XwaylandSurfaceV1Handler handles xwayland_surface_v1 requests.
127type XwaylandSurfaceV1Handler interface {
128 SetSerial(self *XwaylandSurfaceV1, serialLo uint32, serialHi uint32)
129 Destroy(self *XwaylandSurfaceV1)
130}
131
132func NewXwaylandSurfaceV1(c server.Client, version int32, id uint32, h XwaylandSurfaceV1Handler) (*XwaylandSurfaceV1, error) {
133 if h == nil {
134 return nil, fmt.Errorf("purego-libwayland: nil handler for xwayland_surface_v1")
135 }
136 var self *XwaylandSurfaceV1
137 r, err := c.CreateResource(XwaylandSurfaceV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
138 switch opcode {
139 case 0:
140 h.SetSerial(self, args[0].Uint(), args[1].Uint())
141 case 1:
142 h.Destroy(self)
143 self.Destroy()
144 }
145 })
146 if err != nil {
147 return nil, err
148 }
149 self = WrapXwaylandSurfaceV1(r)
150 r.Data = self
151 return self, nil
152}
153func NewXwaylandSurfaceV1Global(d *server.Display, version int32, bind server.BindFunc) error {
154 return d.CreateGlobal(XwaylandSurfaceV1Interface, 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 *XwaylandShellV1) GetResource() *server.Resource {
163 if self == nil {
164 return nil
165 }
166 return self.Resource
167}
168func (self *XwaylandSurfaceV1) GetResource() *server.Resource {
169 if self == nil {
170 return nil
171 }
172 return self.Resource
173}