1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2016, 2023 Red Hat
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 xdgsystembell
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var SystemBellV1Interface *server.Interface
34
35func init() {
36 SystemBellV1Interface = &server.Interface{Name: "xdg_system_bell_v1", Version: 1}
37 SystemBellV1Interface.Requests = []server.Message{
38 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
39 {Name: "ring", Signature: "?o", Types: []*server.Interface{wayland.SurfaceInterface}},
40 }
41 SystemBellV1Interface.Events = []server.Message{}
42 if err := server.NewInterfaces(SystemBellV1Interface); err != nil {
43 panic(err)
44 }
45}
46
47// SystemBellV1 system bell.
48type SystemBellV1 struct{ *server.Resource }
49
50func WrapSystemBellV1(r *server.Resource) *SystemBellV1 {
51 if r == nil {
52 return nil
53 }
54 return &SystemBellV1{r}
55}
56
57const SystemBellV1RequestDestroy uint32 = 0
58const SystemBellV1RequestRing uint32 = 1
59
60// SystemBellV1Handler handles xdg_system_bell_v1 requests.
61type SystemBellV1Handler interface {
62 Destroy(self *SystemBellV1)
63 Ring(self *SystemBellV1, surface *wayland.Surface)
64}
65
66func NewSystemBellV1(c server.Client, version int32, id uint32, h SystemBellV1Handler) (*SystemBellV1, error) {
67 if h == nil {
68 return nil, fmt.Errorf("purego-libwayland: nil handler for xdg_system_bell_v1")
69 }
70 var self *SystemBellV1
71 r, err := c.CreateResource(SystemBellV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
72 switch opcode {
73 case 0:
74 h.Destroy(self)
75 self.Destroy()
76 case 1:
77 h.Ring(self, wayland.WrapSurface(args[0].Resource()))
78 }
79 })
80 if err != nil {
81 return nil, err
82 }
83 self = WrapSystemBellV1(r)
84 r.Data = self
85 return self, nil
86}
87func NewSystemBellV1Global(d *server.Display, version int32, bind server.BindFunc) error {
88 return d.CreateGlobal(SystemBellV1Interface, version, bind)
89}
90func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
91 if v == nil {
92 return nil
93 }
94 return v.GetResource()
95}
96func (self *SystemBellV1) GetResource() *server.Resource {
97 if self == nil {
98 return nil
99 }
100 return self.Resource
101}