1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: viewporter
3// Source: viewporter.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2013-2016 Collabora, Ltd.
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 viewporter
28
29import (
30 cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland"
31 "github.com/bnema/wlturbo/wl"
32)
33
34// ERROR_VIEWPORT_EXISTS is the error viewport_exists value.
35const ERROR_VIEWPORT_EXISTS = 0
36
37// ERROR_BAD_VALUE is the error bad_value value.
38const ERROR_BAD_VALUE = 0
39
40// ERROR_BAD_SIZE is the error bad_size value.
41const ERROR_BAD_SIZE = 1
42
43// ERROR_OUT_OF_BUFFER is the error out_of_buffer value.
44const ERROR_OUT_OF_BUFFER = 2
45
46// ERROR_NO_SURFACE is the error no_surface value.
47const ERROR_NO_SURFACE = 3
48
49// WpViewporterInterface is the protocol interface name.
50const WpViewporterInterface = "wp_viewporter"
51
52// WpViewporter is the generated binding for wp_viewporter version 1.
53type WpViewporter struct {
54 wl.BaseProxy
55}
56
57// NewWpViewporter returns an unbound WpViewporter.
58func NewWpViewporter(ctx *wl.Context) *WpViewporter {
59 obj := &WpViewporter{}
60 obj.SetContext(ctx)
61 ctx.Register(obj)
62 return obj
63}
64
65// Informs the server that the client will not be using this protocol object anymore. This does not affect any other objects, wp_viewport objects included.
66func (o *WpViewporter) Destroy() error {
67 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_viewporter.destroy", Destructor: true}); err != nil {
68 return err
69 }
70 return nil
71}
72
73// Instantiate an interface extension for the given wl_surface to crop and scale its content. If the given wl_surface already has a wp_viewport object associated, the viewport_exists protocol error is raised.
74func (o *WpViewporter) GetViewport(surface *cross_wl_surface.Surface) (*WpViewport, error) {
75 var arg1 wl.Object
76 if surface != nil {
77 arg1 = surface
78 }
79 child := &WpViewport{}
80 child.SetContext(o.Context())
81 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_viewporter.get_viewport", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
82 return nil, err
83 }
84 return child, nil
85}
86
87// EventSignature returns the declared event argument types in wire order.
88func (o *WpViewporter) EventSignature(opcode uint16) (string, bool) {
89 switch opcode {
90 default:
91 return "", false
92 }
93}
94
95// Dispatch decodes one event on wp_viewporter and calls the registered handlers.
96func (o *WpViewporter) Dispatch(event *wl.Event) {
97 switch event.Opcode {
98 default:
99 }
100}
101
102// WpViewportInterface is the protocol interface name.
103const WpViewportInterface = "wp_viewport"
104
105// WpViewport is the generated binding for wp_viewport version 1.
106type WpViewport struct {
107 wl.BaseProxy
108}
109
110// NewWpViewport returns an unbound WpViewport.
111func NewWpViewport(ctx *wl.Context) *WpViewport {
112 obj := &WpViewport{}
113 obj.SetContext(ctx)
114 ctx.Register(obj)
115 return obj
116}
117
118// The associated wl_surface's crop and scale state is removed. The change is applied on the next wl_surface.commit.
119func (o *WpViewport) Destroy() error {
120 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_viewport.destroy", Destructor: true}); err != nil {
121 return err
122 }
123 return nil
124}
125
126// Set the source rectangle of the associated wl_surface. See wp_viewport for the description, and relation to the wl_buffer size. If all of x, y, width and height are -1.0, the source rectangle is unset instead. Any other set of values where width or height are zero or negative, or x or y are negative, raise the bad_value protocol error. The crop and scale state is double-buffered, see wl_surface.commit.
127func (o *WpViewport) SetSource(x wl.Fixed, y wl.Fixed, width wl.Fixed, height wl.Fixed) error {
128 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_viewport.set_source"}, wl.ArgFixed(x), wl.ArgFixed(y), wl.ArgFixed(width), wl.ArgFixed(height)); err != nil {
129 return err
130 }
131 return nil
132}
133
134// Set the destination size of the associated wl_surface. See wp_viewport for the description, and relation to the wl_buffer size. If width is -1 and height is -1, the destination size is unset instead. Any other pair of values for width and height that contains zero or negative values raises the bad_value protocol error. The crop and scale state is double-buffered, see wl_surface.commit.
135func (o *WpViewport) SetDestination(width int32, height int32) error {
136 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wp_viewport.set_destination"}, wl.ArgInt(width), wl.ArgInt(height)); err != nil {
137 return err
138 }
139 return nil
140}
141
142// EventSignature returns the declared event argument types in wire order.
143func (o *WpViewport) EventSignature(opcode uint16) (string, bool) {
144 switch opcode {
145 default:
146 return "", false
147 }
148}
149
150// Dispatch decodes one event on wp_viewport and calls the registered handlers.
151func (o *WpViewport) Dispatch(event *wl.Event) {
152 switch event.Opcode {
153 default:
154 }
155}