OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/desktop_resizer.h" | 5 #include "remoting/host/desktop_resizer.h" |
6 #include "remoting/host/linux/x11_util.h" | 6 #include "remoting/host/linux/x11_util.h" |
7 | 7 |
8 #include <string.h> | 8 #include <string.h> |
9 #include <X11/extensions/Xrandr.h> | 9 #include <X11/extensions/Xrandr.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "remoting/base/logging.h" |
14 | 14 |
15 // On Linux, we use the xrandr extension to change the desktop resolution. For | 15 // On Linux, we use the xrandr extension to change the desktop resolution. For |
16 // now, we only support resize-to-client for Xvfb-based servers that can match | 16 // now, we only support resize-to-client for Xvfb-based servers that can match |
17 // the client resolution exactly. To support best-resolution matching, it would | 17 // the client resolution exactly. To support best-resolution matching, it would |
18 // be necessary to implement |GetSupportedResolutions|, but it's not considered | 18 // be necessary to implement |GetSupportedResolutions|, but it's not considered |
19 // a priority now. | 19 // a priority now. |
20 // | 20 // |
21 // Xrandr has a number of restrictions that make this code more complex: | 21 // Xrandr has a number of restrictions that make this code more complex: |
22 // | 22 // |
23 // 1. It's not possible to change the resolution of an existing mode. Instead, | 23 // 1. It's not possible to change the resolution of an existing mode. Instead, |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // the temporary mode used for the reasons described at the top of this file. | 246 // the temporary mode used for the reasons described at the top of this file. |
247 // The former should be localized if it's user-visible; the latter only | 247 // The former should be localized if it's user-visible; the latter only |
248 // exists briefly and does not need to localized. | 248 // exists briefly and does not need to localized. |
249 const char* kModeName = "Chrome Remote Desktop client resolution"; | 249 const char* kModeName = "Chrome Remote Desktop client resolution"; |
250 const char* kTempModeName = "Chrome Remote Desktop temporary mode"; | 250 const char* kTempModeName = "Chrome Remote Desktop temporary mode"; |
251 | 251 |
252 // Actually do the resize operation, preserving the current mode name. Note | 252 // Actually do the resize operation, preserving the current mode name. Note |
253 // that we have to detach the output from any mode in order to resize it | 253 // that we have to detach the output from any mode in order to resize it |
254 // (strictly speaking, this is only required when reducing the size, but it | 254 // (strictly speaking, this is only required when reducing the size, but it |
255 // seems safe to do it regardless). | 255 // seems safe to do it regardless). |
256 LOG(INFO) << "Changing desktop size to " << resolution.dimensions().width() | 256 HOST_LOG << "Changing desktop size to " << resolution.dimensions().width() |
257 << "x" << resolution.dimensions().height(); | 257 << "x" << resolution.dimensions().height(); |
258 | 258 |
259 // TODO(lambroslambrou): Use the DPI from client size information. | 259 // TODO(lambroslambrou): Use the DPI from client size information. |
260 int width_mm = PixelsToMillimeters(resolution.dimensions().width(), | 260 int width_mm = PixelsToMillimeters(resolution.dimensions().width(), |
261 kDefaultDPI); | 261 kDefaultDPI); |
262 int height_mm = PixelsToMillimeters(resolution.dimensions().height(), | 262 int height_mm = PixelsToMillimeters(resolution.dimensions().height(), |
263 kDefaultDPI); | 263 kDefaultDPI); |
264 CreateMode(kTempModeName, resolution.dimensions().width(), | 264 CreateMode(kTempModeName, resolution.dimensions().width(), |
265 resolution.dimensions().height()); | 265 resolution.dimensions().height()); |
266 SwitchToMode(NULL); | 266 SwitchToMode(NULL); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 XRRSetCrtcConfig(display_, resources_.get(), resources_.GetCrtc(), | 322 XRRSetCrtcConfig(display_, resources_.get(), resources_.GetCrtc(), |
323 CurrentTime, 0, 0, mode_id, 1, outputs, number_of_outputs); | 323 CurrentTime, 0, 0, mode_id, 1, outputs, number_of_outputs); |
324 } | 324 } |
325 | 325 |
326 scoped_ptr<DesktopResizer> DesktopResizer::Create() { | 326 scoped_ptr<DesktopResizer> DesktopResizer::Create() { |
327 return scoped_ptr<DesktopResizer>(new DesktopResizerLinux); | 327 return scoped_ptr<DesktopResizer>(new DesktopResizerLinux); |
328 } | 328 } |
329 | 329 |
330 } // namespace remoting | 330 } // namespace remoting |
OLD | NEW |