123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // Copyright 2020 The Chromium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- #ifndef REMOTING_HOST_DESKTOP_RESIZER_X11_H_
- #define REMOTING_HOST_DESKTOP_RESIZER_X11_H_
- #include <string.h>
- #include "base/command_line.h"
- #include "base/memory/ptr_util.h"
- #include "base/memory/raw_ptr.h"
- #include "remoting/base/logging.h"
- #include "remoting/host/desktop_resizer.h"
- #include "remoting/host/linux/x11_util.h"
- #include "ui/gfx/x/randr.h"
- namespace remoting {
- // Wrapper class for the XRRScreenResources struct.
- class ScreenResources {
- public:
- ScreenResources();
- ~ScreenResources();
- bool Refresh(x11::RandR* randr, x11::Window window);
- x11::RandR::Mode GetIdForMode(const std::string& name);
- x11::RandR::GetScreenResourcesCurrentReply* get();
- private:
- std::unique_ptr<x11::RandR::GetScreenResourcesCurrentReply> resources_;
- };
- class DesktopResizerX11 : public DesktopResizer {
- public:
- DesktopResizerX11();
- DesktopResizerX11(const DesktopResizerX11&) = delete;
- DesktopResizerX11& operator=(const DesktopResizerX11&) = delete;
- ~DesktopResizerX11() override;
- // DesktopResizer interface
- ScreenResolution GetCurrentResolution(webrtc::ScreenId screen_id) override;
- std::list<ScreenResolution> GetSupportedResolutions(
- const ScreenResolution& preferred,
- webrtc::ScreenId screen_id) override;
- void SetResolution(const ScreenResolution& resolution,
- webrtc::ScreenId screen_id) override;
- void RestoreResolution(const ScreenResolution& original,
- webrtc::ScreenId screen_id) override;
- private:
- // Add a mode matching the specified resolution and switch to it.
- void SetResolutionNewMode(x11::RandR::Output output,
- const ScreenResolution& resolution);
- // Attempt to switch to an existing mode matching the specified resolution
- // using RandR, if such a resolution exists. Otherwise, do nothing.
- void SetResolutionExistingMode(const ScreenResolution& resolution);
- // Create a mode, and attach it to the output. If the mode already exists, it
- // is left unchanged. Returns the new mode ID, or None (0) on failure.
- x11::RandR::Mode CreateMode(x11::RandR::Output output,
- const std::string& name,
- int width,
- int height);
- // Remove the specified mode from the output, and delete it. If the mode is in
- // use, it is not deleted.
- void DeleteMode(x11::RandR::Output output, const std::string& name);
- raw_ptr<x11::Connection> connection_;
- const raw_ptr<x11::RandR> randr_ = nullptr;
- const raw_ptr<const x11::Screen> screen_ = nullptr;
- x11::Window root_;
- ScreenResources resources_;
- bool exact_resize_;
- bool has_randr_;
- };
- } // namespace remoting
- #endif // REMOTING_HOST_DESKTOP_RESIZER_X11_H_
|