Merge pull request #3 from bnema/output-power
feat(protocol): add wlr-output-power-management-unstable-v1
4 files · +311 -0
M protocol/gen.go +1 -0
| @@ -58,3 +58,4 @@ package protocol | |||
| 58 | 58 | //go:generate go run ../cmd/wlgen -package xdgtopleveldrag -out xdgtopleveldrag/xdgtopleveldrag.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml -import xdgshell=github.com/bnema/purego-libwayland/protocol/xdgshell -import-xml xdgshell=../protocols/xdg-shell.xml ../protocols/xdg-toplevel-drag-v1.xml | |
| 59 | 59 | //go:generate go run ../cmd/wlgen -package xwaylandkeyboardgrab -out xwaylandkeyboardgrab/xwaylandkeyboardgrab.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/xwayland-keyboard-grab-unstable-v1.xml | |
| 60 | 60 | //go:generate go run ../cmd/wlgen -package xwaylandshell -out xwaylandshell/xwaylandshell.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/xwayland-shell-v1.xml | |
| 61 | + | //go:generate go run ../cmd/wlgen -package wlroutputpower -out wlroutputpower/wlroutputpower.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/wlr-output-power-management-unstable-v1.xml | |
| @@ -58,3 +58,4 @@ package protocol | |||||
| 58 | //go:generate go run ../cmd/wlgen -package xdgtopleveldrag -out xdgtopleveldrag/xdgtopleveldrag.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml -import xdgshell=github.com/bnema/purego-libwayland/protocol/xdgshell -import-xml xdgshell=../protocols/xdg-shell.xml ../protocols/xdg-toplevel-drag-v1.xml | 58 | //go:generate go run ../cmd/wlgen -package xdgtopleveldrag -out xdgtopleveldrag/xdgtopleveldrag.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml -import xdgshell=github.com/bnema/purego-libwayland/protocol/xdgshell -import-xml xdgshell=../protocols/xdg-shell.xml ../protocols/xdg-toplevel-drag-v1.xml | ||
| 59 | //go:generate go run ../cmd/wlgen -package xwaylandkeyboardgrab -out xwaylandkeyboardgrab/xwaylandkeyboardgrab.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/xwayland-keyboard-grab-unstable-v1.xml | 59 | //go:generate go run ../cmd/wlgen -package xwaylandkeyboardgrab -out xwaylandkeyboardgrab/xwaylandkeyboardgrab.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/xwayland-keyboard-grab-unstable-v1.xml | ||
| 60 | //go:generate go run ../cmd/wlgen -package xwaylandshell -out xwaylandshell/xwaylandshell.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/xwayland-shell-v1.xml | 60 | //go:generate go run ../cmd/wlgen -package xwaylandshell -out xwaylandshell/xwaylandshell.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/xwayland-shell-v1.xml | ||
| 61 | + | //go:generate go run ../cmd/wlgen -package wlroutputpower -out wlroutputpower/wlroutputpower.go -import wayland=github.com/bnema/purego-libwayland/protocol/wayland -import-xml wayland=../protocols/wayland.xml ../protocols/wlr-output-power-management-unstable-v1.xml | |||
A protocol/wlroutputpower/wlroutputpower.go +165 -0
| @@ -0,0 +1,165 @@ | |||
| 1 | + | // Code generated by wlgen; DO NOT EDIT. | |
| 2 | + | package wlroutputpower | |
| 3 | + | ||
| 4 | + | import ( | |
| 5 | + | "fmt" | |
| 6 | + | wayland "github.com/bnema/purego-libwayland/protocol/wayland" | |
| 7 | + | "github.com/bnema/purego-libwayland/server" | |
| 8 | + | ) | |
| 9 | + | ||
| 10 | + | var ZwlrOutputPowerManagerV1Interface *server.Interface | |
| 11 | + | var ZwlrOutputPowerV1Interface *server.Interface | |
| 12 | + | ||
| 13 | + | func init() { | |
| 14 | + | ZwlrOutputPowerManagerV1Interface = &server.Interface{Name: "zwlr_output_power_manager_v1", Version: 1} | |
| 15 | + | ZwlrOutputPowerV1Interface = &server.Interface{Name: "zwlr_output_power_v1", Version: 1} | |
| 16 | + | ZwlrOutputPowerManagerV1Interface.Requests = []server.Message{ | |
| 17 | + | {Name: "get_output_power", Signature: "no", Types: []*server.Interface{ZwlrOutputPowerV1Interface, wayland.OutputInterface}}, | |
| 18 | + | {Name: "destroy", Signature: "", Types: []*server.Interface{}}, | |
| 19 | + | } | |
| 20 | + | ZwlrOutputPowerManagerV1Interface.Events = []server.Message{} | |
| 21 | + | ZwlrOutputPowerV1Interface.Requests = []server.Message{ | |
| 22 | + | {Name: "set_mode", Signature: "u", Types: []*server.Interface{nil}}, | |
| 23 | + | {Name: "destroy", Signature: "", Types: []*server.Interface{}}, | |
| 24 | + | } | |
| 25 | + | ZwlrOutputPowerV1Interface.Events = []server.Message{ | |
| 26 | + | {Name: "mode", Signature: "u", Types: []*server.Interface{nil}}, | |
| 27 | + | {Name: "failed", Signature: "", Types: []*server.Interface{}}, | |
| 28 | + | } | |
| 29 | + | if err := server.NewInterfaces(ZwlrOutputPowerManagerV1Interface, ZwlrOutputPowerV1Interface); err != nil { | |
| 30 | + | panic(err) | |
| 31 | + | } | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | // ZwlrOutputPowerManagerV1 manager to create per-output power management. | |
| 35 | + | type ZwlrOutputPowerManagerV1 struct{ *server.Resource } | |
| 36 | + | ||
| 37 | + | func WrapZwlrOutputPowerManagerV1(r *server.Resource) *ZwlrOutputPowerManagerV1 { | |
| 38 | + | if r == nil { | |
| 39 | + | return nil | |
| 40 | + | } | |
| 41 | + | return &ZwlrOutputPowerManagerV1{r} | |
| 42 | + | } | |
| 43 | + | ||
| 44 | + | const ZwlrOutputPowerManagerV1RequestGetOutputPower uint32 = 0 | |
| 45 | + | const ZwlrOutputPowerManagerV1RequestDestroy uint32 = 1 | |
| 46 | + | ||
| 47 | + | // ZwlrOutputPowerManagerV1Handler handles zwlr_output_power_manager_v1 requests. | |
| 48 | + | type ZwlrOutputPowerManagerV1Handler interface { | |
| 49 | + | GetOutputPower(self *ZwlrOutputPowerManagerV1, id uint32, output *wayland.Output) | |
| 50 | + | Destroy(self *ZwlrOutputPowerManagerV1) | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | func NewZwlrOutputPowerManagerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerManagerV1Handler) (*ZwlrOutputPowerManagerV1, error) { | |
| 54 | + | if h == nil { | |
| 55 | + | return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_manager_v1") | |
| 56 | + | } | |
| 57 | + | var self *ZwlrOutputPowerManagerV1 | |
| 58 | + | r, err := c.CreateResource(ZwlrOutputPowerManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { | |
| 59 | + | switch opcode { | |
| 60 | + | case 0: | |
| 61 | + | h.GetOutputPower(self, args[0].NewID(), wayland.WrapOutput(args[1].Resource())) | |
| 62 | + | case 1: | |
| 63 | + | h.Destroy(self) | |
| 64 | + | self.Destroy() | |
| 65 | + | } | |
| 66 | + | }) | |
| 67 | + | if err != nil { | |
| 68 | + | return nil, err | |
| 69 | + | } | |
| 70 | + | self = WrapZwlrOutputPowerManagerV1(r) | |
| 71 | + | r.Data = self | |
| 72 | + | return self, nil | |
| 73 | + | } | |
| 74 | + | func NewZwlrOutputPowerManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error { | |
| 75 | + | return d.CreateGlobal(ZwlrOutputPowerManagerV1Interface, version, bind) | |
| 76 | + | } | |
| 77 | + | ||
| 78 | + | // ZwlrOutputPowerV1 adjust power management mode for an output. | |
| 79 | + | type ZwlrOutputPowerV1 struct{ *server.Resource } | |
| 80 | + | ||
| 81 | + | func WrapZwlrOutputPowerV1(r *server.Resource) *ZwlrOutputPowerV1 { | |
| 82 | + | if r == nil { | |
| 83 | + | return nil | |
| 84 | + | } | |
| 85 | + | return &ZwlrOutputPowerV1{r} | |
| 86 | + | } | |
| 87 | + | ||
| 88 | + | const ZwlrOutputPowerV1RequestSetMode uint32 = 0 | |
| 89 | + | const ZwlrOutputPowerV1RequestDestroy uint32 = 1 | |
| 90 | + | const ZwlrOutputPowerV1EventMode uint32 = 0 | |
| 91 | + | const ZwlrOutputPowerV1EventFailed uint32 = 1 | |
| 92 | + | ||
| 93 | + | // ZwlrOutputPowerV1Mode . | |
| 94 | + | type ZwlrOutputPowerV1Mode uint32 | |
| 95 | + | ||
| 96 | + | const ( | |
| 97 | + | ZwlrOutputPowerV1ModeOff ZwlrOutputPowerV1Mode = 0 | |
| 98 | + | ZwlrOutputPowerV1ModeOn ZwlrOutputPowerV1Mode = 1 | |
| 99 | + | ) | |
| 100 | + | ||
| 101 | + | // ZwlrOutputPowerV1Error . | |
| 102 | + | type ZwlrOutputPowerV1Error uint32 | |
| 103 | + | ||
| 104 | + | const ( | |
| 105 | + | ZwlrOutputPowerV1ErrorInvalidMode ZwlrOutputPowerV1Error = 1 | |
| 106 | + | ) | |
| 107 | + | ||
| 108 | + | // ZwlrOutputPowerV1Handler handles zwlr_output_power_v1 requests. | |
| 109 | + | type ZwlrOutputPowerV1Handler interface { | |
| 110 | + | SetMode(self *ZwlrOutputPowerV1, mode uint32) | |
| 111 | + | Destroy(self *ZwlrOutputPowerV1) | |
| 112 | + | } | |
| 113 | + | ||
| 114 | + | func NewZwlrOutputPowerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerV1Handler) (*ZwlrOutputPowerV1, error) { | |
| 115 | + | if h == nil { | |
| 116 | + | return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_v1") | |
| 117 | + | } | |
| 118 | + | var self *ZwlrOutputPowerV1 | |
| 119 | + | r, err := c.CreateResource(ZwlrOutputPowerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { | |
| 120 | + | switch opcode { | |
| 121 | + | case 0: | |
| 122 | + | h.SetMode(self, args[0].Uint()) | |
| 123 | + | case 1: | |
| 124 | + | h.Destroy(self) | |
| 125 | + | self.Destroy() | |
| 126 | + | } | |
| 127 | + | }) | |
| 128 | + | if err != nil { | |
| 129 | + | return nil, err | |
| 130 | + | } | |
| 131 | + | self = WrapZwlrOutputPowerV1(r) | |
| 132 | + | r.Data = self | |
| 133 | + | return self, nil | |
| 134 | + | } | |
| 135 | + | ||
| 136 | + | // SendMode Report a power management mode change. | |
| 137 | + | func (self *ZwlrOutputPowerV1) SendMode(mode uint32) { | |
| 138 | + | self.PostEvent(ZwlrOutputPowerV1EventMode, server.Uint(mode)) | |
| 139 | + | } | |
| 140 | + | ||
| 141 | + | // SendFailed object no longer valid. | |
| 142 | + | func (self *ZwlrOutputPowerV1) SendFailed() { | |
| 143 | + | self.PostEvent(ZwlrOutputPowerV1EventFailed) | |
| 144 | + | } | |
| 145 | + | func NewZwlrOutputPowerV1Global(d *server.Display, version int32, bind server.BindFunc) error { | |
| 146 | + | return d.CreateGlobal(ZwlrOutputPowerV1Interface, version, bind) | |
| 147 | + | } | |
| 148 | + | func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource { | |
| 149 | + | if v == nil { | |
| 150 | + | return nil | |
| 151 | + | } | |
| 152 | + | return v.GetResource() | |
| 153 | + | } | |
| 154 | + | func (self *ZwlrOutputPowerManagerV1) GetResource() *server.Resource { | |
| 155 | + | if self == nil { | |
| 156 | + | return nil | |
| 157 | + | } | |
| 158 | + | return self.Resource | |
| 159 | + | } | |
| 160 | + | func (self *ZwlrOutputPowerV1) GetResource() *server.Resource { | |
| 161 | + | if self == nil { | |
| 162 | + | return nil | |
| 163 | + | } | |
| 164 | + | return self.Resource | |
| 165 | + | } | |
| @@ -0,0 +1,165 @@ | |||||
| 1 | + | // Code generated by wlgen; DO NOT EDIT. | |||
| 2 | + | package wlroutputpower | |||
| 3 | + | ||||
| 4 | + | import ( | |||
| 5 | + | "fmt" | |||
| 6 | + | wayland "github.com/bnema/purego-libwayland/protocol/wayland" | |||
| 7 | + | "github.com/bnema/purego-libwayland/server" | |||
| 8 | + | ) | |||
| 9 | + | ||||
| 10 | + | var ZwlrOutputPowerManagerV1Interface *server.Interface | |||
| 11 | + | var ZwlrOutputPowerV1Interface *server.Interface | |||
| 12 | + | ||||
| 13 | + | func init() { | |||
| 14 | + | ZwlrOutputPowerManagerV1Interface = &server.Interface{Name: "zwlr_output_power_manager_v1", Version: 1} | |||
| 15 | + | ZwlrOutputPowerV1Interface = &server.Interface{Name: "zwlr_output_power_v1", Version: 1} | |||
| 16 | + | ZwlrOutputPowerManagerV1Interface.Requests = []server.Message{ | |||
| 17 | + | {Name: "get_output_power", Signature: "no", Types: []*server.Interface{ZwlrOutputPowerV1Interface, wayland.OutputInterface}}, | |||
| 18 | + | {Name: "destroy", Signature: "", Types: []*server.Interface{}}, | |||
| 19 | + | } | |||
| 20 | + | ZwlrOutputPowerManagerV1Interface.Events = []server.Message{} | |||
| 21 | + | ZwlrOutputPowerV1Interface.Requests = []server.Message{ | |||
| 22 | + | {Name: "set_mode", Signature: "u", Types: []*server.Interface{nil}}, | |||
| 23 | + | {Name: "destroy", Signature: "", Types: []*server.Interface{}}, | |||
| 24 | + | } | |||
| 25 | + | ZwlrOutputPowerV1Interface.Events = []server.Message{ | |||
| 26 | + | {Name: "mode", Signature: "u", Types: []*server.Interface{nil}}, | |||
| 27 | + | {Name: "failed", Signature: "", Types: []*server.Interface{}}, | |||
| 28 | + | } | |||
| 29 | + | if err := server.NewInterfaces(ZwlrOutputPowerManagerV1Interface, ZwlrOutputPowerV1Interface); err != nil { | |||
| 30 | + | panic(err) | |||
| 31 | + | } | |||
| 32 | + | } | |||
| 33 | + | ||||
| 34 | + | // ZwlrOutputPowerManagerV1 manager to create per-output power management. | |||
| 35 | + | type ZwlrOutputPowerManagerV1 struct{ *server.Resource } | |||
| 36 | + | ||||
| 37 | + | func WrapZwlrOutputPowerManagerV1(r *server.Resource) *ZwlrOutputPowerManagerV1 { | |||
| 38 | + | if r == nil { | |||
| 39 | + | return nil | |||
| 40 | + | } | |||
| 41 | + | return &ZwlrOutputPowerManagerV1{r} | |||
| 42 | + | } | |||
| 43 | + | ||||
| 44 | + | const ZwlrOutputPowerManagerV1RequestGetOutputPower uint32 = 0 | |||
| 45 | + | const ZwlrOutputPowerManagerV1RequestDestroy uint32 = 1 | |||
| 46 | + | ||||
| 47 | + | // ZwlrOutputPowerManagerV1Handler handles zwlr_output_power_manager_v1 requests. | |||
| 48 | + | type ZwlrOutputPowerManagerV1Handler interface { | |||
| 49 | + | GetOutputPower(self *ZwlrOutputPowerManagerV1, id uint32, output *wayland.Output) | |||
| 50 | + | Destroy(self *ZwlrOutputPowerManagerV1) | |||
| 51 | + | } | |||
| 52 | + | ||||
| 53 | + | func NewZwlrOutputPowerManagerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerManagerV1Handler) (*ZwlrOutputPowerManagerV1, error) { | |||
| 54 | + | if h == nil { | |||
| 55 | + | return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_manager_v1") | |||
| 56 | + | } | |||
| 57 | + | var self *ZwlrOutputPowerManagerV1 | |||
| 58 | + | r, err := c.CreateResource(ZwlrOutputPowerManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { | |||
| 59 | + | switch opcode { | |||
| 60 | + | case 0: | |||
| 61 | + | h.GetOutputPower(self, args[0].NewID(), wayland.WrapOutput(args[1].Resource())) | |||
| 62 | + | case 1: | |||
| 63 | + | h.Destroy(self) | |||
| 64 | + | self.Destroy() | |||
| 65 | + | } | |||
| 66 | + | }) | |||
| 67 | + | if err != nil { | |||
| 68 | + | return nil, err | |||
| 69 | + | } | |||
| 70 | + | self = WrapZwlrOutputPowerManagerV1(r) | |||
| 71 | + | r.Data = self | |||
| 72 | + | return self, nil | |||
| 73 | + | } | |||
| 74 | + | func NewZwlrOutputPowerManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error { | |||
| 75 | + | return d.CreateGlobal(ZwlrOutputPowerManagerV1Interface, version, bind) | |||
| 76 | + | } | |||
| 77 | + | ||||
| 78 | + | // ZwlrOutputPowerV1 adjust power management mode for an output. | |||
| 79 | + | type ZwlrOutputPowerV1 struct{ *server.Resource } | |||
| 80 | + | ||||
| 81 | + | func WrapZwlrOutputPowerV1(r *server.Resource) *ZwlrOutputPowerV1 { | |||
| 82 | + | if r == nil { | |||
| 83 | + | return nil | |||
| 84 | + | } | |||
| 85 | + | return &ZwlrOutputPowerV1{r} | |||
| 86 | + | } | |||
| 87 | + | ||||
| 88 | + | const ZwlrOutputPowerV1RequestSetMode uint32 = 0 | |||
| 89 | + | const ZwlrOutputPowerV1RequestDestroy uint32 = 1 | |||
| 90 | + | const ZwlrOutputPowerV1EventMode uint32 = 0 | |||
| 91 | + | const ZwlrOutputPowerV1EventFailed uint32 = 1 | |||
| 92 | + | ||||
| 93 | + | // ZwlrOutputPowerV1Mode . | |||
| 94 | + | type ZwlrOutputPowerV1Mode uint32 | |||
| 95 | + | ||||
| 96 | + | const ( | |||
| 97 | + | ZwlrOutputPowerV1ModeOff ZwlrOutputPowerV1Mode = 0 | |||
| 98 | + | ZwlrOutputPowerV1ModeOn ZwlrOutputPowerV1Mode = 1 | |||
| 99 | + | ) | |||
| 100 | + | ||||
| 101 | + | // ZwlrOutputPowerV1Error . | |||
| 102 | + | type ZwlrOutputPowerV1Error uint32 | |||
| 103 | + | ||||
| 104 | + | const ( | |||
| 105 | + | ZwlrOutputPowerV1ErrorInvalidMode ZwlrOutputPowerV1Error = 1 | |||
| 106 | + | ) | |||
| 107 | + | ||||
| 108 | + | // ZwlrOutputPowerV1Handler handles zwlr_output_power_v1 requests. | |||
| 109 | + | type ZwlrOutputPowerV1Handler interface { | |||
| 110 | + | SetMode(self *ZwlrOutputPowerV1, mode uint32) | |||
| 111 | + | Destroy(self *ZwlrOutputPowerV1) | |||
| 112 | + | } | |||
| 113 | + | ||||
| 114 | + | func NewZwlrOutputPowerV1(c server.Client, version int32, id uint32, h ZwlrOutputPowerV1Handler) (*ZwlrOutputPowerV1, error) { | |||
| 115 | + | if h == nil { | |||
| 116 | + | return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_output_power_v1") | |||
| 117 | + | } | |||
| 118 | + | var self *ZwlrOutputPowerV1 | |||
| 119 | + | r, err := c.CreateResource(ZwlrOutputPowerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { | |||
| 120 | + | switch opcode { | |||
| 121 | + | case 0: | |||
| 122 | + | h.SetMode(self, args[0].Uint()) | |||
| 123 | + | case 1: | |||
| 124 | + | h.Destroy(self) | |||
| 125 | + | self.Destroy() | |||
| 126 | + | } | |||
| 127 | + | }) | |||
| 128 | + | if err != nil { | |||
| 129 | + | return nil, err | |||
| 130 | + | } | |||
| 131 | + | self = WrapZwlrOutputPowerV1(r) | |||
| 132 | + | r.Data = self | |||
| 133 | + | return self, nil | |||
| 134 | + | } | |||
| 135 | + | ||||
| 136 | + | // SendMode Report a power management mode change. | |||
| 137 | + | func (self *ZwlrOutputPowerV1) SendMode(mode uint32) { | |||
| 138 | + | self.PostEvent(ZwlrOutputPowerV1EventMode, server.Uint(mode)) | |||
| 139 | + | } | |||
| 140 | + | ||||
| 141 | + | // SendFailed object no longer valid. | |||
| 142 | + | func (self *ZwlrOutputPowerV1) SendFailed() { | |||
| 143 | + | self.PostEvent(ZwlrOutputPowerV1EventFailed) | |||
| 144 | + | } | |||
| 145 | + | func NewZwlrOutputPowerV1Global(d *server.Display, version int32, bind server.BindFunc) error { | |||
| 146 | + | return d.CreateGlobal(ZwlrOutputPowerV1Interface, version, bind) | |||
| 147 | + | } | |||
| 148 | + | func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource { | |||
| 149 | + | if v == nil { | |||
| 150 | + | return nil | |||
| 151 | + | } | |||
| 152 | + | return v.GetResource() | |||
| 153 | + | } | |||
| 154 | + | func (self *ZwlrOutputPowerManagerV1) GetResource() *server.Resource { | |||
| 155 | + | if self == nil { | |||
| 156 | + | return nil | |||
| 157 | + | } | |||
| 158 | + | return self.Resource | |||
| 159 | + | } | |||
| 160 | + | func (self *ZwlrOutputPowerV1) GetResource() *server.Resource { | |||
| 161 | + | if self == nil { | |||
| 162 | + | return nil | |||
| 163 | + | } | |||
| 164 | + | return self.Resource | |||
| 165 | + | } | |||
A protocol/wlroutputpower/wlroutputpower_test.go +17 -0
| @@ -0,0 +1,17 @@ | |||
| 1 | + | package wlroutputpower | |
| 2 | + | ||
| 3 | + | import ( | |
| 4 | + | "testing" | |
| 5 | + | ||
| 6 | + | "github.com/bnema/purego-libwayland/protocol/wayland" | |
| 7 | + | ) | |
| 8 | + | ||
| 9 | + | func TestImportedInterfaces(t *testing.T) { | |
| 10 | + | req := ZwlrOutputPowerManagerV1Interface.Requests[ZwlrOutputPowerManagerV1RequestGetOutputPower] | |
| 11 | + | if got := req.Types[0]; got != ZwlrOutputPowerV1Interface { | |
| 12 | + | t.Fatalf("new_id type=%v", got) | |
| 13 | + | } | |
| 14 | + | if got := req.Types[1]; got != wayland.OutputInterface { | |
| 15 | + | t.Fatalf("output type=%v", got) | |
| 16 | + | } | |
| 17 | + | } | |
| @@ -0,0 +1,17 @@ | |||||
| 1 | + | package wlroutputpower | |||
| 2 | + | ||||
| 3 | + | import ( | |||
| 4 | + | "testing" | |||
| 5 | + | ||||
| 6 | + | "github.com/bnema/purego-libwayland/protocol/wayland" | |||
| 7 | + | ) | |||
| 8 | + | ||||
| 9 | + | func TestImportedInterfaces(t *testing.T) { | |||
| 10 | + | req := ZwlrOutputPowerManagerV1Interface.Requests[ZwlrOutputPowerManagerV1RequestGetOutputPower] | |||
| 11 | + | if got := req.Types[0]; got != ZwlrOutputPowerV1Interface { | |||
| 12 | + | t.Fatalf("new_id type=%v", got) | |||
| 13 | + | } | |||
| 14 | + | if got := req.Types[1]; got != wayland.OutputInterface { | |||
| 15 | + | t.Fatalf("output type=%v", got) | |||
| 16 | + | } | |||
| 17 | + | } | |||
A protocols/wlr-output-power-management-unstable-v1.xml +128 -0
| @@ -0,0 +1,128 @@ | |||
| 1 | + | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | + | <protocol name="wlr_output_power_management_unstable_v1"> | |
| 3 | + | <copyright> | |
| 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 | + | </copyright> | |
| 25 | + | ||
| 26 | + | <description summary="Control power management modes of outputs"> | |
| 27 | + | This protocol allows clients to control power management modes | |
| 28 | + | of outputs that are currently part of the compositor space. The | |
| 29 | + | intent is to allow special clients like desktop shells to power | |
| 30 | + | down outputs when the system is idle. | |
| 31 | + | ||
| 32 | + | To modify outputs not currently part of the compositor space see | |
| 33 | + | wlr-output-management. | |
| 34 | + | ||
| 35 | + | Warning! The protocol described in this file is experimental and | |
| 36 | + | backward incompatible changes may be made. Backward compatible changes | |
| 37 | + | may be added together with the corresponding interface version bump. | |
| 38 | + | Backward incompatible changes are done by bumping the version number in | |
| 39 | + | the protocol and interface names and resetting the interface version. | |
| 40 | + | Once the protocol is to be declared stable, the 'z' prefix and the | |
| 41 | + | version number in the protocol and interface names are removed and the | |
| 42 | + | interface version number is reset. | |
| 43 | + | </description> | |
| 44 | + | ||
| 45 | + | <interface name="zwlr_output_power_manager_v1" version="1"> | |
| 46 | + | <description summary="manager to create per-output power management"> | |
| 47 | + | This interface is a manager that allows creating per-output power | |
| 48 | + | management mode controls. | |
| 49 | + | </description> | |
| 50 | + | ||
| 51 | + | <request name="get_output_power"> | |
| 52 | + | <description summary="get a power management for an output"> | |
| 53 | + | Create an output power management mode control that can be used to | |
| 54 | + | adjust the power management mode for a given output. | |
| 55 | + | </description> | |
| 56 | + | <arg name="id" type="new_id" interface="zwlr_output_power_v1"/> | |
| 57 | + | <arg name="output" type="object" interface="wl_output"/> | |
| 58 | + | </request> | |
| 59 | + | ||
| 60 | + | <request name="destroy" type="destructor"> | |
| 61 | + | <description summary="destroy the manager"> | |
| 62 | + | All objects created by the manager will still remain valid, until their | |
| 63 | + | appropriate destroy request has been called. | |
| 64 | + | </description> | |
| 65 | + | </request> | |
| 66 | + | </interface> | |
| 67 | + | ||
| 68 | + | <interface name="zwlr_output_power_v1" version="1"> | |
| 69 | + | <description summary="adjust power management mode for an output"> | |
| 70 | + | This object offers requests to set the power management mode of | |
| 71 | + | an output. | |
| 72 | + | </description> | |
| 73 | + | ||
| 74 | + | <enum name="mode"> | |
| 75 | + | <entry name="off" value="0" | |
| 76 | + | summary="Output is turned off."/> | |
| 77 | + | <entry name="on" value="1" | |
| 78 | + | summary="Output is turned on, no power saving"/> | |
| 79 | + | </enum> | |
| 80 | + | ||
| 81 | + | <enum name="error"> | |
| 82 | + | <entry name="invalid_mode" value="1" summary="nonexistent power save mode"/> | |
| 83 | + | </enum> | |
| 84 | + | ||
| 85 | + | <request name="set_mode"> | |
| 86 | + | <description summary="Set an outputs power save mode"> | |
| 87 | + | Set an output's power save mode to the given mode. The mode change | |
| 88 | + | is effective immediately. If the output does not support the given | |
| 89 | + | mode a failed event is sent. | |
| 90 | + | </description> | |
| 91 | + | <arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/> | |
| 92 | + | </request> | |
| 93 | + | ||
| 94 | + | <event name="mode"> | |
| 95 | + | <description summary="Report a power management mode change"> | |
| 96 | + | Report the power management mode change of an output. | |
| 97 | + | ||
| 98 | + | The mode event is sent after an output changed its power | |
| 99 | + | management mode. The reason can be a client using set_mode or the | |
| 100 | + | compositor deciding to change an output's mode. | |
| 101 | + | This event is also sent immediately when the object is created | |
| 102 | + | so the client is informed about the current power management mode. | |
| 103 | + | </description> | |
| 104 | + | <arg name="mode" type="uint" enum="mode" | |
| 105 | + | summary="the output's new power management mode"/> | |
| 106 | + | </event> | |
| 107 | + | ||
| 108 | + | <event name="failed"> | |
| 109 | + | <description summary="object no longer valid"> | |
| 110 | + | This event indicates that the output power management mode control | |
| 111 | + | is no longer valid. This can happen for a number of reasons, | |
| 112 | + | including: | |
| 113 | + | - The output doesn't support power management | |
| 114 | + | - Another client already has exclusive power management mode control | |
| 115 | + | for this output | |
| 116 | + | - The output disappeared | |
| 117 | + | ||
| 118 | + | Upon receiving this event, the client should destroy this object. | |
| 119 | + | </description> | |
| 120 | + | </event> | |
| 121 | + | ||
| 122 | + | <request name="destroy" type="destructor"> | |
| 123 | + | <description summary="destroy this power management"> | |
| 124 | + | Destroys the output power management mode control object. | |
| 125 | + | </description> | |
| 126 | + | </request> | |
| 127 | + | </interface> | |
| 128 | + | </protocol> | |
| @@ -0,0 +1,128 @@ | |||||
| 1 | + | <?xml version="1.0" encoding="UTF-8"?> | |||
| 2 | + | <protocol name="wlr_output_power_management_unstable_v1"> | |||
| 3 | + | <copyright> | |||
| 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 | + | </copyright> | |||
| 25 | + | ||||
| 26 | + | <description summary="Control power management modes of outputs"> | |||
| 27 | + | This protocol allows clients to control power management modes | |||
| 28 | + | of outputs that are currently part of the compositor space. The | |||
| 29 | + | intent is to allow special clients like desktop shells to power | |||
| 30 | + | down outputs when the system is idle. | |||
| 31 | + | ||||
| 32 | + | To modify outputs not currently part of the compositor space see | |||
| 33 | + | wlr-output-management. | |||
| 34 | + | ||||
| 35 | + | Warning! The protocol described in this file is experimental and | |||
| 36 | + | backward incompatible changes may be made. Backward compatible changes | |||
| 37 | + | may be added together with the corresponding interface version bump. | |||
| 38 | + | Backward incompatible changes are done by bumping the version number in | |||
| 39 | + | the protocol and interface names and resetting the interface version. | |||
| 40 | + | Once the protocol is to be declared stable, the 'z' prefix and the | |||
| 41 | + | version number in the protocol and interface names are removed and the | |||
| 42 | + | interface version number is reset. | |||
| 43 | + | </description> | |||
| 44 | + | ||||
| 45 | + | <interface name="zwlr_output_power_manager_v1" version="1"> | |||
| 46 | + | <description summary="manager to create per-output power management"> | |||
| 47 | + | This interface is a manager that allows creating per-output power | |||
| 48 | + | management mode controls. | |||
| 49 | + | </description> | |||
| 50 | + | ||||
| 51 | + | <request name="get_output_power"> | |||
| 52 | + | <description summary="get a power management for an output"> | |||
| 53 | + | Create an output power management mode control that can be used to | |||
| 54 | + | adjust the power management mode for a given output. | |||
| 55 | + | </description> | |||
| 56 | + | <arg name="id" type="new_id" interface="zwlr_output_power_v1"/> | |||
| 57 | + | <arg name="output" type="object" interface="wl_output"/> | |||
| 58 | + | </request> | |||
| 59 | + | ||||
| 60 | + | <request name="destroy" type="destructor"> | |||
| 61 | + | <description summary="destroy the manager"> | |||
| 62 | + | All objects created by the manager will still remain valid, until their | |||
| 63 | + | appropriate destroy request has been called. | |||
| 64 | + | </description> | |||
| 65 | + | </request> | |||
| 66 | + | </interface> | |||
| 67 | + | ||||
| 68 | + | <interface name="zwlr_output_power_v1" version="1"> | |||
| 69 | + | <description summary="adjust power management mode for an output"> | |||
| 70 | + | This object offers requests to set the power management mode of | |||
| 71 | + | an output. | |||
| 72 | + | </description> | |||
| 73 | + | ||||
| 74 | + | <enum name="mode"> | |||
| 75 | + | <entry name="off" value="0" | |||
| 76 | + | summary="Output is turned off."/> | |||
| 77 | + | <entry name="on" value="1" | |||
| 78 | + | summary="Output is turned on, no power saving"/> | |||
| 79 | + | </enum> | |||
| 80 | + | ||||
| 81 | + | <enum name="error"> | |||
| 82 | + | <entry name="invalid_mode" value="1" summary="nonexistent power save mode"/> | |||
| 83 | + | </enum> | |||
| 84 | + | ||||
| 85 | + | <request name="set_mode"> | |||
| 86 | + | <description summary="Set an outputs power save mode"> | |||
| 87 | + | Set an output's power save mode to the given mode. The mode change | |||
| 88 | + | is effective immediately. If the output does not support the given | |||
| 89 | + | mode a failed event is sent. | |||
| 90 | + | </description> | |||
| 91 | + | <arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/> | |||
| 92 | + | </request> | |||
| 93 | + | ||||
| 94 | + | <event name="mode"> | |||
| 95 | + | <description summary="Report a power management mode change"> | |||
| 96 | + | Report the power management mode change of an output. | |||
| 97 | + | ||||
| 98 | + | The mode event is sent after an output changed its power | |||
| 99 | + | management mode. The reason can be a client using set_mode or the | |||
| 100 | + | compositor deciding to change an output's mode. | |||
| 101 | + | This event is also sent immediately when the object is created | |||
| 102 | + | so the client is informed about the current power management mode. | |||
| 103 | + | </description> | |||
| 104 | + | <arg name="mode" type="uint" enum="mode" | |||
| 105 | + | summary="the output's new power management mode"/> | |||
| 106 | + | </event> | |||
| 107 | + | ||||
| 108 | + | <event name="failed"> | |||
| 109 | + | <description summary="object no longer valid"> | |||
| 110 | + | This event indicates that the output power management mode control | |||
| 111 | + | is no longer valid. This can happen for a number of reasons, | |||
| 112 | + | including: | |||
| 113 | + | - The output doesn't support power management | |||
| 114 | + | - Another client already has exclusive power management mode control | |||
| 115 | + | for this output | |||
| 116 | + | - The output disappeared | |||
| 117 | + | ||||
| 118 | + | Upon receiving this event, the client should destroy this object. | |||
| 119 | + | </description> | |||
| 120 | + | </event> | |||
| 121 | + | ||||
| 122 | + | <request name="destroy" type="destructor"> | |||
| 123 | + | <description summary="destroy this power management"> | |||
| 124 | + | Destroys the output power management mode control object. | |||
| 125 | + | </description> | |||
| 126 | + | </request> | |||
| 127 | + | </interface> | |||
| 128 | + | </protocol> | |||