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

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

Issue 11233052: Use the current state when resuming. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_)) {
616 // Force the DPMS on since the driver doesn't always detect that it should
617 // turn on.
618 CHECK(DPMSEnable(display));
619 CHECK(DPMSForceLevel(display, DPMSModeOn));
620
621 XRRFreeScreenResources(screen);
622 XUngrabServer(display);
623 return true;
624 }
625 }
609 626
610 RRCrtc crtc = None; 627 RRCrtc crtc = None;
611 // Set the CRTCs based on whether we want to turn the power on or off and 628 // 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. 629 // select the outputs to operate on by name or all_displays.
613 for (int i = 0; i < connected_output_count_; ++i) { 630 for (int i = 0; i < connected_output_count_; ++i) {
614 if (all_displays || outputs[i].is_internal || power_on) { 631 if (all_displays || outputs[i].is_internal || power_on) {
615 const int x = 0; 632 const int x = 0;
616 const int y = outputs[i].y; 633 const int y = outputs[i].y;
617 RROutput output = outputs[i].output; 634 RROutput output = outputs[i].output;
618 RRMode mode = None; 635 RRMode mode = None;
619 if (power_on) { 636 if (power_on) {
620 mode = (STATE_DUAL_MIRROR == output_state_) ? 637 mode = (STATE_DUAL_MIRROR == output_state_) ?
621 outputs[i].mirror_mode : outputs[i].native_mode; 638 outputs[i].mirror_mode : outputs[i].native_mode;
622 } else if (connected_output_count_ > 1 && !all_displays && 639 } else if (connected_output_count_ > 1 && !all_displays &&
623 STATE_DUAL_MIRROR != output_state_ && outputs[i].is_internal) { 640 outputs[i].is_internal) {
624 // Workaround for crbug.com/148365: leave internal display in native 641 // Workaround for crbug.com/148365: leave internal display in native
625 // mode so user can move cursor (and hence windows) onto internal 642 // mode so user can move cursor (and hence windows) onto internal
626 // display even when dimmed 643 // display even when dimmed
627 mode = outputs[i].native_mode; 644 mode = outputs[i].native_mode;
628 } 645 }
629 crtc = GetNextCrtcAfter(display, screen, output, crtc); 646 crtc = GetNextCrtcAfter(display, screen, output, crtc);
630 647
631 // The values we are setting are already from the cache so no update
632 // required.
633 ConfigureCrtc(display, 648 ConfigureCrtc(display,
634 screen, 649 screen,
635 crtc, 650 crtc,
636 x, 651 x,
637 y, 652 y,
638 mode, 653 mode,
639 output); 654 output);
640 success = true; 655 success = true;
641 } 656 }
642 } 657 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // static 955 // static
941 RRMode OutputConfigurator::GetOutputNativeMode( 956 RRMode OutputConfigurator::GetOutputNativeMode(
942 const XRROutputInfo* output_info) { 957 const XRROutputInfo* output_info) {
943 if (output_info->nmode <= 0) 958 if (output_info->nmode <= 0)
944 return None; 959 return None;
945 960
946 return output_info->modes[0]; 961 return output_info->modes[0];
947 } 962 }
948 963
949 } // namespace chromeos 964 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698