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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 CrtcConfig* config1, | 170 CrtcConfig* config1, |
171 CrtcConfig* config2) = 0; | 171 CrtcConfig* config2) = 0; |
172 | 172 |
173 // Configures XInput's Coordinate Transformation Matrix property. | 173 // Configures XInput's Coordinate Transformation Matrix property. |
174 // |touch_device_id| the ID of the touchscreen device to configure. | 174 // |touch_device_id| the ID of the touchscreen device to configure. |
175 // |ctm| contains the desired transformation parameters. The offsets | 175 // |ctm| contains the desired transformation parameters. The offsets |
176 // in it should be normalized so that 1 corresponds to the X or Y axis | 176 // in it should be normalized so that 1 corresponds to the X or Y axis |
177 // size for the corresponding offset. | 177 // size for the corresponding offset. |
178 virtual void ConfigureCTM(int touch_device_id, | 178 virtual void ConfigureCTM(int touch_device_id, |
179 const CoordinateTransformation& ctm) = 0; | 179 const CoordinateTransformation& ctm) = 0; |
180 | |
181 // Sends a D-Bus message to the power manager telling it that the | |
182 // machine is or is not projecting. | |
183 virtual void SendProjectingStateToPowerManager(bool projecting) = 0; | |
184 }; | |
185 | |
186 // Helper class used by tests. | |
187 class TestApi { | |
188 public: | |
189 TestApi(OutputConfigurator* configurator, int xrandr_event_base) | |
190 : configurator_(configurator), | |
191 xrandr_event_base_(xrandr_event_base) {} | |
192 ~TestApi() {} | |
193 | |
194 // Dispatches RRScreenChangeNotify and RRNotify_OutputChange events to | |
195 // |configurator_| and runs ConfigureOutputs(). Returns false if | |
196 // |configure_timer_| wasn't started. | |
197 bool SendOutputChangeEvents(bool connected); | |
198 | |
199 private: | |
200 OutputConfigurator* configurator_; // not owned | |
201 | |
202 int xrandr_event_base_; | |
203 | |
204 DISALLOW_COPY_AND_ASSIGN(TestApi); | |
180 }; | 205 }; |
oshima
2013/04/08 17:29:15
can you move testapi to chromeos/test ? I believe
Daniel Erat
2013/04/08 21:47:53
There are a lot of existing examples of TestApi cl
oshima
2013/04/08 23:21:44
Ok, I was asked to separate TestApi in the past to
| |
181 | 206 |
182 // Flags that can be passed to SetDisplayPower(). | 207 // Flags that can be passed to SetDisplayPower(). |
183 static const int kSetDisplayPowerNoFlags = 0; | 208 static const int kSetDisplayPowerNoFlags = 0; |
184 // Configure displays even if the passed-in state matches |power_state_|. | 209 // Configure displays even if the passed-in state matches |power_state_|. |
185 static const int kSetDisplayPowerForceProbe = 1 << 0; | 210 static const int kSetDisplayPowerForceProbe = 1 << 0; |
186 // Do not change the state if multiple displays are connected or if the | 211 // Do not change the state if multiple displays are connected or if the |
187 // only connected display is external. | 212 // only connected display is external. |
188 static const int kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; | 213 static const int kSetDisplayPowerOnlyIfSingleInternalDisplay = 1 << 1; |
189 | 214 |
215 // Gap between screens so cursor at bottom of active display doesn't | |
216 // partially appear on top of inactive display. Higher numbers guard | |
217 // against larger cursors, but also waste more memory. | |
218 // For simplicity, this is hard-coded to avoid the complexity of always | |
219 // determining the DPI of the screen and rationalizing which screen we | |
220 // need to use for the DPI calculation. | |
221 // See crbug.com/130188 for initial discussion. | |
222 static const int kVerticalGap = 60; | |
223 | |
190 // Returns true if an output named |name| is an internal display. | 224 // Returns true if an output named |name| is an internal display. |
191 static bool IsInternalOutputName(const std::string& name); | 225 static bool IsInternalOutputName(const std::string& name); |
192 | 226 |
193 OutputConfigurator(); | 227 OutputConfigurator(); |
194 virtual ~OutputConfigurator(); | 228 virtual ~OutputConfigurator(); |
195 | 229 |
196 int connected_output_count() const { return connected_output_count_; } | 230 int connected_output_count() const { return connected_output_count_; } |
197 | 231 |
198 OutputState output_state() const { return output_state_; } | 232 OutputState output_state() const { return output_state_; } |
199 | 233 |
200 void set_display_power_state(DisplayPowerState power_state) { | 234 void set_display_power_state(DisplayPowerState power_state) { |
201 power_state_ = power_state; | 235 power_state_ = power_state; |
202 } | 236 } |
203 DisplayPowerState display_power_state() const { return power_state_; } | 237 DisplayPowerState display_power_state() const { return power_state_; } |
204 | 238 |
205 void set_state_controller(StateController* controller) { | 239 void set_state_controller(StateController* controller) { |
206 state_controller_ = controller; | 240 state_controller_ = controller; |
207 } | 241 } |
208 | 242 |
243 // Replaces |delegate_| with |delegate| and sets |configure_display_| to | |
244 // true. Should be called before Init(). | |
245 void SetDelegateForTesting(scoped_ptr<Delegate> delegate); | |
246 | |
209 // Initialization, must be called right after constructor. | 247 // Initialization, must be called right after constructor. |
210 // |is_panel_fitting_enabled| indicates hardware panel fitting support. | 248 // |is_panel_fitting_enabled| indicates hardware panel fitting support. |
211 // If |background_color_argb| is non zero and there are multiple displays, | 249 // If |background_color_argb| is non zero and there are multiple displays, |
212 // OutputConfigurator sets the background color of X's RootWindow to this | 250 // OutputConfigurator sets the background color of X's RootWindow to this |
213 // color. | 251 // color. |
214 void Init(bool is_panel_fitting_enabled, uint32 background_color_argb); | 252 void Init(bool is_panel_fitting_enabled, uint32 background_color_argb); |
215 | 253 |
216 // Detects displays first time from unknown state. | 254 // Detects displays first time from unknown state. |
217 void Start(); | 255 void Start(); |
218 | 256 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 // The timer to delay configuring outputs. See also the comments in | 338 // The timer to delay configuring outputs. See also the comments in |
301 // |Dispatch()|. | 339 // |Dispatch()|. |
302 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; | 340 scoped_ptr<base::OneShotTimer<OutputConfigurator> > configure_timer_; |
303 | 341 |
304 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); | 342 DISALLOW_COPY_AND_ASSIGN(OutputConfigurator); |
305 }; | 343 }; |
306 | 344 |
307 } // namespace chromeos | 345 } // namespace chromeos |
308 | 346 |
309 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ | 347 #endif // CHROMEOS_DISPLAY_OUTPUT_CONFIGURATOR_H_ |
OLD | NEW |