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

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

Issue 12036092: Implement support for monitor suspend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@git-svn
Patch Set: Fixed nits Created 7 years, 10 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
« no previous file with comments | « chromeos/display/output_configurator.h ('k') | 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 <cmath> 7 #include <cmath>
8 8
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 XRRFreeScreenResources(screen); 762 XRRFreeScreenResources(screen);
763 XUngrabServer(display); 763 XUngrabServer(display);
764 764
765 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 765 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
766 SetIsProjecting(is_projecting); 766 SetIsProjecting(is_projecting);
767 } 767 }
768 // Ignore the case of RR_UnkownConnection. 768 // Ignore the case of RR_UnkownConnection.
769 } 769 }
770 770
771 // Sets the timer for NotifyOnDisplayChanged(). When an output state change 771 // Sets the timer for NotifyOnDisplayChanged(). When an output state change
772 // is issued, several notifications chould arrive and NotifyOnDisplayChanged() 772 // is issued, several notifications should arrive and NotifyOnDisplayChanged()
773 // should be called once for the last one. The timer could lead at most a few 773 // should be called once for the last one. The timer could lead at most a few
774 // handreds milliseconds of delay for the notification, but it would be 774 // hundreds of milliseconds of delay for the notification, but it would be
775 // unrecognizable for users. 775 // unrecognizable for users.
776 if (notification_timer_.get()) { 776 if (notification_timer_.get()) {
777 notification_timer_->Reset(); 777 notification_timer_->Reset();
778 } else { 778 } else {
779 notification_timer_.reset(new base::OneShotTimer<OutputConfigurator>()); 779 notification_timer_.reset(new base::OneShotTimer<OutputConfigurator>());
780 notification_timer_->Start( 780 notification_timer_->Start(
781 FROM_HERE, 781 FROM_HERE,
782 base::TimeDelta::FromMilliseconds(kNotificationTimerDelayMs), 782 base::TimeDelta::FromMilliseconds(kNotificationTimerDelayMs),
783 this, 783 this,
784 &OutputConfigurator::NotifyOnDisplayChanged); 784 &OutputConfigurator::NotifyOnDisplayChanged);
785 } 785 }
786 return true; 786 return true;
787 } 787 }
788 788
789 void OutputConfigurator::AddObserver(Observer* observer) { 789 void OutputConfigurator::AddObserver(Observer* observer) {
790 observers_.AddObserver(observer); 790 observers_.AddObserver(observer);
791 } 791 }
792 792
793 void OutputConfigurator::RemoveObserver(Observer* observer) { 793 void OutputConfigurator::RemoveObserver(Observer* observer) {
794 observers_.RemoveObserver(observer); 794 observers_.RemoveObserver(observer);
795 } 795 }
796 796
797 // static 797 // static
798 bool OutputConfigurator::IsInternalOutputName(const std::string& name) { 798 bool OutputConfigurator::IsInternalOutputName(const std::string& name) {
799 return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0; 799 return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0;
800 } 800 }
801 801
802 void OutputConfigurator::SuspendDisplays() {
803 // Turn displays on before suspend. At this point, the backlight is off,
804 // so we turn on the internal display so that we can resume directly into
805 // "on" state. This greatly reduces resume times.
806 ScreenPowerSet(true, true);
807 // We need to make sure that the monitor configuration we just did actually
808 // completes before we return, because otherwise the X message could be
809 // racing with the HandleSuspendReadiness message.
810 XSync(base::MessagePumpAuraX11::GetDefaultXDisplay(), 0);
811 }
812
802 void OutputConfigurator::NotifyOnDisplayChanged() { 813 void OutputConfigurator::NotifyOnDisplayChanged() {
803 notification_timer_.reset(); 814 notification_timer_.reset();
804 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); 815 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged());
805 } 816 }
806 817
807 std::vector<OutputSnapshot> OutputConfigurator::GetDualOutputs( 818 std::vector<OutputSnapshot> OutputConfigurator::GetDualOutputs(
808 Display* display, 819 Display* display,
809 XRRScreenResources* screen) { 820 XRRScreenResources* screen) {
810 std::vector<OutputSnapshot> outputs; 821 std::vector<OutputSnapshot> outputs;
811 XRROutputInfo* one_info = NULL; 822 XRROutputInfo* one_info = NULL;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 // static 1299 // static
1289 RRMode OutputConfigurator::GetOutputNativeMode( 1300 RRMode OutputConfigurator::GetOutputNativeMode(
1290 const XRROutputInfo* output_info) { 1301 const XRROutputInfo* output_info) {
1291 if (output_info->nmode <= 0) 1302 if (output_info->nmode <= 0)
1292 return None; 1303 return None;
1293 1304
1294 return output_info->modes[0]; 1305 return output_info->modes[0];
1295 } 1306 }
1296 1307
1297 } // namespace chromeos 1308 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698