OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ | 5 #ifndef MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ |
6 #define MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ | 6 #define MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include <X11/Xlib.h> | 12 #include <X11/Xlib.h> |
13 #include <X11/extensions/Xrandr.h> | 13 #include <X11/extensions/Xrandr.h> |
14 | 14 |
15 #include "monitor_reconfig/resolution_selector.h" | 15 #include "monitor_reconfig/resolution_selector.h" |
16 | 16 |
17 namespace monitor_reconfig { | 17 namespace monitor_reconfig { |
18 | 18 |
19 // MonitorReconfigureMain is the class responsible for setting the external | 19 // MonitorReconfigureMain is the class responsible for setting the external |
20 // monitor to the max resolution based on the modes supported by the native | 20 // monitor to the max resolution based on the modes supported by the native |
21 // monitor and the external monitor | 21 // monitor and the external monitor. |
22 class MonitorReconfigureMain { | 22 class MonitorReconfigureMain { |
23 public: | 23 public: |
24 MonitorReconfigureMain(Display* display, XRRScreenResources* screen_info); | 24 MonitorReconfigureMain(Display* display, |
25 virtual ~MonitorReconfigureMain() {} | 25 Window window, |
Daniel Erat
2011/03/25 03:39:02
can you add a comment about what the 'window' para
marcheu
2011/03/25 17:39:42
Done.
| |
26 XRRScreenResources* screen_info); | |
27 virtual ~MonitorReconfigureMain() { | |
Daniel Erat
2011/03/25 03:39:02
not your fault, but mind removing the 'virtual' he
marcheu
2011/03/25 17:39:42
Done.
| |
28 XRRFreeOutputInfo(lcd_output_info_); | |
Daniel Erat
2011/03/25 03:39:02
do you need to check for NULL here first, or is XR
marcheu
2011/03/25 17:39:42
It's just a free() so NULL is a valid parameter.
| |
29 XRRFreeOutputInfo(external_output_info_); | |
30 } | |
26 | 31 |
27 // Main entry point | 32 // Main entry point. |
28 void Run(); | 33 void Run(); |
29 | 34 |
30 private: | 35 private: |
31 // Initializes the |lcd_output_| and |external_output_| members. | 36 // Initializes the |lcd_output_| and |external_output_| members. |
32 void DetermineOutputs(); | 37 void DetermineOutputs(); |
33 | 38 |
34 // Returns whether an external monitor is connected | 39 // Returns whether an external monitor is connected. |
35 bool IsExternalMonitorConnected(); | 40 bool IsExternalMonitorConnected(); |
36 | 41 |
37 // Sorts |output_info|'s modes by decreasing number of pixels, storing the | 42 // Sorts |output_info|'s modes by decreasing number of pixels, storing the |
38 // results in |modes_out|. | 43 // results in |modes_out|. |
39 void SortModesByResolution(const XRROutputInfo& output_info, | 44 void SortModesByResolution(RROutput output, |
40 std::vector<ResolutionSelector::Mode>* modes_out); | 45 std::vector<ResolutionSelector::Mode>* modes_out); |
41 | 46 |
42 // Set the resolution for a particular device or for the screen. | 47 // Set the resolution for a particular device or for the screen. |
43 bool SetDeviceResolution(const std::string& device_name, | 48 bool SetDeviceResolution(RROutput output, |
44 const std::string& resolution); | 49 const XRROutputInfo* output_info, |
45 bool SetScreenResolution(const std::string& resolution); | 50 const ResolutionSelector::Mode& resolution); |
51 bool SetScreenResolution(const ResolutionSelector::Mode& resolution); | |
46 | 52 |
47 // Disable output to a device. | 53 // Disable output to a device. |
48 bool DisableDevice(const std::string& device_name); | 54 bool DisableDevice(RROutput output, |
55 const XRROutputInfo* output_info); | |
49 | 56 |
50 // Mapping between mode XIDs and mode information structures. | 57 // Mapping between mode XIDs and mode information structures. |
51 std::map<int, XRRModeInfo*> mode_map_; | 58 std::map<int, XRRModeInfo*> mode_map_; |
52 | 59 |
53 // X Resources needed between functions | 60 // X Resources needed between functions. |
54 Display* display_; | 61 Display* display_; |
62 Window window_; | |
55 XRRScreenResources* screen_info_; | 63 XRRScreenResources* screen_info_; |
56 XRROutputInfo* lcd_output_; | 64 |
57 XRROutputInfo* external_output_; | 65 RROutput lcd_output_; |
66 XRROutputInfo* lcd_output_info_; | |
67 | |
68 RROutput external_output_; | |
69 XRROutputInfo* external_output_info_; | |
58 }; | 70 }; |
59 | 71 |
60 } // namespace monitor_reconfig | 72 } // namespace monitor_reconfig |
61 | 73 |
62 #endif // MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ | 74 #endif // MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ |
OLD | NEW |