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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 675 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
676 CHECK(display != NULL); | 676 CHECK(display != NULL); |
677 XGrabServer(display); | 677 XGrabServer(display); |
678 Window window = DefaultRootWindow(display); | 678 Window window = DefaultRootWindow(display); |
679 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); | 679 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); |
680 CHECK(screen != NULL); | 680 CHECK(screen != NULL); |
681 | 681 |
682 OutputSnapshot outputs[2] = { {0}, {0} }; | 682 OutputSnapshot outputs[2] = { {0}, {0} }; |
683 connected_output_count_ = | 683 connected_output_count_ = |
684 GetDualOutputs(display, screen, &outputs[0], &outputs[1]); | 684 GetDualOutputs(display, screen, &outputs[0], &outputs[1]); |
685 output_state_ = | 685 |
686 InferCurrentState(display, screen, outputs, connected_output_count_); | 686 if (all_displays && power_on) { |
| 687 // Resume all displays using the current state. |
| 688 if (EnterState(display, |
| 689 screen, |
| 690 window, |
| 691 output_state_, |
| 692 outputs, |
| 693 connected_output_count_)) { |
| 694 // Force the DPMS on since the driver doesn't always detect that it should |
| 695 // turn on. |
| 696 CHECK(DPMSEnable(display)); |
| 697 CHECK(DPMSForceLevel(display, DPMSModeOn)); |
| 698 |
| 699 XRRFreeScreenResources(screen); |
| 700 XUngrabServer(display); |
| 701 return true; |
| 702 } |
| 703 } |
687 | 704 |
688 RRCrtc crtc = None; | 705 RRCrtc crtc = None; |
689 // Set the CRTCs based on whether we want to turn the power on or off and | 706 // Set the CRTCs based on whether we want to turn the power on or off and |
690 // select the outputs to operate on by name or all_displays. | 707 // select the outputs to operate on by name or all_displays. |
691 for (int i = 0; i < connected_output_count_; ++i) { | 708 for (int i = 0; i < connected_output_count_; ++i) { |
692 if (all_displays || outputs[i].is_internal || power_on) { | 709 if (all_displays || outputs[i].is_internal || power_on) { |
693 const int x = 0; | 710 const int x = 0; |
694 const int y = outputs[i].y; | 711 const int y = outputs[i].y; |
695 RROutput output = outputs[i].output; | 712 RROutput output = outputs[i].output; |
696 RRMode mode = None; | 713 RRMode mode = None; |
697 if (power_on) { | 714 if (power_on) { |
698 mode = (STATE_DUAL_MIRROR == output_state_) ? | 715 mode = (STATE_DUAL_MIRROR == output_state_) ? |
699 outputs[i].mirror_mode : outputs[i].native_mode; | 716 outputs[i].mirror_mode : outputs[i].native_mode; |
700 } else if (connected_output_count_ > 1 && !all_displays && | 717 } else if (connected_output_count_ > 1 && !all_displays && |
701 STATE_DUAL_MIRROR != output_state_ && outputs[i].is_internal) { | 718 outputs[i].is_internal) { |
702 // Workaround for crbug.com/148365: leave internal display in native | 719 // Workaround for crbug.com/148365: leave internal display in native |
703 // mode so user can move cursor (and hence windows) onto internal | 720 // mode so user can move cursor (and hence windows) onto internal |
704 // display even when dimmed | 721 // display even when dimmed |
705 mode = outputs[i].native_mode; | 722 mode = outputs[i].native_mode; |
706 } | 723 } |
707 crtc = GetNextCrtcAfter(display, screen, output, crtc); | 724 crtc = GetNextCrtcAfter(display, screen, output, crtc); |
708 | 725 |
709 // The values we are setting are already from the cache so no update | |
710 // required. | |
711 ConfigureCrtc(display, | 726 ConfigureCrtc(display, |
712 screen, | 727 screen, |
713 crtc, | 728 crtc, |
714 x, | 729 x, |
715 y, | 730 y, |
716 mode, | 731 mode, |
717 output); | 732 output); |
718 success = true; | 733 success = true; |
719 } | 734 } |
720 } | 735 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 // distinguish internal display. | 861 // distinguish internal display. |
847 return false; | 862 return false; |
848 } | 863 } |
849 | 864 |
850 void OutputConfigurator::NotifyOnDisplayChanged() { | 865 void OutputConfigurator::NotifyOnDisplayChanged() { |
851 notification_timer_.reset(); | 866 notification_timer_.reset(); |
852 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); | 867 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); |
853 } | 868 } |
854 | 869 |
855 } // namespace chromeos | 870 } // namespace chromeos |
OLD | NEW |