summaryrefslogtreecommitdiffstats
path: root/ash/wm/window_animations.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ash/wm/window_animations.cc')
-rw-r--r--ash/wm/window_animations.cc78
1 files changed, 56 insertions, 22 deletions
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index dc6ff2e..0278a93 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -11,6 +11,8 @@
#include "ash/launcher/launcher.h"
#include "ash/screen_ash.h"
+#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_animations.h"
@@ -71,33 +73,16 @@ int64 Round64(float f) {
} // namespace
-gfx::Rect GetMinimizeRectForWindow(aura::Window* window) {
- Launcher* launcher = Launcher::ForWindow(window);
- // Launcher is created lazily and can be NULL.
- if (!launcher)
- return gfx::Rect();
- gfx::Rect target_bounds = Launcher::ForWindow(window)->
- GetScreenBoundsOfItemIconForWindow(window);
- if (target_bounds.IsEmpty()) {
- // Assume the launcher is overflowed, zoom off to the bottom right of the
- // work area.
- gfx::Rect work_area =
- Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
- target_bounds.SetRect(work_area.right(), work_area.bottom(), 0, 0);
- }
- target_bounds =
- ScreenAsh::ConvertRectFromScreen(window->parent(), target_bounds);
- return target_bounds;
-}
-
void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
// Recalculate the transform at restore time since the launcher item may have
// moved while the window was minimized.
gfx::Rect bounds = window->bounds();
- gfx::Rect target_bounds = GetMinimizeRectForWindow(window);
+ gfx::Rect target_bounds = GetMinimizeAnimationTargetBoundsInScreen(window);
+ target_bounds =
+ ScreenAsh::ConvertRectFromScreen(window->parent(), target_bounds);
- float scale_x = static_cast<float>(target_bounds.height()) / bounds.width();
- float scale_y = static_cast<float>(target_bounds.width()) / bounds.height();
+ float scale_x = static_cast<float>(target_bounds.width()) / bounds.width();
+ float scale_y = static_cast<float>(target_bounds.height()) / bounds.height();
scoped_ptr<ui::InterpolatedTransform> scale(
new ui::InterpolatedScale(gfx::Point3F(1, 1, 1),
@@ -522,4 +507,53 @@ void SetTransformForScaleAnimation(ui::Layer* layer,
layer->SetTransform(transform);
}
+gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) {
+ Launcher* launcher = Launcher::ForWindow(window);
+ // Launcher is created lazily and can be NULL.
+ if (!launcher)
+ return gfx::Rect();
+ gfx::Rect item_rect = launcher->
+ GetScreenBoundsOfItemIconForWindow(window);
+
+ // The launcher item is visible and has an icon.
+ if (!item_rect.IsEmpty())
+ return item_rect;
+
+ // If both the icon width and height are 0, then there is no icon in the
+ // launcher for |window| or the icon is hidden in the overflow menu. If the
+ // launcher is auto hidden, one of the height or width will be 0 but the
+ // position in the launcher and the major dimension are still reported
+ // correctly and the window can be animated to the launcher item's light
+ // bar.
+ if (item_rect.width() != 0 || item_rect.height() != 0) {
+ internal::ShelfLayoutManager* layout_manager =
+ internal::ShelfLayoutManager::ForLauncher(window);
+ if (layout_manager->visibility_state() == SHELF_AUTO_HIDE) {
+ gfx::Rect shelf_bounds =
+ launcher->shelf_widget()->GetWindowBoundsInScreen();
+ switch (layout_manager->GetAlignment()) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ item_rect.set_y(shelf_bounds.y());
+ break;
+ case SHELF_ALIGNMENT_LEFT:
+ item_rect.set_x(shelf_bounds.right());
+ break;
+ case SHELF_ALIGNMENT_RIGHT:
+ item_rect.set_x(shelf_bounds.x());
+ break;
+ case SHELF_ALIGNMENT_TOP:
+ item_rect.set_y(shelf_bounds.bottom());
+ break;
+ }
+ return item_rect;
+ }
+ }
+
+ // Assume the launcher is overflowed, zoom off to the bottom right of the
+ // work area.
+ gfx::Rect work_area =
+ Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
+ return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0);
+}
+
} // namespace ash