| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "ash/wm/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // Shelf is created lazily and can be NULL. | 455 // Shelf is created lazily and can be NULL. |
| 456 if (!shelf) | 456 if (!shelf) |
| 457 return gfx::Rect(); | 457 return gfx::Rect(); |
| 458 gfx::Rect item_rect = shelf->GetScreenBoundsOfItemIconForWindow(window); | 458 gfx::Rect item_rect = shelf->GetScreenBoundsOfItemIconForWindow(window); |
| 459 | 459 |
| 460 // The launcher item is visible and has an icon. | 460 // The launcher item is visible and has an icon. |
| 461 if (!item_rect.IsEmpty()) | 461 if (!item_rect.IsEmpty()) |
| 462 return item_rect; | 462 return item_rect; |
| 463 | 463 |
| 464 // If both the icon width and height are 0, then there is no icon in the | 464 // If both the icon width and height are 0, then there is no icon in the |
| 465 // launcher for |window| or the icon is hidden in the overflow menu. If the | 465 // launcher for |window|. If the launcher is auto hidden, one of the height or |
| 466 // launcher is auto hidden, one of the height or width will be 0 but the | 466 // width will be 0 but the position in the launcher and the major dimension |
| 467 // position in the launcher and the major dimension are still reported | 467 // are still reported correctly and the window can be animated to the launcher |
| 468 // correctly and the window can be animated to the launcher item's light | 468 // item's light bar. |
| 469 // bar. | 469 ShelfLayoutManager* layout_manager = ShelfLayoutManager::ForShelf(window); |
| 470 if (item_rect.width() != 0 || item_rect.height() != 0) { | 470 if (item_rect.width() != 0 || item_rect.height() != 0) { |
| 471 ShelfLayoutManager* layout_manager = ShelfLayoutManager::ForShelf(window); | |
| 472 if (layout_manager->visibility_state() == SHELF_AUTO_HIDE) { | 471 if (layout_manager->visibility_state() == SHELF_AUTO_HIDE) { |
| 473 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); | 472 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); |
| 474 switch (layout_manager->GetAlignment()) { | 473 switch (layout_manager->GetAlignment()) { |
| 475 case SHELF_ALIGNMENT_BOTTOM: | 474 case SHELF_ALIGNMENT_BOTTOM: |
| 476 item_rect.set_y(shelf_bounds.y()); | 475 item_rect.set_y(shelf_bounds.y()); |
| 477 break; | 476 break; |
| 478 case SHELF_ALIGNMENT_LEFT: | 477 case SHELF_ALIGNMENT_LEFT: |
| 479 item_rect.set_x(shelf_bounds.right()); | 478 item_rect.set_x(shelf_bounds.right()); |
| 480 break; | 479 break; |
| 481 case SHELF_ALIGNMENT_RIGHT: | 480 case SHELF_ALIGNMENT_RIGHT: |
| 482 item_rect.set_x(shelf_bounds.x()); | 481 item_rect.set_x(shelf_bounds.x()); |
| 483 break; | 482 break; |
| 484 case SHELF_ALIGNMENT_TOP: | 483 case SHELF_ALIGNMENT_TOP: |
| 485 item_rect.set_y(shelf_bounds.bottom()); | 484 item_rect.set_y(shelf_bounds.bottom()); |
| 486 break; | 485 break; |
| 487 } | 486 } |
| 488 return item_rect; | 487 return item_rect; |
| 489 } | 488 } |
| 490 } | 489 } |
| 491 | 490 |
| 492 // Assume the shelf is overflowed, zoom off to the bottom right of the | 491 // Coming here, there is no visible icon of that shelf item and we zoom back |
| 493 // work area. | 492 // to the location of the application launcher (which is fixed as first item |
| 493 // of the shelf). |
| 494 gfx::Rect work_area = | 494 gfx::Rect work_area = |
| 495 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 495 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
| 496 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); | 496 int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x(); |
| 497 switch (layout_manager->GetAlignment()) { |
| 498 case SHELF_ALIGNMENT_BOTTOM: |
| 499 return gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0); |
| 500 case SHELF_ALIGNMENT_TOP: |
| 501 return gfx::Rect(ltr_adjusted_x, work_area.y(), 0, 0); |
| 502 case SHELF_ALIGNMENT_LEFT: |
| 503 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); |
| 504 case SHELF_ALIGNMENT_RIGHT: |
| 505 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); |
| 506 } |
| 507 NOTREACHED(); |
| 508 return gfx::Rect(); |
| 497 } | 509 } |
| 498 | 510 |
| 499 } // namespace ash | 511 } // namespace ash |
| OLD | NEW |