| Index: ui/keyboard/keyboard_controller.cc
|
| diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc
|
| index 3e01d812f34e6ba921cf3df03c8c39baec5aa2ee..d4d3ceca44f7b01f0857e0d166a49ad870946800 100644
|
| --- a/ui/keyboard/keyboard_controller.cc
|
| +++ b/ui/keyboard/keyboard_controller.cc
|
| @@ -6,11 +6,24 @@
|
|
|
| #include "ui/aura/layout_manager.h"
|
| #include "ui/aura/window.h"
|
| +#include "ui/aura/window_delegate.h"
|
| +#include "ui/base/hit_test.h"
|
| +#include "ui/gfx/path.h"
|
| #include "ui/gfx/rect.h"
|
| +#include "ui/gfx/skia_util.h"
|
| #include "ui/keyboard/keyboard_controller_proxy.h"
|
|
|
| namespace {
|
|
|
| +gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds) {
|
| + const float kKeyboardHeightRatio = 0.3f;
|
| + return gfx::Rect(
|
| + window_bounds.x(),
|
| + window_bounds.y() + window_bounds.height() * (1 - kKeyboardHeightRatio),
|
| + window_bounds.width(),
|
| + window_bounds.height() * kKeyboardHeightRatio);
|
| +}
|
| +
|
| // LayoutManager for the virtual keyboard container. Manages a single window
|
| // (the virtual keyboard) and keeps it positioned at the bottom of the
|
| // container window.
|
| @@ -21,13 +34,8 @@ class KeyboardLayoutManager : public aura::LayoutManager {
|
|
|
| // Overridden from aura::LayoutManager
|
| virtual void OnWindowResized() OVERRIDE {
|
| - gfx::Rect owner_bounds = owner_->bounds();
|
| - gfx::Rect keyboard_bounds = gfx::Rect(
|
| - owner_bounds.x(),
|
| - owner_bounds.y() + owner_bounds.height() * 0.7,
|
| - owner_bounds.width(),
|
| - owner_bounds.height() * 0.3);
|
| - SetChildBoundsDirect(keyboard_, keyboard_bounds);
|
| + SetChildBoundsDirect(keyboard_,
|
| + KeyboardBoundsFromWindowBounds(owner_->bounds()));
|
| }
|
| virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE {
|
| CHECK(child == keyboard_);
|
| @@ -48,6 +56,52 @@ class KeyboardLayoutManager : public aura::LayoutManager {
|
| DISALLOW_COPY_AND_ASSIGN(KeyboardLayoutManager);
|
| };
|
|
|
| +// The KeyboardWindowDelegate makes sure the keyboard-window does not get focus.
|
| +// This is necessary to make sure that the synthetic key-events reach the target
|
| +// window.
|
| +// The delegate deletes itself when the window is destroyed.
|
| +class KeyboardWindowDelegate : public aura::WindowDelegate {
|
| + public:
|
| + KeyboardWindowDelegate() {}
|
| + virtual ~KeyboardWindowDelegate() {}
|
| +
|
| + private:
|
| + // Overridden from aura::WindowDelegate:
|
| + virtual gfx::Size GetMinimumSize() const OVERRIDE { return gfx::Size(); }
|
| + virtual gfx::Size GetMaximumSize() const OVERRIDE { return gfx::Size(); }
|
| + virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
|
| + const gfx::Rect& new_bounds) OVERRIDE {
|
| + bounds_ = new_bounds;
|
| + }
|
| + virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
|
| + return gfx::kNullCursor;
|
| + }
|
| + virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE {
|
| + return HTNOWHERE;
|
| + }
|
| + virtual bool ShouldDescendIntoChildForEventHandling(
|
| + aura::Window* child,
|
| + const gfx::Point& location) OVERRIDE {
|
| + return true;
|
| + }
|
| + virtual bool CanFocus() OVERRIDE { return false; }
|
| + virtual void OnCaptureLost() OVERRIDE {}
|
| + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {}
|
| + virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {}
|
| + virtual void OnWindowDestroying() OVERRIDE {}
|
| + virtual void OnWindowDestroyed() OVERRIDE { delete this; }
|
| + virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {}
|
| + virtual bool HasHitTestMask() const OVERRIDE { return true; }
|
| + virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {
|
| + gfx::Rect keyboard_bounds = KeyboardBoundsFromWindowBounds(bounds_);
|
| + mask->addRect(RectToSkRect(keyboard_bounds));
|
| + }
|
| + virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE { return NULL; }
|
| +
|
| + gfx::Rect bounds_;
|
| + DISALLOW_COPY_AND_ASSIGN(KeyboardWindowDelegate);
|
| +};
|
| +
|
| } // namespace
|
|
|
| namespace keyboard {
|
| @@ -61,7 +115,7 @@ KeyboardController::~KeyboardController() {}
|
|
|
| aura::Window* KeyboardController::GetContainerWindow() {
|
| if (!container_) {
|
| - container_ = new aura::Window(NULL);
|
| + container_ = new aura::Window(new KeyboardWindowDelegate());
|
| container_->SetName("KeyboardContainer");
|
| container_->Init(ui::LAYER_NOT_DRAWN);
|
|
|
|
|