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

Side by Side Diff: monitor_reconfigure_main.cc

Issue 5024002: Avoid a kernel driver / X server crash situation. (Closed) Base URL: http://git.chromium.org/git/monitor_reconfig.git@master
Patch Set: Created 10 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698