summaryrefslogtreecommitdiffstats
path: root/ash/accelerators
diff options
context:
space:
mode:
authorvarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-25 21:19:57 +0000
committervarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-25 21:19:57 +0000
commitae6f06153630c4c0940a4630443ae4faf44ef409 (patch)
tree3a0e2d688106828131e624ef2aec8fc175f51db6 /ash/accelerators
parente7df39152ff45e8abdbfbab57a5dcec0c09ae34f (diff)
downloadchromium_src-ae6f06153630c4c0940a4630443ae4faf44ef409.zip
chromium_src-ae6f06153630c4c0940a4630443ae4faf44ef409.tar.gz
chromium_src-ae6f06153630c4c0940a4630443ae4faf44ef409.tar.bz2
Avoids centering docked windows, Unsnaps when centering.
BUG=322196 Review URL: https://codereview.chromium.org/79023009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/accelerators')
-rw-r--r--ash/accelerators/accelerator_controller.cc6
-rw-r--r--ash/accelerators/accelerator_controller_unittest.cc32
2 files changed, 36 insertions, 2 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 2e8d4b7..d9c2d79 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -851,7 +851,7 @@ bool AcceleratorController::PerformAction(int action,
case WINDOW_SNAP_LEFT:
case WINDOW_SNAP_RIGHT: {
wm::WindowState* window_state = wm::GetActiveWindowState();
- // Disable window docking shortcut key for full screen window due to
+ // Disable window snapping shortcut key for full screen window due to
// http://crbug.com/135487.
if (!window_state ||
window_state->window()->type() != aura::client::WINDOW_TYPE_NORMAL ||
@@ -879,8 +879,10 @@ bool AcceleratorController::PerformAction(int action,
return true;
}
case WINDOW_POSITION_CENTER: {
+ content::RecordAction(content::UserMetricsAction("Accel_Center"));
aura::Window* window = wm::GetActiveWindow();
- if (window) {
+ // Docked windows do not support centering and ignore accelerator.
+ if (window && !wm::GetWindowState(window)->IsDocked()) {
wm::CenterWindow(window);
return true;
}
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index 4a98b0e..278630c 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -9,6 +9,7 @@
#include "ash/caps_lock_delegate.h"
#include "ash/display/display_manager.h"
#include "ash/ime_control_delegate.h"
+#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/system/brightness_control_delegate.h"
@@ -536,6 +537,37 @@ TEST_F(AcceleratorControllerTest, WindowSnap) {
}
}
+TEST_F(AcceleratorControllerTest, CenterWindowAccelerator) {
+ scoped_ptr<aura::Window> window(
+ CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
+ const ui::Accelerator dummy;
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ window_state->Activate();
+
+ // Center the window using accelerator.
+ GetController()->PerformAction(WINDOW_POSITION_CENTER, dummy);
+ gfx::Rect work_area =
+ Shell::GetScreen()->GetDisplayNearestWindow(window.get()).work_area();
+ gfx::Rect bounds = window->GetBoundsInScreen();
+ EXPECT_NEAR(bounds.x() - work_area.x(),
+ work_area.right() - bounds.right(),
+ 1);
+ EXPECT_NEAR(bounds.y() - work_area.y(),
+ work_area.bottom() - bounds.bottom(),
+ 1);
+
+ // Add the window to docked container and try to center it.
+ window->SetBounds(gfx::Rect(0, 0, 20, 20));
+ aura::Window* docked_container = Shell::GetContainer(
+ window->GetRootWindow(), internal::kShellWindowId_DockedContainer);
+ docked_container->AddChild(window.get());
+ gfx::Rect docked_bounds = window->GetBoundsInScreen();
+ GetController()->PerformAction(WINDOW_POSITION_CENTER, dummy);
+ // It should not get centered and should remain docked.
+ EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
+ EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().ToString());
+}
+
TEST_F(AcceleratorControllerTest, ControllerContext) {
ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE);
ui::Accelerator accelerator_a2(ui::VKEY_A, ui::EF_NONE);