File: wayland_object.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (257 lines) | stat: -rw-r--r-- 11,494 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/ozone/platform/wayland/common/wayland_object.h"

#include <alpha-compositing-unstable-v1-client-protocol.h>
#include <appmenu-client-protocol.h>
#include <chrome-color-management-client-protocol.h>
#include <content-type-v1-client-protocol.h>
#include <cursor-shape-v1-client-protocol.h>
#include <extended-drag-unstable-v1-client-protocol.h>
#include <fractional-scale-v1-client-protocol.h>
#include <gtk-primary-selection-client-protocol.h>
#include <idle-client-protocol.h>
#include <idle-inhibit-unstable-v1-client-protocol.h>
#include <keyboard-extension-unstable-v1-client-protocol.h>
#include <keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h>
#include <linux-dmabuf-unstable-v1-client-protocol.h>
#include <linux-drm-syncobj-v1-client-protocol.h>
#include <linux-explicit-synchronization-unstable-v1-client-protocol.h>
#include <overlay-prioritizer-client-protocol.h>
#include <pointer-constraints-unstable-v1-client-protocol.h>
#include <pointer-gestures-unstable-v1-client-protocol.h>
#include <presentation-time-client-protocol.h>
#include <primary-selection-unstable-v1-client-protocol.h>
#include <relative-pointer-unstable-v1-client-protocol.h>
#include <single-pixel-buffer-v1-client-protocol.h>
#include <text-input-extension-unstable-v1-client-protocol.h>
#include <text-input-unstable-v1-client-protocol.h>
#include <text-input-unstable-v3-client-protocol.h>
#include <viewporter-client-protocol.h>
#include <wayland-client-core.h>
#include <wayland-cursor.h>
#include <wayland-drm-client-protocol.h>
#include <xdg-activation-v1-client-protocol.h>
#include <xdg-decoration-unstable-v1-client-protocol.h>
#include <xdg-foreign-unstable-v1-client-protocol.h>
#include <xdg-foreign-unstable-v2-client-protocol.h>
#include <xdg-output-unstable-v1-client-protocol.h>
#include <xdg-shell-client-protocol.h>
#include <xdg-toplevel-drag-v1-client-protocol.h>
#include <xdg-toplevel-icon-v1-client-protocol.h>
#include <xx-session-management-v1-client-protocol.h>

#include "base/logging.h"

