Backed out 3 changesets (bug 1870106, bug 1845276) for causing doc generate failures...
[gecko.git] / widget / gtk / nsWaylandDisplay.h
blobcd8124d97f8e7a38273a9cae30a9977f4e92be54
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=2:tabstop=2:
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef __MOZ_WAYLAND_DISPLAY_H__
9 #define __MOZ_WAYLAND_DISPLAY_H__
11 #include "DMABufLibWrapper.h"
13 #include "mozilla/widget/mozwayland.h"
14 #include "mozilla/widget/gbm.h"
15 #include "mozilla/widget/fractional-scale-v1-client-protocol.h"
16 #include "mozilla/widget/idle-inhibit-unstable-v1-client-protocol.h"
17 #include "mozilla/widget/relative-pointer-unstable-v1-client-protocol.h"
18 #include "mozilla/widget/pointer-constraints-unstable-v1-client-protocol.h"
19 #include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h"
20 #include "mozilla/widget/viewporter-client-protocol.h"
21 #include "mozilla/widget/xdg-activation-v1-client-protocol.h"
22 #include "mozilla/widget/xdg-output-unstable-v1-client-protocol.h"
24 namespace mozilla::widget {
26 // Our general connection to Wayland display server,
27 // holds our display connection and runs event loop.
28 // We have a global nsWaylandDisplay object for each thread.
29 class nsWaylandDisplay {
30 public:
31 // Create nsWaylandDisplay object on top of native Wayland wl_display
32 // connection.
33 explicit nsWaylandDisplay(wl_display* aDisplay);
35 wl_display* GetDisplay() { return mDisplay; };
36 wl_compositor* GetCompositor() { return mCompositor; };
37 wl_subcompositor* GetSubcompositor() { return mSubcompositor; };
38 wl_shm* GetShm() { return mShm; };
39 zwp_idle_inhibit_manager_v1* GetIdleInhibitManager() {
40 return mIdleInhibitManager;
42 wp_viewporter* GetViewporter() { return mViewporter; };
43 zwp_relative_pointer_manager_v1* GetRelativePointerManager() {
44 return mRelativePointerManager;
46 zwp_pointer_constraints_v1* GetPointerConstraints() {
47 return mPointerConstraints;
49 zwp_linux_dmabuf_v1* GetDmabuf() { return mDmabuf; };
50 xdg_activation_v1* GetXdgActivation() { return mXdgActivation; };
51 wp_fractional_scale_manager_v1* GetFractionalScaleManager() {
52 return mFractionalScaleManager;
54 bool IsPrimarySelectionEnabled() { return mIsPrimarySelectionEnabled; }
56 void SetShm(wl_shm* aShm);
57 void SetCompositor(wl_compositor* aCompositor);
58 void SetSubcompositor(wl_subcompositor* aSubcompositor);
59 void SetDataDeviceManager(wl_data_device_manager* aDataDeviceManager);
60 void SetIdleInhibitManager(zwp_idle_inhibit_manager_v1* aIdleInhibitManager);
61 void SetViewporter(wp_viewporter* aViewporter);
62 void SetRelativePointerManager(
63 zwp_relative_pointer_manager_v1* aRelativePointerManager);
64 void SetPointerConstraints(zwp_pointer_constraints_v1* aPointerConstraints);
65 void SetDmabuf(zwp_linux_dmabuf_v1* aDmabuf);
66 void SetXdgActivation(xdg_activation_v1* aXdgActivation);
67 void SetFractionalScaleManager(wp_fractional_scale_manager_v1* aManager) {
68 mFractionalScaleManager = aManager;
70 void EnablePrimarySelection() { mIsPrimarySelectionEnabled = true; }
72 ~nsWaylandDisplay();
74 private:
75 PRThread* mThreadId = nullptr;
76 wl_registry* mRegistry = nullptr;
77 wl_display* mDisplay = nullptr;
78 wl_compositor* mCompositor = nullptr;
79 wl_subcompositor* mSubcompositor = nullptr;
80 wl_shm* mShm = nullptr;
81 zwp_idle_inhibit_manager_v1* mIdleInhibitManager = nullptr;
82 zwp_relative_pointer_manager_v1* mRelativePointerManager = nullptr;
83 zwp_pointer_constraints_v1* mPointerConstraints = nullptr;
84 wp_viewporter* mViewporter = nullptr;
85 zwp_linux_dmabuf_v1* mDmabuf = nullptr;
86 xdg_activation_v1* mXdgActivation = nullptr;
87 wp_fractional_scale_manager_v1* mFractionalScaleManager = nullptr;
88 bool mExplicitSync = false;
89 bool mIsPrimarySelectionEnabled = false;
92 wl_display* WaylandDisplayGetWLDisplay();
93 nsWaylandDisplay* WaylandDisplayGet();
94 void WaylandDisplayRelease();
96 } // namespace mozilla::widget
98 template <class T>
99 static inline T* WaylandRegistryBind(struct wl_registry* wl_registry,
100 uint32_t name,
101 const struct wl_interface* interface,
102 uint32_t version) {
103 struct wl_proxy* id;
105 // When libwayland-client does not provide this symbol, it will be
106 // linked to the fallback in libmozwayland, which returns NULL.
107 id = wl_proxy_marshal_constructor_versioned(
108 (struct wl_proxy*)wl_registry, WL_REGISTRY_BIND, interface, version, name,
109 interface->name, version, nullptr);
111 if (id == nullptr) {
112 id = wl_proxy_marshal_constructor((struct wl_proxy*)wl_registry,
113 WL_REGISTRY_BIND, interface, name,
114 interface->name, version, nullptr);
117 return reinterpret_cast<T*>(id);
120 #endif // __MOZ_WAYLAND_DISPLAY_H__