diff options
-rw-r--r-- | ash/display/display_change_observer_chromeos.cc | 2 | ||||
-rw-r--r-- | ash/shell.cc | 5 | ||||
-rw-r--r-- | chromeos/display/output_configurator.cc | 14 | ||||
-rw-r--r-- | chromeos/display/output_configurator.h | 4 | ||||
-rw-r--r-- | chromeos/display/output_configurator_unittest.cc | 20 |
5 files changed, 20 insertions, 25 deletions
diff --git a/ash/display/display_change_observer_chromeos.cc b/ash/display/display_change_observer_chromeos.cc index 111394d..d201c96 100644 --- a/ash/display/display_change_observer_chromeos.cc +++ b/ash/display/display_change_observer_chromeos.cc @@ -180,7 +180,7 @@ void DisplayChangeObserver::OnAppTerminating() { #if defined(USE_ASH) // Stop handling display configuration events once the shutdown // process starts. crbug.com/177014. - Shell::GetInstance()->output_configurator()->Stop(); + Shell::GetInstance()->output_configurator()->PrepareForExit(); #endif } diff --git a/ash/shell.cc b/ash/shell.cc index 36357d0..8ed71fe 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -604,8 +604,6 @@ Shell::Shell(ShellDelegate* delegate) display_manager_.reset(new internal::DisplayManager); display_controller_.reset(new DisplayController); #if defined(OS_CHROMEOS) && defined(USE_X11) - // TODO: Move this initialization into Shell::Init(). - output_configurator_->Init(!gpu_support_->IsPanelFittingDisabled()); user_metrics_recorder_.reset(new UserMetricsRecorder); #endif // defined(OS_CHROMEOS) @@ -766,6 +764,7 @@ void Shell::Init() { } bool display_initialized = display_manager_->InitFromCommandLine(); #if defined(OS_CHROMEOS) && defined(USE_X11) + output_configurator_->Init(!gpu_support_->IsPanelFittingDisabled()); output_configurator_animation_.reset( new internal::OutputConfiguratorAnimation()); output_configurator_->AddObserver(output_configurator_animation_.get()); @@ -782,7 +781,7 @@ void Shell::Init() { output_configurator_->AddObserver(display_error_observer_.get()); output_configurator_->set_state_controller(display_change_observer_.get()); output_configurator_->set_mirroring_controller(display_manager_.get()); - output_configurator_->Start( + output_configurator_->ForceInitialConfigure( delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); display_initialized = true; } diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc index 3bf0791..bc61248 100644 --- a/chromeos/display/output_configurator.cc +++ b/chromeos/display/output_configurator.cc @@ -259,7 +259,7 @@ void OutputConfigurator::Init(bool is_panel_fitting_enabled) { touchscreen_delegate_.reset(new TouchscreenDelegateX11()); } -void OutputConfigurator::Start(uint32 background_color_argb) { +void OutputConfigurator::ForceInitialConfigure(uint32 background_color_argb) { if (!configure_display_) return; @@ -437,15 +437,8 @@ bool OutputConfigurator::EnableOutputProtection( return true; } -void OutputConfigurator::Stop() { +void OutputConfigurator::PrepareForExit() { configure_display_ = false; - - // Since we need to stop processing configuration updates, we can just destroy - // the display delegate. - if (native_display_delegate_) { - native_display_delegate_->RemoveObserver(this); - native_display_delegate_.reset(); - } } bool OutputConfigurator::SetDisplayPower(DisplayPowerState power_state, @@ -686,6 +679,9 @@ bool OutputConfigurator::FindMirrorMode(OutputSnapshot* internal_output, void OutputConfigurator::ConfigureOutputs() { configure_timer_.reset(); + if (!configure_display_) + return; + native_display_delegate_->GrabServer(); UpdateCachedOutputs(); const ui::OutputState new_state = ChooseOutputState(power_state_); diff --git a/chromeos/display/output_configurator.h b/chromeos/display/output_configurator.h index 571da9a..b063caa 100644 --- a/chromeos/display/output_configurator.h +++ b/chromeos/display/output_configurator.h @@ -257,10 +257,10 @@ class CHROMEOS_EXPORT OutputConfigurator // If |background_color_argb| is non zero and there are multiple displays, // OutputConfigurator sets the background color of X's RootWindow to this // color. - void Start(uint32 background_color_argb); + void ForceInitialConfigure(uint32 background_color_argb); // Stop handling display configuration events/requests. - void Stop(); + void PrepareForExit(); // Called when powerd notifies us that some set of displays should be turned // on or off. This requires enabling or disabling the CRTC associated with diff --git a/chromeos/display/output_configurator_unittest.cc b/chromeos/display/output_configurator_unittest.cc index 012c2ace..88a92bc 100644 --- a/chromeos/display/output_configurator_unittest.cc +++ b/chromeos/display/output_configurator_unittest.cc @@ -463,7 +463,7 @@ class OutputConfiguratorTest : public testing::Test { EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); configurator_.Init(false); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); EXPECT_EQ( JoinActions( kGrab, @@ -997,7 +997,7 @@ TEST_F(OutputConfiguratorTest, Headless) { EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); configurator_.Init(false); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); EXPECT_EQ(JoinActions(kGrab, kInitXRandR, kForceDPMS, kUngrab, NULL), log_->GetActionsAndClear()); @@ -1033,7 +1033,7 @@ TEST_F(OutputConfiguratorTest, StartWithTwoOutputs) { EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); EXPECT_EQ( JoinActions( kGrab, @@ -1056,7 +1056,7 @@ TEST_F(OutputConfiguratorTest, InvalidOutputStates) { UpdateOutputs(0, false); EXPECT_EQ(kNoActions, log_->GetActionsAndClear()); configurator_.Init(false); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); observer_.Reset(); EXPECT_TRUE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_HEADLESS)); EXPECT_FALSE(configurator_.SetDisplayMode(ui::OUTPUT_STATE_SINGLE)); @@ -1090,7 +1090,7 @@ TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithoutId) { UpdateOutputs(2, false); configurator_.Init(false); state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); EXPECT_EQ(ui::OUTPUT_STATE_DUAL_EXTENDED, configurator_.output_state()); } @@ -1099,7 +1099,7 @@ TEST_F(OutputConfiguratorTest, GetOutputStateForDisplaysWithId) { UpdateOutputs(2, false); configurator_.Init(false); state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); EXPECT_EQ(ui::OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); } @@ -1140,7 +1140,7 @@ TEST_F(OutputConfiguratorTest, PanelFitting) { UpdateOutputs(2, false); state_controller_.set_state(ui::OUTPUT_STATE_DUAL_MIRROR); configurator_.Init(true /* is_panel_fitting_enabled */); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); EXPECT_EQ(ui::OUTPUT_STATE_DUAL_MIRROR, configurator_.output_state()); EXPECT_EQ( JoinActions( @@ -1179,7 +1179,7 @@ TEST_F(OutputConfiguratorTest, PanelFitting) { TEST_F(OutputConfiguratorTest, OutputProtection) { configurator_.Init(false); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); EXPECT_NE(kNoActions, log_->GetActionsAndClear()); OutputConfigurator::OutputProtectionClientId id = @@ -1242,7 +1242,7 @@ TEST_F(OutputConfiguratorTest, OutputProtectionTwoClients) { EXPECT_NE(client1, client2); configurator_.Init(false); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); UpdateOutputs(2, true); EXPECT_NE(kNoActions, log_->GetActionsAndClear()); @@ -1290,7 +1290,7 @@ TEST_F(OutputConfiguratorTest, CTMForMultiScreens) { UpdateOutputs(2, false); configurator_.Init(false); state_controller_.set_state(ui::OUTPUT_STATE_DUAL_EXTENDED); - configurator_.Start(0); + configurator_.ForceInitialConfigure(0); const int kDualHeight = kSmallModeHeight + OutputConfigurator::kVerticalGap + kBigModeHeight; |