Chromium Code Reviews| 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 <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 Loading... | |
| 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 milliseconds of delay for the notification, but it would be |
|
Daniel Erat
2013/01/08 00:51:35
nit: s/hundreds/hundred/ or /hundreds of/
marcheu
2013/01/10 01:03:49
Done.
| |
| 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 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); | |
|
Daniel Erat
2013/01/08 00:51:35
nit: remove this line and just move this down to t
marcheu
2013/01/10 01:03:49
Done.
| |
| 807 ScreenPowerSet(true, true); | |
| 808 // We need to make sure that the monitor configuration we just did actually | |
| 809 // completes before we return, because otherwise the X message could be | |
| 810 // racing with the HandleSuspendReadiness message. | |
| 811 XSync(display, 0); | |
| 812 } | |
| 813 | |
| 802 void OutputConfigurator::NotifyOnDisplayChanged() { | 814 void OutputConfigurator::NotifyOnDisplayChanged() { |
| 803 notification_timer_.reset(); | 815 notification_timer_.reset(); |
| 804 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); | 816 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); |
| 805 } | 817 } |
| 806 | 818 |
| 807 std::vector<OutputSnapshot> OutputConfigurator::GetDualOutputs( | 819 std::vector<OutputSnapshot> OutputConfigurator::GetDualOutputs( |
| 808 Display* display, | 820 Display* display, |
| 809 XRRScreenResources* screen) { | 821 XRRScreenResources* screen) { |
| 810 std::vector<OutputSnapshot> outputs; | 822 std::vector<OutputSnapshot> outputs; |
| 811 XRROutputInfo* one_info = NULL; | 823 XRROutputInfo* one_info = NULL; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1288 // static | 1300 // static |
| 1289 RRMode OutputConfigurator::GetOutputNativeMode( | 1301 RRMode OutputConfigurator::GetOutputNativeMode( |
| 1290 const XRROutputInfo* output_info) { | 1302 const XRROutputInfo* output_info) { |
| 1291 if (output_info->nmode <= 0) | 1303 if (output_info->nmode <= 0) |
| 1292 return None; | 1304 return None; |
| 1293 | 1305 |
| 1294 return output_info->modes[0]; | 1306 return output_info->modes[0]; |
| 1295 } | 1307 } |
| 1296 | 1308 |
| 1297 } // namespace chromeos | 1309 } // namespace chromeos |
| OLD | NEW |