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

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

Issue 2629233003: Revert of Change the keyboard bounds when moving to another display. (Closed)
Patch Set: 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 AdjustKeyboardBounds(); 286 // TODO(bshe): revisit this logic after we decide to support resize virtual
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);
287 // No animation added, so call ShowAnimationFinished immediately. 294 // No animation added, so call ShowAnimationFinished immediately.
288 ShowAnimationFinished(); 295 ShowAnimationFinished();
289 } 296 }
290 } 297 }
291 298
292 void KeyboardController::ShowKeyboard(bool lock) { 299 void KeyboardController::ShowKeyboard(bool lock) {
293 set_keyboard_locked(lock); 300 set_keyboard_locked(lock);
294 ShowKeyboardInternal(display::kInvalidDisplayId); 301 ShowKeyboardInternal(display::kInvalidDisplayId);
295 } 302 }
296 303
297 void KeyboardController::ShowKeyboardInDisplay(int64_t display_id) { 304 void KeyboardController::ShowKeyboardInDisplay(int64_t display_id) {
298 set_keyboard_locked(true); 305 set_keyboard_locked(true);
299 ShowKeyboardInternal(display_id); 306 ShowKeyboardInternal(display_id);
300 } 307 }
301 308
302 bool KeyboardController::IsKeyboardWindowCreated() { 309 bool KeyboardController::IsKeyboardWindowCreated() {
303 return keyboard_container_initialized() && ui_->HasKeyboardWindow(); 310 return keyboard_container_initialized() && ui_->HasKeyboardWindow();
304 } 311 }
305 312
306 void KeyboardController::OnWindowHierarchyChanged( 313 void KeyboardController::OnWindowHierarchyChanged(
307 const HierarchyChangeParams& params) { 314 const HierarchyChangeParams& params) {
308 if (params.new_parent && params.target == container_.get()) 315 if (params.new_parent && params.target == container_.get())
309 OnTextInputStateChanged(ui_->GetInputMethod()->GetTextInputClient()); 316 OnTextInputStateChanged(ui_->GetInputMethod()->GetTextInputClient());
310 } 317 }
311 318
312 void KeyboardController::OnWindowAddedToRootWindow(aura::Window* window) { 319 void KeyboardController::OnWindowAddedToRootWindow(aura::Window* window) {
313 if (!window->GetRootWindow()->HasObserver(this)) 320 if (!window->GetRootWindow()->HasObserver(this))
314 window->GetRootWindow()->AddObserver(this); 321 window->GetRootWindow()->AddObserver(this);
315 AdjustKeyboardBounds();
316 } 322 }
317 323
318 void KeyboardController::OnWindowRemovingFromRootWindow(aura::Window* window, 324 void KeyboardController::OnWindowRemovingFromRootWindow(aura::Window* window,
319 aura::Window* new_root) { 325 aura::Window* new_root) {
320 if (window->GetRootWindow()->HasObserver(this)) 326 if (window->GetRootWindow()->HasObserver(this))
321 window->GetRootWindow()->RemoveObserver(this); 327 window->GetRootWindow()->RemoveObserver(this);
322 } 328 }
323 329
324 void KeyboardController::OnWindowBoundsChanged(aura::Window* window, 330 void KeyboardController::OnWindowBoundsChanged(aura::Window* window,
325 const gfx::Rect& old_bounds, 331 const gfx::Rect& old_bounds,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 NotifyKeyboardBoundsChanging(container_->bounds()); 504 NotifyKeyboardBoundsChanging(container_->bounds());
499 ui_->EnsureCaretInWorkArea(); 505 ui_->EnsureCaretInWorkArea();
500 } 506 }
501 507
502 void KeyboardController::HideAnimationFinished() { 508 void KeyboardController::HideAnimationFinished() {
503 ui_->HideKeyboardContainer(container_.get()); 509 ui_->HideKeyboardContainer(container_.get());
504 for (KeyboardControllerObserver& observer : observer_list_) 510 for (KeyboardControllerObserver& observer : observer_list_)
505 observer.OnKeyboardHidden(); 511 observer.OnKeyboardHidden();
506 } 512 }
507 513
508 void KeyboardController::AdjustKeyboardBounds() {
509 // When keyboard is floating, no resize is necessary.
510 if (keyboard_mode_ == FLOATING)
511 return;
512
513 if (keyboard_mode_ == FULL_WIDTH) {
514 // TODO(bshe): revisit this logic after we decide to support resize virtual
515 // keyboard.
516 int keyboard_height = GetContainerWindow()->bounds().height();
517 const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds();
518 gfx::Rect new_bounds = root_bounds;
519 new_bounds.set_y(root_bounds.height() - keyboard_height);
520 new_bounds.set_height(keyboard_height);
521 GetContainerWindow()->SetBounds(new_bounds);
522 }
523 }
524
525 } // namespace keyboard 514 } // 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