Chromium Code Reviews| 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_MAIN_H_ | |
|
Daniel Erat
2011/04/14 19:07:24
nit: this should just be POWER_MANAGER_MONITOR_REC
marcheu
2011/04/14 19:54:57
Done.
| |
| 6 #define POWER_MANAGER_MONITOR_RECONFIGURE_MAIN_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include <X11/Xlib.h> | |
| 13 #include <X11/extensions/Xrandr.h> | |
| 14 | |
| 15 #include "power_manager/backlight_controller.h" | |
| 16 #include "power_manager/resolution_selector.h" | |
| 17 #include "power_manager/udev_listener.h" | |
| 18 | |
| 19 namespace power_manager { | |
| 20 | |
| 21 class MonitorReconfigureMain; | |
| 22 | |
| 23 // Callback class for udev events. | |
| 24 class MonitorReconfigureCallback : public UdevCallback { | |
| 25 public: | |
| 26 MonitorReconfigureCallback(MonitorReconfigureMain* monitor_reconfigure) | |
| 27 : monitor_reconfigure_(monitor_reconfigure) {} | |
| 28 | |
| 29 void Run(GIOChannel* source, GIOCondition condition); | |
|
Daniel Erat
2011/04/14 19:07:24
nit: add virtual (per style guide)
marcheu
2011/04/14 19:54:57
Done.
| |
| 30 private: | |
| 31 MonitorReconfigureMain* monitor_reconfigure_; | |
| 32 }; | |
| 33 | |
| 34 // MonitorReconfigureMain 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 MonitorReconfigureMain { | |
|
Daniel Erat
2011/04/14 19:07:24
rename this class to MonitorReconfigure to match t
marcheu
2011/04/14 19:54:57
Done.
| |
| 38 public: | |
| 39 // We need a default constructor for unit tests. | |
| 40 MonitorReconfigureMain(); | |
| 41 // |backlight_ctl| is a pointer to the backlight controller for the | |
| 42 // internal screen. | |
| 43 MonitorReconfigureMain(BacklightController* backlight_ctl); | |
| 44 ~MonitorReconfigureMain(); | |
| 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 linstener. | |
|
Daniel Erat
2011/04/14 19:07:24
s/linstener/listener/
marcheu
2011/04/14 19:54:57
Done.
| |
| 94 UdevListener* listener_; | |
| 95 | |
|
Daniel Erat
2011/04/14 19:07:24
nit: delete extra blank line
marcheu
2011/04/14 19:54:57
Done.
| |
| 96 }; | |
| 97 | |
| 98 } // namespace power_manager | |
| 99 | |
| 100 #endif // POWER_MANAGER_MONITOR_RECONFIGURE_MAIN_H_ | |
| OLD | NEW |