1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: viewporter
3// Source: viewporter.xml
4
5package viewporter
6
7import (
8 cross_wl_surface "github.com/bnema/wlturbo/protocol/core"
9 "github.com/bnema/wlturbo/wl"
10)
11
12// ERROR_VIEWPORT_EXISTS is the error viewport_exists value.
13const ERROR_VIEWPORT_EXISTS = 0
14
15// ERROR_BAD_VALUE is the error bad_value value.
16const ERROR_BAD_VALUE = 0
17
18// ERROR_BAD_SIZE is the error bad_size value.
19const ERROR_BAD_SIZE = 1
20
21// ERROR_OUT_OF_BUFFER is the error out_of_buffer value.
22const ERROR_OUT_OF_BUFFER = 2
23
24// ERROR_NO_SURFACE is the error no_surface value.
25const ERROR_NO_SURFACE = 3
26
27// WpViewporterInterface is the protocol interface name.
28const WpViewporterInterface = "wp_viewporter"
29
30// WpViewporter is the generated binding for wp_viewporter version 1.
31type WpViewporter struct {
32 wl.BaseProxy
33}
34
35// NewWpViewporter returns an unbound WpViewporter.
36func NewWpViewporter(ctx *wl.Context) *WpViewporter {
37 obj := &WpViewporter{}
38 obj.SetContext(ctx)
39 ctx.Register(obj)
40 return obj
41}
42
43// 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.
44func (o *WpViewporter) Destroy() error {
45 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 0, Name: "wp_viewporter.destroy", Destructor: true}); err != nil {
46 return err
47 }
48 return nil
49}
50
51// 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.
52func (o *WpViewporter) GetViewport(surface *cross_wl_surface.Surface) (*WpViewport, error) {
53 var arg1 wl.Object
54 if surface != nil {
55 arg1 = surface
56 }
57 child := &WpViewport{}
58 child.SetContext(o.Context())
59 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 1, Name: "wp_viewporter.get_viewport", Child: child}, child, arg1); err != nil {
60 return nil, err
61 }
62 return child, nil
63}
64
65// EventSignature returns the declared event argument types in wire order.
66func (o *WpViewporter) EventSignature(opcode uint16) (string, bool) {
67 switch opcode {
68 default:
69 return "", false
70 }
71}
72
73// Dispatch decodes one event on wp_viewporter and calls the registered handlers.
74func (o *WpViewporter) Dispatch(event *wl.Event) {
75 switch event.Opcode {
76 default:
77 }
78}
79
80// WpViewportInterface is the protocol interface name.
81const WpViewportInterface = "wp_viewport"
82
83// WpViewport is the generated binding for wp_viewport version 1.
84type WpViewport struct {
85 wl.BaseProxy
86}
87
88// NewWpViewport returns an unbound WpViewport.
89func NewWpViewport(ctx *wl.Context) *WpViewport {
90 obj := &WpViewport{}
91 obj.SetContext(ctx)
92 ctx.Register(obj)
93 return obj
94}
95
96// The associated wl_surface's crop and scale state is removed. The change is applied on the next wl_surface.commit.
97func (o *WpViewport) Destroy() error {
98 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 0, Name: "wp_viewport.destroy", Destructor: true}); err != nil {
99 return err
100 }
101 return nil
102}
103
104// 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.
105func (o *WpViewport) SetSource(x wl.Fixed, y wl.Fixed, width wl.Fixed, height wl.Fixed) error {
106 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 1, Name: "wp_viewport.set_source"}, x, y, width, height); err != nil {
107 return err
108 }
109 return nil
110}
111
112// 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.
113func (o *WpViewport) SetDestination(width int32, height int32) error {
114 if err := o.Context().Request(wl.Request{Proxy: o, Opcode: 2, Name: "wp_viewport.set_destination"}, width, height); err != nil {
115 return err
116 }
117 return nil
118}
119
120// EventSignature returns the declared event argument types in wire order.
121func (o *WpViewport) EventSignature(opcode uint16) (string, bool) {
122 switch opcode {
123 default:
124 return "", false
125 }
126}
127
128// Dispatch decodes one event on wp_viewport and calls the registered handlers.
129func (o *WpViewport) Dispatch(event *wl.Event) {
130 switch event.Opcode {
131 default:
132 }
133}