OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef POWER_MANAGER_MONITOR_RECONFIGURE_H_ | |
6 #define POWER_MANAGER_MONITOR_RECONFIGURE_H_ | |
7 | |
8 #include <map> | |
9 #include <string> | |
tfarina
2011/04/14 20:03:57
you can get rid of this include.
marcheu
2011/04/14 20:41:24
Done.
| |
10 #include <vector> | |
11 | |
12 #include <X11/Xlib.h> | |
13 #include <X11/extensions/Xrandr.h> | |
14 | |
15 #include "power_manager/backlight_controller.h" | |
tfarina
2011/04/14 20:03:57
Please, forward declare this.
marcheu
2011/04/14 20:41:24
Done.
| |
16 #include "power_manager/resolution_selector.h" | |
17 #include "power_manager/udev_listener.h" | |
tfarina
2011/04/14 20:03:57
please, forward declare this.
marcheu
2011/04/14 20:41:24
MonitorReconfigureCallback inherits UdevCallback s
| |
18 | |
19 namespace power_manager { | |
20 | |
21 class MonitorReconfigure; | |
22 | |
23 // Callback class for udev events. | |
24 class MonitorReconfigureCallback : public UdevCallback { | |
25 public: | |
26 MonitorReconfigureCallback(MonitorReconfigure* monitor_reconfigure) | |
27 : monitor_reconfigure_(monitor_reconfigure) {} | |
28 | |
29 virtual void Run(GIOChannel* source, GIOCondition condition); | |
30 private: | |
31 MonitorReconfigure* monitor_reconfigure_; | |
32 }; | |
33 | |
34 // MonitorReconfigure is the class responsible for setting the external | |
35 // monitor to the max resolution based on the modes supported by the native | |
36 // monitor and the external monitor. | |
37 class MonitorReconfigure { | |
38 public: | |
39 // We need a default constructor for unit tests. | |
40 MonitorReconfigure(); | |
41 // |backlight_ctl| is a pointer to the backlight controller for the | |
42 // internal screen. | |
43 MonitorReconfigure(BacklightController* backlight_ctl); | |
44 ~MonitorReconfigure(); | |
45 | |
46 // Initialization. | |
47 bool Init(); | |
48 | |
49 // Main entry point. | |
50 void Run(); | |
51 | |
52 private: | |
53 // Initializes the |lcd_output_| and |external_output_| members. | |
54 void DetermineOutputs(); | |
55 | |
56 // Returns whether an external monitor is connected. | |
57 bool IsExternalMonitorConnected(); | |
58 | |
59 // Sorts |output_info|'s modes by decreasing number of pixels, storing the | |
60 // results in |modes_out|. | |
61 void SortModesByResolution(RROutput output, | |
62 std::vector<ResolutionSelector::Mode>* modes_out); | |
63 | |
64 // Set the resolution for a particular device or for the screen. | |
65 bool SetDeviceResolution(RROutput output, | |
66 const XRROutputInfo* output_info, | |
67 const ResolutionSelector::Mode& resolution); | |
68 bool SetScreenResolution(const ResolutionSelector::Mode& resolution); | |
69 | |
70 // Disable output to a device. | |
71 bool DisableDevice(const XRROutputInfo* output_info); | |
72 | |
73 // Mapping between mode XIDs and mode information structures. | |
74 std::map<int, XRRModeInfo*> mode_map_; | |
75 | |
76 // X Resources needed between functions. | |
77 Display* display_; | |
78 Window window_; | |
79 XRRScreenResources* screen_info_; | |
80 | |
81 RROutput lcd_output_; | |
82 XRROutputInfo* lcd_output_info_; | |
83 | |
84 RROutput external_output_; | |
85 XRROutputInfo* external_output_info_; | |
86 | |
87 // Not owned. | |
88 BacklightController* backlight_ctl_; | |
89 | |
90 // Callback for the Udev listener. | |
91 MonitorReconfigureCallback* callback_; | |
92 | |
93 // Udev listener. | |
94 UdevListener* listener_; | |
95 }; | |
tfarina
2011/04/14 20:03:57
Is there a reason to this class to not have a DISA
marcheu
2011/04/14 20:41:24
Done.
| |
96 | |
97 } // namespace power_manager | |
98 | |
99 #endif // POWER_MANAGER_MONITOR_RECONFIGURE_H_ | |
OLD | NEW |