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

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

Issue 10989084: Handles the failures of output state change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/dpms.h> 8 #include <X11/extensions/dpms.h>
9 #include <X11/extensions/Xrandr.h> 9 #include <X11/extensions/Xrandr.h>
10 10
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 connected_output_count_)) { 654 connected_output_count_)) {
655 did_change = true; 655 did_change = true;
656 } 656 }
657 // We have seen cases where the XRandR data can get out of sync with our own 657 // We have seen cases where the XRandR data can get out of sync with our own
658 // cache so over-write it with whatever we detected, even if we didn't think 658 // cache so over-write it with whatever we detected, even if we didn't think
659 // anything changed. 659 // anything changed.
660 output_state_ = next_state; 660 output_state_ = next_state;
661 661
662 XRRFreeScreenResources(screen); 662 XRRFreeScreenResources(screen);
663 XUngrabServer(display); 663 XUngrabServer(display);
664
665 if (!did_change)
666 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed());
664 return did_change; 667 return did_change;
665 } 668 }
666 669
667 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { 670 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) {
668 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on 671 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on
669 << " all displays " << all_displays; 672 << " all displays " << all_displays;
670 if (!is_running_on_chrome_os_) 673 if (!is_running_on_chrome_os_)
671 return false; 674 return false;
672 675
673 bool success = false; 676 bool success = false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 733
731 return success; 734 return success;
732 } 735 }
733 736
734 bool OutputConfigurator::SetDisplayMode(OutputState new_state) { 737 bool OutputConfigurator::SetDisplayMode(OutputState new_state) {
735 if (output_state_ == STATE_INVALID || 738 if (output_state_ == STATE_INVALID ||
736 output_state_ == STATE_HEADLESS || 739 output_state_ == STATE_HEADLESS ||
737 output_state_ == STATE_SINGLE) 740 output_state_ == STATE_SINGLE)
738 return false; 741 return false;
739 742
743 if (output_state_ == new_state)
744 return true;
745
740 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 746 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
741 CHECK(display != NULL); 747 CHECK(display != NULL);
742 XGrabServer(display); 748 XGrabServer(display);
743 Window window = DefaultRootWindow(display); 749 Window window = DefaultRootWindow(display);
744 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); 750 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window);
745 CHECK(screen != NULL); 751 CHECK(screen != NULL);
746 752
753 bool did_change = false;
747 OutputSnapshot outputs[2] = { {0}, {0} }; 754 OutputSnapshot outputs[2] = { {0}, {0} };
748 connected_output_count_ = 755 connected_output_count_ =
749 GetDualOutputs(display, screen, &outputs[0], &outputs[1]); 756 GetDualOutputs(display, screen, &outputs[0], &outputs[1]);
750 if (EnterState(display, 757 if (EnterState(display,
751 screen, 758 screen,
752 window, 759 window,
753 new_state, 760 new_state,
754 outputs, 761 outputs,
755 connected_output_count_)) { 762 connected_output_count_)) {
756 output_state_ = new_state; 763 output_state_ = new_state;
764 did_change = true;
757 } 765 }
758 766
759 XRRFreeScreenResources(screen); 767 XRRFreeScreenResources(screen);
760 XUngrabServer(display); 768 XUngrabServer(display);
769
770 if (!did_change)
oshima 2012/10/02 07:53:02 if (output_state_ != new_state)
Jun Mukai 2012/10/02 20:55:00 Done.
771 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed());
761 return true; 772 return true;
762 } 773 }
763 774
764 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) { 775 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) {
765 // Ignore this event if the Xrandr extension isn't supported. 776 // Ignore this event if the Xrandr extension isn't supported.
766 if (!is_running_on_chrome_os_ || 777 if (!is_running_on_chrome_os_ ||
767 (event->type - xrandr_event_base_ != RRNotify)) { 778 (event->type - xrandr_event_base_ != RRNotify)) {
768 return true; 779 return true;
769 } 780 }
770 XEvent* xevent = static_cast<XEvent*>(event); 781 XEvent* xevent = static_cast<XEvent*>(event);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 // distinguish internal display. 856 // distinguish internal display.
846 return false; 857 return false;
847 } 858 }
848 859
849 void OutputConfigurator::NotifyOnDisplayChanged() { 860 void OutputConfigurator::NotifyOnDisplayChanged() {
850 notification_timer_.reset(); 861 notification_timer_.reset();
851 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); 862 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged());
852 } 863 }
853 864
854 } // namespace chromeos 865 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698