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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 result = &screen->modes[i]; | 128 result = &screen->modes[i]; |
| 129 | 129 |
| 130 return result; | 130 return result; |
| 131 } | 131 } |
| 132 | 132 |
| 133 // A helper to call XRRSetCrtcConfig with the given options but some of our | 133 // A helper to call XRRSetCrtcConfig with the given options but some of our |
| 134 // default output count and rotation arguments. | 134 // default output count and rotation arguments. |
| 135 void ConfigureCrtc(Display* display, | 135 void ConfigureCrtc(Display* display, |
| 136 XRRScreenResources* screen, | 136 XRRScreenResources* screen, |
| 137 CrtcConfig* config) { | 137 CrtcConfig* config) { |
| 138 VLOG(1) << "ConfigureCrtc crtc: " << config->crtc | 138 LOG(ERROR) << "ConfigureCrtc crtc: " << config->crtc |
| 139 << ", mode " << config->mode | 139 << ", mode " << config->mode |
|
Daniel Erat
2013/01/10 01:48:00
nit: change this back to VLOG(1) (which will also
| |
| 140 << ", output " << config->output | 140 << ", output " << config->output |
| 141 << ", x " << config->x | 141 << ", x " << config->x |
| 142 << ", y " << config->y; | 142 << ", y " << config->y; |
| 143 | 143 |
| 144 const Rotation kRotate = RR_Rotate_0; | 144 const Rotation kRotate = RR_Rotate_0; |
| 145 RROutput* outputs = NULL; | 145 RROutput* outputs = NULL; |
| 146 int num_outputs = 0; | 146 int num_outputs = 0; |
| 147 | 147 |
| 148 // Check the output and mode argument - if either are None, we should disable. | 148 // Check the output and mode argument - if either are None, we should disable. |
| 149 if ((config->output != None) && (config->mode != None)) { | 149 if ((config->output != None) && (config->mode != None)) { |
| (...skipping 612 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 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 Loading... | |
| 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 |
| OLD | NEW |