Commit 04190d84 authored by Lambros Lambrou's avatar Lambros Lambrou Committed by Commit Bot

[remoting] Fix resize-to-fit in Linux host.

The X11 desktop-resizer was recently switched from XLib to XProto.
This CL fixes some bugs introduced by that change.

Bug: 1092630
Change-Id: I947ca8af0311d91db014c2afa235929532e06634
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236682
Auto-Submit: Lambros Lambrou <lambroslambrou@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776311}
parent 7b6d2b3f
...@@ -144,7 +144,6 @@ class DesktopResizerX11 : public DesktopResizer { ...@@ -144,7 +144,6 @@ class DesktopResizerX11 : public DesktopResizer {
// its resolution. // its resolution.
void SwitchToMode(const char* name); void SwitchToMode(const char* name);
XDisplay* const display_;
x11::Connection connection_; x11::Connection connection_;
x11::RandR* const randr_ = nullptr; x11::RandR* const randr_ = nullptr;
const x11::Screen* const screen_ = nullptr; const x11::Screen* const screen_ = nullptr;
...@@ -157,8 +156,7 @@ class DesktopResizerX11 : public DesktopResizer { ...@@ -157,8 +156,7 @@ class DesktopResizerX11 : public DesktopResizer {
}; };
DesktopResizerX11::DesktopResizerX11() DesktopResizerX11::DesktopResizerX11()
: display_(XOpenDisplay(nullptr)), : randr_(connection_.randr()),
randr_(connection_.randr()),
screen_(connection_.default_screen()), screen_(connection_.default_screen()),
root_(screen_->root), root_(screen_->root),
exact_resize_(base::CommandLine::ForCurrentProcess()->HasSwitch( exact_resize_(base::CommandLine::ForCurrentProcess()->HasSwitch(
...@@ -181,16 +179,18 @@ ScreenResolution DesktopResizerX11::GetCurrentResolution() { ...@@ -181,16 +179,18 @@ ScreenResolution DesktopResizerX11::GetCurrentResolution() {
// X server socket by the time the resize function returns, hence the // X server socket by the time the resize function returns, hence the
// file descriptor is never seen as readable. // file descriptor is never seen as readable.
if (has_randr_) { if (has_randr_) {
while (XEventsQueued(display_, QueuedAlready)) { while (XEventsQueued(connection_.display(), QueuedAlready)) {
XEvent event; XEvent event;
XNextEvent(display_, &event); XNextEvent(connection_.display(), &event);
XRRUpdateConfiguration(&event); XRRUpdateConfiguration(&event);
} }
} }
ScreenResolution result( ScreenResolution result(
webrtc::DesktopSize(DisplayWidth(display_, DefaultScreen(display_)), webrtc::DesktopSize(DisplayWidth(connection_.display(),
DisplayHeight(display_, DefaultScreen(display_))), DefaultScreen(connection_.display())),
DisplayHeight(connection_.display(),
DefaultScreen(connection_.display()))),
webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); webrtc::DesktopVector(kDefaultDPI, kDefaultDPI));
return result; return result;
} }
...@@ -240,7 +240,7 @@ void DesktopResizerX11::SetResolution(const ScreenResolution& resolution) { ...@@ -240,7 +240,7 @@ void DesktopResizerX11::SetResolution(const ScreenResolution& resolution) {
// Grab the X server while we're changing the display resolution. This ensures // Grab the X server while we're changing the display resolution. This ensures
// that the display configuration doesn't change under our feet. // that the display configuration doesn't change under our feet.
ScopedXGrabServer grabber(display_); ScopedXGrabServer grabber(connection_.display());
if (exact_resize_) if (exact_resize_)
SetResolutionNewMode(resolution); SetResolutionNewMode(resolution);
...@@ -319,7 +319,7 @@ void DesktopResizerX11::CreateMode(const char* name, int width, int height) { ...@@ -319,7 +319,7 @@ void DesktopResizerX11::CreateMode(const char* name, int width, int height) {
if (!resources_.Refresh(randr_, root_)) if (!resources_.Refresh(randr_, root_))
return; return;
x11::RandR::Mode mode_id = resources_.GetIdForMode(name); x11::RandR::Mode mode_id = resources_.GetIdForMode(name);
if (mode_id != kInvalidMode) if (mode_id == kInvalidMode)
return; return;
randr_->AddOutputMode({ randr_->AddOutputMode({
resources_.GetOutput(), resources_.GetOutput(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment