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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 597 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
598 CHECK(display != NULL); | 598 CHECK(display != NULL); |
599 XGrabServer(display); | 599 XGrabServer(display); |
600 Window window = DefaultRootWindow(display); | 600 Window window = DefaultRootWindow(display); |
601 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); | 601 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); |
602 CHECK(screen != NULL); | 602 CHECK(screen != NULL); |
603 | 603 |
604 OutputSnapshot outputs[2] = { {0}, {0} }; | 604 OutputSnapshot outputs[2] = { {0}, {0} }; |
605 connected_output_count_ = | 605 connected_output_count_ = |
606 GetDualOutputs(display, screen, &outputs[0], &outputs[1]); | 606 GetDualOutputs(display, screen, &outputs[0], &outputs[1]); |
607 output_state_ = | 607 |
608 InferCurrentState(display, screen, outputs, connected_output_count_); | 608 if (all_displays && power_on) { |
609 // Resume all displays using the current state. | |
610 if (EnterState(display, | |
611 screen, | |
612 window, | |
613 output_state_, | |
614 outputs, | |
615 connected_output_count_)) { | |
Josh Horwich
2012/10/23 17:12:21
Do we need to do the DPMSEnable / DPMSForceLevel c
| |
616 XRRFreeScreenResources(screen); | |
617 XUngrabServer(display); | |
618 return true; | |
619 } | |
620 } | |
609 | 621 |
610 RRCrtc crtc = None; | 622 RRCrtc crtc = None; |
611 // Set the CRTCs based on whether we want to turn the power on or off and | 623 // Set the CRTCs based on whether we want to turn the power on or off and |
612 // select the outputs to operate on by name or all_displays. | 624 // select the outputs to operate on by name or all_displays. |
613 for (int i = 0; i < connected_output_count_; ++i) { | 625 for (int i = 0; i < connected_output_count_; ++i) { |
614 if (all_displays || outputs[i].is_internal || power_on) { | 626 if (all_displays || outputs[i].is_internal || power_on) { |
615 const int x = 0; | 627 const int x = 0; |
616 const int y = outputs[i].y; | 628 const int y = outputs[i].y; |
617 RROutput output = outputs[i].output; | 629 RROutput output = outputs[i].output; |
618 RRMode mode = None; | 630 RRMode mode = None; |
619 if (power_on) { | 631 if (power_on) { |
620 mode = (STATE_DUAL_MIRROR == output_state_) ? | 632 mode = (STATE_DUAL_MIRROR == output_state_) ? |
621 outputs[i].mirror_mode : outputs[i].native_mode; | 633 outputs[i].mirror_mode : outputs[i].native_mode; |
622 } else if (connected_output_count_ > 1 && !all_displays && | 634 } else if (connected_output_count_ > 1 && !all_displays && |
623 STATE_DUAL_MIRROR != output_state_ && outputs[i].is_internal) { | 635 && outputs[i].is_internal) { |
624 // Workaround for crbug.com/148365: leave internal display in native | 636 // Workaround for crbug.com/148365: leave internal display in native |
625 // mode so user can move cursor (and hence windows) onto internal | 637 // mode so user can move cursor (and hence windows) onto internal |
626 // display even when dimmed | 638 // display even when dimmed |
627 mode = outputs[i].native_mode; | 639 mode = outputs[i].native_mode; |
628 } | 640 } |
629 crtc = GetNextCrtcAfter(display, screen, output, crtc); | 641 crtc = GetNextCrtcAfter(display, screen, output, crtc); |
630 | 642 |
631 // The values we are setting are already from the cache so no update | |
632 // required. | |
633 ConfigureCrtc(display, | 643 ConfigureCrtc(display, |
634 screen, | 644 screen, |
635 crtc, | 645 crtc, |
636 x, | 646 x, |
637 y, | 647 y, |
638 mode, | 648 mode, |
639 output); | 649 output); |
640 success = true; | 650 success = true; |
641 } | 651 } |
642 } | 652 } |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 // static | 950 // static |
941 RRMode OutputConfigurator::GetOutputNativeMode( | 951 RRMode OutputConfigurator::GetOutputNativeMode( |
942 const XRROutputInfo* output_info) { | 952 const XRROutputInfo* output_info) { |
943 if (output_info->nmode <= 0) | 953 if (output_info->nmode <= 0) |
944 return None; | 954 return None; |
945 | 955 |
946 return output_info->modes[0]; | 956 return output_info->modes[0]; |
947 } | 957 } |
948 | 958 |
949 } // namespace chromeos | 959 } // namespace chromeos |
OLD | NEW |