| Index: chromeos/display/output_configurator.cc
|
| diff --git a/chromeos/display/output_configurator.cc b/chromeos/display/output_configurator.cc
|
| index 60013092234cbe9ba6612111b451f5159126c88e..d493cf2458cae441e66c63ffb8091dd0a6f69176 100644
|
| --- a/chromeos/display/output_configurator.cc
|
| +++ b/chromeos/display/output_configurator.cc
|
| @@ -16,6 +16,7 @@
|
| #undef Status
|
| #undef RootWindow
|
|
|
| +#include "base/bind.h"
|
| #include "base/chromeos/chromeos_version.h"
|
| #include "base/logging.h"
|
| #include "base/message_pump_aurax11.h"
|
| @@ -756,19 +757,13 @@ bool OutputConfigurator::SetDisplayMode(State new_state) {
|
| output_state_ == STATE_SINGLE)
|
| return false;
|
|
|
| - Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
|
| - CHECK(display != NULL);
|
| - XGrabServer(display);
|
| - Window window = DefaultRootWindow(display);
|
| - XRRScreenResources* screen = XRRGetScreenResources(display, window);
|
| - CHECK(screen != NULL);
|
| -
|
| - UpdateCacheAndXrandrToState(display,
|
| - screen,
|
| - window,
|
| - new_state);
|
| - XRRFreeScreenResources(screen);
|
| - XUngrabServer(display);
|
| + if (animation_delegate_.get()) {
|
| + animation_delegate_->WillDisplayModeChange(
|
| + base::Bind(&OutputConfigurator::SetDisplayModeInternal,
|
| + base::Unretained(this), new_state));
|
| + } else {
|
| + SetDisplayModeInternal(new_state);
|
| + }
|
| return true;
|
| }
|
|
|
| @@ -793,6 +788,40 @@ bool OutputConfigurator::Dispatch(const base::NativeEvent& event) {
|
| return true;
|
| }
|
|
|
| +void OutputConfigurator::SetDisplayModeInternal(State new_state) {
|
| + // We should have this guard both in SetDisplayMode and SetDisplayModeInternal
|
| + // because |output_state_| may change during the animation.
|
| + if (output_state_ == STATE_INVALID ||
|
| + output_state_ == STATE_HEADLESS ||
|
| + output_state_ == STATE_SINGLE) {
|
| + if (animation_delegate_.get()) {
|
| + MessageLoop::current()->PostTask(
|
| + FROM_HERE, base::Bind(&AnimationDelegate::OnDisplayModeChanged,
|
| + base::Unretained(animation_delegate_.get())));
|
| + }
|
| + return;
|
| + }
|
| +
|
| + Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
|
| + CHECK(display != NULL);
|
| + XGrabServer(display);
|
| + Window window = DefaultRootWindow(display);
|
| + XRRScreenResources* screen = XRRGetScreenResources(display, window);
|
| + CHECK(screen != NULL);
|
| +
|
| + UpdateCacheAndXrandrToState(display,
|
| + screen,
|
| + window,
|
| + new_state);
|
| + XRRFreeScreenResources(screen);
|
| + XUngrabServer(display);
|
| + if (animation_delegate_.get()) {
|
| + MessageLoop::current()->PostTask(
|
| + FROM_HERE, base::Bind(&AnimationDelegate::OnDisplayModeChanged,
|
| + base::Unretained(animation_delegate_.get())));
|
| + }
|
| +}
|
| +
|
| void OutputConfigurator::CheckIsProjectingAndNotify() {
|
| // Determine if there is an "internal" output and how many outputs are
|
| // connected.
|
|
|