namespace wl {
namespace {

void delete_data_device(wl_data_device* data_device) {
  if (wl::get_version_of_object(data_device) >=
      WL_DATA_DEVICE_RELEASE_SINCE_VERSION) {
    wl_data_device_release(data_device);
  } else {
    wl_data_device_destroy(data_device);
  }
}

void delete_output(wl_output* output) {
  if (wl::get_version_of_object(output) >= WL_OUTPUT_RELEASE_SINCE_VERSION) {
    wl_output_release(output);
  } else {
    wl_output_destroy(output);
  }
}

void delete_keyboard(wl_keyboard* keyboard) {
  if (wl::get_version_of_object(keyboard) >=
      WL_KEYBOARD_RELEASE_SINCE_VERSION) {
    wl_keyboard_release(keyboard);
  } else {
    wl_keyboard_destroy(keyboard);
  }
}

void delete_pointer(wl_pointer* pointer) {
  if (wl::get_version_of_object(pointer) >= WL_POINTER_RELEASE_SINCE_VERSION) {
    wl_pointer_release(pointer);
  } else {
    wl_pointer_destroy(pointer);
  }
}

void delete_seat(wl_seat* seat) {
  if (wl::get_version_of_object(seat) >= WL_SEAT_RELEASE_SINCE_VERSION) {
    wl_seat_release(seat);
  } else {
    wl_seat_destroy(seat);
  }
}

void delete_touch(wl_touch* touch) {
  if (wl::get_version_of_object(touch) >= WL_TOUCH_RELEASE_SINCE_VERSION) {
    wl_touch_release(touch);
  } else {
    wl_touch_destroy(touch);
  }
}

void delete_appmenu(org_kde_kwin_appmenu* appmenu) {
  org_kde_kwin_appmenu_release(appmenu);
}

}  // namespace

bool CanBind(const std::string& interface,
             uint32_t available_version,
             uint32_t min_version,
             uint32_t max_version) {
  if (available_version < min_version) {
    LOG(WARNING) << "Unable to bind to " << interface << " version "
                 << available_version << ".  The minimum supported version is "
                 << min_version << ".";
    return false;
  }

  if (available_version > max_version) {
    LOG(WARNING) << "Binding to " << interface << " version " << max_version
                 << " but version " << available_version << " is available.";
  }

  return true;
}

void (*ObjectTraits<wl_cursor_theme>::deleter)(wl_cursor_theme*) =
    &wl_cursor_theme_destroy;

const wl_interface* ObjectTraits<wl_display>::interface = &wl_display_interface;
void (*ObjectTraits<wl_display>::deleter)(wl_display*) = &wl_display_disconnect;

const wl_interface* ObjectTraits<wl_event_queue>::interface = nullptr;
void (*ObjectTraits<wl_event_queue>::deleter)(wl_event_queue*) =
    &wl_event_queue_destroy;

const wl_interface* ObjectTraits<struct wl_proxy>::interface = nullptr;
void (*ObjectTraits<wl_proxy>::deleter)(void*) = &wl_proxy_wrapper_destroy;

// The overwhelming majority of Wayland interfaces follow the fixed pattern for
// naming their interface definition struct and their deleter function, with the
// exception for a few interfaces that use special deleter functions.  This lets
// us generate a lot of boilerplate code by two simple macros defined below.
#define IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(TYPE, DELETER) \
  const wl_interface* ObjectTraits<struct TYPE>::interface =        \
      &TYPE##_interface;                                            \
  void (*ObjectTraits<struct TYPE>::deleter)(struct TYPE*) = &DELETER;

#define IMPLEMENT_WAYLAND_OBJECT_TRAITS(TYPE) \
  IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(TYPE, TYPE##_destroy)

// For convenience, keep aphabetical order in this list.
IMPLEMENT_WAYLAND_OBJECT_TRAITS(gtk_primary_selection_device)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(gtk_primary_selection_device_manager)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(gtk_primary_selection_offer)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(gtk_primary_selection_source)
IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(org_kde_kwin_appmenu,
                                             delete_appmenu)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(org_kde_kwin_appmenu_manager)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(org_kde_kwin_idle)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(org_kde_kwin_idle_timeout)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(overlay_prioritizer)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(overlay_prioritized_surface)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_buffer)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_callback)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_compositor)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_data_device_manager)
IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(wl_data_device, delete_data_device)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_data_offer)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_data_source)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_drm)
IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(wl_keyboard, delete_keyboard)
IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(wl_output, delete_output)
IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(wl_pointer, delete_pointer)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_registry)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_region)
IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(wl_seat, delete_seat)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_shm)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_shm_pool)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_subcompositor)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_subsurface)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wl_surface)
IMPLEMENT_WAYLAND_OBJECT_TRAITS_WITH_DELETER(wl_touch, delete_touch)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_presentation)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_presentation_feedback)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_single_pixel_buffer_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_viewport)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_viewporter)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_content_type_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_content_type_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_cursor_shape_device_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_cursor_shape_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_fractional_scale_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_fractional_scale_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_linux_drm_syncobj_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_linux_drm_syncobj_surface_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(wp_linux_drm_syncobj_timeline_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_activation_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_activation_token_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_popup)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_positioner)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_surface)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_toplevel)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_toplevel_drag_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_toplevel_drag_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_toplevel_icon_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_toplevel_icon_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xdg_wm_base)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xx_toplevel_session_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xx_session_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(xx_session_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_color_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_color_management_output_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_color_management_surface_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_color_space_creator_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_color_space_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_keyboard_extension_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_extended_keyboard_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_extended_drag_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_extended_drag_source_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_extended_drag_offer_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_extended_text_input_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_blending_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zcr_alpha_compositing_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_idle_inhibit_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_idle_inhibitor_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_keyboard_shortcuts_inhibit_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_keyboard_shortcuts_inhibitor_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_linux_buffer_release_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_linux_buffer_params_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_linux_dmabuf_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_linux_explicit_synchronization_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_linux_surface_synchronization_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_locked_pointer_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_pointer_constraints_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_pointer_gesture_pinch_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_pointer_gesture_hold_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_pointer_gestures_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_primary_selection_device_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_primary_selection_device_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_primary_selection_offer_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_primary_selection_source_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_relative_pointer_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_relative_pointer_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_manager_v3)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zwp_text_input_v3)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_decoration_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_exporter_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_exported_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_exporter_v2)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_exported_v2)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_output_manager_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_output_v1)
IMPLEMENT_WAYLAND_OBJECT_TRAITS(zxdg_toplevel_decoration_v1)

}  // namespace wl