| Index: monitor_reconfigure.h
|
| diff --git a/monitor_reconfigure.h b/monitor_reconfigure.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0639965131e4053ec4fa0e6756eb6ffd57321b18
|
| --- /dev/null
|
| +++ b/monitor_reconfigure.h
|
| @@ -0,0 +1,100 @@
|
| +// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef POWER_MANAGER_MONITOR_RECONFIGURE_MAIN_H_
|
| +#define POWER_MANAGER_MONITOR_RECONFIGURE_MAIN_H_
|
| +
|
| +#include <map>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include <X11/Xlib.h>
|
| +#include <X11/extensions/Xrandr.h>
|
| +
|
| +#include "power_manager/backlight_controller.h"
|
| +#include "power_manager/resolution_selector.h"
|
| +#include "power_manager/udev_listener.h"
|
| +
|
| +namespace power_manager {
|
| +
|
| +class MonitorReconfigureMain;
|
| +
|
| +// Callback class for udev events.
|
| +class MonitorReconfigureCallback : public UdevCallback {
|
| + public:
|
| + MonitorReconfigureCallback(MonitorReconfigureMain* monitor_reconfigure)
|
| + : monitor_reconfigure_(monitor_reconfigure) {}
|
| +
|
| + void Run(GIOChannel* source, GIOCondition condition);
|
| + private:
|
| + MonitorReconfigureMain* monitor_reconfigure_;
|
| +};
|
| +
|
| +// MonitorReconfigureMain is the class responsible for setting the external
|
| +// monitor to the max resolution based on the modes supported by the native
|
| +// monitor and the external monitor.
|
| +class MonitorReconfigureMain {
|
| + public:
|
| + // We need a default constructor for unit tests.
|
| + MonitorReconfigureMain();
|
| + // |backlight_ctl| is a pointer to the backlight controller for the
|
| + // internal screen.
|
| + MonitorReconfigureMain(BacklightController* backlight_ctl);
|
| + ~MonitorReconfigureMain();
|
| +
|
| + // Initialization.
|
| + bool Init();
|
| +
|
| + // Main entry point.
|
| + void Run();
|
| +
|
| + private:
|
| + // Initializes the |lcd_output_| and |external_output_| members.
|
| + void DetermineOutputs();
|
| +
|
| + // Returns whether an external monitor is connected.
|
| + bool IsExternalMonitorConnected();
|
| +
|
| + // Sorts |output_info|'s modes by decreasing number of pixels, storing the
|
| + // results in |modes_out|.
|
| + void SortModesByResolution(RROutput output,
|
| + std::vector<ResolutionSelector::Mode>* modes_out);
|
| +
|
| + // Set the resolution for a particular device or for the screen.
|
| + bool SetDeviceResolution(RROutput output,
|
| + const XRROutputInfo* output_info,
|
| + const ResolutionSelector::Mode& resolution);
|
| + bool SetScreenResolution(const ResolutionSelector::Mode& resolution);
|
| +
|
| + // Disable output to a device.
|
| + bool DisableDevice(const XRROutputInfo* output_info);
|
| +
|
| + // Mapping between mode XIDs and mode information structures.
|
| + std::map<int, XRRModeInfo*> mode_map_;
|
| +
|
| + // X Resources needed between functions.
|
| + Display* display_;
|
| + Window window_;
|
| + XRRScreenResources* screen_info_;
|
| +
|
| + RROutput lcd_output_;
|
| + XRROutputInfo* lcd_output_info_;
|
| +
|
| + RROutput external_output_;
|
| + XRROutputInfo* external_output_info_;
|
| +
|
| + // Not owned.
|
| + BacklightController* backlight_ctl_;
|
| +
|
| + // Callback for the Udev listener.
|
| + MonitorReconfigureCallback* callback_;
|
| +
|
| + // Udev linstener.
|
| + UdevListener* listener_;
|
| +
|
| +};
|
| +
|
| +} // namespace power_manager
|
| +
|
| +#endif // POWER_MANAGER_MONITOR_RECONFIGURE_MAIN_H_
|
|
|