WaylandOutputViewport.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #ifdef ENABLE_WAYLAND
  3. #include <EGL/egl.h>
  4. #include <EGL/eglext.h>
  5. #include <GL/glew.h>
  6. #include <wayland-client.h>
  7. #include <wayland-cursor.h>
  8. #include <wayland-egl.h>
  9. #include "../WaylandOpenGLDriver.h"
  10. #include "OutputViewport.h"
  11. #include <WallpaperEngine/Input/MouseInput.h>
  12. #include <glm/vec2.hpp>
  13. struct zwlr_layer_shell_v1;
  14. struct zwlr_layer_surface_v1;
  15. struct zxdg_output_v1;
  16. struct zxdg_output_manager_v1;
  17. namespace WallpaperEngine::Render::Drivers {
  18. class WaylandOpenGLDriver;
  19. namespace Output {
  20. class OutputViewport;
  21. class WaylandOutputViewport final : public OutputViewport {
  22. public:
  23. WaylandOutputViewport (WaylandOpenGLDriver* driver, uint32_t waylandName, struct wl_registry* registry);
  24. /**
  25. * @return The wayland driver
  26. */
  27. WaylandOpenGLDriver* getDriver () const;
  28. wl_output* output = nullptr;
  29. glm::ivec2 size = {};
  30. glm::ivec2 position = {};
  31. uint32_t waylandName;
  32. int scale = 1;
  33. bool initialized = false;
  34. bool rendering = false;
  35. wl_egl_window* eglWindow = nullptr;
  36. EGLSurface eglSurface = nullptr;
  37. wl_surface* surface = nullptr;
  38. zwlr_layer_surface_v1* layerSurface = nullptr;
  39. wl_callback* frameCallback = nullptr;
  40. glm::dvec2 mousePos = { 0, 0 };
  41. WallpaperEngine::Input::MouseClickStatus leftClick = WallpaperEngine::Input::MouseClickStatus::Released;
  42. WallpaperEngine::Input::MouseClickStatus rightClick = WallpaperEngine::Input::MouseClickStatus::Released;
  43. wl_cursor* pointer = nullptr;
  44. wl_surface* cursorSurface = nullptr;
  45. bool callbackInitialized = false;
  46. bool hasXdgLogicalPosition = false;
  47. zxdg_output_v1* xdgOutput = nullptr;
  48. void setupLS ();
  49. void setupXdgOutput (zxdg_output_manager_v1* manager);
  50. /**
  51. * Activates output's context for drawing
  52. */
  53. void makeCurrent () override;
  54. /**
  55. * Swaps buffers to present data on the viewport
  56. */
  57. void swapOutput () override;
  58. /**
  59. * Updates the viewport size
  60. */
  61. void resize ();
  62. private:
  63. WaylandOpenGLDriver* m_driver = nullptr;
  64. };
  65. } // namespace Output
  66. } // namespace WallpaperEngine::Render::Drivers
  67. #endif /* ENABLE_WAYLAND */