#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "remoting/host/x11_desktop_resizer.h"
#include <gio/gio.h>
#include <algorithm>
#include <iterator>
#include <memory>
#include <ranges>
#include <string>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/system/sys_info.h"
#include "base/types/cxx23_to_underlying.h"
#include "remoting/base/logging.h"
#include "remoting/host/desktop_geometry.h"
#include "remoting/host/linux/x11_util.h"
#include "remoting/host/x11_crtc_resizer.h"
#include "remoting/host/x11_display_util.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/x/future.h"
#include "ui/gfx/x/randr.h"
namespace {
constexpr auto kInvalidMode = …;
constexpr auto kDisabledCrtc = …;
constexpr base::TimeDelta kGnomeWaitTime = …;
int PixelsToMillimeters(int pixels, int dpi) { … }
gfx::Size CalculateSizeInMmForGnome(
const remoting::DesktopResolution& resolution) { … }
const int kDefaultDPI = …;
x11::RandR::Output GetOutputFromContext(void* context) { … }
std::string GetModeNameForOutput(x11::RandR::Output output) { … }
uint32_t GetDotClockForModeInfo() { … }
std::vector<remoting::DesktopLayoutWithContext> GetLayoutWithContext(
std::vector<x11::RandR::MonitorInfo>& monitors) { … }
}
namespace remoting {
ScreenResources::ScreenResources() = default;
ScreenResources::~ScreenResources() = default;
bool ScreenResources::Refresh(x11::RandR* randr, x11::Window window) { … }
x11::RandR::Mode ScreenResources::GetIdForMode(const std::string& name) { … }
x11::RandR::GetScreenResourcesCurrentReply* ScreenResources::get() { … }
X11DesktopResizer::X11DesktopResizer()
: … { … }
X11DesktopResizer::~X11DesktopResizer() = default;
DesktopResolution X11DesktopResizer::GetCurrentResolution(
DesktopScreenId screen_id) { … }
std::list<DesktopResolution> X11DesktopResizer::GetSupportedResolutions(
const DesktopResolution& preferred,
DesktopScreenId screen_id) { … }
void X11DesktopResizer::SetResolution(const DesktopResolution& resolution,
DesktopScreenId screen_id) { … }
void X11DesktopResizer::RestoreResolution(const DesktopResolution& original,
DesktopScreenId screen_id) { … }
bool X11DesktopResizer::TryGetCurrentMonitors(
std::vector<x11::RandR::MonitorInfo>& list) { … }
DesktopLayoutSet X11DesktopResizer::GetLayout() { … }
void X11DesktopResizer::SetVideoLayout(const DesktopLayoutSet& layout) { … }
void X11DesktopResizer::SetResolutionForOutput(
x11::RandR::Output output,
const DesktopResolution& resolution) { … }
x11::RandR::Mode X11DesktopResizer::UpdateMode(x11::RandR::Output output,
int width,
int height) { … }
void X11DesktopResizer::DeleteMode(x11::RandR::Output output,
const std::string& name) { … }
void X11DesktopResizer::UpdateRootWindow(X11CrtcResizer& resizer) { … }
X11DesktopResizer::OutputInfoList X11DesktopResizer::GetDisabledOutputs() { … }
void X11DesktopResizer::RequestGnomeDisplayConfig() { … }
void X11DesktopResizer::OnGnomeDisplayConfigReceived(
GnomeDisplayConfig config) { … }
}