| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "mojo/examples/keyboard/keyboard.mojom.h" | 7 #include "mojo/examples/keyboard/keyboard.mojom.h" |
| 8 #include "mojo/examples/window_manager/debug_panel.h" | 8 #include "mojo/examples/window_manager/debug_panel.h" |
| 9 #include "mojo/examples/window_manager/window_manager.mojom.h" | 9 #include "mojo/examples/window_manager/window_manager.mojom.h" |
| 10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 int32_t code, | 133 int32_t code, |
| 134 int32_t flags) OVERRIDE { | 134 int32_t flags) OVERRIDE { |
| 135 View* view = view_manager_->GetViewById(view_id); | 135 View* view = view_manager_->GetViewById(view_id); |
| 136 if (!view) | 136 if (!view) |
| 137 return; | 137 return; |
| 138 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
| 139 const bool is_char = code != ui::VKEY_BACK && code != ui::VKEY_RETURN; | 139 const bool is_char = code != ui::VKEY_BACK && code != ui::VKEY_RETURN; |
| 140 #else | 140 #else |
| 141 const bool is_char = false; | 141 const bool is_char = false; |
| 142 #endif | 142 #endif |
| 143 view_manager_->DispatchEvent( | 143 if (is_char) { |
| 144 view, | 144 view_manager_->DispatchEvent( |
| 145 Event::From(ui::KeyEvent(ui::ET_KEY_PRESSED, | 145 view, |
| 146 static_cast<ui::KeyboardCode>(code), | 146 Event::From(ui::KeyEvent(ui::ET_KEY_PRESSED, |
| 147 flags, is_char))); | 147 static_cast<ui::KeyboardCode>(code), |
| 148 flags))); |
| 149 } else { |
| 150 view_manager_->DispatchEvent( |
| 151 view, |
| 152 Event::From(ui::KeyEvent(static_cast<base::char16>(code), |
| 153 static_cast<ui::KeyboardCode>(code), |
| 154 flags))); |
| 155 } |
| 148 view_manager_->DispatchEvent( | 156 view_manager_->DispatchEvent( |
| 149 view, | 157 view, |
| 150 Event::From(ui::KeyEvent(ui::ET_KEY_RELEASED, | 158 Event::From(ui::KeyEvent(ui::ET_KEY_RELEASED, |
| 151 static_cast<ui::KeyboardCode>(code), | 159 static_cast<ui::KeyboardCode>(code), |
| 152 flags, false))); | 160 flags))); |
| 153 } | 161 } |
| 154 | 162 |
| 155 // Overridden from NodeObserver: | 163 // Overridden from NodeObserver: |
| 156 virtual void OnNodeBoundsChanged(Node* parent, | 164 virtual void OnNodeBoundsChanged(Node* parent, |
| 157 const gfx::Rect& old_bounds, | 165 const gfx::Rect& old_bounds, |
| 158 const gfx::Rect& new_bounds) OVERRIDE { | 166 const gfx::Rect& new_bounds) OVERRIDE { |
| 159 gfx::Rect keyboard_bounds(node_->bounds()); | 167 gfx::Rect keyboard_bounds(node_->bounds()); |
| 160 keyboard_bounds.set_y(new_bounds.bottom() - keyboard_bounds.height()); | 168 keyboard_bounds.set_y(new_bounds.bottom() - keyboard_bounds.height()); |
| 161 keyboard_bounds.set_width(keyboard_bounds.width() + | 169 keyboard_bounds.set_width(keyboard_bounds.width() + |
| 162 new_bounds.width() - old_bounds.width()); | 170 new_bounds.width() - old_bounds.width()); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 } | 557 } |
| 550 | 558 |
| 551 } // namespace examples | 559 } // namespace examples |
| 552 | 560 |
| 553 // static | 561 // static |
| 554 ApplicationDelegate* ApplicationDelegate::Create() { | 562 ApplicationDelegate* ApplicationDelegate::Create() { |
| 555 return new examples::WindowManager; | 563 return new examples::WindowManager; |
| 556 } | 564 } |
| 557 | 565 |
| 558 } // namespace mojo | 566 } // namespace mojo |
| OLD | NEW |