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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 642 // cache so over-write it with whatever we detected, even if we didn't think | 642 // cache so over-write it with whatever we detected, even if we didn't think |
| 643 // anything changed. | 643 // anything changed. |
| 644 output_state_ = next_state; | 644 output_state_ = next_state; |
| 645 | 645 |
| 646 XRRFreeScreenResources(screen); | 646 XRRFreeScreenResources(screen); |
| 647 XUngrabServer(display); | 647 XUngrabServer(display); |
| 648 | 648 |
| 649 if (did_change) | 649 if (did_change) |
| 650 NotifyOnDisplayChanged(); | 650 NotifyOnDisplayChanged(); |
| 651 else | 651 else |
| 652 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed()); | 652 FOR_EACH_OBSERVER( |
| 653 Observer, observers_, OnDisplayModeChangeFailed(next_state)); | |
| 653 return did_change; | 654 return did_change; |
| 654 } | 655 } |
| 655 | 656 |
| 656 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { | 657 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { |
| 657 TRACE_EVENT0("chromeos", "OutputConfigurator::ScreenPowerSet"); | 658 TRACE_EVENT0("chromeos", "OutputConfigurator::ScreenPowerSet"); |
| 658 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on | 659 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on |
| 659 << " all displays " << all_displays; | 660 << " all displays " << all_displays; |
| 660 if (!is_running_on_chrome_os_) | 661 if (!is_running_on_chrome_os_) |
| 661 return false; | 662 return false; |
| 662 | 663 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 connected_output_count_ = outputs.size(); | 748 connected_output_count_ = outputs.size(); |
| 748 if (EnterState(display, screen, window, new_state, outputs)) | 749 if (EnterState(display, screen, window, new_state, outputs)) |
| 749 output_state_ = new_state; | 750 output_state_ = new_state; |
| 750 | 751 |
| 751 XRRFreeScreenResources(screen); | 752 XRRFreeScreenResources(screen); |
| 752 XUngrabServer(display); | 753 XUngrabServer(display); |
| 753 | 754 |
| 754 if (output_state_ == new_state) | 755 if (output_state_ == new_state) |
| 755 NotifyOnDisplayChanged(); | 756 NotifyOnDisplayChanged(); |
| 756 else | 757 else |
| 757 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed()); | 758 FOR_EACH_OBSERVER( |
| 759 Observer, observers_, OnDisplayModeChangeFailed(new_state)); | |
| 758 return true; | 760 return true; |
| 759 } | 761 } |
| 760 | 762 |
| 761 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) { | 763 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) { |
| 762 TRACE_EVENT0("chromeos", "OutputConfigurator::Dispatch"); | 764 TRACE_EVENT0("chromeos", "OutputConfigurator::Dispatch"); |
| 763 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) | 765 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) |
| 764 XRRUpdateConfiguration(event); | 766 XRRUpdateConfiguration(event); |
| 765 // Ignore this event if the Xrandr extension isn't supported. | 767 // Ignore this event if the Xrandr extension isn't supported. |
| 766 if (!is_running_on_chrome_os_ || | 768 if (!is_running_on_chrome_os_ || |
| 767 (event->type - xrandr_event_base_ != RRNotify)) { | 769 (event->type - xrandr_event_base_ != RRNotify)) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 CHECK(screen != NULL); | 809 CHECK(screen != NULL); |
| 808 | 810 |
| 809 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); | 811 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); |
| 810 int new_output_count = outputs.size(); | 812 int new_output_count = outputs.size(); |
| 811 bool changed = false; | 813 bool changed = false; |
| 812 if (new_output_count != connected_output_count_) { | 814 if (new_output_count != connected_output_count_) { |
| 813 connected_output_count_ = new_output_count; | 815 connected_output_count_ = new_output_count; |
| 814 OutputState new_state = | 816 OutputState new_state = |
| 815 GetNextState(display, screen, STATE_INVALID, outputs); | 817 GetNextState(display, screen, STATE_INVALID, outputs); |
| 816 changed = EnterState(display, screen, window, new_state, outputs); | 818 changed = EnterState(display, screen, window, new_state, outputs); |
| 817 if (changed) | 819 if (changed) |
|
oshima
2013/02/26 18:27:22
you need {} for this case.
Jun Mukai
2013/02/28 22:57:36
Done.
| |
| 818 output_state_ = new_state; | 820 output_state_ = new_state; |
| 821 else | |
| 822 FOR_EACH_OBSERVER( | |
| 823 Observer, observers_, OnDisplayModeChangeFailed(new_state)); | |
| 819 } | 824 } |
| 820 bool is_projecting = IsProjecting(outputs); | 825 bool is_projecting = IsProjecting(outputs); |
| 821 XRRFreeScreenResources(screen); | 826 XRRFreeScreenResources(screen); |
| 822 XUngrabServer(display); | 827 XUngrabServer(display); |
| 823 | 828 |
| 824 if (changed) | 829 if (changed) |
| 825 NotifyOnDisplayChanged(); | 830 NotifyOnDisplayChanged(); |
| 826 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 831 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 827 SetIsProjecting(is_projecting); | 832 SetIsProjecting(is_projecting); |
| 828 } | 833 } |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1341 // static | 1346 // static |
| 1342 RRMode OutputConfigurator::GetOutputNativeMode( | 1347 RRMode OutputConfigurator::GetOutputNativeMode( |
| 1343 const XRROutputInfo* output_info) { | 1348 const XRROutputInfo* output_info) { |
| 1344 if (output_info->nmode <= 0) | 1349 if (output_info->nmode <= 0) |
| 1345 return None; | 1350 return None; |
| 1346 | 1351 |
| 1347 return output_info->modes[0]; | 1352 return output_info->modes[0]; |
| 1348 } | 1353 } |
| 1349 | 1354 |
| 1350 } // namespace chromeos | 1355 } // namespace chromeos |
| OLD | NEW |