// Code generated by wlbgen; DO NOT EDIT. // Upstream protocol copyright and license: // Copyright © 2019 Purism SPC // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice (including the next // paragraph) shall be included in all copies or substantial portions of the // Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. package wlroutputpowermanagement import ( "fmt" wayland "github.com/bnema/go-wayland-bindings/server/wayland" "github.com/bnema/purego-libwayland/server" ) var ZwlrOutputPowerManagerV1Interface *server.Interface var ZwlrOutputPowerV1Interface *server.Interface func init() { ZwlrOutputPowerManagerV1Interface = &server.Interface{Name: "zwlr_output_power_manager_v1", Version: 1} ZwlrOutputPowerV1Interface = &server.Interface{Name: "zwlr_output_power_v1", Version: 1} ZwlrOutputPowerManagerV1Interface.Requests = []server.Message{ {Name: "get_output_power", Signature: "no", Types: []*server.Interface{ZwlrOutputPowerV1Interface, wayland.OutputInterface}}, {Name: "destroy", Signature: "", Types: []*server.Interface{}}, } ZwlrOutputPowerManagerV1Interface.Events = []server.Message{} ZwlrOutputPowerV1Interface.Requests = []server.Message{ {Name: "set_mode", Signature: "u", Types: []*server.Interface{nil}}, {Name: "destroy", Signature: "", Types: []*server.Interface{}}, } ZwlrOutputPowerV1Interface.Events = []server.Message{ {Name: "mode", Signature: "u", Types: []*server.Interface{nil}}, {Name: "failed", Signature: "", Types: []*server.Interface{}}, } if err := server.NewInterfaces(ZwlrOutputPowerManagerV1Interface, ZwlrOutputPowerV1Interface); err != nil { panic(err) } } // ZwlrOutputPowerManagerV1 manager to create per-output power management. type ZwlrOutputPowerManagerV1 struct{ *server.Resource } func WrapZwlrOutputPowerManagerV1(r *server.Resource) *ZwlrOutputPowerManagerV1 { if r == nil { return nil } return &ZwlrOutputPowerManagerV1{r} } const ZwlrOutputPowerManagerV1RequestGetOutputPower uint32 = 0 const ZwlrOutputPowerManagerV1RequestDestroy uint32 = 1 // ZwlrOutputPowerManagerV1Handler handles zwlr_output_power_manager_v1 requests. type ZwlrOutputPowerManagerV1Handler interface { GetOutputPower(self *ZwlrOutputPowerManagerV1, id uint32, output *wayland.Output) Destroy(self *ZwlrOutputPowerManagerV1) } func NewZwlrOutputPowerManagerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerManagerV1Handler) (*ZwlrOutputPowerManagerV1, error) { if h == nil { return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_manager_v1") } var self *ZwlrOutputPowerManagerV1 r, err := c.CreateResource(ZwlrOutputPowerManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { switch opcode { case 0: h.GetOutputPower(self, args[0].NewID(), wayland.WrapOutput(args[1].Resource())) case 1: h.Destroy(self) self.Destroy() } }) if err != nil { return nil, err } self = WrapZwlrOutputPowerManagerV1(r) r.Data = self return self, nil } func NewZwlrOutputPowerManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error { return d.CreateGlobal(ZwlrOutputPowerManagerV1Interface, version, bind) } // ZwlrOutputPowerV1 adjust power management mode for an output. type ZwlrOutputPowerV1 struct{ *server.Resource } func WrapZwlrOutputPowerV1(r *server.Resource) *ZwlrOutputPowerV1 { if r == nil { return nil } return &ZwlrOutputPowerV1{r} } const ZwlrOutputPowerV1RequestSetMode uint32 = 0 const ZwlrOutputPowerV1RequestDestroy uint32 = 1 const ZwlrOutputPowerV1EventMode uint32 = 0 const ZwlrOutputPowerV1EventFailed uint32 = 1 // ZwlrOutputPowerV1Mode . type ZwlrOutputPowerV1Mode uint32 const ( ZwlrOutputPowerV1ModeOff ZwlrOutputPowerV1Mode = 0 ZwlrOutputPowerV1ModeOn ZwlrOutputPowerV1Mode = 1 ) // ZwlrOutputPowerV1Error . type ZwlrOutputPowerV1Error uint32 const ( ZwlrOutputPowerV1ErrorInvalidMode ZwlrOutputPowerV1Error = 1 ) // ZwlrOutputPowerV1Handler handles zwlr_output_power_v1 requests. type ZwlrOutputPowerV1Handler interface { SetMode(self *ZwlrOutputPowerV1, mode uint32) Destroy(self *ZwlrOutputPowerV1) } func NewZwlrOutputPowerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerV1Handler) (*ZwlrOutputPowerV1, error) { if h == nil { return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_v1") } var self *ZwlrOutputPowerV1 r, err := c.CreateResource(ZwlrOutputPowerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { switch opcode { case 0: h.SetMode(self, args[0].Uint()) case 1: h.Destroy(self) self.Destroy() } }) if err != nil { return nil, err } self = WrapZwlrOutputPowerV1(r) r.Data = self return self, nil } // SendMode Report a power management mode change. func (self *ZwlrOutputPowerV1) SendMode(mode uint32) { self.PostEvent(ZwlrOutputPowerV1EventMode, server.Uint(mode)) } // SendFailed object no longer valid. func (self *ZwlrOutputPowerV1) SendFailed() { self.PostEvent(ZwlrOutputPowerV1EventFailed) } func NewZwlrOutputPowerV1Global(d *server.Display, version int32, bind server.BindFunc) error { return d.CreateGlobal(ZwlrOutputPowerV1Interface, version, bind) } func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource { if v == nil { return nil } return v.GetResource() } func (self *ZwlrOutputPowerManagerV1) GetResource() *server.Resource { if self == nil { return nil } return self.Resource } func (self *ZwlrOutputPowerV1) GetResource() *server.Resource { if self == nil { return nil } return self.Resource }