1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: server_decoration
3// Source: server-decoration.xml
4
5// Upstream protocol copyright and license:
6// SPDX-FileCopyrightText: 2015 Martin Gräßlin
7//
8// SPDX-License-Identifier: LGPL-2.1-or-later
9
10package kdeserverdecoration
11
12import (
13 "sync"
14
15 cross_wl_surface "github.com/bnema/wlturbo/protocol/core"
16 "github.com/bnema/wlturbo/wl"
17)
18
19// ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE is the mode None value.
20const ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE = 0
21
22// ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT is the mode Client value.
23const ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_CLIENT = 1
24
25// ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER is the mode Server value.
26const ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER = 2
27
28// ORG_KDE_KWIN_SERVER_DECORATION_MODE_NONE is the mode None value.
29const ORG_KDE_KWIN_SERVER_DECORATION_MODE_NONE = 0
30
31// ORG_KDE_KWIN_SERVER_DECORATION_MODE_CLIENT is the mode Client value.
32const ORG_KDE_KWIN_SERVER_DECORATION_MODE_CLIENT = 1
33
34// ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER is the mode Server value.
35const ORG_KDE_KWIN_SERVER_DECORATION_MODE_SERVER = 2
36
37// OrgKdeKwinServerDecorationManagerInterface is the protocol interface name.
38const OrgKdeKwinServerDecorationManagerInterface = "org_kde_kwin_server_decoration_manager"
39
40// OrgKdeKwinServerDecorationManager is the generated binding for org_kde_kwin_server_decoration_manager version 1.
41type OrgKdeKwinServerDecorationManager struct {
42 wl.BaseProxy
43 // handlersMu guards the handler slices: a client may register or replace
44 // handlers while another goroutine dispatches events.
45 handlersMu sync.Mutex
46 onDefaultMode []func(mode uint32)
47}
48
49// NewOrgKdeKwinServerDecorationManager returns an unbound OrgKdeKwinServerDecorationManager.
50func NewOrgKdeKwinServerDecorationManager(ctx *wl.Context) *OrgKdeKwinServerDecorationManager {
51 obj := &OrgKdeKwinServerDecorationManager{}
52 obj.SetContext(ctx)
53 ctx.Register(obj)
54 return obj
55}
56
57// When a client creates a server-side decoration object it indicates that it supports the protocol. The client is supposed to tell the server whether it wants server-side decorations or will provide client-side decorations. If the client does not create a server-side decoration object for a surface the server interprets this as lack of support for this protocol and considers it as client-side decorated. Nevertheless a client-side decorated surface should use this protocol to indicate to the server that it does not want a server-side deco.
58func (o *OrgKdeKwinServerDecorationManager) Create(surface *cross_wl_surface.Surface) (*OrgKdeKwinServerDecoration, error) {
59 var arg1 wl.Object
60 if surface != nil {
61 arg1 = surface
62 }
63 child := &OrgKdeKwinServerDecoration{}
64 child.SetContext(o.Context())
65 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "org_kde_kwin_server_decoration_manager.create", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
66 return nil, err
67 }
68 return child, nil
69}
70
71// OnDefaultMode registers a handler for the default_mode event.
72//
73// Handlers are appended, so a second call adds another handler rather than
74// replacing the first. Registration is safe while another goroutine dispatches.
75func (o *OrgKdeKwinServerDecorationManager) OnDefaultMode(handler func(mode uint32)) {
76 if handler == nil {
77 return
78 }
79 o.handlersMu.Lock()
80 defer o.handlersMu.Unlock()
81 o.onDefaultMode = append(o.onDefaultMode, handler)
82}
83
84// handlersForDefaultMode returns the handlers registered for default_mode, taken
85// under the lock so a handler may register another handler while events are
86// being dispatched.
87func (o *OrgKdeKwinServerDecorationManager) handlersForDefaultMode() []func(mode uint32) {
88 o.handlersMu.Lock()
89 defer o.handlersMu.Unlock()
90 return o.onDefaultMode
91}
92
93// EventSignature returns the declared event argument types in wire order.
94func (o *OrgKdeKwinServerDecorationManager) EventSignature(opcode uint16) (string, bool) {
95 switch opcode {
96 case 0:
97 return "uint,", true
98 default:
99 return "", false
100 }
101}
102
103// Dispatch decodes one event on org_kde_kwin_server_decoration_manager and calls the registered handlers.
104func (o *OrgKdeKwinServerDecorationManager) Dispatch(event *wl.Event) {
105 switch event.Opcode {
106 case 0: // default_mode
107 mode := event.Uint32()
108
109 for i, handler := range o.handlersForDefaultMode() {
110 _ = i
111 handler(mode)
112 }
113 default:
114 }
115}
116
117// OrgKdeKwinServerDecorationInterface is the protocol interface name.
118const OrgKdeKwinServerDecorationInterface = "org_kde_kwin_server_decoration"
119
120// OrgKdeKwinServerDecoration is the generated binding for org_kde_kwin_server_decoration version 1.
121type OrgKdeKwinServerDecoration struct {
122 wl.BaseProxy
123 // handlersMu guards the handler slices: a client may register or replace
124 // handlers while another goroutine dispatches events.
125 handlersMu sync.Mutex
126 onMode []func(mode uint32)
127}
128
129// NewOrgKdeKwinServerDecoration returns an unbound OrgKdeKwinServerDecoration.
130func NewOrgKdeKwinServerDecoration(ctx *wl.Context) *OrgKdeKwinServerDecoration {
131 obj := &OrgKdeKwinServerDecoration{}
132 obj.SetContext(ctx)
133 ctx.Register(obj)
134 return obj
135}
136
137// release the server decoration object
138func (o *OrgKdeKwinServerDecoration) Release() error {
139 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "org_kde_kwin_server_decoration.release", Destructor: true}); err != nil {
140 return err
141 }
142 return nil
143}
144
145// The decoration mode the surface wants to use.
146func (o *OrgKdeKwinServerDecoration) RequestMode(mode uint32) error {
147 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "org_kde_kwin_server_decoration.request_mode"}, wl.ArgUint(mode)); err != nil {
148 return err
149 }
150 return nil
151}
152
153// OnMode registers a handler for the mode event.
154//
155// Handlers are appended, so a second call adds another handler rather than
156// replacing the first. Registration is safe while another goroutine dispatches.
157func (o *OrgKdeKwinServerDecoration) OnMode(handler func(mode uint32)) {
158 if handler == nil {
159 return
160 }
161 o.handlersMu.Lock()
162 defer o.handlersMu.Unlock()
163 o.onMode = append(o.onMode, handler)
164}
165
166// handlersForMode returns the handlers registered for mode, taken
167// under the lock so a handler may register another handler while events are
168// being dispatched.
169func (o *OrgKdeKwinServerDecoration) handlersForMode() []func(mode uint32) {
170 o.handlersMu.Lock()
171 defer o.handlersMu.Unlock()
172 return o.onMode
173}
174
175// EventSignature returns the declared event argument types in wire order.
176func (o *OrgKdeKwinServerDecoration) EventSignature(opcode uint16) (string, bool) {
177 switch opcode {
178 case 0:
179 return "uint,", true
180 default:
181 return "", false
182 }
183}
184
185// Dispatch decodes one event on org_kde_kwin_server_decoration and calls the registered handlers.
186func (o *OrgKdeKwinServerDecoration) Dispatch(event *wl.Event) {
187 switch event.Opcode {
188 case 0: // mode
189 mode := event.Uint32()
190
191 for i, handler := range o.handlersForMode() {
192 _ = i
193 handler(mode)
194 }
195 default:
196 }
197}