| 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 // |window| is the root window. |
| 25 virtual ~MonitorReconfigureMain() {} | 25 MonitorReconfigureMain(Display* display, |
| 26 Window window, |
| 27 XRRScreenResources* screen_info); |
| 28 ~MonitorReconfigureMain() { |
| 29 XRRFreeOutputInfo(lcd_output_info_); |
| 30 XRRFreeOutputInfo(external_output_info_); |
| 31 } |
| 26 | 32 |
| 27 // Main entry point | 33 // Main entry point. |
| 28 void Run(); | 34 void Run(); |
| 29 | 35 |
| 30 private: | 36 private: |
| 31 // Initializes the |lcd_output_| and |external_output_| members. | 37 // Initializes the |lcd_output_| and |external_output_| members. |
| 32 void DetermineOutputs(); | 38 void DetermineOutputs(); |
| 33 | 39 |
| 34 // Returns whether an external monitor is connected | 40 // Returns whether an external monitor is connected. |
| 35 bool IsExternalMonitorConnected(); | 41 bool IsExternalMonitorConnected(); |
| 36 | 42 |
| 37 // Sorts |output_info|'s modes by decreasing number of pixels, storing the | 43 // Sorts |output_info|'s modes by decreasing number of pixels, storing the |
| 38 // results in |modes_out|. | 44 // results in |modes_out|. |
| 39 void SortModesByResolution(const XRROutputInfo& output_info, | 45 void SortModesByResolution(RROutput output, |
| 40 std::vector<ResolutionSelector::Mode>* modes_out); | 46 std::vector<ResolutionSelector::Mode>* modes_out); |
| 41 | 47 |
| 42 // Set the resolution for a particular device or for the screen. | 48 // Set the resolution for a particular device or for the screen. |
| 43 bool SetDeviceResolution(const std::string& device_name, | 49 bool SetDeviceResolution(RROutput output, |
| 44 const std::string& resolution); | 50 const XRROutputInfo* output_info, |
| 45 bool SetScreenResolution(const std::string& resolution); | 51 const ResolutionSelector::Mode& resolution); |
| 52 bool SetScreenResolution(const ResolutionSelector::Mode& resolution); |
| 46 | 53 |
| 47 // Disable output to a device. | 54 // Disable output to a device. |
| 48 bool DisableDevice(const std::string& device_name); | 55 bool DisableDevice(RROutput output, |
| 56 const XRROutputInfo* output_info); |
| 49 | 57 |
| 50 // Mapping between mode XIDs and mode information structures. | 58 // Mapping between mode XIDs and mode information structures. |
| 51 std::map<int, XRRModeInfo*> mode_map_; | 59 std::map<int, XRRModeInfo*> mode_map_; |
| 52 | 60 |
| 53 // X Resources needed between functions | 61 // X Resources needed between functions. |
| 54 Display* display_; | 62 Display* display_; |
| 63 Window window_; |
| 55 XRRScreenResources* screen_info_; | 64 XRRScreenResources* screen_info_; |
| 56 XRROutputInfo* lcd_output_; | 65 |
| 57 XRROutputInfo* external_output_; | 66 RROutput lcd_output_; |
| 67 XRROutputInfo* lcd_output_info_; |
| 68 |
| 69 RROutput external_output_; |
| 70 XRROutputInfo* external_output_info_; |
| 58 }; | 71 }; |
| 59 | 72 |
| 60 } // namespace monitor_reconfig | 73 } // namespace monitor_reconfig |
| 61 | 74 |
| 62 #endif // MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ | 75 #endif // MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_ |
| OLD | NEW |