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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 CHECK(!lcd_resolution.empty() || !external_resolution.empty()); |
56 | 56 |
57 // Disable the LCD if we were told to do so (because we're using a higher | 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). | 58 // resolution that'd be clipped on the LCD). |
59 if (!lcd_resolution.empty()) | 59 if (lcd_resolution.empty()) |
60 SetDeviceResolution(lcd_output_->name, lcd_resolution); | |
61 else | |
62 DisableDevice(lcd_output_->name); | 60 DisableDevice(lcd_output_->name); |
63 | 61 |
64 // If there's no external output connected, disable the device before we try | 62 // If there's no external output connected, disable the device before we try |
65 // to set the screen resolution; otherwise xrandr will complain if we're | 63 // to set the screen resolution; otherwise xrandr will complain if we're |
66 // trying to set the screen to a smaller size than what the now-unplugged | 64 // trying to set the screen to a smaller size than what the now-unplugged |
67 // device was using. | 65 // device was using. |
| 66 if (external_resolution.empty()) |
| 67 DisableDevice(external_output_->name); |
| 68 |
| 69 // Set the fb to try to avoid the driver's "crtc has no fb" message. |
| 70 // Doing this before enabling the display reduces the likelihood of a |
| 71 // visible "snap" when returning to the panel. |
| 72 SetScreenResolution(screen_resolution); |
| 73 |
| 74 // Enable the LCD if appropriate. |
| 75 if (!lcd_resolution.empty()) |
| 76 SetDeviceResolution(lcd_output_->name, lcd_resolution); |
| 77 |
| 78 // Enable the external device if appropriate. |
68 if (!external_resolution.empty()) | 79 if (!external_resolution.empty()) |
69 SetDeviceResolution(external_output_->name, external_resolution); | 80 SetDeviceResolution(external_output_->name, external_resolution); |
70 else | |
71 DisableDevice(external_output_->name); | |
72 | |
73 SetScreenResolution(screen_resolution); | |
74 } | 81 } |
75 | 82 |
76 void MonitorReconfigureMain::DetermineOutputs() { | 83 void MonitorReconfigureMain::DetermineOutputs() { |
77 CHECK(screen_info_->noutput > 1) << "Expected at least two outputs"; | 84 CHECK(screen_info_->noutput > 1) << "Expected at least two outputs"; |
78 XRROutputInfo* first_output = | 85 XRROutputInfo* first_output = |
79 XRRGetOutputInfo(display_, screen_info_, screen_info_->outputs[0]); | 86 XRRGetOutputInfo(display_, screen_info_, screen_info_->outputs[0]); |
80 XRROutputInfo* second_output = | 87 XRROutputInfo* second_output = |
81 XRRGetOutputInfo(display_, screen_info_, screen_info_->outputs[1]); | 88 XRRGetOutputInfo(display_, screen_info_, screen_info_->outputs[1]); |
82 | 89 |
83 if (strcmp(first_output->name, kLcdOutputName) == 0) { | 90 if (strcmp(first_output->name, kLcdOutputName) == 0) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 logging::APPEND_TO_OLD_LOG_FILE); | 160 logging::APPEND_TO_OLD_LOG_FILE); |
154 Display* display = XOpenDisplay(NULL); | 161 Display* display = XOpenDisplay(NULL); |
155 CHECK(display) << "Could not open display"; | 162 CHECK(display) << "Could not open display"; |
156 | 163 |
157 Window window = RootWindow(display, DefaultScreen(display)); | 164 Window window = RootWindow(display, DefaultScreen(display)); |
158 XRRScreenResources* screen_info = XRRGetScreenResources(display, window); | 165 XRRScreenResources* screen_info = XRRGetScreenResources(display, window); |
159 monitor_reconfig::MonitorReconfigureMain main_app(display, screen_info); | 166 monitor_reconfig::MonitorReconfigureMain main_app(display, screen_info); |
160 main_app.Run(); | 167 main_app.Run(); |
161 return 0; | 168 return 0; |
162 } | 169 } |
OLD | NEW |