// Code generated by wlbgen; DO NOT EDIT. // Upstream protocol copyright and license: // Copyright © 2013-2016 Collabora, Ltd. // // 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 viewporter import ( "fmt" wayland "github.com/bnema/go-wayland-bindings/server/wayland" "github.com/bnema/purego-libwayland/server" ) var WpViewporterInterface *server.Interface var WpViewportInterface *server.Interface func init() { WpViewporterInterface = &server.Interface{Name: "wp_viewporter", Version: 1} WpViewportInterface = &server.Interface{Name: "wp_viewport", Version: 1} WpViewporterInterface.Requests = []server.Message{ {Name: "destroy", Signature: "", Types: []*server.Interface{}}, {Name: "get_viewport", Signature: "no", Types: []*server.Interface{WpViewportInterface, wayland.SurfaceInterface}}, } WpViewporterInterface.Events = []server.Message{} WpViewportInterface.Requests = []server.Message{ {Name: "destroy", Signature: "", Types: []*server.Interface{}}, {Name: "set_source", Signature: "ffff", Types: []*server.Interface{nil, nil, nil, nil}}, {Name: "set_destination", Signature: "ii", Types: []*server.Interface{nil, nil}}, } WpViewportInterface.Events = []server.Message{} if err := server.NewInterfaces(WpViewporterInterface, WpViewportInterface); err != nil { panic(err) } } // WpViewporter surface cropping and scaling. type WpViewporter struct{ *server.Resource } func WrapWpViewporter(r *server.Resource) *WpViewporter { if r == nil { return nil } return &WpViewporter{r} } const WpViewporterRequestDestroy uint32 = 0 const WpViewporterRequestGetViewport uint32 = 1 // WpViewporterError . type WpViewporterError uint32 const ( WpViewporterErrorViewportExists WpViewporterError = 0 ) // WpViewporterHandler handles wp_viewporter requests. type WpViewporterHandler interface { Destroy(self *WpViewporter) GetViewport(self *WpViewporter, id uint32, surface *wayland.Surface) } func NewWpViewporter(c server.Client, version int32, id uint32, h WpViewporterHandler) (*WpViewporter, error) { if h == nil { return nil, fmt.Errorf("purego-libwayland: nil handler for wp_viewporter") } var self *WpViewporter r, err := c.CreateResource(WpViewporterInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { switch opcode { case 0: h.Destroy(self) self.Destroy() case 1: h.GetViewport(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource())) } }) if err != nil { return nil, err } self = WrapWpViewporter(r) r.Data = self return self, nil } func NewWpViewporterGlobal(d *server.Display, version int32, bind server.BindFunc) error { return d.CreateGlobal(WpViewporterInterface, version, bind) } // WpViewport crop and scale interface to a wl_surface. type WpViewport struct{ *server.Resource } func WrapWpViewport(r *server.Resource) *WpViewport { if r == nil { return nil } return &WpViewport{r} } const WpViewportRequestDestroy uint32 = 0 const WpViewportRequestSetSource uint32 = 1 const WpViewportRequestSetDestination uint32 = 2 // WpViewportError . type WpViewportError uint32 const ( WpViewportErrorBadValue WpViewportError = 0 WpViewportErrorBadSize WpViewportError = 1 WpViewportErrorOutOfBuffer WpViewportError = 2 WpViewportErrorNoSurface WpViewportError = 3 ) // WpViewportHandler handles wp_viewport requests. type WpViewportHandler interface { Destroy(self *WpViewport) SetSource(self *WpViewport, x server.Fixed, y server.Fixed, width server.Fixed, height server.Fixed) SetDestination(self *WpViewport, width int32, height int32) } func NewWpViewport(c server.Client, version int32, id uint32, h WpViewportHandler) (*WpViewport, error) { if h == nil { return nil, fmt.Errorf("purego-libwayland: nil handler for wp_viewport") } var self *WpViewport r, err := c.CreateResource(WpViewportInterface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) { switch opcode { case 0: h.Destroy(self) self.Destroy() case 1: h.SetSource(self, args[0].Fixed(), args[1].Fixed(), args[2].Fixed(), args[3].Fixed()) case 2: h.SetDestination(self, args[0].Int(), args[1].Int()) } }) if err != nil { return nil, err } self = WrapWpViewport(r) r.Data = self return self, nil } func NewWpViewportGlobal(d *server.Display, version int32, bind server.BindFunc) error { return d.CreateGlobal(WpViewportInterface, version, bind) } func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource { if v == nil { return nil } return v.GetResource() } func (self *WpViewporter) GetResource() *server.Resource { if self == nil { return nil } return self.Resource } func (self *WpViewport) GetResource() *server.Resource { if self == nil { return nil } return self.Resource }