wlroutputpowermanagement_generated.go RawHistoryFolder
1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2019 Purism SPC
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 wlroutputpowermanagement
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var ZwlrOutputPowerManagerV1Interface *server.Interface
34var ZwlrOutputPowerV1Interface *server.Interface
35
36func init() {
37 ZwlrOutputPowerManagerV1Interface = &server.Interface{Name: "zwlr_output_power_manager_v1", Version: 1}
38 ZwlrOutputPowerV1Interface = &server.Interface{Name: "zwlr_output_power_v1", Version: 1}
39 ZwlrOutputPowerManagerV1Interface.Requests = []server.Message{
40 {Name: "get_output_power", Signature: "no", Types: []*server.Interface{ZwlrOutputPowerV1Interface, wayland.OutputInterface}},
41 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
42 }
43 ZwlrOutputPowerManagerV1Interface.Events = []server.Message{}
44 ZwlrOutputPowerV1Interface.Requests = []server.Message{
45 {Name: "set_mode", Signature: "u", Types: []*server.Interface{nil}},
46 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
47 }
48 ZwlrOutputPowerV1Interface.Events = []server.Message{
49 {Name: "mode", Signature: "u", Types: []*server.Interface{nil}},
50 {Name: "failed", Signature: "", Types: []*server.Interface{}},
51 }
52 if err := server.NewInterfaces(ZwlrOutputPowerManagerV1Interface, ZwlrOutputPowerV1Interface); err != nil {
53 panic(err)
54 }
55}
56
57// ZwlrOutputPowerManagerV1 manager to create per-output power management.
58type ZwlrOutputPowerManagerV1 struct{ *server.Resource }
59
60func WrapZwlrOutputPowerManagerV1(r *server.Resource) *ZwlrOutputPowerManagerV1 {
61 if r == nil {
62 return nil
63 }
64 return &ZwlrOutputPowerManagerV1{r}
65}
66
67const ZwlrOutputPowerManagerV1RequestGetOutputPower uint32 = 0
68const ZwlrOutputPowerManagerV1RequestDestroy uint32 = 1
69
70// ZwlrOutputPowerManagerV1Handler handles zwlr_output_power_manager_v1 requests.
71type ZwlrOutputPowerManagerV1Handler interface {
72 GetOutputPower(self *ZwlrOutputPowerManagerV1, id uint32, output *wayland.Output)
73 Destroy(self *ZwlrOutputPowerManagerV1)
74}
75
76func NewZwlrOutputPowerManagerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerManagerV1Handler) (*ZwlrOutputPowerManagerV1, error) {
77 if h == nil {
78 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_manager_v1")
79 }
80 var self *ZwlrOutputPowerManagerV1
81 r, err := c.CreateResource(ZwlrOutputPowerManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
82 switch opcode {
83 case 0:
84 h.GetOutputPower(self, args[0].NewID(), wayland.WrapOutput(args[1].Resource()))
85 case 1:
86 h.Destroy(self)
87 self.Destroy()
88 }
89 })
90 if err != nil {
91 return nil, err
92 }
93 self = WrapZwlrOutputPowerManagerV1(r)
94 r.Data = self
95 return self, nil
96}
97func NewZwlrOutputPowerManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
98 return d.CreateGlobal(ZwlrOutputPowerManagerV1Interface, version, bind)
99}
100
101// ZwlrOutputPowerV1 adjust power management mode for an output.
102type ZwlrOutputPowerV1 struct{ *server.Resource }
103
104func WrapZwlrOutputPowerV1(r *server.Resource) *ZwlrOutputPowerV1 {
105 if r == nil {
106 return nil
107 }
108 return &ZwlrOutputPowerV1{r}
109}
110
111const ZwlrOutputPowerV1RequestSetMode uint32 = 0
112const ZwlrOutputPowerV1RequestDestroy uint32 = 1
113const ZwlrOutputPowerV1EventMode uint32 = 0
114const ZwlrOutputPowerV1EventFailed uint32 = 1
115
116// ZwlrOutputPowerV1Mode .
117type ZwlrOutputPowerV1Mode uint32
118
119const (
120 ZwlrOutputPowerV1ModeOff ZwlrOutputPowerV1Mode = 0
121 ZwlrOutputPowerV1ModeOn ZwlrOutputPowerV1Mode = 1
122)
123
124// ZwlrOutputPowerV1Error .
125type ZwlrOutputPowerV1Error uint32
126
127const (
128 ZwlrOutputPowerV1ErrorInvalidMode ZwlrOutputPowerV1Error = 1
129)
130
131// ZwlrOutputPowerV1Handler handles zwlr_output_power_v1 requests.
132type ZwlrOutputPowerV1Handler interface {
133 SetMode(self *ZwlrOutputPowerV1, mode uint32)
134 Destroy(self *ZwlrOutputPowerV1)
135}
136
137func NewZwlrOutputPowerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerV1Handler) (*ZwlrOutputPowerV1, error) {
138 if h == nil {
139 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_v1")
140 }
141 var self *ZwlrOutputPowerV1
142 r, err := c.CreateResource(ZwlrOutputPowerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
143 switch opcode {
144 case 0:
145 h.SetMode(self, args[0].Uint())
146 case 1:
147 h.Destroy(self)
148 self.Destroy()
149 }
150 })
151 if err != nil {
152 return nil, err
153 }
154 self = WrapZwlrOutputPowerV1(r)
155 r.Data = self
156 return self, nil
157}
158
159// SendMode Report a power management mode change.
160func (self *ZwlrOutputPowerV1) SendMode(mode uint32) {
161 self.PostEvent(ZwlrOutputPowerV1EventMode, server.Uint(mode))
162}
163
164// SendFailed object no longer valid.
165func (self *ZwlrOutputPowerV1) SendFailed() {
166 self.PostEvent(ZwlrOutputPowerV1EventFailed)
167}
168func NewZwlrOutputPowerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
169 return d.CreateGlobal(ZwlrOutputPowerV1Interface, version, bind)
170}
171func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
172 if v == nil {
173 return nil
174 }
175 return v.GetResource()
176}
177func (self *ZwlrOutputPowerManagerV1) GetResource() *server.Resource {
178 if self == nil {
179 return nil
180 }
181 return self.Resource
182}
183func (self *ZwlrOutputPowerV1) GetResource() *server.Resource {
184 if self == nil {
185 return nil
186 }
187 return self.Resource
188}