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 #include "monitor_reconfig/monitor_reconfigure_main.h" | 5 #include "monitor_reconfig/monitor_reconfigure_main.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstdio> | 8 #include <cstdio> |
9 #include <cstdlib> | 9 #include <cstdlib> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 DCHECK(!external_modes.empty()); | 45 DCHECK(!external_modes.empty()); |
46 } | 46 } |
47 | 47 |
48 ResolutionSelector selector; | 48 ResolutionSelector selector; |
49 string lcd_resolution, external_resolution, screen_resolution; | 49 string lcd_resolution, external_resolution, screen_resolution; |
50 CHECK(selector.FindBestResolutions(lcd_modes, | 50 CHECK(selector.FindBestResolutions(lcd_modes, |
51 external_modes, | 51 external_modes, |
52 &lcd_resolution, | 52 &lcd_resolution, |
53 &external_resolution, | 53 &external_resolution, |
54 &screen_resolution)); | 54 &screen_resolution)); |
| 55 CHECK(!lcd_resolution.empty() || !external_resolution.empty()); |
55 | 56 |
56 SetDeviceResolution(lcd_output_->name, lcd_resolution); | 57 // Disable the LCD if we were told to do so (because we're using a higher |
| 58 // resolution that'd be clipped on the LCD). |
| 59 if (!lcd_resolution.empty()) |
| 60 SetDeviceResolution(lcd_output_->name, lcd_resolution); |
| 61 else |
| 62 DisableDevice(lcd_output_->name); |
57 | 63 |
58 // If there's no external output connected, disable the device before we try | 64 // If there's no external output connected, disable the device before we try |
59 // to set the screen resolution; otherwise xrandr will complain if we're | 65 // to set the screen resolution; otherwise xrandr will complain if we're |
60 // trying to set the screen to a smaller size than what the now-unplugged | 66 // trying to set the screen to a smaller size than what the now-unplugged |
61 // device was using. | 67 // device was using. |
62 if (IsExternalMonitorConnected()) | 68 if (!external_resolution.empty()) |
63 SetDeviceResolution(external_output_->name, external_resolution); | 69 SetDeviceResolution(external_output_->name, external_resolution); |
64 else | 70 else |
65 DisableDevice(external_output_->name); | 71 DisableDevice(external_output_->name); |
66 | 72 |
67 SetScreenResolution(screen_resolution); | 73 SetScreenResolution(screen_resolution); |
68 } | 74 } |
69 | 75 |
70 void MonitorReconfigureMain::DetermineOutputs() { | 76 void MonitorReconfigureMain::DetermineOutputs() { |
71 CHECK(screen_info_->noutput > 1) << "Expected at least two outputs"; | 77 CHECK(screen_info_->noutput > 1) << "Expected at least two outputs"; |
72 XRROutputInfo* first_output = | 78 XRROutputInfo* first_output = |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 logging::APPEND_TO_OLD_LOG_FILE); | 153 logging::APPEND_TO_OLD_LOG_FILE); |
148 Display* display = XOpenDisplay(NULL); | 154 Display* display = XOpenDisplay(NULL); |
149 CHECK(display) << "Could not open display"; | 155 CHECK(display) << "Could not open display"; |
150 | 156 |
151 Window window = RootWindow(display, DefaultScreen(display)); | 157 Window window = RootWindow(display, DefaultScreen(display)); |
152 XRRScreenResources* screen_info = XRRGetScreenResources(display, window); | 158 XRRScreenResources* screen_info = XRRGetScreenResources(display, window); |
153 monitor_reconfig::MonitorReconfigureMain main_app(display, screen_info); | 159 monitor_reconfig::MonitorReconfigureMain main_app(display, screen_info); |
154 main_app.Run(); | 160 main_app.Run(); |
155 return 0; | 161 return 0; |
156 } | 162 } |
OLD | NEW |