1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2024 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 alphamodifier
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var WpAlphaModifierV1Interface *server.Interface
34var WpAlphaModifierSurfaceV1Interface *server.Interface
35
36func init() {
37 WpAlphaModifierV1Interface = &server.Interface{Name: "wp_alpha_modifier_v1", Version: 1}
38 WpAlphaModifierSurfaceV1Interface = &server.Interface{Name: "wp_alpha_modifier_surface_v1", Version: 1}
39 WpAlphaModifierV1Interface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 {Name: "get_surface", Signature: "no", Types: []*server.Interface{WpAlphaModifierSurfaceV1Interface, wayland.SurfaceInterface}},
42 }
43 WpAlphaModifierV1Interface.Events = []server.Message{}
44 WpAlphaModifierSurfaceV1Interface.Requests = []server.Message{
45 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
46 {Name: "set_multiplier", Signature: "u", Types: []*server.Interface{nil}},
47 }
48 WpAlphaModifierSurfaceV1Interface.Events = []server.Message{}
49 if err := server.NewInterfaces(WpAlphaModifierV1Interface, WpAlphaModifierSurfaceV1Interface); err != nil {
50 panic(err)
51 }
52}
53
54// WpAlphaModifierV1 surface alpha modifier manager.
55type WpAlphaModifierV1 struct{ *server.Resource }
56
57func WrapWpAlphaModifierV1(r *server.Resource) *WpAlphaModifierV1 {
58 if r == nil {
59 return nil
60 }
61 return &WpAlphaModifierV1{r}
62}
63
64const WpAlphaModifierV1RequestDestroy uint32 = 0
65const WpAlphaModifierV1RequestGetSurface uint32 = 1
66
67// WpAlphaModifierV1Error .
68type WpAlphaModifierV1Error uint32
69
70const (
71 WpAlphaModifierV1ErrorAlreadyConstructed WpAlphaModifierV1Error = 0
72)
73
74// WpAlphaModifierV1Handler handles wp_alpha_modifier_v1 requests.
75type WpAlphaModifierV1Handler interface {
76 Destroy(self *WpAlphaModifierV1)
77 GetSurface(self *WpAlphaModifierV1, id uint32, surface *wayland.Surface)
78}
79
80func NewWpAlphaModifierV1(c server.Client, version int32, id uint32, h WpAlphaModifierV1Handler) (*WpAlphaModifierV1, error) {
81 if h == nil {
82 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_alpha_modifier_v1")
83 }
84 var self *WpAlphaModifierV1
85 r, err := c.CreateResource(WpAlphaModifierV1Interface, 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.GetSurface(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
92 }
93 })
94 if err != nil {
95 return nil, err
96 }
97 self = WrapWpAlphaModifierV1(r)
98 r.Data = self
99 return self, nil
100}
101func NewWpAlphaModifierV1Global(d *server.Display, version int32, bind server.BindFunc) error {
102 return d.CreateGlobal(WpAlphaModifierV1Interface, version, bind)
103}
104
105// WpAlphaModifierSurfaceV1 alpha modifier object for a surface.
106type WpAlphaModifierSurfaceV1 struct{ *server.Resource }
107
108func WrapWpAlphaModifierSurfaceV1(r *server.Resource) *WpAlphaModifierSurfaceV1 {
109 if r == nil {
110 return nil
111 }
112 return &WpAlphaModifierSurfaceV1{r}
113}
114
115const WpAlphaModifierSurfaceV1RequestDestroy uint32 = 0
116const WpAlphaModifierSurfaceV1RequestSetMultiplier uint32 = 1
117
118// WpAlphaModifierSurfaceV1Error .
119type WpAlphaModifierSurfaceV1Error uint32
120
121const (
122 WpAlphaModifierSurfaceV1ErrorNoSurface WpAlphaModifierSurfaceV1Error = 0
123)
124
125// WpAlphaModifierSurfaceV1Handler handles wp_alpha_modifier_surface_v1 requests.
126type WpAlphaModifierSurfaceV1Handler interface {
127 Destroy(self *WpAlphaModifierSurfaceV1)
128 SetMultiplier(self *WpAlphaModifierSurfaceV1, factor uint32)
129}
130
131func NewWpAlphaModifierSurfaceV1(c server.Client, version int32, id uint32, h WpAlphaModifierSurfaceV1Handler) (*WpAlphaModifierSurfaceV1, error) {
132 if h == nil {
133 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_alpha_modifier_surface_v1")
134 }
135 var self *WpAlphaModifierSurfaceV1
136 r, err := c.CreateResource(WpAlphaModifierSurfaceV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
137 switch opcode {
138 case 0:
139 h.Destroy(self)
140 self.Destroy()
141 case 1:
142 h.SetMultiplier(self, args[0].Uint())
143 }
144 })
145 if err != nil {
146 return nil, err
147 }
148 self = WrapWpAlphaModifierSurfaceV1(r)
149 r.Data = self
150 return self, nil
151}
152func NewWpAlphaModifierSurfaceV1Global(d *server.Display, version int32, bind server.BindFunc) error {
153 return d.CreateGlobal(WpAlphaModifierSurfaceV1Interface, version, bind)
154}
155func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
156 if v == nil {
157 return nil
158 }
159 return v.GetResource()
160}
161func (self *WpAlphaModifierV1) GetResource() *server.Resource {
162 if self == nil {
163 return nil
164 }
165 return self.Resource
166}
167func (self *WpAlphaModifierSurfaceV1) GetResource() *server.Resource {
168 if self == nil {
169 return nil
170 }
171 return self.Resource
172}