Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chromeos/display/output_configurator.cc

Issue 10836037: Start in extended desktop mode if it is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chromeos/display/output_configurator.h" 5 #include "chromeos/display/output_configurator.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/dpms.h> 8 #include <X11/extensions/dpms.h>
9 #include <X11/extensions/Xrandr.h> 9 #include <X11/extensions/Xrandr.h>
10 10
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 static float ComputeDeviceScaleFactor(unsigned int width, 215 static float ComputeDeviceScaleFactor(unsigned int width,
216 unsigned long mm_width) { 216 unsigned long mm_width) {
217 float device_scale_factor = 1.0f; 217 float device_scale_factor = 1.0f;
218 if (mm_width > 0 && (kMmInInch * width / mm_width) > kHighDensityDIPThreshold) 218 if (mm_width > 0 && (kMmInInch * width / mm_width) > kHighDensityDIPThreshold)
219 device_scale_factor = 2.0f; 219 device_scale_factor = 2.0f;
220 return device_scale_factor; 220 return device_scale_factor;
221 } 221 }
222 222
223 } // namespace 223 } // namespace
224 224
225 OutputConfigurator::OutputConfigurator() 225 OutputConfigurator::OutputConfigurator(bool is_extended_display_enabled)
226 : is_running_on_chrome_os_(base::chromeos::IsRunningOnChromeOS()), 226 : is_running_on_chrome_os_(base::chromeos::IsRunningOnChromeOS()),
227 is_extended_display_enabled_(is_extended_display_enabled),
227 output_count_(0), 228 output_count_(0),
228 output_cache_(NULL), 229 output_cache_(NULL),
229 mirror_supported_(false), 230 mirror_supported_(false),
230 primary_output_index_(-1), 231 primary_output_index_(-1),
231 secondary_output_index_(-1), 232 secondary_output_index_(-1),
232 xrandr_event_base_(0), 233 xrandr_event_base_(0),
233 output_state_(STATE_INVALID) { 234 output_state_(STATE_INVALID) {
234 if (!is_running_on_chrome_os_) 235 if (!is_running_on_chrome_os_)
235 return; 236 return;
236 // Send the signal to powerd to tell it that we will take over output 237 // Send the signal to powerd to tell it that we will take over output
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 XRRQueryExtension(display, &xrandr_event_base_, &error_base_ignored); 269 XRRQueryExtension(display, &xrandr_event_base_, &error_base_ignored);
269 // Relinquish X resources. 270 // Relinquish X resources.
270 XRRFreeScreenResources(screen); 271 XRRFreeScreenResources(screen);
271 XUngrabServer(display); 272 XUngrabServer(display);
272 CheckIsProjectingAndNotify(); 273 CheckIsProjectingAndNotify();
273 } 274 }
274 275
275 OutputConfigurator::~OutputConfigurator() { 276 OutputConfigurator::~OutputConfigurator() {
276 } 277 }
277 278
278 bool OutputConfigurator::CycleDisplayMode(bool extended_desktop_enabled) { 279 bool OutputConfigurator::CycleDisplayMode() {
279 VLOG(1) << "CycleDisplayMode"; 280 VLOG(1) << "CycleDisplayMode";
280 if (!is_running_on_chrome_os_) 281 if (!is_running_on_chrome_os_)
281 return false; 282 return false;
282 283
283 bool did_change = false; 284 bool did_change = false;
284 // Rules: 285 // Rules:
285 // - if there are 0 or 1 displays, do nothing and return false. 286 // - if there are 0 or 1 displays, do nothing and return false.
286 // - use y-coord of CRTCs to determine if we are mirror, primary-first, or 287 // - use y-coord of CRTCs to determine if we are mirror, primary-first, or
287 // secondary-first. The cycle order is: 288 // secondary-first. The cycle order is:
288 // mirror->primary->secondary->mirror. 289 // mirror->primary->secondary->mirror.
289 // Note: If the extended desktop is enabled, the cycle order becomes, 290 // Note: If the extended desktop is enabled, the cycle order becomes,
290 // mirror->extended->mirror 291 // mirror->extended->mirror
291 OutputState new_state = STATE_INVALID; 292 OutputState new_state = STATE_INVALID;
292 switch (output_state_) { 293 switch (output_state_) {
293 case STATE_DUAL_MIRROR: 294 case STATE_DUAL_MIRROR:
294 new_state = STATE_DUAL_PRIMARY_ONLY; 295 new_state = STATE_DUAL_PRIMARY_ONLY;
295 break; 296 break;
296 case STATE_DUAL_PRIMARY_ONLY: 297 case STATE_DUAL_PRIMARY_ONLY:
297 if (extended_desktop_enabled) { 298 if (is_extended_display_enabled_) {
298 if (mirror_supported_) 299 if (mirror_supported_)
299 new_state = STATE_DUAL_MIRROR; 300 new_state = STATE_DUAL_MIRROR;
300 else 301 else
301 new_state = STATE_INVALID; 302 new_state = STATE_INVALID;
302 } else { 303 } else {
303 new_state = STATE_DUAL_SECONDARY_ONLY; 304 new_state = STATE_DUAL_SECONDARY_ONLY;
304 } 305 }
305 break; 306 break;
306 case STATE_DUAL_SECONDARY_ONLY: 307 case STATE_DUAL_SECONDARY_ONLY:
307 new_state = mirror_supported_ ? 308 new_state = mirror_supported_ ?
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 UpdateCacheAndXrandrToState(display, screen, window, state); 715 UpdateCacheAndXrandrToState(display, screen, window, state);
715 } 716 }
716 XRRFreeScreenResources(screen); 717 XRRFreeScreenResources(screen);
717 XUngrabServer(display); 718 XUngrabServer(display);
718 return did_detect_change; 719 return did_detect_change;
719 } 720 }
720 721
721 OutputState OutputConfigurator::GetDefaultState() const { 722 OutputState OutputConfigurator::GetDefaultState() const {
722 OutputState state = STATE_HEADLESS; 723 OutputState state = STATE_HEADLESS;
723 if (-1 != primary_output_index_) { 724 if (-1 != primary_output_index_) {
724 if (-1 != secondary_output_index_) 725 if (-1 != secondary_output_index_) {
725 state = mirror_supported_ ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY; 726 if (is_extended_display_enabled_ || !mirror_supported_)
726 else 727 state = STATE_DUAL_PRIMARY_ONLY;
728 else
729 state = STATE_DUAL_MIRROR;
730 } else {
727 state = STATE_SINGLE; 731 state = STATE_SINGLE;
732 }
728 } 733 }
729 return state; 734 return state;
730 } 735 }
731 736
732 OutputState OutputConfigurator::InferCurrentState( 737 OutputState OutputConfigurator::InferCurrentState(
733 Display* display, XRRScreenResources* screen) const { 738 Display* display, XRRScreenResources* screen) const {
734 // STATE_INVALID will be our default or "unknown" state. 739 // STATE_INVALID will be our default or "unknown" state.
735 OutputState state = STATE_INVALID; 740 OutputState state = STATE_INVALID;
736 // First step: count the number of connected outputs. 741 // First step: count the number of connected outputs.
737 if (secondary_output_index_ == -1) { 742 if (secondary_output_index_ == -1) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 power_manager::kSetIsProjectingMethod); 837 power_manager::kSetIsProjectingMethod);
833 dbus::MessageWriter writer(&method_call); 838 dbus::MessageWriter writer(&method_call);
834 writer.AppendBool(is_projecting); 839 writer.AppendBool(is_projecting);
835 power_manager_proxy->CallMethod( 840 power_manager_proxy->CallMethod(
836 &method_call, 841 &method_call,
837 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 842 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
838 dbus::ObjectProxy::EmptyResponseCallback()); 843 dbus::ObjectProxy::EmptyResponseCallback());
839 } 844 }
840 845
841 } // namespace chromeos 846 } // namespace chromeos
OLDNEW
« chromeos/display/output_configurator.h ('K') | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698