WaylandOutputViewport.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. namespace WallpaperEngine::Render::Drivers {
  16. class WaylandOpenGLDriver;
  17. namespace Output {
  18. class OutputViewport;
  19. class WaylandOutputViewport final : public OutputViewport {
  20. public:
  21. WaylandOutputViewport (WaylandOpenGLDriver* driver, uint32_t waylandName, struct wl_registry* registry);
  22. /**
  23. * @return The wayland driver
  24. */
  25. WaylandOpenGLDriver* getDriver () const;
  26. wl_output* output = nullptr;
  27. glm::ivec2 size = {};
  28. glm::ivec2 position = {};
  29. uint32_t waylandName;
  30. int scale = 1;
  31. bool initialized = false;
  32. bool rendering = false;
  33. wl_egl_window* eglWindow = nullptr;
  34. EGLSurface eglSurface = nullptr;
  35. wl_surface* surface = nullptr;
  36. zwlr_layer_surface_v1* layerSurface = nullptr;
  37. wl_callback* frameCallback = nullptr;
  38. glm::dvec2 mousePos = { 0, 0 };
  39. WallpaperEngine::Input::MouseClickStatus leftClick = WallpaperEngine::Input::MouseClickStatus::Released;
  40. WallpaperEngine::Input::MouseClickStatus rightClick = WallpaperEngine::Input::MouseClickStatus::Released;
  41. wl_cursor* pointer = nullptr;
  42. wl_surface* cursorSurface = nullptr;
  43. bool callbackInitialized = false;
  44. void setupLS ();
  45. /**
  46. * Activates output's context for drawing
  47. */
  48. void makeCurrent () override;
  49. /**
  50. * Swaps buffers to present data on the viewport
  51. */
  52. void swapOutput () override;
  53. /**
  54. * Updates the viewport size
  55. */
  56. void resize ();
  57. private:
  58. WaylandOpenGLDriver* m_driver = nullptr;
  59. };
  60. } // namespace Output
  61. } // namespace WallpaperEngine::Render::Drivers
  62. #endif /* ENABLE_WAYLAND */