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 33 void setNativeDisplay(EGLNativeDisplayType display) override; 34 EGLNativeDisplayType getNativeDisplay() const override; 35 36 void messageLoop() override; 37 38 void setMousePosition(int x, int y) override; 39 bool setOrientation(int width, int height) override; 40 bool setPosition(int x, int y) override; 41 bool resize(int width, int height) override; 42 void setVisible(bool isVisible) override; 43 44 void signalTestEvent() override; 45 46 private: 47 static void RegistryHandleGlobal(void *data, 48 struct wl_registry *registry, 49 uint32_t name, 50 const char *interface, 51 uint32_t version); 52 static void RegistryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name); 53 54 bool initializeImpl(const std::string &name, int width, int height) override; 55 56 static const struct wl_registry_listener registryListener; 57 58 struct wl_display *mDisplay; 59 struct wl_compositor *mCompositor; 60 struct wl_surface *mSurface; 61 struct wl_egl_window *mWindow; 62 63 struct pollfd fds[1]; 64 }; 65 66 #endif // UTIL_WAYLAND_WINDOW_H 67