summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 19:26:30 +0000
committervollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 19:26:30 +0000
commit2ddfe43ba403bd2272154b2307e631d7394b55c3 (patch)
treeb736178f711282c82a5b28f5ff47990dd90b79fe
parent554890fecb9712a3e7a99c5c82ca5b3d4f06f0d5 (diff)
downloadchromium_src-2ddfe43ba403bd2272154b2307e631d7394b55c3.zip
chromium_src-2ddfe43ba403bd2272154b2307e631d7394b55c3.tar.gz
chromium_src-2ddfe43ba403bd2272154b2307e631d7394b55c3.tar.bz2
Reenable triggering of screen rotations by sensors.
Depends on http://codereview.chromium.org/8395046 BUG=None TEST=Visiting about:rotate?right, about:rotate?left, etc. should cause the appropriate screen rotations. Review URL: http://codereview.chromium.org/8402002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108889 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/common.gypi3
-rw-r--r--chrome/browser/chrome_browser_parts_touch.cc20
-rw-r--r--chrome/browser/chrome_browser_parts_touch.h29
-rw-r--r--chrome/browser/chrome_content_browser_client.cc7
-rw-r--r--chrome/browser/ui/touch/sensors/screen_orientation_listener.cc106
-rw-r--r--chrome/browser/ui/touch/sensors/screen_orientation_listener.h32
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--ui/aura/aura.gyp2
-rw-r--r--ui/aura/desktop.cc76
-rw-r--r--ui/gfx/compositor/compositor.gyp2
-rw-r--r--ui/gfx/compositor/layer_animator.cc5
-rw-r--r--ui/gfx/compositor/screen_rotation.cc (renamed from ui/aura/screen_rotation.cc)40
-rw-r--r--ui/gfx/compositor/screen_rotation.h (renamed from ui/aura/screen_rotation.h)24
-rw-r--r--views/desktop/desktop_window_view.cc22
-rw-r--r--views/desktop/desktop_window_view.h16
15 files changed, 305 insertions, 83 deletions
diff --git a/build/common.gypi b/build/common.gypi
index f3b8de4..896245e 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -1317,6 +1317,9 @@
['use_aura==0 or OS!="win"', {
'sources/': [ ['exclude', '_aurawin\\.(h|cc)$'] ]
}],
+ ['touchui!=1', {
+ 'sources/': [ ['exclude', '_touch\\.(h|cc)$'] ]
+ }],
],
}],
], # target_conditions for 'target_defaults'
diff --git a/chrome/browser/chrome_browser_parts_touch.cc b/chrome/browser/chrome_browser_parts_touch.cc
new file mode 100644
index 0000000..506cf1d
--- /dev/null
+++ b/chrome/browser/chrome_browser_parts_touch.cc
@@ -0,0 +1,20 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chrome_browser_parts_touch.h"
+
+#include "chrome/browser/ui/touch/sensors/screen_orientation_listener.h"
+
+ChromeBrowserPartsTouch::ChromeBrowserPartsTouch()
+ : content::BrowserMainParts() {
+}
+
+void ChromeBrowserPartsTouch::PreMainMessageLoopRun() {
+ // Make sure the singleton ScreenOrientationListener object is created.
+ ScreenOrientationListener::GetInstance();
+}
+
+bool ChromeBrowserPartsTouch::MainMessageLoopRun(int* result_code) {
+ return false;
+}
diff --git a/chrome/browser/chrome_browser_parts_touch.h b/chrome/browser/chrome_browser_parts_touch.h
new file mode 100644
index 0000000..0cd9502
--- /dev/null
+++ b/chrome/browser/chrome_browser_parts_touch.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROME_BROWSER_PARTS_TOUCH_H_
+#define CHROME_BROWSER_CHROME_BROWSER_PARTS_TOUCH_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "content/public/browser/browser_main_parts.h"
+
+class ChromeBrowserPartsTouch : public content::BrowserMainParts {
+ public:
+ ChromeBrowserPartsTouch();
+
+ virtual void PreEarlyInitialization() OVERRIDE {}
+ virtual void PostEarlyInitialization() OVERRIDE {}
+ virtual void PreMainMessageLoopStart() OVERRIDE {}
+ virtual void ToolkitInitialized() OVERRIDE {}
+ virtual void PostMainMessageLoopStart() OVERRIDE {}
+ virtual void PreMainMessageLoopRun() OVERRIDE;
+ virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
+ virtual void PostMainMessageLoopRun() OVERRIDE {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeBrowserPartsTouch);
+};
+
+#endif // CHROME_BROWSER_CHROME_BROWSER_PARTS_TOUCH_H_
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 00ee6b0..4909a7f 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -97,6 +97,10 @@
#include "chrome/browser/chrome_browser_parts_gtk.h"
#endif
+#if defined(TOUCH_UI)
+#include "chrome/browser/chrome_browser_parts_touch.h"
+#endif
+
#if defined(OS_LINUX)
#include "base/linux_util.h"
#include "chrome/browser/crash_handler_host_linux.h"
@@ -230,6 +234,9 @@ void ChromeContentBrowserClient::CreateBrowserMainParts(
#if defined(TOOLKIT_USES_GTK)
parts_list->push_back(new ChromeBrowserPartsGtk());
#endif
+#if defined(TOUCH_UI)
+ parts_list->push_back(new ChromeBrowserPartsTouch());
+#endif
}
RenderWidgetHostView* ChromeContentBrowserClient::CreateViewForWidget(
diff --git a/chrome/browser/ui/touch/sensors/screen_orientation_listener.cc b/chrome/browser/ui/touch/sensors/screen_orientation_listener.cc
new file mode 100644
index 0000000..4b2aa86
--- /dev/null
+++ b/chrome/browser/ui/touch/sensors/screen_orientation_listener.cc
@@ -0,0 +1,106 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/touch/sensors/screen_orientation_listener.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/sensors/sensors_provider.h"
+#include "ui/gfx/compositor/layer.h"
+#include "ui/gfx/compositor/layer_animation_sequence.h"
+#include "ui/gfx/compositor/layer_animator.h"
+#include "ui/gfx/compositor/screen_rotation.h"
+#include "ui/gfx/interpolated_transform.h"
+#include "views/desktop/desktop_window_view.h"
+
+#if defined(USE_AURA)
+#include "ui/aura/desktop.h"
+#endif
+
+namespace {
+
+// Converts degrees to an angle in the range [-180, 180).
+int NormalizeAngle(int degrees) {
+ while (degrees <= -180) degrees += 360;
+ while (degrees > 180) degrees -= 360;
+ return degrees;
+}
+
+static int SymmetricRound(float x) {
+ return static_cast<int>(
+ x > 0
+ ? std::floor(x + 0.5f)
+ : std::ceil(x - 0.5f));
+}
+
+} // namespace
+
+ScreenOrientationListener::ScreenOrientationListener() {
+ sensors::Provider::GetInstance()->AddListener(this);
+}
+
+ScreenOrientationListener::~ScreenOrientationListener() {
+ sensors::Provider::GetInstance()->RemoveListener(this);
+}
+
+void ScreenOrientationListener::OnScreenOrientationChanged(
+ const sensors::ScreenOrientation& change) {
+ ui::Layer* to_rotate = NULL;
+ ui::LayerAnimationObserver* observer = NULL;
+#if defined(USE_AURA)
+ aura::Desktop* aura_desktop = aura::Desktop::GetInstance();
+ if (aura_desktop) {
+ to_rotate = aura_desktop->layer();
+ observer = aura_desktop;
+ }
+#endif
+ if (!to_rotate) {
+ views::desktop::DesktopWindowView* views_desktop =
+ views::desktop::DesktopWindowView::desktop_window_view;
+ if (views_desktop) {
+ views_desktop->SetPaintToLayer(true);
+ to_rotate = views_desktop->layer();
+ observer = views_desktop;
+ }
+ }
+
+ if (!to_rotate || !observer)
+ return;
+
+ bool should_rotate = true;
+ int new_degrees = 0;
+ switch (change.upward) {
+ case sensors::ScreenOrientation::TOP: break;
+ case sensors::ScreenOrientation::RIGHT: new_degrees = 90; break;
+ case sensors::ScreenOrientation::LEFT: new_degrees = -90; break;
+ case sensors::ScreenOrientation::BOTTOM: new_degrees = 180; break;
+ // Ignore front and back orientations.
+ default: should_rotate = false;
+ }
+
+ if (!should_rotate)
+ return;
+
+ float rotation = 0.0f;
+ int delta = 0;
+ const ui::Transform& transform = to_rotate->GetTargetTransform();
+ if (ui::InterpolatedTransform::FactorTRS(transform,
+ NULL, &rotation, NULL))
+ delta = NormalizeAngle(new_degrees - SymmetricRound(rotation));
+
+ // No rotation to do.
+ if (delta == 0)
+ return;
+
+ scoped_ptr<ui::LayerAnimationSequence> screen_rotation(
+ new ui::LayerAnimationSequence(new ui::ScreenRotation(delta)));
+ screen_rotation->AddObserver(observer);
+ to_rotate->GetAnimator()->set_preemption_strategy(
+ ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
+ to_rotate->GetAnimator()->ScheduleAnimation(screen_rotation.release());
+}
+
+// static
+ScreenOrientationListener* ScreenOrientationListener::GetInstance() {
+ return Singleton<ScreenOrientationListener>::get();
+}
diff --git a/chrome/browser/ui/touch/sensors/screen_orientation_listener.h b/chrome/browser/ui/touch/sensors/screen_orientation_listener.h
new file mode 100644
index 0000000..cd68cfd
--- /dev/null
+++ b/chrome/browser/ui/touch/sensors/screen_orientation_listener.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_TOUCH_SENSORS_SCREEN_ORIENTATION_LISTENER_H_
+#define CHROME_BROWSER_UI_TOUCH_SENSORS_SCREEN_ORIENTATION_LISTENER_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/memory/singleton.h"
+#include "content/common/sensors_listener.h"
+
+// A singleton object to manage screen orientation.
+class ScreenOrientationListener : public sensors::Listener {
+ public:
+ // Returns the singleton object.
+ static ScreenOrientationListener* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<ScreenOrientationListener>;
+
+ ScreenOrientationListener();
+ virtual ~ScreenOrientationListener();
+
+ // sensors::Listener implementation
+ virtual void OnScreenOrientationChanged(
+ const sensors::ScreenOrientation& change) OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenOrientationListener);
+};
+
+#endif // CHROME_BROWSER_UI_TOUCH_SENSORS_SCREEN_ORIENTATION_LISTENER_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 1f46e4b..e93b349 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -355,6 +355,8 @@
'browser/chrome_browser_parts_aura.h',
'browser/chrome_browser_parts_gtk.cc',
'browser/chrome_browser_parts_gtk.h',
+ 'browser/chrome_browser_parts_touch.cc',
+ 'browser/chrome_browser_parts_touch.h',
'browser/chrome_content_browser_client.cc',
'browser/chrome_content_browser_client.h',
'browser/chrome_plugin_message_filter.cc',
@@ -3257,6 +3259,8 @@
'browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc',
'browser/ui/touch/frame/touch_browser_frame_view.cc',
'browser/ui/touch/frame/touch_browser_frame_view.h',
+ 'browser/ui/touch/sensors/screen_orientation_listener.cc',
+ 'browser/ui/touch/sensors/screen_orientation_listener.h',
'browser/ui/touch/status_bubble_touch.cc',
'browser/ui/touch/status_bubble_touch.h',
'browser/ui/touch/tabs/tab_strip_factory.cc',
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index d012a80..1149373 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -45,8 +45,6 @@
'layout_manager.h',
'screen_aura.cc',
'screen_aura.h',
- 'screen_rotation.cc',
- 'screen_rotation.h',
'toplevel_window_container.cc',
'toplevel_window_container.h',
'toplevel_window_event_filter.cc',
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index 07edd11..4b16a0a 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -21,7 +21,6 @@
#include "ui/aura/event_filter.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/screen_aura.h"
-#include "ui/aura/screen_rotation.h"
#include "ui/aura/toplevel_window_container.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
@@ -29,6 +28,7 @@
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_animation_sequence.h"
#include "ui/gfx/compositor/layer_animator.h"
+#include "ui/gfx/compositor/screen_rotation.h"
#include "ui/gfx/interpolated_transform.h"
using std::string;
@@ -44,22 +44,6 @@ static const int kDefaultHostWindowY = 200;
static const int kDefaultHostWindowWidth = 1280;
static const int kDefaultHostWindowHeight = 1024;
-#if !defined(NDEBUG)
-// Converts degrees to an angle in the range [-180, 180).
-int NormalizeAngle(int degrees) {
- while (degrees <= -180) degrees += 360;
- while (degrees > 180) degrees -= 360;
- return degrees;
-}
-
-static int SymmetricRound(float x) {
- return static_cast<int>(
- x > 0
- ? std::floor(x + 0.5f)
- : std::ceil(x - 0.5f));
-}
-#endif
-
class DefaultDesktopDelegate : public DesktopDelegate {
public:
explicit DefaultDesktopDelegate(Desktop* desktop) : desktop_(desktop) {}
@@ -168,37 +152,35 @@ bool MaybeFullScreen(DesktopHost* host, KeyEvent* event) {
}
bool MaybeRotate(Desktop* desktop, KeyEvent* event) {
- if ((event->flags() & ui::EF_SHIFT_DOWN) &&
- (event->flags() & ui::EF_ALT_DOWN)) {
- bool should_rotate = true;
- int new_degrees = 0;
- switch (event->key_code()) {
- case ui::VKEY_UP: new_degrees = 0; break;
- case ui::VKEY_DOWN: new_degrees = 180; break;
- case ui::VKEY_RIGHT: new_degrees = 90; break;
- case ui::VKEY_LEFT: new_degrees = -90; break;
- default: should_rotate = false; break;
- }
-
- if (should_rotate) {
- float rotation = 0.0f;
- int degrees = 0;
- const ui::Transform& transform = desktop->layer()->GetTargetTransform();
- if (ui::InterpolatedTransform::FactorTRS(transform,
- NULL, &rotation, NULL))
- degrees = NormalizeAngle(new_degrees - SymmetricRound(rotation));
-
- if (degrees != 0) {
- desktop->layer()->GetAnimator()->set_preemption_strategy(
- ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
- scoped_ptr<ui::LayerAnimationSequence> screen_rotation(
- new ui::LayerAnimationSequence(new ScreenRotation(degrees)));
- screen_rotation->AddObserver(desktop);
- desktop->layer()->GetAnimator()->ScheduleAnimation(
- screen_rotation.release());
- return true;
- }
+ if ((event->flags() & ui::EF_CONTROL_DOWN) &&
+ event->key_code() == ui::VKEY_HOME) {
+ static int i = 0;
+ int delta = 0;
+ switch (i) {
+ case 0: delta = 90; break;
+ case 1: delta = 90; break;
+ case 2: delta = 90; break;
+ case 3: delta = 90; break;
+ case 4: delta = -90; break;
+ case 5: delta = -90; break;
+ case 6: delta = -90; break;
+ case 7: delta = -90; break;
+ case 8: delta = -90; break;
+ case 9: delta = 180; break;
+ case 10: delta = 180; break;
+ case 11: delta = 90; break;
+ case 12: delta = 180; break;
+ case 13: delta = 180; break;
}
+ i = (i + 1) % 14;
+ desktop->layer()->GetAnimator()->set_preemption_strategy(
+ ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
+ scoped_ptr<ui::LayerAnimationSequence> screen_rotation(
+ new ui::LayerAnimationSequence(new ui::ScreenRotation(delta)));
+ screen_rotation->AddObserver(desktop);
+ desktop->layer()->GetAnimator()->ScheduleAnimation(
+ screen_rotation.release());
+ return true;
}
return false;
}
diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp
index 9fa4201..c98aab4 100644
--- a/ui/gfx/compositor/compositor.gyp
+++ b/ui/gfx/compositor/compositor.gyp
@@ -57,6 +57,8 @@
'layer_animation_sequence.h',
'layer_animator.cc',
'layer_animator.h',
+ 'screen_rotation.cc',
+ 'screen_rotation.h',
],
'conditions': [
['os_posix == 1 and OS != "mac"', {
diff --git a/ui/gfx/compositor/layer_animator.cc b/ui/gfx/compositor/layer_animator.cc
index 7bc9698..588231c 100644
--- a/ui/gfx/compositor/layer_animator.cc
+++ b/ui/gfx/compositor/layer_animator.cc
@@ -304,8 +304,9 @@ void LayerAnimator::FinishAnimation(LayerAnimationSequence* sequence) {
}
void LayerAnimator::FinishAnyAnimationWithZeroDuration() {
- // We need to make a copy because Progress may indirectly cause new animations
- // to start running.
+ // Special case: if we've started a 0 duration animation, just finish it now
+ // and get rid of it. We need to make a copy because Progress may indirectly
+ // cause new animations to start running.
RunningAnimations running_animations_copy = running_animations_;
for (size_t i = 0; i < running_animations_copy.size(); ++i) {
if (running_animations_copy[i].sequence->duration() == base::TimeDelta()) {
diff --git a/ui/aura/screen_rotation.cc b/ui/gfx/compositor/screen_rotation.cc
index 6b46817..df399e2 100644
--- a/ui/aura/screen_rotation.cc
+++ b/ui/gfx/compositor/screen_rotation.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura/screen_rotation.h"
+#include "ui/gfx/compositor/screen_rotation.h"
#include "base/debug/trace_event.h"
#include "base/time.h"
@@ -11,6 +11,8 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
+namespace ui {
+
namespace {
const int k90DegreeTransitionDurationMs = 350;
@@ -27,22 +29,19 @@ base::TimeDelta GetTransitionDuration(int degrees) {
} // namespace
ScreenRotation::ScreenRotation(int degrees)
- : ui::LayerAnimationElement(GetProperties(),
- GetTransitionDuration(degrees)),
+ : LayerAnimationElement(GetProperties(), GetTransitionDuration(degrees)),
degrees_(degrees) {
}
ScreenRotation::~ScreenRotation() {
}
-void ScreenRotation::OnStart(ui::LayerAnimationDelegate* delegate) {
- //TRACE_EVENT0("ScreenRotation", "init");
-
+void ScreenRotation::OnStart(LayerAnimationDelegate* delegate) {
// No rotation required.
if (degrees_ == 0)
return;
- const ui::Transform& current_transform = delegate->GetTransformForAnimation();
+ const Transform& current_transform = delegate->GetTransformForAnimation();
const gfx::Rect& bounds = delegate->GetBoundsForAnimation();
gfx::Point old_pivot;
@@ -69,26 +68,26 @@ void ScreenRotation::OnStart(ui::LayerAnimationDelegate* delegate) {
current_transform.TransformPoint(new_pivot);
current_transform.TransformPoint(new_origin_);
- scoped_ptr<ui::InterpolatedTransform> rotation(
- new ui::InterpolatedTransformAboutPivot(
+ scoped_ptr<InterpolatedTransform> rotation(
+ new InterpolatedTransformAboutPivot(
old_pivot,
- new ui::InterpolatedRotation(0, degrees_)));
+ new InterpolatedRotation(0, degrees_)));
- scoped_ptr<ui::InterpolatedTransform> translation(
- new ui::InterpolatedTranslation(
+ scoped_ptr<InterpolatedTransform> translation(
+ new InterpolatedTranslation(
gfx::Point(0, 0),
gfx::Point(new_pivot.x() - old_pivot.x(),
new_pivot.y() - old_pivot.y())));
float scale_factor = 0.9f;
- scoped_ptr<ui::InterpolatedTransform> scale_down(
- new ui::InterpolatedScale(1.0f, scale_factor, 0.0f, 0.5f));
+ scoped_ptr<InterpolatedTransform> scale_down(
+ new InterpolatedScale(1.0f, scale_factor, 0.0f, 0.5f));
- scoped_ptr<ui::InterpolatedTransform> scale_up(
- new ui::InterpolatedScale(1.0f, 1.0f / scale_factor, 0.5f, 1.0f));
+ scoped_ptr<InterpolatedTransform> scale_up(
+ new InterpolatedScale(1.0f, 1.0f / scale_factor, 0.5f, 1.0f));
interpolated_transform_.reset(
- new ui::InterpolatedConstantTransform(current_transform));
+ new InterpolatedConstantTransform(current_transform));
scale_up->SetChild(scale_down.release());
translation->SetChild(scale_up.release());
@@ -97,8 +96,7 @@ void ScreenRotation::OnStart(ui::LayerAnimationDelegate* delegate) {
}
void ScreenRotation::OnProgress(double t,
- ui::LayerAnimationDelegate* delegate) {
- //TRACE_EVENT0("ScreenRotation", "Progress");
+ LayerAnimationDelegate* delegate) {
delegate->SetTransformFromAnimation(interpolated_transform_->Interpolate(t));
delegate->ScheduleDrawForAnimation();
}
@@ -111,10 +109,12 @@ void ScreenRotation::OnAbort() {
}
// static
-const ui::LayerAnimationElement::AnimatableProperties&
+const LayerAnimationElement::AnimatableProperties&
ScreenRotation::GetProperties() {
static LayerAnimationElement::AnimatableProperties properties;
if (properties.empty())
properties.insert(LayerAnimationElement::TRANSFORM);
return properties;
}
+
+} // namespace ui
diff --git a/ui/aura/screen_rotation.h b/ui/gfx/compositor/screen_rotation.h
index e947b83..1d95a5d 100644
--- a/ui/aura/screen_rotation.h
+++ b/ui/gfx/compositor/screen_rotation.h
@@ -2,26 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_AURA_SCREEN_ROTATION_H_
-#define UI_AURA_SCREEN_ROTATION_H_
+#ifndef UI_GFX_COMPOSITOR_SCREEN_ROTATION_H_
+#define UI_GFX_COMPOSITOR_SCREEN_ROTATION_H_
#pragma once
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/base/animation/animation_delegate.h"
+#include "ui/gfx/compositor/compositor_export.h"
#include "ui/gfx/compositor/layer_animation_element.h"
#include "ui/gfx/point.h"
namespace ui {
class InterpolatedTransform;
class LayerAnimationDelegate;
-}
// A screen rotation represents a single transition from one screen orientation
// to another. The intended usage is that a new instance of the class is
// created for every transition. It is possible to update the target orientation
// in the middle of a transition.
-class ScreenRotation : public ui::LayerAnimationElement {
+class COMPOSITOR_EXPORT ScreenRotation : public LayerAnimationElement {
public:
// The screen rotation does not own the view or the listener, and these
// objects are required to outlive the Screen rotation object.
@@ -29,26 +29,28 @@ class ScreenRotation : public ui::LayerAnimationElement {
virtual ~ScreenRotation();
private:
- // Implementation of ui::LayerAnimationDelegate
- virtual void OnStart(ui::LayerAnimationDelegate* delegate) OVERRIDE;
+ // Implementation of LayerAnimationDelegate
+ virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE;
virtual void OnProgress(double t,
- ui::LayerAnimationDelegate* delegate) OVERRIDE;
+ LayerAnimationDelegate* delegate) OVERRIDE;
virtual void OnGetTarget(TargetValue* target) const OVERRIDE;
virtual void OnAbort() OVERRIDE;
- static const ui::LayerAnimationElement::AnimatableProperties& GetProperties();
+ static const LayerAnimationElement::AnimatableProperties& GetProperties();
// Generates the intermediate transformation matrices used during the
// animation.
- scoped_ptr<ui::InterpolatedTransform> interpolated_transform_;
+ scoped_ptr<InterpolatedTransform> interpolated_transform_;
// The number of degrees to rotate.
int degrees_;
- // The target origin for |view_|
+ // The target origin
gfx::Point new_origin_;
DISALLOW_COPY_AND_ASSIGN(ScreenRotation);
};
-#endif // UI_AURA_SCREEN_ROTATION_H_
+} // namespace ui
+
+#endif // UI_GFX_COMPOSITOR_SCREEN_ROTATION_H_
diff --git a/views/desktop/desktop_window_view.cc b/views/desktop/desktop_window_view.cc
index 94fda7d..9ad146c 100644
--- a/views/desktop/desktop_window_view.cc
+++ b/views/desktop/desktop_window_view.cc
@@ -269,5 +269,27 @@ NonClientFrameView* DesktopWindowView::CreateNonClientFrameView() {
return NULL;
}
+////////////////////////////////////////////////////////////////////////////////
+// ui::LayerAnimationObserver Implementation:
+
+void DesktopWindowView::OnLayerAnimationEnded(
+ const ui::LayerAnimationSequence* animation) {
+ // The layer, and all the observers should be notified of the
+ // transformed size of the desktop.
+ if (widget_) {
+ gfx::Rect current_bounds(widget_->GetClientAreaScreenBounds().size());
+ layer()->transform().TransformRect(&current_bounds);
+ SetBoundsRect(gfx::Rect(current_bounds.size()));
+ }
+}
+
+void DesktopWindowView::OnLayerAnimationScheduled(
+ const ui::LayerAnimationSequence* animation) {
+}
+
+void DesktopWindowView::OnLayerAnimationAborted(
+ const ui::LayerAnimationSequence* animation) {
+}
+
} // namespace desktop
} // namespace views
diff --git a/views/desktop/desktop_window_view.h b/views/desktop/desktop_window_view.h
index fadc04e..54471c9 100644
--- a/views/desktop/desktop_window_view.h
+++ b/views/desktop/desktop_window_view.h
@@ -6,16 +6,22 @@
#define VIEWS_DESKTOP_DESKTOP_WINDOW_VIEW_H_
#include "base/observer_list.h"
+#include "ui/gfx/compositor/layer_animation_observer.h"
#include "views/view.h"
#include "views/widget/widget_delegate.h"
+namespace ui {
+class LayerAnimationSequence;
+} // namespace ui
+
namespace views {
class NativeWidgetViews;
class Widget;
namespace desktop {
-class DesktopWindowView : public WidgetDelegateView {
+class DesktopWindowView : public WidgetDelegateView,
+ public ui::LayerAnimationObserver {
public:
// Observers can listen to various events on the desktop.
class Observer {
@@ -73,6 +79,14 @@ class DesktopWindowView : public WidgetDelegateView {
virtual View* GetContentsView() OVERRIDE;
virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
+ // Implementation of ui::LayerAnimationObserver:
+ virtual void OnLayerAnimationEnded(
+ const ui::LayerAnimationSequence* animation) OVERRIDE;
+ virtual void OnLayerAnimationScheduled(
+ const ui::LayerAnimationSequence* animation) OVERRIDE;
+ virtual void OnLayerAnimationAborted(
+ const ui::LayerAnimationSequence* animation) OVERRIDE;
+
ObserverList<Observer> observers_;
DesktopType type_;
Widget* widget_;