| 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 "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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 to_populate->height = 0; | 248 to_populate->height = 0; |
| 249 to_populate->y = 0; | 249 to_populate->y = 0; |
| 250 } | 250 } |
| 251 // Find the native_mode and leave the mirror_mode for the pass after the | 251 // Find the native_mode and leave the mirror_mode for the pass after the |
| 252 // loop. | 252 // loop. |
| 253 if (output_info->nmode > 0) | 253 if (output_info->nmode > 0) |
| 254 to_populate->native_mode = output_info->modes[0]; | 254 to_populate->native_mode = output_info->modes[0]; |
| 255 to_populate->mirror_mode = 0; | 255 to_populate->mirror_mode = 0; |
| 256 | 256 |
| 257 // See if this output refers to an internal display. | 257 // See if this output refers to an internal display. |
| 258 // TODO(oshmia): Use |IsInternalOutputName| once the change is merged |
| 259 // to m23. crbug.com/152003. |
| 260 const std::string name(output_info->name); |
| 258 to_populate->is_internal = | 261 to_populate->is_internal = |
| 259 OutputConfigurator::IsInternalOutputName( | 262 name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0; |
| 260 std::string(output_info->name)); | |
| 261 | 263 |
| 262 VLOG(1) << "Found display #" << found_count | 264 VLOG(1) << "Found display #" << found_count |
| 263 << " with output " << (int)to_populate->output | 265 << " with output " << (int)to_populate->output |
| 264 << " crtc " << (int)to_populate->crtc | 266 << " crtc " << (int)to_populate->crtc |
| 265 << " current mode " << (int)to_populate->current_mode; | 267 << " current mode " << (int)to_populate->current_mode; |
| 266 ++found_count; | 268 ++found_count; |
| 267 } else { | 269 } else { |
| 268 XRRFreeOutputInfo(output_info); | 270 XRRFreeOutputInfo(output_info); |
| 269 } | 271 } |
| 270 } | 272 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 state = STATE_HEADLESS; | 370 state = STATE_HEADLESS; |
| 369 break; | 371 break; |
| 370 case 1: | 372 case 1: |
| 371 state = STATE_SINGLE; | 373 state = STATE_SINGLE; |
| 372 break; | 374 break; |
| 373 case 2: { | 375 case 2: { |
| 374 bool mirror_supported = (0 != outputs[0].mirror_mode) && | 376 bool mirror_supported = (0 != outputs[0].mirror_mode) && |
| 375 (0 != outputs[1].mirror_mode); | 377 (0 != outputs[1].mirror_mode); |
| 376 switch (current_state) { | 378 switch (current_state) { |
| 377 case STATE_DUAL_PRIMARY_ONLY: | 379 case STATE_DUAL_PRIMARY_ONLY: |
| 378 state = | 380 // TODO(oshima): Temporarily disable extended |
| 379 mirror_supported ? STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY; | 381 // desktop. crbug.com/152003. |
| 382 state = STATE_DUAL_SECONDARY_ONLY; |
| 383 break; |
| 384 case STATE_DUAL_SECONDARY_ONLY: |
| 385 state = mirror_supported ? |
| 386 STATE_DUAL_MIRROR : STATE_DUAL_PRIMARY_ONLY; |
| 380 break; | 387 break; |
| 381 case STATE_DUAL_MIRROR: | 388 case STATE_DUAL_MIRROR: |
| 382 state = STATE_DUAL_PRIMARY_ONLY; | 389 state = STATE_DUAL_PRIMARY_ONLY; |
| 383 break; | 390 break; |
| 384 default: | 391 default: |
| 385 // Unknown so just request something safe. | 392 // Unknown so just request something safe. |
| 386 state = STATE_DUAL_PRIMARY_ONLY; | 393 state = STATE_DUAL_PRIMARY_ONLY; |
| 387 } | 394 } |
| 388 break; | 395 break; |
| 389 } | 396 } |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 void OutputConfigurator::AddObserver(Observer* observer) { | 834 void OutputConfigurator::AddObserver(Observer* observer) { |
| 828 observers_.AddObserver(observer); | 835 observers_.AddObserver(observer); |
| 829 } | 836 } |
| 830 | 837 |
| 831 void OutputConfigurator::RemoveObserver(Observer* observer) { | 838 void OutputConfigurator::RemoveObserver(Observer* observer) { |
| 832 observers_.RemoveObserver(observer); | 839 observers_.RemoveObserver(observer); |
| 833 } | 840 } |
| 834 | 841 |
| 835 // static | 842 // static |
| 836 bool OutputConfigurator::IsInternalOutputName(const std::string& name) { | 843 bool OutputConfigurator::IsInternalOutputName(const std::string& name) { |
| 837 return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0; | 844 // TODO(oshima): There is only one display for m23 and no need to |
| 845 // distinguish internal display. |
| 846 return false; |
| 838 } | 847 } |
| 839 | 848 |
| 840 void OutputConfigurator::NotifyOnDisplayChanged() { | 849 void OutputConfigurator::NotifyOnDisplayChanged() { |
| 841 notification_timer_.reset(); | 850 notification_timer_.reset(); |
| 842 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); | 851 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); |
| 843 } | 852 } |
| 844 | 853 |
| 845 } // namespace chromeos | 854 } // namespace chromeos |
| OLD | NEW |