1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2015 Martin Gräßlin
5// Copyright © 2022 Simon Ser
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 extidlenotify
27
28import (
29 "fmt"
30 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
31 "github.com/bnema/purego-libwayland/server"
32)
33
34var ExtIdleNotifierV1Interface *server.Interface
35var ExtIdleNotificationV1Interface *server.Interface
36
37func init() {
38 ExtIdleNotifierV1Interface = &server.Interface{Name: "ext_idle_notifier_v1", Version: 2}
39 ExtIdleNotificationV1Interface = &server.Interface{Name: "ext_idle_notification_v1", Version: 2}
40 ExtIdleNotifierV1Interface.Requests = []server.Message{
41 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
42 {Name: "get_idle_notification", Signature: "nuo", Types: []*server.Interface{ExtIdleNotificationV1Interface, nil, wayland.SeatInterface}},
43 {Name: "get_input_idle_notification", Signature: "2nuo", Types: []*server.Interface{ExtIdleNotificationV1Interface, nil, wayland.SeatInterface}},
44 }
45 ExtIdleNotifierV1Interface.Events = []server.Message{}
46 ExtIdleNotificationV1Interface.Requests = []server.Message{
47 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
48 }
49 ExtIdleNotificationV1Interface.Events = []server.Message{
50 {Name: "idled", Signature: "", Types: []*server.Interface{}},
51 {Name: "resumed", Signature: "", Types: []*server.Interface{}},
52 }
53 if err := server.NewInterfaces(ExtIdleNotifierV1Interface, ExtIdleNotificationV1Interface); err != nil {
54 panic(err)
55 }
56}
57
58// ExtIdleNotifierV1 idle notification manager.
59type ExtIdleNotifierV1 struct{ *server.Resource }
60
61func WrapExtIdleNotifierV1(r *server.Resource) *ExtIdleNotifierV1 {
62 if r == nil {
63 return nil
64 }
65 return &ExtIdleNotifierV1{r}
66}
67
68const ExtIdleNotifierV1RequestDestroy uint32 = 0
69const ExtIdleNotifierV1RequestGetIdleNotification uint32 = 1
70const ExtIdleNotifierV1RequestGetInputIdleNotification uint32 = 2
71
72// ExtIdleNotifierV1Handler handles ext_idle_notifier_v1 requests.
73type ExtIdleNotifierV1Handler interface {
74 Destroy(self *ExtIdleNotifierV1)
75 GetIdleNotification(self *ExtIdleNotifierV1, id uint32, timeout uint32, seat *wayland.Seat)
76 GetInputIdleNotification(self *ExtIdleNotifierV1, id uint32, timeout uint32, seat *wayland.Seat)
77}
78
79func NewExtIdleNotifierV1(c server.Client, version int32, id uint32, h ExtIdleNotifierV1Handler) (*ExtIdleNotifierV1, error) {
80 if h == nil {
81 return nil, fmt.Errorf("purego-libwayland: nil handler for ext_idle_notifier_v1")
82 }
83 var self *ExtIdleNotifierV1
84 r, err := c.CreateResource(ExtIdleNotifierV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
85 switch opcode {
86 case 0:
87 h.Destroy(self)
88 self.Destroy()
89 case 1:
90 h.GetIdleNotification(self, args[0].NewID(), args[1].Uint(), wayland.WrapSeat(args[2].Resource()))
91 case 2:
92 h.GetInputIdleNotification(self, args[0].NewID(), args[1].Uint(), wayland.WrapSeat(args[2].Resource()))
93 }
94 })
95 if err != nil {
96 return nil, err
97 }
98 self = WrapExtIdleNotifierV1(r)
99 r.Data = self
100 return self, nil
101}
102func NewExtIdleNotifierV1Global(d *server.Display, version int32, bind server.BindFunc) error {
103 return d.CreateGlobal(ExtIdleNotifierV1Interface, version, bind)
104}
105
106// ExtIdleNotificationV1 idle notification.
107type ExtIdleNotificationV1 struct{ *server.Resource }
108
109func WrapExtIdleNotificationV1(r *server.Resource) *ExtIdleNotificationV1 {
110 if r == nil {
111 return nil
112 }
113 return &ExtIdleNotificationV1{r}
114}
115
116const ExtIdleNotificationV1RequestDestroy uint32 = 0
117const ExtIdleNotificationV1EventIdled uint32 = 0
118const ExtIdleNotificationV1EventResumed uint32 = 1
119
120// ExtIdleNotificationV1Handler handles ext_idle_notification_v1 requests.
121type ExtIdleNotificationV1Handler interface {
122 Destroy(self *ExtIdleNotificationV1)
123}
124
125func NewExtIdleNotificationV1(c server.Client, version int32, id uint32, h ExtIdleNotificationV1Handler) (*ExtIdleNotificationV1, error) {
126 if h == nil {
127 return nil, fmt.Errorf("purego-libwayland: nil handler for ext_idle_notification_v1")
128 }
129 var self *ExtIdleNotificationV1
130 r, err := c.CreateResource(ExtIdleNotificationV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
131 switch opcode {
132 case 0:
133 h.Destroy(self)
134 self.Destroy()
135 }
136 })
137 if err != nil {
138 return nil, err
139 }
140 self = WrapExtIdleNotificationV1(r)
141 r.Data = self
142 return self, nil
143}
144
145// SendIdled notification object is idle.
146func (self *ExtIdleNotificationV1) SendIdled() {
147 self.PostEvent(ExtIdleNotificationV1EventIdled)
148}
149
150// SendResumed notification object is no longer idle.
151func (self *ExtIdleNotificationV1) SendResumed() {
152 self.PostEvent(ExtIdleNotificationV1EventResumed)
153}
154func NewExtIdleNotificationV1Global(d *server.Display, version int32, bind server.BindFunc) error {
155 return d.CreateGlobal(ExtIdleNotificationV1Interface, version, bind)
156}
157func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
158 if v == nil {
159 return nil
160 }
161 return v.GetResource()
162}
163func (self *ExtIdleNotifierV1) GetResource() *server.Resource {
164 if self == nil {
165 return nil
166 }
167 return self.Resource
168}
169func (self *ExtIdleNotificationV1) GetResource() *server.Resource {
170 if self == nil {
171 return nil
172 }
173 return self.Resource
174}