| 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/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 Shell::GetPrimaryRootWindowController()->GetContainer( | 57 Shell::GetPrimaryRootWindowController()->GetContainer( |
| 58 kShellWindowId_DefaultContainer); | 58 kShellWindowId_DefaultContainer); |
| 59 layout_manager_ = GetWorkspaceLayoutManager(default_container); | 59 layout_manager_ = GetWorkspaceLayoutManager(default_container); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ShowKeyboard() { | 62 void ShowKeyboard() { |
| 63 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); | 63 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); |
| 64 restore_work_area_insets_ = | 64 restore_work_area_insets_ = |
| 65 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); | 65 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); |
| 66 ShellPort::Get()->SetDisplayWorkAreaInsets( | 66 ShellPort::Get()->SetDisplayWorkAreaInsets( |
| 67 ShellPort::Get()->GetPrimaryRootWindow(), | 67 WmWindow::Get(Shell::GetPrimaryRootWindow()), |
| 68 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); | 68 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void HideKeyboard() { | 71 void HideKeyboard() { |
| 72 ShellPort::Get()->SetDisplayWorkAreaInsets( | 72 ShellPort::Get()->SetDisplayWorkAreaInsets( |
| 73 ShellPort::Get()->GetPrimaryRootWindow(), restore_work_area_insets_); | 73 WmWindow::Get(Shell::GetPrimaryRootWindow()), |
| 74 restore_work_area_insets_); |
| 74 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); | 75 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 // Initializes the keyboard bounds using the bottom half of the work area. | 78 // Initializes the keyboard bounds using the bottom half of the work area. |
| 78 void InitKeyboardBounds() { | 79 void InitKeyboardBounds() { |
| 79 gfx::Rect work_area( | 80 gfx::Rect work_area( |
| 80 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 81 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 81 keyboard_bounds_.SetRect(work_area.x(), | 82 keyboard_bounds_.SetRect(work_area.x(), |
| 82 work_area.y() + work_area.height() / 2, | 83 work_area.y() + work_area.height() / 2, |
| 83 work_area.width(), work_area.height() / 2); | 84 work_area.width(), work_area.height() / 2); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 114 std::unique_ptr<aura::Window> window( | 115 std::unique_ptr<aura::Window> window( |
| 115 CreateToplevelTestWindow(orig_window_bounds)); | 116 CreateToplevelTestWindow(orig_window_bounds)); |
| 116 | 117 |
| 117 wm::ActivateWindow(window.get()); | 118 wm::ActivateWindow(window.get()); |
| 118 EXPECT_EQ(orig_window_bounds, window->bounds()); | 119 EXPECT_EQ(orig_window_bounds, window->bounds()); |
| 119 | 120 |
| 120 // Open keyboard in non-sticky mode. | 121 // Open keyboard in non-sticky mode. |
| 121 kb_controller->ShowKeyboard(false); | 122 kb_controller->ShowKeyboard(false); |
| 122 kb_controller->ui()->GetKeyboardWindow()->SetBounds( | 123 kb_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 123 keyboard::FullWidthKeyboardBoundsFromRootBounds( | 124 keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 124 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100)); | 125 Shell::GetPrimaryRootWindow()->bounds(), 100)); |
| 125 | 126 |
| 126 int shift = | 127 int shift = |
| 127 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); | 128 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); |
| 128 gfx::Rect changed_window_bounds(orig_window_bounds); | 129 gfx::Rect changed_window_bounds(orig_window_bounds); |
| 129 changed_window_bounds.Offset(0, -shift); | 130 changed_window_bounds.Offset(0, -shift); |
| 130 // Window should be shifted up. | 131 // Window should be shifted up. |
| 131 EXPECT_EQ(changed_window_bounds, window->bounds()); | 132 EXPECT_EQ(changed_window_bounds, window->bounds()); |
| 132 | 133 |
| 133 kb_controller->HideKeyboard( | 134 kb_controller->HideKeyboard( |
| 134 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 135 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 std::unique_ptr<aura::Window> window( | 167 std::unique_ptr<aura::Window> window( |
| 167 CreateToplevelTestWindow(orig_window_bounds)); | 168 CreateToplevelTestWindow(orig_window_bounds)); |
| 168 | 169 |
| 169 wm::ActivateWindow(window.get()); | 170 wm::ActivateWindow(window.get()); |
| 170 EXPECT_EQ(orig_window_bounds, window->bounds()); | 171 EXPECT_EQ(orig_window_bounds, window->bounds()); |
| 171 | 172 |
| 172 // Open keyboard in non-sticky mode. | 173 // Open keyboard in non-sticky mode. |
| 173 kb_controller->ShowKeyboard(false); | 174 kb_controller->ShowKeyboard(false); |
| 174 kb_controller->ui()->GetKeyboardWindow()->SetBounds( | 175 kb_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 175 keyboard::FullWidthKeyboardBoundsFromRootBounds( | 176 keyboard::FullWidthKeyboardBoundsFromRootBounds( |
| 176 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100)); | 177 Shell::GetPrimaryRootWindow()->bounds(), 100)); |
| 177 | 178 |
| 178 // Window should not be shifted up. | 179 // Window should not be shifted up. |
| 179 EXPECT_EQ(orig_window_bounds, window->bounds()); | 180 EXPECT_EQ(orig_window_bounds, window->bounds()); |
| 180 | 181 |
| 181 kb_controller->HideKeyboard( | 182 kb_controller->HideKeyboard( |
| 182 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 183 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 183 EXPECT_EQ(orig_window_bounds, window->bounds()); | 184 EXPECT_EQ(orig_window_bounds, window->bounds()); |
| 184 | 185 |
| 185 // Open keyboard in sticky mode. | 186 // Open keyboard in sticky mode. |
| 186 kb_controller->ShowKeyboard(true); | 187 kb_controller->ShowKeyboard(true); |
| 187 | 188 |
| 188 int shift = | 189 int shift = |
| 189 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); | 190 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); |
| 190 gfx::Rect changed_window_bounds(orig_window_bounds); | 191 gfx::Rect changed_window_bounds(orig_window_bounds); |
| 191 changed_window_bounds.Offset(0, -shift); | 192 changed_window_bounds.Offset(0, -shift); |
| 192 // Window should be shifted up. | 193 // Window should be shifted up. |
| 193 EXPECT_EQ(changed_window_bounds, window->bounds()); | 194 EXPECT_EQ(changed_window_bounds, window->bounds()); |
| 194 | 195 |
| 195 kb_controller->HideKeyboard( | 196 kb_controller->HideKeyboard( |
| 196 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 197 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 197 EXPECT_EQ(orig_window_bounds, window->bounds()); | 198 EXPECT_EQ(orig_window_bounds, window->bounds()); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace ash | 201 } // namespace ash |
| OLD | NEW |