-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
globals.h
79 lines (65 loc) · 2.45 KB
/
globals.h
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
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_WAYLAND_CLIENTS_GLOBALS_H_
#define COMPONENTS_EXO_WAYLAND_CLIENTS_GLOBALS_H_
#include <memory>
#include <string>
#include "base/containers/flat_map.h"
#include "components/exo/wayland/clients/client_helper.h"
namespace exo::wayland::clients {
struct Globals {
template <typename T>
class Object : public std::unique_ptr<T> {
public:
Object() = default;
explicit Object(T* ptr) : std::unique_ptr<T>(ptr) {}
explicit Object(std::unique_ptr<T>&& from)
: std::unique_ptr<T>(std::move(from)) {}
Object& operator=(std::unique_ptr<T>&& from) {
std::unique_ptr<T>::operator=(std::move(from));
name_ = 0;
return *this;
}
~Object() = default;
// Numeric name of the global object.
uint32_t name() const { return name_; }
void set_name(uint32_t name) { name_ = name; }
private:
uint32_t name_ = 0;
};
Globals();
~Globals();
// Initializes the members. `versions` optionally specify the maximum
// versions to use for corresponding interfaces.
void Init(wl_display* display,
base::flat_map<std::string, uint32_t> in_requested_versions);
std::unique_ptr<wl_registry> registry;
// TODO(aluh): Support multiple outputs, and probably other globals like
// aura_output, seat, etc.
Object<wl_output> output;
Object<wl_compositor> compositor;
Object<wl_shm> shm;
Object<wp_presentation> presentation;
Object<zwp_linux_dmabuf_v1> linux_dmabuf;
Object<wl_shell> shell;
Object<wl_seat> seat;
Object<wl_subcompositor> subcompositor;
Object<wl_touch> touch;
Object<zaura_shell> aura_shell;
Object<zaura_output> aura_output;
Object<zxdg_shell_v6> xdg_shell_v6;
Object<xdg_wm_base> xdg_wm_base;
Object<zwp_fullscreen_shell_v1> fullscreen_shell;
Object<zwp_input_timestamps_manager_v1> input_timestamps_manager;
Object<zwp_linux_explicit_synchronization_v1> linux_explicit_synchronization;
Object<zcr_vsync_feedback_v1> vsync_feedback;
Object<zcr_color_manager_v1> color_manager;
Object<zcr_stylus_v2> stylus;
Object<zcr_remote_shell_v1> cr_remote_shell_v1;
Object<zcr_remote_shell_v2> cr_remote_shell_v2;
Object<surface_augmenter> surface_augmenter;
base::flat_map<std::string, uint32_t> requested_versions;
};
} // namespace exo::wayland::clients
#endif // COMPONENTS_EXO_WAYLAND_CLIENTS_GLOBALS_H_