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

Unified Diff: ash/wm/workspace/workspace_layout_manager.cc

Issue 313463002: Prevent a11y on-screen keyboard from occluding active text field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/workspace/workspace_layout_manager.cc
diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc
index 668f895d2eae1b1e240eaa5fc0b063c997bf4211..bb6eb5c37533bb7617ecf01b5437873c050e72ad 100644
--- a/ash/wm/workspace/workspace_layout_manager.cc
+++ b/ash/wm/workspace/workspace_layout_manager.cc
@@ -21,10 +21,13 @@
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/text_input_client.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer.h"
#include "ui/events/event.h"
#include "ui/gfx/screen.h"
+#include "ui/keyboard/keyboard_controller_observer.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
@@ -124,6 +127,34 @@ void WorkspaceLayoutManager::SetChildBounds(
}
//////////////////////////////////////////////////////////////////////////////
+// WorkspaceLayoutManager, keyboard::KeyboardControllerObserver implementation:
+
+void WorkspaceLayoutManager::OnKeyboardBoundsChanging(
+ const gfx::Rect& new_bounds) {
+ aura::Window* root_window = window_->GetRootWindow();
+ ui::InputMethod* input_method =
+ root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
+ ui::TextInputClient* text_input_client = input_method->GetTextInputClient();
+ if(text_input_client) {
+ aura::Window *window = text_input_client->GetAttachedWindow();
+ if (window && window_->Contains(window)) {
flackr 2014/06/03 13:36:30 Use early returns rather than nesting if's
kevers 2014/06/03 15:32:44 Done.
+ gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen(
+ window_,
+ window->GetTargetBounds());
+ gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds);
+ if (intersect.height() > 0) {
flackr 2014/06/03 13:36:30 nit: This is basically a no-op, I would remove thi
kevers 2014/06/03 15:32:44 Done.
+ int shift = std::min(intersect.height(),
+ window->bounds().y() - work_area_in_parent_.y());
+ if (shift != 0) {
flackr 2014/06/03 13:36:30 nit: shift > 0.
kevers 2014/06/03 15:32:44 Done.
+ gfx::Point origin(window->bounds().x(), window->bounds().y() - shift);
+ SetChildBounds(window, gfx::Rect(origin, window->bounds().size()));
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
// WorkspaceLayoutManager, ash::ShellObserver implementation:
void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() {

Powered by Google App Engine
This is Rietveld 408576698