OLD | NEW |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 keyboard::KeyboardControllerProxy* proxy) | 55 keyboard::KeyboardControllerProxy* proxy) |
56 : wm::MaskedWindowTargeter(container), | 56 : wm::MaskedWindowTargeter(container), |
57 proxy_(proxy) { | 57 proxy_(proxy) { |
58 } | 58 } |
59 | 59 |
60 virtual ~KeyboardContainerTargeter() {} | 60 virtual ~KeyboardContainerTargeter() {} |
61 | 61 |
62 private: | 62 private: |
63 // wm::MaskedWindowTargeter: | 63 // wm::MaskedWindowTargeter: |
64 virtual bool GetHitTestMask(aura::Window* window, | 64 virtual bool GetHitTestMask(aura::Window* window, |
65 gfx::Path* mask) const OVERRIDE { | 65 gfx::Path* mask) const override { |
66 if (proxy_ && !proxy_->HasKeyboardWindow()) | 66 if (proxy_ && !proxy_->HasKeyboardWindow()) |
67 return true; | 67 return true; |
68 gfx::Rect keyboard_bounds = proxy_ ? proxy_->GetKeyboardWindow()->bounds() : | 68 gfx::Rect keyboard_bounds = proxy_ ? proxy_->GetKeyboardWindow()->bounds() : |
69 keyboard::DefaultKeyboardBoundsFromWindowBounds(window->bounds()); | 69 keyboard::DefaultKeyboardBoundsFromWindowBounds(window->bounds()); |
70 mask->addRect(RectToSkRect(keyboard_bounds)); | 70 mask->addRect(RectToSkRect(keyboard_bounds)); |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 keyboard::KeyboardControllerProxy* proxy_; | 74 keyboard::KeyboardControllerProxy* proxy_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerTargeter); | 76 DISALLOW_COPY_AND_ASSIGN(KeyboardContainerTargeter); |
77 }; | 77 }; |
78 | 78 |
79 // The KeyboardWindowDelegate makes sure the keyboard-window does not get focus. | 79 // The KeyboardWindowDelegate makes sure the keyboard-window does not get focus. |
80 // This is necessary to make sure that the synthetic key-events reach the target | 80 // This is necessary to make sure that the synthetic key-events reach the target |
81 // window. | 81 // window. |
82 // The delegate deletes itself when the window is destroyed. | 82 // The delegate deletes itself when the window is destroyed. |
83 class KeyboardWindowDelegate : public aura::WindowDelegate { | 83 class KeyboardWindowDelegate : public aura::WindowDelegate { |
84 public: | 84 public: |
85 explicit KeyboardWindowDelegate(keyboard::KeyboardControllerProxy* proxy) | 85 explicit KeyboardWindowDelegate(keyboard::KeyboardControllerProxy* proxy) |
86 : proxy_(proxy) {} | 86 : proxy_(proxy) {} |
87 virtual ~KeyboardWindowDelegate() {} | 87 virtual ~KeyboardWindowDelegate() {} |
88 | 88 |
89 private: | 89 private: |
90 // Overridden from aura::WindowDelegate: | 90 // Overridden from aura::WindowDelegate: |
91 virtual gfx::Size GetMinimumSize() const OVERRIDE { return gfx::Size(); } | 91 virtual gfx::Size GetMinimumSize() const override { return gfx::Size(); } |
92 virtual gfx::Size GetMaximumSize() const OVERRIDE { return gfx::Size(); } | 92 virtual gfx::Size GetMaximumSize() const override { return gfx::Size(); } |
93 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | 93 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, |
94 const gfx::Rect& new_bounds) OVERRIDE { | 94 const gfx::Rect& new_bounds) override { |
95 bounds_ = new_bounds; | 95 bounds_ = new_bounds; |
96 } | 96 } |
97 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE { | 97 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) override { |
98 return gfx::kNullCursor; | 98 return gfx::kNullCursor; |
99 } | 99 } |
100 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE { | 100 virtual int GetNonClientComponent(const gfx::Point& point) const override { |
101 return HTNOWHERE; | 101 return HTNOWHERE; |
102 } | 102 } |
103 virtual bool ShouldDescendIntoChildForEventHandling( | 103 virtual bool ShouldDescendIntoChildForEventHandling( |
104 aura::Window* child, | 104 aura::Window* child, |
105 const gfx::Point& location) OVERRIDE { | 105 const gfx::Point& location) override { |
106 return true; | 106 return true; |
107 } | 107 } |
108 virtual bool CanFocus() OVERRIDE { return false; } | 108 virtual bool CanFocus() override { return false; } |
109 virtual void OnCaptureLost() OVERRIDE {} | 109 virtual void OnCaptureLost() override {} |
110 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {} | 110 virtual void OnPaint(gfx::Canvas* canvas) override {} |
111 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {} | 111 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override {} |
112 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {} | 112 virtual void OnWindowDestroying(aura::Window* window) override {} |
113 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE { delete this; } | 113 virtual void OnWindowDestroyed(aura::Window* window) override { delete this; } |
114 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {} | 114 virtual void OnWindowTargetVisibilityChanged(bool visible) override {} |
115 virtual bool HasHitTestMask() const OVERRIDE { | 115 virtual bool HasHitTestMask() const override { |
116 return !proxy_ || proxy_->HasKeyboardWindow(); | 116 return !proxy_ || proxy_->HasKeyboardWindow(); |
117 } | 117 } |
118 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE { | 118 virtual void GetHitTestMask(gfx::Path* mask) const override { |
119 if (proxy_ && !proxy_->HasKeyboardWindow()) | 119 if (proxy_ && !proxy_->HasKeyboardWindow()) |
120 return; | 120 return; |
121 gfx::Rect keyboard_bounds = proxy_ ? proxy_->GetKeyboardWindow()->bounds() : | 121 gfx::Rect keyboard_bounds = proxy_ ? proxy_->GetKeyboardWindow()->bounds() : |
122 keyboard::DefaultKeyboardBoundsFromWindowBounds(bounds_); | 122 keyboard::DefaultKeyboardBoundsFromWindowBounds(bounds_); |
123 mask->addRect(RectToSkRect(keyboard_bounds)); | 123 mask->addRect(RectToSkRect(keyboard_bounds)); |
124 } | 124 } |
125 | 125 |
126 gfx::Rect bounds_; | 126 gfx::Rect bounds_; |
127 keyboard::KeyboardControllerProxy* proxy_; | 127 keyboard::KeyboardControllerProxy* proxy_; |
128 | 128 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // Observer for both keyboard show and hide animations. It should be owned by | 164 // Observer for both keyboard show and hide animations. It should be owned by |
165 // KeyboardController. | 165 // KeyboardController. |
166 class CallbackAnimationObserver : public ui::LayerAnimationObserver { | 166 class CallbackAnimationObserver : public ui::LayerAnimationObserver { |
167 public: | 167 public: |
168 CallbackAnimationObserver(ui::LayerAnimator* animator, | 168 CallbackAnimationObserver(ui::LayerAnimator* animator, |
169 base::Callback<void(void)> callback); | 169 base::Callback<void(void)> callback); |
170 virtual ~CallbackAnimationObserver(); | 170 virtual ~CallbackAnimationObserver(); |
171 | 171 |
172 private: | 172 private: |
173 // Overridden from ui::LayerAnimationObserver: | 173 // Overridden from ui::LayerAnimationObserver: |
174 virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) OVERRIDE; | 174 virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override; |
175 virtual void OnLayerAnimationAborted( | 175 virtual void OnLayerAnimationAborted( |
176 ui::LayerAnimationSequence* seq) OVERRIDE; | 176 ui::LayerAnimationSequence* seq) override; |
177 virtual void OnLayerAnimationScheduled( | 177 virtual void OnLayerAnimationScheduled( |
178 ui::LayerAnimationSequence* seq) OVERRIDE {} | 178 ui::LayerAnimationSequence* seq) override {} |
179 | 179 |
180 ui::LayerAnimator* animator_; | 180 ui::LayerAnimator* animator_; |
181 base::Callback<void(void)> callback_; | 181 base::Callback<void(void)> callback_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); | 183 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); |
184 }; | 184 }; |
185 | 185 |
186 CallbackAnimationObserver::CallbackAnimationObserver( | 186 CallbackAnimationObserver::CallbackAnimationObserver( |
187 ui::LayerAnimator* animator, base::Callback<void(void)> callback) | 187 ui::LayerAnimator* animator, base::Callback<void(void)> callback) |
188 : animator_(animator), callback_(callback) { | 188 : animator_(animator), callback_(callback) { |
(...skipping 13 matching lines...) Expand all Loading... |
202 | 202 |
203 void CallbackAnimationObserver::OnLayerAnimationAborted( | 203 void CallbackAnimationObserver::OnLayerAnimationAborted( |
204 ui::LayerAnimationSequence* seq) { | 204 ui::LayerAnimationSequence* seq) { |
205 animator_->RemoveObserver(this); | 205 animator_->RemoveObserver(this); |
206 } | 206 } |
207 | 207 |
208 class WindowBoundsChangeObserver : public aura::WindowObserver { | 208 class WindowBoundsChangeObserver : public aura::WindowObserver { |
209 public: | 209 public: |
210 virtual void OnWindowBoundsChanged(aura::Window* window, | 210 virtual void OnWindowBoundsChanged(aura::Window* window, |
211 const gfx::Rect& old_bounds, | 211 const gfx::Rect& old_bounds, |
212 const gfx::Rect& new_bounds) OVERRIDE; | 212 const gfx::Rect& new_bounds) override; |
213 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | 213 virtual void OnWindowDestroyed(aura::Window* window) override; |
214 | 214 |
215 void AddObservedWindow(aura::Window* window); | 215 void AddObservedWindow(aura::Window* window); |
216 void RemoveAllObservedWindows(); | 216 void RemoveAllObservedWindows(); |
217 | 217 |
218 private: | 218 private: |
219 std::set<aura::Window*> observed_windows_; | 219 std::set<aura::Window*> observed_windows_; |
220 }; | 220 }; |
221 | 221 |
222 void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window, | 222 void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window, |
223 const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { | 223 const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 proxy_->HideKeyboardContainer(container_.get()); | 578 proxy_->HideKeyboardContainer(container_.get()); |
579 } | 579 } |
580 | 580 |
581 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { | 581 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
582 aura::Window* target_window = GetFrameWindow(window); | 582 aura::Window* target_window = GetFrameWindow(window); |
583 if (target_window) | 583 if (target_window) |
584 window_bounds_observer_->AddObservedWindow(target_window); | 584 window_bounds_observer_->AddObservedWindow(target_window); |
585 } | 585 } |
586 | 586 |
587 } // namespace keyboard | 587 } // namespace keyboard |
OLD | NEW |