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 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 5 #ifndef CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
| 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 6 #define CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/event_types.h" | 9 #include "base/event_types.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
| 14 | 14 |
| 15 // Forward declarations for Xlib and Xrandr. | 15 // Forward declarations for Xlib and Xrandr. |
| 16 // This is so unused X definitions don't pollute the namespace. | 16 // This is so unused X definitions don't pollute the namespace. |
| 17 typedef unsigned long XID; | 17 typedef unsigned long XID; |
| 18 typedef XID Window; | 18 typedef XID Window; |
| 19 typedef XID RROutput; | 19 typedef XID RROutput; |
| 20 typedef XID RRCrtc; | 20 typedef XID RRCrtc; |
| 21 typedef XID RRMode; | 21 typedef XID RRMode; |
| 22 | 22 |
| 23 struct _XRRScreenResources; | 23 struct _XRRScreenResources; |
| 24 typedef _XRRScreenResources XRRScreenResources; | 24 typedef _XRRScreenResources XRRScreenResources; |
| 25 struct _XRROutputInfo; | |
| 26 typedef _XRROutputInfo XRROutputInfo; | |
| 25 | 27 |
| 26 namespace chromeos { | 28 namespace chromeos { |
| 27 | 29 |
| 28 // Used to describe the state of a multi-display configuration. | 30 // Used to describe the state of a multi-display configuration. |
| 29 // TODO(oshima): remove DUAL_SECONDARY_ONLY | 31 // TODO(oshima): remove DUAL_SECONDARY_ONLY |
| 30 enum OutputState { | 32 enum OutputState { |
| 31 STATE_INVALID, | 33 STATE_INVALID, |
| 32 STATE_HEADLESS, | 34 STATE_HEADLESS, |
| 33 STATE_SINGLE, | 35 STATE_SINGLE, |
| 34 STATE_DUAL_MIRROR, | 36 STATE_DUAL_MIRROR, |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 50 virtual void OnDisplayModeChanged() = 0; | 52 virtual void OnDisplayModeChanged() = 0; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 OutputConfigurator(); | 55 OutputConfigurator(); |
| 54 virtual ~OutputConfigurator(); | 56 virtual ~OutputConfigurator(); |
| 55 | 57 |
| 56 int connected_output_count() const { return connected_output_count_; } | 58 int connected_output_count() const { return connected_output_count_; } |
| 57 | 59 |
| 58 OutputState output_state() const { return output_state_; } | 60 OutputState output_state() const { return output_state_; } |
| 59 | 61 |
| 62 // Initialization, must be called right after constructor. | |
| 63 // |is_panel_fitting_supported| indicates hardware panel fitting support. | |
| 64 void Init(bool is_panel_fitting_supported); | |
| 65 | |
| 60 // Called when the user hits ctrl-F4 to request a display mode change. | 66 // Called when the user hits ctrl-F4 to request a display mode change. |
| 61 // This method should only return false if it was called in a single-head or | 67 // This method should only return false if it was called in a single-head or |
| 62 // headless mode. | 68 // headless mode. |
| 63 bool CycleDisplayMode(); | 69 bool CycleDisplayMode(); |
| 64 | 70 |
| 65 // Called when powerd notifies us that some set of displays should be turned | 71 // Called when powerd notifies us that some set of displays should be turned |
| 66 // on or off. This requires enabling or disabling the CRTC associated with | 72 // on or off. This requires enabling or disabling the CRTC associated with |
| 67 // the display(s) in question so that the low power state is engaged. | 73 // the display(s) in question so that the low power state is engaged. |
| 68 bool ScreenPowerSet(bool power_on, bool all_displays); | 74 bool ScreenPowerSet(bool power_on, bool all_displays); |
| 69 | 75 |
| 70 // Force switching the display mode to |new_state|. This method is used when | 76 // Force switching the display mode to |new_state|. This method is used when |
| 71 // the user explicitly changes the display mode in the options UI. Returns | 77 // the user explicitly changes the display mode in the options UI. Returns |
| 72 // false if it was called in a single-head or headless mode. | 78 // false if it was called in a single-head or headless mode. |
| 73 bool SetDisplayMode(OutputState new_state); | 79 bool SetDisplayMode(OutputState new_state); |
| 74 | 80 |
| 75 // Called when an RRNotify event is received. The implementation is | 81 // Called when an RRNotify event is received. The implementation is |
| 76 // interested in the cases of RRNotify events which correspond to output | 82 // interested in the cases of RRNotify events which correspond to output |
| 77 // add/remove events. Note that Output add/remove events are sent in response | 83 // add/remove events. Note that Output add/remove events are sent in response |
| 78 // to our own reconfiguration operations so spurious events are common. | 84 // to our own reconfiguration operations so spurious events are common. |
| 79 // Spurious events will have no effect. | 85 // Spurious events will have no effect. |
| 80 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; | 86 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; |
| 81 | 87 |
| 82 void AddObserver(Observer* observer); | 88 void AddObserver(Observer* observer); |
| 83 void RemoveObserver(Observer* observer); | 89 void RemoveObserver(Observer* observer); |
| 84 | 90 |
| 85 // Tells if the output specified by |name| is for internal display. | 91 // Tells if the output specified by |name| is for internal display. |
| 86 static bool IsInternalOutputName(const std::string& name); | 92 static bool IsInternalOutputName(const std::string& name); |
| 87 | 93 |
| 94 // Returns output's native mode, None if not found. | |
| 95 static RRMode GetOutputNativeMode(const XRROutputInfo* output_info); | |
| 96 | |
| 88 private: | 97 private: |
| 89 // Fires OnDisplayModeChanged() event to the observers. | 98 // Fires OnDisplayModeChanged() event to the observers. |
| 90 void NotifyOnDisplayChanged(); | 99 void NotifyOnDisplayChanged(); |
| 91 | 100 |
| 92 // This is detected by the constructor to determine whether or not we should | 101 // This is detected by the constructor to determine whether or not we should |
| 93 // be enabled. If we aren't running on ChromeOS, we can't assume that the | 102 // be enabled. If we aren't running on ChromeOS, we can't assume that the |
| 94 // Xrandr X11 extension is supported. | 103 // Xrandr X11 extension is supported. |
| 95 // If this flag is set to false, any attempts to change the output | 104 // If this flag is set to false, any attempts to change the output |
| 96 // configuration to immediately fail without changing the state. | 105 // configuration to immediately fail without changing the state. |
| 97 bool is_running_on_chrome_os_; | 106 bool is_running_on_chrome_os_; |
| 98 | 107 |
| 108 // This is set externally in Init, | |
| 109 // and is used to enable modes which rely on panel fitting. | |
| 110 bool is_panel_fitting_supported_; | |
|
cwolfe
2012/09/18 13:27:47
Weak preference for something like use_panel_fitti
ynovikov
2012/09/21 18:48:27
Done.
| |
| 111 | |
| 99 // The number of outputs that are connected. | 112 // The number of outputs that are connected. |
| 100 int connected_output_count_; | 113 int connected_output_count_; |
| 101 | 114 |
| 102 // The base of the event numbers used to represent XRandr events used in | 115 // The base of the event numbers used to represent XRandr events used in |
| 103 // decoding events regarding output add/remove. | 116 // decoding events regarding output add/remove. |
| 104 int xrandr_event_base_; | 117 int xrandr_event_base_; |
| 105 | 118 |
| 106 // The display state as derived from the outputs observed in |output_cache_|. | 119 // The display state as derived from the outputs observed in |output_cache_|. |
| 107 // This is used for rotating display modes. | 120 // This is used for rotating display modes. |
| 108 OutputState output_state_; | 121 OutputState output_state_; |
| 109 | 122 |
| 110 ObserverList<Observer> observers_; | 123 ObserverList<Observer> observers_; |
| 111 | 124 |
| 112 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 125 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
| 113 }; | 126 }; |
| 114 | 127 |
| 115 } // namespace chromeos | 128 } // namespace chromeos |
| 116 | 129 |
| 117 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 130 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
| OLD | NEW |