Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: ui/keyboard/keyboard_controller.cc

Issue 2620273002: Change the keyboard bounds when moving to another display. (Closed)
Patch Set: Fix a test failure Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/keyboard/keyboard_controller.h ('k') | ui/keyboard/keyboard_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 void KeyboardController::SetKeyboardMode(KeyboardMode mode) { 276 void KeyboardController::SetKeyboardMode(KeyboardMode mode) {
277 if (keyboard_mode_ == mode) 277 if (keyboard_mode_ == mode)
278 return; 278 return;
279 279
280 keyboard_mode_ = mode; 280 keyboard_mode_ = mode;
281 // When keyboard is floating, no overscroll or resize is necessary. Sets 281 // When keyboard is floating, no overscroll or resize is necessary. Sets
282 // keyboard bounds to zero so overscroll or resize is disabled. 282 // keyboard bounds to zero so overscroll or resize is disabled.
283 if (keyboard_mode_ == FLOATING) { 283 if (keyboard_mode_ == FLOATING) {
284 NotifyKeyboardBoundsChanging(gfx::Rect()); 284 NotifyKeyboardBoundsChanging(gfx::Rect());
285 } else if (keyboard_mode_ == FULL_WIDTH) { 285 } else if (keyboard_mode_ == FULL_WIDTH) {
286 // TODO(bshe): revisit this logic after we decide to support resize virtual 286 AdjustKeyboardBounds();
287 // keyboard.
288 int keyboard_height = GetContainerWindow()->bounds().height();
289 const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds();
290 gfx::Rect new_bounds = root_bounds;
291 new_bounds.set_y(root_bounds.height() - keyboard_height);
292 new_bounds.set_height(keyboard_height);
293 GetContainerWindow()->SetBounds(new_bounds);
294 // No animation added, so call ShowAnimationFinished immediately. 287 // No animation added, so call ShowAnimationFinished immediately.
295 ShowAnimationFinished(); 288 ShowAnimationFinished();
296 } 289 }
297 } 290 }
298 291
299 void KeyboardController::ShowKeyboard(bool lock) { 292 void KeyboardController::ShowKeyboard(bool lock) {
300 set_keyboard_locked(lock); 293 set_keyboard_locked(lock);
301 ShowKeyboardInternal(display::kInvalidDisplayId); 294 ShowKeyboardInternal(display::kInvalidDisplayId);
302 } 295 }
303 296
304 void KeyboardController::ShowKeyboardInDisplay(int64_t display_id) { 297 void KeyboardController::ShowKeyboardInDisplay(int64_t display_id) {
305 set_keyboard_locked(true); 298 set_keyboard_locked(true);
306 ShowKeyboardInternal(display_id); 299 ShowKeyboardInternal(display_id);
307 } 300 }
308 301
309 bool KeyboardController::IsKeyboardWindowCreated() { 302 bool KeyboardController::IsKeyboardWindowCreated() {
310 return keyboard_container_initialized() && ui_->HasKeyboardWindow(); 303 return keyboard_container_initialized() && ui_->HasKeyboardWindow();
311 } 304 }
312 305
313 void KeyboardController::OnWindowHierarchyChanged( 306 void KeyboardController::OnWindowHierarchyChanged(
314 const HierarchyChangeParams& params) { 307 const HierarchyChangeParams& params) {
315 if (params.new_parent && params.target == container_.get()) 308 if (params.new_parent && params.target == container_.get())
316 OnTextInputStateChanged(ui_->GetInputMethod()->GetTextInputClient()); 309 OnTextInputStateChanged(ui_->GetInputMethod()->GetTextInputClient());
317 } 310 }
318 311
319 void KeyboardController::OnWindowAddedToRootWindow(aura::Window* window) { 312 void KeyboardController::OnWindowAddedToRootWindow(aura::Window* window) {
320 if (!window->GetRootWindow()->HasObserver(this)) 313 if (!window->GetRootWindow()->HasObserver(this))
321 window->GetRootWindow()->AddObserver(this); 314 window->GetRootWindow()->AddObserver(this);
315 AdjustKeyboardBounds();
322 } 316 }
323 317
324 void KeyboardController::OnWindowRemovingFromRootWindow(aura::Window* window, 318 void KeyboardController::OnWindowRemovingFromRootWindow(aura::Window* window,
325 aura::Window* new_root) { 319 aura::Window* new_root) {
326 if (window->GetRootWindow()->HasObserver(this)) 320 if (window->GetRootWindow()->HasObserver(this))
327 window->GetRootWindow()->RemoveObserver(this); 321 window->GetRootWindow()->RemoveObserver(this);
328 } 322 }
329 323
330 void KeyboardController::OnWindowBoundsChanged(aura::Window* window, 324 void KeyboardController::OnWindowBoundsChanged(aura::Window* window,
331 const gfx::Rect& old_bounds, 325 const gfx::Rect& old_bounds,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 NotifyKeyboardBoundsChanging(container_->bounds()); 498 NotifyKeyboardBoundsChanging(container_->bounds());
505 ui_->EnsureCaretInWorkArea(); 499 ui_->EnsureCaretInWorkArea();
506 } 500 }
507 501
508 void KeyboardController::HideAnimationFinished() { 502 void KeyboardController::HideAnimationFinished() {
509 ui_->HideKeyboardContainer(container_.get()); 503 ui_->HideKeyboardContainer(container_.get());
510 for (KeyboardControllerObserver& observer : observer_list_) 504 for (KeyboardControllerObserver& observer : observer_list_)
511 observer.OnKeyboardHidden(); 505 observer.OnKeyboardHidden();
512 } 506 }
513 507
508 void KeyboardController::AdjustKeyboardBounds() {
509 if (keyboard_mode_ == FLOATING) {
bshe 2017/01/11 14:37:35 nit: if (keyboard_mode == FLOATING) return;
yhanada 2017/01/12 14:26:11 Done.
510 // When keyboard is floating, no resize is necessary.
511 } else if (keyboard_mode_ == FULL_WIDTH) {
512 // TODO(bshe): revisit this logic after we decide to support resize virtual
513 // keyboard.
514 int keyboard_height = GetContainerWindow()->bounds().height();
515 const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds();
516 gfx::Rect new_bounds = root_bounds;
517 new_bounds.set_y(root_bounds.height() - keyboard_height);
518 new_bounds.set_height(keyboard_height);
519 GetContainerWindow()->SetBounds(new_bounds);
520 }
521 }
522
514 } // namespace keyboard 523 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_controller.h ('k') | ui/keyboard/keyboard_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698