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