X11Output.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <chrono>
  3. #include <glm/vec4.hpp>
  4. #include <map>
  5. #include <memory>
  6. #include <string>
  7. #include <vector>
  8. #include <X11/Xlib.h>
  9. #include <X11/extensions/Xrandr.h>
  10. #include "Output.h"
  11. #include "WallpaperEngine/Render/Drivers/VideoDriver.h"
  12. #include "X11BackgroundWindow.h"
  13. namespace WallpaperEngine::Render::Drivers::Output {
  14. class X11Output final : public Output {
  15. public:
  16. X11Output (ApplicationContext& context, VideoDriver& driver);
  17. ~X11Output () override;
  18. void reset () override;
  19. bool renderVFlip () const override;
  20. bool renderMultiple () const override;
  21. bool haveImageBuffer () const override;
  22. void* getImageBuffer () const override;
  23. uint32_t getImageBufferSize () const override;
  24. void updateRender () const override;
  25. private:
  26. void loadScreenInfo ();
  27. void discoverOutputs (XRRScreenResources* screenResources);
  28. void validateOutputs () const;
  29. void initX11Background ();
  30. void free ();
  31. [[nodiscard]] static bool desktopHidesRootWindow ();
  32. void updateDesktopWindow () const;
  33. [[nodiscard]] std::vector<Window> findCoveringDesktopWindows (const std::vector<Window>& stacking) const;
  34. [[nodiscard]] std::vector<Window> stackingOrder () const;
  35. [[nodiscard]] bool isDesktopType (Window window) const;
  36. [[nodiscard]] Window topLevelOf (Window window) const;
  37. void createDesktopWindow () const;
  38. Display* m_display = nullptr;
  39. Pixmap m_pixmap;
  40. Window m_root;
  41. GC m_gc;
  42. char* m_imageData = nullptr;
  43. uint32_t m_imageSize = 0;
  44. XImage* m_image = nullptr;
  45. std::vector<OutputViewport*> m_screens = {};
  46. std::unique_ptr<X11BackgroundWindow> m_background;
  47. mutable Window m_desktopWindow = None;
  48. mutable bool m_desktopWindowMapped = false;
  49. mutable std::chrono::steady_clock::time_point m_nextDesktopCheck = {};
  50. };
  51. }