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

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

Issue 12212171: Provides more types of errors for output status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 did_change = true; 642 did_change = true;
643 } 643 }
644 // We have seen cases where the XRandR data can get out of sync with our own 644 // We have seen cases where the XRandR data can get out of sync with our own
645 // cache so over-write it with whatever we detected, even if we didn't think 645 // cache so over-write it with whatever we detected, even if we didn't think
646 // anything changed. 646 // anything changed.
647 output_state_ = next_state; 647 output_state_ = next_state;
648 648
649 XRRFreeScreenResources(screen); 649 XRRFreeScreenResources(screen);
650 XUngrabServer(display); 650 XUngrabServer(display);
651 651
652 if (did_change) 652 if (did_change) {
653 NotifyOnDisplayChanged(); 653 NotifyOnDisplayChanged();
654 else 654 } else {
655 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed()); 655 FOR_EACH_OBSERVER(
656 Observer, observers_, OnDisplayModeChangeFailed(next_state));
657 }
656 return did_change; 658 return did_change;
657 } 659 }
658 660
659 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { 661 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) {
660 TRACE_EVENT0("chromeos", "OutputConfigurator::ScreenPowerSet"); 662 TRACE_EVENT0("chromeos", "OutputConfigurator::ScreenPowerSet");
661 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on 663 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on
662 << " all displays " << all_displays; 664 << " all displays " << all_displays;
663 if (!configure_display_) 665 if (!configure_display_)
664 return false; 666 return false;
665 667
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 CHECK(screen != NULL); 749 CHECK(screen != NULL);
748 750
749 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); 751 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen);
750 connected_output_count_ = outputs.size(); 752 connected_output_count_ = outputs.size();
751 if (EnterState(display, screen, window, new_state, outputs)) 753 if (EnterState(display, screen, window, new_state, outputs))
752 output_state_ = new_state; 754 output_state_ = new_state;
753 755
754 XRRFreeScreenResources(screen); 756 XRRFreeScreenResources(screen);
755 XUngrabServer(display); 757 XUngrabServer(display);
756 758
757 if (output_state_ == new_state) 759 if (output_state_ == new_state) {
758 NotifyOnDisplayChanged(); 760 NotifyOnDisplayChanged();
759 else 761 } else {
760 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed()); 762 FOR_EACH_OBSERVER(
763 Observer, observers_, OnDisplayModeChangeFailed(new_state));
764 }
761 return true; 765 return true;
762 } 766 }
763 767
764 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) { 768 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) {
765 TRACE_EVENT0("chromeos", "OutputConfigurator::Dispatch"); 769 TRACE_EVENT0("chromeos", "OutputConfigurator::Dispatch");
766 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) 770 if (event->type - xrandr_event_base_ == RRScreenChangeNotify)
767 XRRUpdateConfiguration(event); 771 XRRUpdateConfiguration(event);
768 // Ignore this event if the Xrandr extension isn't supported, or 772 // Ignore this event if the Xrandr extension isn't supported, or
769 // the device is being shutdown. 773 // the device is being shutdown.
770 if (!configure_display_ || 774 if (!configure_display_ ||
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // STATE_DUAL_EXTENDED to STATE_DUAL_EXTENDED, so don't rely on 825 // STATE_DUAL_EXTENDED to STATE_DUAL_EXTENDED, so don't rely on
822 // the state chagne to tell if it was successful. 826 // the state chagne to tell if it was successful.
823 bool success = EnterState(display, screen, window, new_state, outputs); 827 bool success = EnterState(display, screen, window, new_state, outputs);
824 bool is_projecting = IsProjecting(outputs); 828 bool is_projecting = IsProjecting(outputs);
825 XRRFreeScreenResources(screen); 829 XRRFreeScreenResources(screen);
826 XUngrabServer(display); 830 XUngrabServer(display);
827 831
828 if (success) { 832 if (success) {
829 output_state_ = new_state; 833 output_state_ = new_state;
830 NotifyOnDisplayChanged(); 834 NotifyOnDisplayChanged();
835 } else {
836 FOR_EACH_OBSERVER(
837 Observer, observers_, OnDisplayModeChangeFailed(new_state));
831 } 838 }
832 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 839 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
833 SetIsProjecting(is_projecting); 840 SetIsProjecting(is_projecting);
834 } 841 }
835 842
836 void OutputConfigurator::AddObserver(Observer* observer) { 843 void OutputConfigurator::AddObserver(Observer* observer) {
837 observers_.AddObserver(observer); 844 observers_.AddObserver(observer);
838 } 845 }
839 846
840 void OutputConfigurator::RemoveObserver(Observer* observer) { 847 void OutputConfigurator::RemoveObserver(Observer* observer) {
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 // static 1351 // static
1345 RRMode OutputConfigurator::GetOutputNativeMode( 1352 RRMode OutputConfigurator::GetOutputNativeMode(
1346 const XRROutputInfo* output_info) { 1353 const XRROutputInfo* output_info) {
1347 if (output_info->nmode <= 0) 1354 if (output_info->nmode <= 0)
1348 return None; 1355 return None;
1349 1356
1350 return output_info->modes[0]; 1357 return output_info->modes[0];
1351 } 1358 }
1352 1359
1353 } // namespace chromeos 1360 } // namespace chromeos
OLDNEW
« ash/display/display_error_dialog_unittest.cc ('K') | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698