Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Unified Diff: src/platform/monitor_reconfig/monitor_reconfigure_main.h

Issue 1646010: monitor_reconfigure: Try to improve resolution selection. (Closed)
Patch Set: apply review feedback Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/platform/monitor_reconfig/monitor_reconfigure_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/monitor_reconfig/monitor_reconfigure_main.h
diff --git a/src/platform/monitor_reconfig/monitor_reconfigure_main.h b/src/platform/monitor_reconfig/monitor_reconfigure_main.h
index 0b602d02fdf8524904750c3db69569ce9e163f81..3aa17d0a1be923c8d80797c44904d28413ee0a3f 100644
--- a/src/platform/monitor_reconfig/monitor_reconfigure_main.h
+++ b/src/platform/monitor_reconfig/monitor_reconfigure_main.h
@@ -6,6 +6,8 @@
#define MONITOR_RECONFIGURE_MONITOR_RECONFIGURE_MAIN_H_
#include <map>
+#include <string>
+#include <vector>
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
@@ -23,38 +25,58 @@ class MonitorReconfigureMain {
// Main entry point
void Run();
- // Returns whether an external monitor is connected
- bool IsExternalMonitorConnected();
-
private:
- // Finds the max resolution mode for the given |output|
- XRRModeInfo* FindMaxResolution(XRROutputInfo* output);
-
- // Finds the best matching resolution as compared to the |matching_mode|
- XRRModeInfo* FindBestMatchingResolution(XRRModeInfo* matching_mode);
-
- // Initializes the |notebook_output_| and |external_output_| fields
+ // Initializes the |lcd_output_| and |external_output_| members.
void DetermineOutputs();
- // Sets the resolution of the notebook's screen, the external monitor's
- // screen, and the overall virtual screen to the given size.
- void SetResolutions(XRRModeInfo* notebook_mode,
- XRRModeInfo* external_mode,
- XRRModeInfo* overall_screen_size);
-
- // Inline helper functions for FindBestMatchingResolution
- inline bool IsEqual(XRRModeInfo*, XRRModeInfo*);
- inline bool IsBiggerOrEqual(XRRModeInfo*, XRRModeInfo*);
- inline bool IsBetterMatching(XRRModeInfo* target, XRRModeInfo* to_match,
- XRRModeInfo* previous_best);
+ // Returns whether an external monitor is connected
+ bool IsExternalMonitorConnected();
- // Mapping between mode XID's and mode information structures
+ // Comparator used by SortModeByResolution().
+ // Returns true if |mode_a| has more pixels than |mode_b| and false otherwise.
+ class ModeResolutionComparator {
+ public:
+ bool operator()(XRRModeInfo* mode_a, XRRModeInfo* mode_b) const {
+ return mode_a->width * mode_a->height > mode_b->width * mode_b->height;
+ }
+ };
+
+ // Sorts |output_info|'s modes by decreasing number of pixels, storing the
+ // results in |modes_out|.
+ void SortModesByResolution(const XRROutputInfo& output_info,
+ std::vector<XRRModeInfo*>* modes_out);
+
+ // Find resolutions to use.
+ bool FindBestResolutions(
+ std::string* lcd_resolution,
+ std::string* external_resolution,
+ std::string* screen_resolution);
+
+ // Find resolutions to use that are reasonably close together.
+ // |larger_device_modes| and |smaller_device_modes| should be sorted by
+ // descending resolution. We choose the highest resolution from
+ // |smaller_device_modes| and the lowest resolution from |larger_device_modes|
+ // that's at least as high as the resolution from the smaller device.
+ // |screen_resolution| gets set to |smaller_resolution| to avoid clipping.
+ bool FindNearestResolutions(
+ const std::vector<XRRModeInfo*>& larger_device_modes,
+ const std::vector<XRRModeInfo*>& smaller_device_modes,
+ std::string* larger_resolution,
+ std::string* smaller_resolution,
+ std::string* screen_resolution);
+
+ // Set the resolution for a particular display or for the screen.
+ bool SetDeviceResolution(const std::string& device_name,
+ const std::string& resolution);
+ bool SetScreenResolution(const std::string& resolution);
+
+ // Mapping between mode XIDs and mode information structures.
std::map<int, XRRModeInfo*> mode_map_;
// X Resources needed between functions
Display* display_;
XRRScreenResources* screen_info_;
- XRROutputInfo* notebook_output_;
+ XRROutputInfo* lcd_output_;
XRROutputInfo* external_output_;
};
« no previous file with comments | « no previous file | src/platform/monitor_reconfig/monitor_reconfigure_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698