1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2024 Neal Gompa
5// Copyright © 2024 Xaver Hugl
6// Copyright © 2024 Matthias Klumpp
7// Copyright © 2024 Vlad Zahorodnii
8//
9// Permission is hereby granted, free of charge, to any person obtaining a
10// copy of this software and associated documentation files (the "Software"),
11// to deal in the Software without restriction, including without limitation
12// the rights to use, copy, modify, merge, publish, distribute, sublicense,
13// and/or sell copies of the Software, and to permit persons to whom the
14// Software is furnished to do so, subject to the following conditions:
15// The above copyright notice and this permission notice (including the next
16// paragraph) shall be included in all copies or substantial portions of the
17// Software.
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 pointerwarp
27
28import (
29 "fmt"
30 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
31 "github.com/bnema/purego-libwayland/server"
32)
33
34var WpPointerWarpV1Interface *server.Interface
35
36func init() {
37 WpPointerWarpV1Interface = &server.Interface{Name: "wp_pointer_warp_v1", Version: 1}
38 WpPointerWarpV1Interface.Requests = []server.Message{
39 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
40 {Name: "warp_pointer", Signature: "ooffu", Types: []*server.Interface{wayland.SurfaceInterface, wayland.PointerInterface, nil, nil, nil}},
41 }
42 WpPointerWarpV1Interface.Events = []server.Message{}
43 if err := server.NewInterfaces(WpPointerWarpV1Interface); err != nil {
44 panic(err)
45 }
46}
47
48// WpPointerWarpV1 reposition the pointer to a location on a surface.
49type WpPointerWarpV1 struct{ *server.Resource }
50
51func WrapWpPointerWarpV1(r *server.Resource) *WpPointerWarpV1 {
52 if r == nil {
53 return nil
54 }
55 return &WpPointerWarpV1{r}
56}
57
58const WpPointerWarpV1RequestDestroy uint32 = 0
59const WpPointerWarpV1RequestWarpPointer uint32 = 1
60
61// WpPointerWarpV1Handler handles wp_pointer_warp_v1 requests.
62type WpPointerWarpV1Handler interface {
63 Destroy(self *WpPointerWarpV1)
64 WarpPointer(self *WpPointerWarpV1, surface *wayland.Surface, pointer *wayland.Pointer, x server.Fixed, y server.Fixed, serial uint32)
65}
66
67func NewWpPointerWarpV1(c server.Client, version int32, id uint32, h WpPointerWarpV1Handler) (*WpPointerWarpV1, error) {
68 if h == nil {
69 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_pointer_warp_v1")
70 }
71 var self *WpPointerWarpV1
72 r, err := c.CreateResource(WpPointerWarpV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
73 switch opcode {
74 case 0:
75 h.Destroy(self)
76 self.Destroy()
77 case 1:
78 h.WarpPointer(self, wayland.WrapSurface(args[0].Resource()), wayland.WrapPointer(args[1].Resource()), args[2].Fixed(), args[3].Fixed(), args[4].Uint())
79 }
80 })
81 if err != nil {
82 return nil, err
83 }
84 self = WrapWpPointerWarpV1(r)
85 r.Data = self
86 return self, nil
87}
88func NewWpPointerWarpV1Global(d *server.Display, version int32, bind server.BindFunc) error {
89 return d.CreateGlobal(WpPointerWarpV1Interface, version, bind)
90}
91func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
92 if v == nil {
93 return nil
94 }
95 return v.GetResource()
96}
97func (self *WpPointerWarpV1) GetResource() *server.Resource {
98 if self == nil {
99 return nil
100 }
101 return self.Resource
102}