X11Output.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <chrono>
  3. #include <glm/vec4.hpp>
  4. #include <map>
  5. #include <string>
  6. #include <vector>
  7. #include <X11/Xlib.h>
  8. #include <X11/extensions/Xrandr.h>
  9. #include "Output.h"
  10. #include "WallpaperEngine/Render/Drivers/VideoDriver.h"
  11. namespace WallpaperEngine::Render::Drivers::Output {
  12. class X11Output final : public Output {
  13. public:
  14. X11Output (ApplicationContext& context, VideoDriver& driver);
  15. ~X11Output () override;
  16. void reset () override;
  17. bool renderVFlip () const override;
  18. bool renderMultiple () const override;
  19. bool haveImageBuffer () const override;
  20. void* getImageBuffer () const override;
  21. uint32_t getImageBufferSize () const override;
  22. void updateRender () const override;
  23. private:
  24. void loadScreenInfo ();
  25. void discoverOutputs (XRRScreenResources* screenResources);
  26. void validateOutputs () const;
  27. void initX11Background ();
  28. void free ();
  29. // XFCE, MATE and LXQt cover the root with an opaque desktop window; frames then go into our own window right above
  30. // it, input passing through. Translucent ones (nemo-desktop) are left alone
  31. void updateDesktopWindow () const;
  32. [[nodiscard]] Window findCoveringDesktopWindow (const std::vector<Window>& stacking) const;
  33. [[nodiscard]] std::vector<Window> stackingOrder () const;
  34. [[nodiscard]] bool isDesktopType (Window window) const;
  35. [[nodiscard]] Window topLevelOf (Window window) const;
  36. void createDesktopWindow () const;
  37. Display* m_display = nullptr;
  38. Pixmap m_pixmap;
  39. Window m_root;
  40. GC m_gc;
  41. char* m_imageData = nullptr;
  42. uint32_t m_imageSize = 0;
  43. XImage* m_image = nullptr;
  44. std::vector<OutputViewport*> m_screens = {};
  45. mutable Window m_desktopWindow = None;
  46. mutable bool m_desktopWindowMapped = false;
  47. mutable std::chrono::steady_clock::time_point m_nextDesktopCheck = {};
  48. };
  49. } // namespace WallpaperEngine::Render::Drivers::Output