1 // 2 // Copyright 2022 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // WaylandWindow.h: Definition of the implementation of OSWindow for Wayland 8 9 #ifndef UTIL_WAYLAND_WINDOW_H 10 #define UTIL_WAYLAND_WINDOW_H 11 12 #include <poll.h> 13 #include <wayland-client.h> 14 #include <wayland-egl-core.h> 15 16 #include "util/OSWindow.h" 17 #include "util/util_export.h" 18 19 bool IsWaylandWindowAvailable(); 20 21 class ANGLE_UTIL_EXPORT WaylandWindow : public OSWindow 22 { 23 public: 24 WaylandWindow(); 25 ~WaylandWindow() override; 26 27 void disableErrorMessageDialog() override; 28 void destroy() override; 29 30 void resetNativeWindow() override; 31 EGLNativeWindowType getNativeWindow() const override; 32 EGLNativeDisplayType getNativeDisplay() const override; 33 34 void messageLoop() override; 35 36 void setMousePosition(int x, int y) override; 37 bool setOrientation(int width, int height) override; 38 bool setPosition(int x, int y) override; 39 bool resize(int width, int height) override; 40 void setVisible(bool isVisible) override; 41 42 void signalTestEvent() override; 43 44 private: 45 static void RegistryHandleGlobal(void *data, 46 struct wl_registry *registry, 47 uint32_t name, 48 const char *interface, 49 uint32_t version); 50 static void RegistryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name); 51 52 bool initializeImpl(const std::string &name, int width, int height) override; 53 54 static const struct wl_registry_listener registryListener; 55 56 struct wl_display *mDisplay; 57 struct wl_compositor *mCompositor; 58 struct wl_surface *mSurface; 59 struct wl_egl_window *mWindow; 60 61 struct pollfd fds[1]; 62 }; 63 64 #endif // UTIL_WAYLAND_WINDOW_H 65