1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: xdg_toplevel_drag_v1
3// Source: xdg-toplevel-drag-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright 2023 David Redondo
7//
8// Permission is hereby granted, free of charge, to any person obtaining a
9// copy of this software and associated documentation files (the "Software"),
10// to deal in the Software without restriction, including without limitation
11// the rights to use, copy, modify, merge, publish, distribute, sublicense,
12// and/or sell copies of the Software, and to permit persons to whom the
13// Software is furnished to do so, subject to the following conditions:
14//
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//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25// DEALINGS IN THE SOFTWARE.
26
27package xdgtopleveldrag
28
29import (
30 cross_wl_data_source "github.com/bnema/go-wayland-bindings/client/wayland"
31 cross_xdg_toplevel "github.com/bnema/go-wayland-bindings/client/xdgshell"
32 "github.com/bnema/wlturbo/wl"
33)
34
35// ERROR_INVALID_SOURCE is the error invalid_source value.
36const ERROR_INVALID_SOURCE = 0
37
38// ERROR_TOPLEVEL_ATTACHED is the error toplevel_attached value.
39const ERROR_TOPLEVEL_ATTACHED = 0
40
41// ERROR_ONGOING_DRAG is the error ongoing_drag value.
42const ERROR_ONGOING_DRAG = 1
43
44// XdgToplevelDragManagerInterface is the protocol interface name.
45const XdgToplevelDragManagerInterface = "xdg_toplevel_drag_manager_v1"
46
47// XdgToplevelDragManager is the generated binding for xdg_toplevel_drag_manager_v1 version 1.
48type XdgToplevelDragManager struct {
49 wl.BaseProxy
50}
51
52// NewXdgToplevelDragManager returns an unbound XdgToplevelDragManager.
53func NewXdgToplevelDragManager(ctx *wl.Context) *XdgToplevelDragManager {
54 obj := &XdgToplevelDragManager{}
55 obj.SetContext(ctx)
56 ctx.Register(obj)
57 return obj
58}
59
60// Destroy this xdg_toplevel_drag_manager_v1 object. Other objects, including xdg_toplevel_drag_v1 objects created by this factory, are not affected by this request.
61func (o *XdgToplevelDragManager) Destroy() error {
62 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "xdg_toplevel_drag_manager_v1.destroy", Destructor: true}); err != nil {
63 return err
64 }
65 return nil
66}
67
68// Create an xdg_toplevel_drag for a drag and drop operation that is going to be started with data_source. This request can only be made on sources used in drag-and-drop, so it must be performed before wl_data_device.start_drag. Attempting to use the source other than for drag-and-drop such as in wl_data_device.set_selection will raise an invalid_source error. Destroying data_source while a toplevel is attached to the xdg_toplevel_drag is undefined.
69func (o *XdgToplevelDragManager) GetXdgToplevelDrag(dataSource *cross_wl_data_source.DataSource) (*XdgToplevelDrag, error) {
70 var arg1 wl.Object
71 if dataSource != nil {
72 arg1 = dataSource
73 }
74 child := &XdgToplevelDrag{}
75 child.SetContext(o.Context())
76 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "xdg_toplevel_drag_manager_v1.get_xdg_toplevel_drag", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
77 return nil, err
78 }
79 return child, nil
80}
81
82// EventSignature returns the declared event argument types in wire order.
83func (o *XdgToplevelDragManager) EventSignature(opcode uint16) (string, bool) {
84 switch opcode {
85 default:
86 return "", false
87 }
88}
89
90// Dispatch decodes one event on xdg_toplevel_drag_manager_v1 and calls the registered handlers.
91func (o *XdgToplevelDragManager) Dispatch(event *wl.Event) {
92 switch event.Opcode {
93 default:
94 }
95}
96
97// XdgToplevelDragInterface is the protocol interface name.
98const XdgToplevelDragInterface = "xdg_toplevel_drag_v1"
99
100// XdgToplevelDrag is the generated binding for xdg_toplevel_drag_v1 version 1.
101type XdgToplevelDrag struct {
102 wl.BaseProxy
103}
104
105// NewXdgToplevelDrag returns an unbound XdgToplevelDrag.
106func NewXdgToplevelDrag(ctx *wl.Context) *XdgToplevelDrag {
107 obj := &XdgToplevelDrag{}
108 obj.SetContext(ctx)
109 ctx.Register(obj)
110 return obj
111}
112
113// Destroy this xdg_toplevel_drag_v1 object. This request must only be called after the underlying wl_data_source drag has ended, as indicated by the dnd_drop_performed or cancelled events. In any other case an ongoing_drag error is raised.
114func (o *XdgToplevelDrag) Destroy() error {
115 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "xdg_toplevel_drag_v1.destroy", Destructor: true}); err != nil {
116 return err
117 }
118 return nil
119}
120
121// Request that the window will be moved with the cursor during the drag operation. The offset is a hint to the compositor how the toplevel should be positioned relative to the cursor hotspot in surface local coordinates and relative to the geometry of the toplevel being attached. See xdg_surface.set_window_geometry. For example it might only be used when an unmapped window is attached. The attached window does not participate in the selection of the drag target. If the toplevel is unmapped while it is attached, it is automatically detached from the drag. In this case this request has to be called again if the window should be attached after it is remapped. This request can be called multiple times but issuing it while a toplevel with an active role is attached raises a toplevel_attached error.
122func (o *XdgToplevelDrag) Attach(toplevel *cross_xdg_toplevel.XdgToplevel, xOffset int32, yOffset int32) error {
123 var arg0 wl.Object
124 if toplevel != nil {
125 arg0 = toplevel
126 }
127 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "xdg_toplevel_drag_v1.attach"}, wl.ArgObject(arg0), wl.ArgInt(xOffset), wl.ArgInt(yOffset)); err != nil {
128 return err
129 }
130 return nil
131}
132
133// EventSignature returns the declared event argument types in wire order.
134func (o *XdgToplevelDrag) EventSignature(opcode uint16) (string, bool) {
135 switch opcode {
136 default:
137 return "", false
138 }
139}
140
141// Dispatch decodes one event on xdg_toplevel_drag_v1 and calls the registered handlers.
142func (o *XdgToplevelDrag) Dispatch(event *wl.Event) {
143 switch event.Opcode {
144 default:
145 }
146}