| // Copyright 2023 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef REMOTING_HOST_DESKTOP_DISPLAY_INFO_LOADER_X11_H_ |
| #define REMOTING_HOST_DESKTOP_DISPLAY_INFO_LOADER_X11_H_ |
| |
| #include "base/memory/raw_ptr.h" |
| #include "remoting/host/desktop_display_info_loader.h" |
| #include "ui/gfx/x/event.h" |
| #include "ui/gfx/x/randr.h" |
| #include "ui/gfx/x/x11_window_event_manager.h" |
| |
| namespace remoting { |
| |
| class DesktopDisplayInfoLoaderX11 : public DesktopDisplayInfoLoader, |
| public x11::EventObserver { |
| public: |
| DesktopDisplayInfoLoaderX11(); |
| ~DesktopDisplayInfoLoaderX11() override; |
| |
| // DesktopDisplayInfoLoader implementation. |
| void Init() override; |
| DesktopDisplayInfo GetCurrentDisplayInfo() override; |
| |
| // x11::EventObserver implementation. |
| void OnEvent(const x11::Event& xevent) override; |
| |
| private: |
| // Queries the X server and updates |monitors_|. |
| void LoadMonitors(); |
| |
| // XRANDR version as MAJOR * 100 + MINOR, or 0 if XRANDR is not present. |
| int xrandr_version_ = 0; |
| |
| raw_ptr<x11::Connection> connection_ = nullptr; |
| raw_ptr<x11::RandR> randr_ = nullptr; |
| |
| // Selector for root window events. |
| std::unique_ptr<x11::XScopedEventSelector> root_window_events_; |
| |
| std::vector<x11::RandR::MonitorInfo> monitors_; |
| }; |
| |
| } // namespace remoting |
| #endif // REMOTING_HOST_DESKTOP_DISPLAY_INFO_LOADER_X11_H_ |