WaylandFullScreenDetector.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #ifdef ENABLE_WAYLAND
  3. #include <cstdint>
  4. #include <set>
  5. #include <string>
  6. #include <vector>
  7. #include "FullScreenDetector.h"
  8. struct wl_display;
  9. struct wl_output;
  10. struct wl_registry;
  11. struct zwlr_foreign_toplevel_manager_v1;
  12. struct zwlr_foreign_toplevel_handle_v1;
  13. namespace WallpaperEngine::Render::Drivers {
  14. class WaylandOpenGLDriver;
  15. }
  16. namespace WallpaperEngine::Desktop {
  17. struct WindowState;
  18. }
  19. namespace WallpaperEngine::Render::Drivers::Detectors {
  20. // wlroots foreign toplevel: fullscreen (and with --pause-on-maximized maximized) windows pause their outputs, toplevels
  21. // on unknown outputs count everywhere
  22. class WaylandFullScreenDetector final : public FullScreenDetector {
  23. public:
  24. struct Output {
  25. wl_output* output;
  26. uint32_t globalName;
  27. std::string name;
  28. };
  29. struct Toplevel {
  30. WaylandFullScreenDetector* detector;
  31. zwlr_foreign_toplevel_handle_v1* handle;
  32. std::string appId;
  33. std::set<wl_output*> outputs;
  34. bool fullscreen = false;
  35. bool maximized = false;
  36. bool activated = false;
  37. };
  38. WaylandFullScreenDetector (Application::ApplicationContext& appContext, WaylandOpenGLDriver* driver);
  39. ~WaylandFullScreenDetector () override;
  40. [[nodiscard]] bool anythingFullscreen () const override;
  41. void reset () override;
  42. /** what the pause decision sees, one entry per output a toplevel is on */
  43. [[nodiscard]] std::vector<Desktop::WindowState> windows (const std::vector<std::string>& drawn) const;
  44. void addOutput (wl_registry* registry, uint32_t globalName, uint32_t version);
  45. void removeGlobal (uint32_t globalName);
  46. void addToplevel (zwlr_foreign_toplevel_handle_v1* handle);
  47. void removeToplevel (Toplevel* toplevel);
  48. [[nodiscard]] const std::string* outputName (wl_output* output) const;
  49. uint32_t m_managerGlobal = 0;
  50. uint32_t m_managerVersion = 0;
  51. private:
  52. WaylandOpenGLDriver* m_driver;
  53. wl_display* m_display = nullptr;
  54. wl_registry* m_registry = nullptr;
  55. zwlr_foreign_toplevel_manager_v1* m_toplevelManager = nullptr;
  56. std::vector<Output*> m_outputs;
  57. std::vector<Toplevel*> m_toplevels;
  58. };
  59. } // namespace WallpaperEngine::Render::Drivers::Detectors
  60. #endif /* ENABLE_WAYLAND */