summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpschoedel@chromium.org <kpschoedel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-25 17:10:17 +0000
committerkpschoedel@chromium.org <kpschoedel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-25 17:10:17 +0000
commit947211d035a701096dfd2641c14c348b897ee8f4 (patch)
tree24749f5a778bf736ca9758a8f6fddebaadb36b09
parent7225f8584c2672e7ea20514f6f79dfe42aa670e9 (diff)
downloadchromium_src-947211d035a701096dfd2641c14c348b897ee8f4.zip
chromium_src-947211d035a701096dfd2641c14c348b897ee8f4.tar.gz
chromium_src-947211d035a701096dfd2641c14c348b897ee8f4.tar.bz2
Distinguish between keystroke and character events.
As described in its class comment, a ui::KeyEvent can be either of two distinct kinds. When constructing a ui::KeyEvent from a native event, the distinction is made by a new IsCharFromNative() call, in the same way that other ui::Event properties are determined, instead of having the caller inspect the native event itself. Removing the redundant |is_char| parameter from constructors also prevent accidental synthetic `mixed' events that consuming code does not handle. Incidentally, while KeyEvent constructor calls are being touched, use EF_NONE instead of 0 to make that argument's purpose clear. BUG=380349 TEST=unit_tests,ash_unittests,events_unittests,ui_unittests,interactive_ui_tests Review URL: https://codereview.chromium.org/404203003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285605 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/accelerators/accelerator_controller_unittest.cc12
-rw-r--r--ash/accelerators/accelerator_filter_unittest.cc6
-rw-r--r--ash/accelerators/key_hold_detector.cc2
-rw-r--r--ash/accelerators/magnifier_key_scroller_unittest.cc2
-rw-r--r--ash/keyboard_overlay/keyboard_overlay_view_unittest.cc3
-rw-r--r--ash/shelf/shelf.cc3
-rw-r--r--ash/shelf/shelf_tooltip_manager_unittest.cc2
-rw-r--r--ash/sticky_keys/sticky_keys_unittest.cc4
-rw-r--r--ash/wm/window_manager_unittest.cc4
-rw-r--r--chrome/browser/chromeos/events/event_rewriter.cc2
-rw-r--r--chrome/browser/chromeos/events/event_rewriter_unittest.cc20
-rw-r--r--chrome/browser/chromeos/events/keyboard_driven_event_rewriter_unittest.cc2
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine.cc6
-rw-r--r--chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc22
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc3
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views_unittest.cc2
-rw-r--r--chrome/browser/ui/views/extensions/media_galleries_dialog_views_unittest.cc2
-rw-r--r--content/browser/renderer_host/web_input_event_aura_unittest.cc8
-rw-r--r--content/browser/web_contents/aura/window_slider_unittest.cc5
-rw-r--r--content/renderer/render_view_browsertest.cc34
-rw-r--r--mojo/examples/window_manager/window_manager.cc20
-rw-r--r--mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc23
-rw-r--r--ui/app_list/views/apps_grid_view_unittest.cc2
-rw-r--r--ui/app_list/views/search_box_view_unittest.cc2
-rw-r--r--ui/app_list/views/search_result_list_view_unittest.cc2
-rw-r--r--ui/app_list/views/test/apps_grid_view_test_api.cc2
-rw-r--r--ui/aura/remote_window_tree_host_win.cc8
-rw-r--r--ui/aura/window_event_dispatcher_unittest.cc10
-rw-r--r--ui/aura/window_tree_host_x11.cc4
-rw-r--r--ui/base/ime/input_method_auralinux.cc3
-rw-r--r--ui/base/ime/input_method_chromeos.cc6
-rw-r--r--ui/base/ime/input_method_chromeos_unittest.cc14
-rw-r--r--ui/base/ime/input_method_win.cc3
-rw-r--r--ui/base/ime/remote_input_method_win_unittest.cc9
-rw-r--r--ui/chromeos/touch_exploration_controller.cc12
-rw-r--r--ui/chromeos/touch_exploration_controller_unittest.cc12
-rw-r--r--ui/events/cocoa/events_mac.mm4
-rw-r--r--ui/events/event.cc24
-rw-r--r--ui/events/event.h62
-rw-r--r--ui/events/event_processor_unittest.cc8
-rw-r--r--ui/events/event_unittest.cc93
-rw-r--r--ui/events/event_utils.cc2
-rw-r--r--ui/events/event_utils.h4
-rw-r--r--ui/events/events_stub.cc5
-rw-r--r--ui/events/ozone/evdev/key_event_converter_evdev.cc3
-rw-r--r--ui/events/ozone/events_ozone.cc6
-rw-r--r--ui/events/test/event_generator.cc12
-rw-r--r--ui/events/test/events_test_utils.cc5
-rw-r--r--ui/events/test/events_test_utils.h17
-rw-r--r--ui/events/win/events_win.cc4
-rw-r--r--ui/events/x/events_x.cc4
-rw-r--r--ui/events/x/events_x_unittest.cc17
-rw-r--r--ui/keyboard/keyboard_util.cc12
-rw-r--r--ui/platform_window/win/win_window.cc2
-rw-r--r--ui/platform_window/x11/x11_window.cc4
-rw-r--r--ui/views/controls/combobox/combobox_unittest.cc10
-rw-r--r--ui/views/controls/menu/menu_controller_unittest.cc2
-rw-r--r--ui/views/controls/table/table_view_unittest.cc2
-rw-r--r--ui/views/controls/textfield/textfield_unittest.cc5
-rw-r--r--ui/views/focus/focus_manager_unittest.cc12
-rw-r--r--ui/views/ime/mock_input_method.cc4
-rw-r--r--ui/views/view_targeter_unittest.cc2
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc8
-rw-r--r--ui/views/widget/root_view_unittest.cc8
-rw-r--r--ui/views/widget/widget_unittest.cc4
-rw-r--r--ui/views/win/hwnd_message_handler.cc2
-rw-r--r--ui/views/window/dialog_delegate_unittest.cc8
-rw-r--r--ui/wm/core/compound_event_filter_unittest.cc6
-rw-r--r--ui/wm/core/input_method_event_filter_unittest.cc3
-rw-r--r--ui/wm/core/nested_accelerator_dispatcher_linux.cc2
-rw-r--r--ui/wm/core/nested_accelerator_dispatcher_win.cc2
-rw-r--r--ui/wm/core/user_activity_detector_unittest.cc4
72 files changed, 373 insertions, 275 deletions
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index 4fecc24..c5fc1cf 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -623,37 +623,37 @@ TEST_F(AcceleratorControllerTest, MAYBE_ProcessOnce) {
Shell::GetPrimaryRootWindow()->GetHost()->event_processor();
#if defined(OS_WIN)
MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 };
- ui::KeyEvent key_event1(msg1, false);
+ ui::KeyEvent key_event1(msg1);
key_event1.SetTranslated(true);
ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event1);
EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed);
MSG msg2 = { NULL, WM_CHAR, L'A', 0 };
- ui::KeyEvent key_event2(msg2, true);
+ ui::KeyEvent key_event2(msg2);
key_event2.SetTranslated(true);
details = dispatcher->OnEventFromSource(&key_event2);
EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed);
MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 };
- ui::KeyEvent key_event3(msg3, false);
+ ui::KeyEvent key_event3(msg3);
key_event3.SetTranslated(true);
details = dispatcher->OnEventFromSource(&key_event3);
EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed);
#elif defined(USE_X11)
ui::ScopedXI2Event key_event;
key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0);
- ui::KeyEvent key_event1(key_event, false);
+ ui::KeyEvent key_event1(key_event);
key_event1.SetTranslated(true);
ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event1);
EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed);
- ui::KeyEvent key_event2(key_event, true);
+ ui::KeyEvent key_event2('A', ui::VKEY_A, ui::EF_NONE);
key_event2.SetTranslated(true);
details = dispatcher->OnEventFromSource(&key_event2);
EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed);
key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0);
- ui::KeyEvent key_event3(key_event, false);
+ ui::KeyEvent key_event3(key_event);
key_event3.SetTranslated(true);
details = dispatcher->OnEventFromSource(&key_event3);
EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed);
diff --git a/ash/accelerators/accelerator_filter_unittest.cc b/ash/accelerators/accelerator_filter_unittest.cc
index 69db831..67ff1d9 100644
--- a/ash/accelerators/accelerator_filter_unittest.cc
+++ b/ash/accelerators/accelerator_filter_unittest.cc
@@ -92,7 +92,7 @@ TEST_F(AcceleratorFilterTest, CanConsumeSystemKeys) {
aura::Window* root_window = Shell::GetPrimaryRootWindow();
// Normal keys are not consumed.
- ui::KeyEvent press_a(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
+ ui::KeyEvent press_a(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
{
ui::Event::DispatcherApi dispatch_helper(&press_a);
dispatch_helper.set_target(root_window);
@@ -102,7 +102,7 @@ TEST_F(AcceleratorFilterTest, CanConsumeSystemKeys) {
// System keys are directly consumed.
ui::KeyEvent press_mute(
- ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_MUTE, ui::EF_NONE, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
{
ui::Event::DispatcherApi dispatch_helper(&press_mute);
dispatch_helper.set_target(root_window);
@@ -114,7 +114,7 @@ TEST_F(AcceleratorFilterTest, CanConsumeSystemKeys) {
scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(1));
wm::GetWindowState(window.get())->set_can_consume_system_keys(true);
ui::KeyEvent press_volume_up(
- ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_UP, ui::EF_NONE, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_UP, ui::EF_NONE);
ui::Event::DispatcherApi dispatch_helper(&press_volume_up);
dispatch_helper.set_target(window.get());
filter.OnKeyEvent(&press_volume_up);
diff --git a/ash/accelerators/key_hold_detector.cc b/ash/accelerators/key_hold_detector.cc
index 179d4f3..131568e 100644
--- a/ash/accelerators/key_hold_detector.cc
+++ b/ash/accelerators/key_hold_detector.cc
@@ -25,7 +25,7 @@ void DispatchPressedEvent(XEvent native_event,
if (tracker->windows().empty())
return;
aura::Window* target = *(tracker->windows().begin());
- ui::KeyEvent event(&native_event, false);
+ ui::KeyEvent event(&native_event);
event.set_flags(event.flags() | ui::EF_IS_SYNTHESIZED);
ui::EventDispatchDetails result ALLOW_UNUSED =
target->GetHost()->event_processor()->OnEventFromSource(&event);
diff --git a/ash/accelerators/magnifier_key_scroller_unittest.cc b/ash/accelerators/magnifier_key_scroller_unittest.cc
index 21eb2ab..ad91abd 100644
--- a/ash/accelerators/magnifier_key_scroller_unittest.cc
+++ b/ash/accelerators/magnifier_key_scroller_unittest.cc
@@ -22,7 +22,7 @@ class KeyEventDelegate : public aura::test::TestWindowDelegate {
// ui::EventHandler overrides:
virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
key_event.reset(new ui::KeyEvent(
- event->type(), event->key_code(), event->flags(), false));
+ event->type(), event->key_code(), event->flags()));
}
const ui::KeyEvent* event() const { return key_event.get(); }
diff --git a/ash/keyboard_overlay/keyboard_overlay_view_unittest.cc b/ash/keyboard_overlay/keyboard_overlay_view_unittest.cc
index 8875f0e..19435a8 100644
--- a/ash/keyboard_overlay/keyboard_overlay_view_unittest.cc
+++ b/ash/keyboard_overlay/keyboard_overlay_view_unittest.cc
@@ -37,8 +37,7 @@ TEST_F(KeyboardOverlayViewTest, OpenAcceleratorsClose) {
ui::KeyEvent open_key(open_key_data.trigger_on_press ?
ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
open_key_data.keycode,
- open_key_data.modifiers,
- false);
+ open_key_data.modifiers);
EXPECT_TRUE(view.IsCancelingKeyEvent(&open_key));
}
}
diff --git a/ash/shelf/shelf.cc b/ash/shelf/shelf.cc
index f9d3704..08f32e2 100644
--- a/ash/shelf/shelf.cc
+++ b/ash/shelf/shelf.cc
@@ -105,8 +105,7 @@ void Shelf::ActivateShelfItem(int index) {
// next item if the current one is already active.
ui::KeyEvent event(ui::ET_KEY_RELEASED,
ui::VKEY_UNKNOWN, // The actual key gets ignored.
- ui::EF_NONE,
- false);
+ ui::EF_NONE);
const ShelfItem& item = shelf_view_->model()->items()[index];
ShelfItemDelegate* item_delegate =
diff --git a/ash/shelf/shelf_tooltip_manager_unittest.cc b/ash/shelf/shelf_tooltip_manager_unittest.cc
index 44237d3..295c7e9 100644
--- a/ash/shelf/shelf_tooltip_manager_unittest.cc
+++ b/ash/shelf/shelf_tooltip_manager_unittest.cc
@@ -183,7 +183,7 @@ TEST_F(ShelfTooltipManagerTest, ShouldHideForEvents) {
ui::EventHandler* event_handler = GetEventHandler();
// Should not hide for key events.
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
+ ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
SetEventTarget(root_window, &key_event);
event_handler->OnKeyEvent(&key_event);
EXPECT_FALSE(key_event.handled());
diff --git a/ash/sticky_keys/sticky_keys_unittest.cc b/ash/sticky_keys/sticky_keys_unittest.cc
index 6e2fa18..6505b65 100644
--- a/ash/sticky_keys/sticky_keys_unittest.cc
+++ b/ash/sticky_keys/sticky_keys_unittest.cc
@@ -58,7 +58,7 @@ class StickyKeysTest : public test::AshTestBase {
ui::KeyEvent* GenerateKey(ui::EventType type, ui::KeyboardCode code) {
scoped_xevent_.InitKeyEvent(type, code, 0);
- ui::KeyEvent* event = new ui::KeyEvent(scoped_xevent_, false);
+ ui::KeyEvent* event = new ui::KeyEvent(scoped_xevent_);
return event;
}
@@ -122,7 +122,7 @@ class StickyKeysTest : public test::AshTestBase {
// Creates a synthesized KeyEvent that is not backed by a native event.
ui::KeyEvent* GenerateSynthesizedKeyEvent(ui::EventType type,
ui::KeyboardCode code) {
- return new ui::KeyEvent(type, code, 0, true);
+ return new ui::KeyEvent(type, code, ui::EF_NONE);
}
// Creates a synthesized MouseEvent that is not backed by a native event.
diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc
index cc1a675..75b7e4e 100644
--- a/ash/wm/window_manager_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -185,7 +185,7 @@ TEST_F(WindowManagerTest, Focus) {
ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor();
// The key press should be sent to the focused sub-window.
- ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false);
+ ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE);
ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&keyev);
ASSERT_FALSE(details.dispatcher_destroyed);
EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code());
@@ -671,7 +671,7 @@ TEST_F(WindowManagerTest, AdditionalFilters) {
env_filter->AddHandler(f2.get());
// Dispatches mouse and keyboard events.
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
+ ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor();
ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event);
ASSERT_FALSE(details.dispatcher_destroyed);
diff --git a/chrome/browser/chromeos/events/event_rewriter.cc b/chrome/browser/chromeos/events/event_rewriter.cc
index bed4159..9169c0f 100644
--- a/chrome/browser/chromeos/events/event_rewriter.cc
+++ b/chrome/browser/chromeos/events/event_rewriter.cc
@@ -263,7 +263,7 @@ void EventRewriter::BuildRewrittenKeyEvent(
}
UpdateX11EventMask(flags, &xkeyevent.xkey.state);
- ui::KeyEvent x11_key_event(&xkeyevent, false);
+ ui::KeyEvent x11_key_event(&xkeyevent);
rewritten_key_event = new ui::KeyEvent(x11_key_event);
}
#endif
diff --git a/chrome/browser/chromeos/events/event_rewriter_unittest.cc b/chrome/browser/chromeos/events/event_rewriter_unittest.cc
index cdd5b76..4df68a1 100644
--- a/chrome/browser/chromeos/events/event_rewriter_unittest.cc
+++ b/chrome/browser/chromeos/events/event_rewriter_unittest.cc
@@ -64,7 +64,7 @@ std::string GetRewrittenEventAsString(chromeos::EventRewriter* rewriter,
ui::KeyboardCode ui_keycode,
int ui_flags,
ui::EventType ui_type) {
- const ui::KeyEvent event(ui_type, ui_keycode, ui_flags, false);
+ const ui::KeyEvent event(ui_type, ui_keycode, ui_flags);
scoped_ptr<ui::Event> new_event;
rewriter->RewriteEvent(event, &new_event);
if (new_event)
@@ -99,7 +99,7 @@ void CheckX11KeyTestCase(const std::string& expected,
chromeos::EventRewriter* rewriter,
const KeyTestCase& test,
XEvent* xevent) {
- ui::KeyEvent xkey_event(xevent, false);
+ ui::KeyEvent xkey_event(xevent);
if (test.test & KeyTestCase::NUMPAD)
xkey_event.set_flags(xkey_event.flags() | ui::EF_NUMPAD_KEY);
// Verify that the X11-based key event is as expected.
@@ -117,7 +117,7 @@ void CheckX11KeyTestCase(const std::string& expected,
// Build a new ui::KeyEvent from the rewritten native component,
// and check that it also matches the rewritten event.
EXPECT_TRUE(rewritten_key_event.native_event());
- ui::KeyEvent from_native_event(rewritten_key_event.native_event(), false);
+ ui::KeyEvent from_native_event(rewritten_key_event.native_event());
EXPECT_EQ(expected, GetKeyEventAsString(from_native_event));
}
}
@@ -194,7 +194,7 @@ void CheckFunctionKeyTestCase(chromeos::EventRewriter* rewriter,
xev.InitKeyEvent(test.type, test.input.key_code, test.input.flags);
XEvent* xevent = xev;
if (xevent->xkey.keycode) {
- ui::KeyEvent xkey_event(xevent, false);
+ ui::KeyEvent xkey_event(xevent);
// Rewrite the event and check the result.
scoped_ptr<ui::Event> new_event;
rewriter->RewriteEvent(xkey_event, &new_event);
@@ -1713,7 +1713,7 @@ TEST_F(EventRewriterTest, TestRewriteKeyEventSentByXSendEvent) {
// Send left control press.
{
ui::KeyEvent keyevent(
- ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, ui::EF_FINAL, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, ui::EF_FINAL);
scoped_ptr<ui::Event> new_event;
// Control should NOT be remapped to Alt if EF_FINAL is set.
EXPECT_EQ(ui::EVENT_REWRITE_CONTINUE,
@@ -1728,7 +1728,7 @@ TEST_F(EventRewriterTest, TestRewriteKeyEventSentByXSendEvent) {
XEvent* xevent = xev;
xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), XK_Control_L);
xevent->xkey.send_event = True; // XSendEvent() always does this.
- ui::KeyEvent keyevent(xev, false /* is_char */);
+ ui::KeyEvent keyevent(xev);
scoped_ptr<ui::Event> new_event;
// Control should NOT be remapped to Alt if send_event
// flag in the event is True.
@@ -1832,7 +1832,7 @@ class EventRewriterAshTest : public ash::test::AshTestBase {
}
void SendKeyEvent(ui::EventType type, ui::KeyboardCode key_code) {
- ui::KeyEvent press(type, key_code, ui::EF_NONE, false);
+ ui::KeyEvent press(type, key_code, ui::EF_NONE);
ui::EventDispatchDetails details = Send(&press);
CHECK(!details.dispatcher_destroyed);
}
@@ -1891,7 +1891,7 @@ TEST_F(EventRewriterAshTest, TopRowKeysAreFunctionKeys) {
ScopedVector<ui::Event> events;
// Create a simulated keypress of F1 targetted at the window.
- ui::KeyEvent press_f1(ui::ET_KEY_PRESSED, ui::VKEY_F1, 0, false);
+ ui::KeyEvent press_f1(ui::ET_KEY_PRESSED, ui::VKEY_F1, ui::EF_NONE);
// Simulate an apps v2 window that has requested top row keys as function
// keys. The event should not be rewritten.
@@ -2197,7 +2197,7 @@ TEST_F(EventRewriterAshTest, StickyKeyEventDispatchImpl) {
// Test key press event is correctly modified and modifier release
// event is sent.
- ui::KeyEvent press(ui::ET_KEY_PRESSED, ui::VKEY_C, ui::EF_NONE, false);
+ ui::KeyEvent press(ui::ET_KEY_PRESSED, ui::VKEY_C, ui::EF_NONE);
ui::EventDispatchDetails details = Send(&press);
PopEvents(&events);
EXPECT_EQ(2u, events.size());
@@ -2209,7 +2209,7 @@ TEST_F(EventRewriterAshTest, StickyKeyEventDispatchImpl) {
static_cast<ui::KeyEvent*>(events[1])->key_code());
// Test key release event is not modified.
- ui::KeyEvent release(ui::ET_KEY_RELEASED, ui::VKEY_C, ui::EF_NONE, false);
+ ui::KeyEvent release(ui::ET_KEY_RELEASED, ui::VKEY_C, ui::EF_NONE);
details = Send(&release);
ASSERT_FALSE(details.dispatcher_destroyed);
PopEvents(&events);
diff --git a/chrome/browser/chromeos/events/keyboard_driven_event_rewriter_unittest.cc b/chrome/browser/chromeos/events/keyboard_driven_event_rewriter_unittest.cc
index 20b315b6..1608924 100644
--- a/chrome/browser/chromeos/events/keyboard_driven_event_rewriter_unittest.cc
+++ b/chrome/browser/chromeos/events/keyboard_driven_event_rewriter_unittest.cc
@@ -23,7 +23,7 @@ class KeyboardDrivenEventRewriterTest : public testing::Test {
std::string GetRewrittenEventAsString(ui::KeyboardCode ui_keycode,
int ui_flags,
ui::EventType ui_type) {
- ui::KeyEvent keyevent(ui_type, ui_keycode, ui_flags, false);
+ ui::KeyEvent keyevent(ui_type, ui_keycode, ui_flags);
scoped_ptr<ui::Event> rewritten_event;
ui::EventRewriteStatus status =
rewriter_.RewriteForTesting(keyevent, &rewritten_event);
diff --git a/chrome/browser/chromeos/input_method/input_method_engine.cc b/chrome/browser/chromeos/input_method/input_method_engine.cc
index 540766a..031edb1 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine.cc
@@ -83,8 +83,7 @@ std::string GetKeyFromEvent(const ui::KeyEvent& event) {
if (event.flags() & ui::EF_CONTROL_DOWN) {
ui::KeyEvent event_no_ctrl(event.type(),
event.key_code(),
- event.flags() ^ ui::EF_CONTROL_DOWN,
- false);
+ event.flags() ^ ui::EF_CONTROL_DOWN);
ch = event_no_ctrl.GetCharacter();
} else {
ch = event.GetCharacter();
@@ -317,8 +316,7 @@ bool InputMethodEngine::SendKeyEvents(
ui::KeyEvent ui_event(type,
key_code,
event.code,
- flags,
- false /* is_char */);
+ flags);
if (!event.key.empty())
ui_event.set_character(base::UTF8ToUTF16(event.key)[0]);
base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_,
diff --git a/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc b/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc
index 494371f..fe428bb 100644
--- a/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc
+++ b/chrome/browser/chromeos/input_method/input_method_engine_browsertests.cc
@@ -186,7 +186,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
// onKeyEvent should be fired if ProcessKeyEvent is called.
KeyEventDoneCallback callback(false); // EchoBackIME doesn't consume keys.
ExtensionTestMessageListener keyevent_listener("onKeyEvent", false);
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
+ ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
@@ -267,7 +267,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ExtensionTestMessageListener keyevent_listener(expected_value, false);
ui::KeyEvent key_event(
- ui::ET_KEY_PRESSED, ui::VKEY_A, "KeyA", ui::EF_NONE, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_A, "KeyA", ui::EF_NONE);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
@@ -285,8 +285,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::KeyEvent key_event(ui::ET_KEY_PRESSED,
ui::VKEY_A,
"KeyA",
- ui::EF_CONTROL_DOWN,
- false);
+ ui::EF_CONTROL_DOWN);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
@@ -304,8 +303,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::KeyEvent key_event(ui::ET_KEY_PRESSED,
ui::VKEY_A,
"KeyA",
- ui::EF_ALT_DOWN,
- false);
+ ui::EF_ALT_DOWN);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
@@ -323,8 +321,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::KeyEvent key_event(ui::ET_KEY_PRESSED,
ui::VKEY_A,
"KeyA",
- ui::EF_SHIFT_DOWN,
- false);
+ ui::EF_SHIFT_DOWN);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
@@ -342,8 +339,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::KeyEvent key_event(ui::ET_KEY_PRESSED,
ui::VKEY_A,
"KeyA",
- ui::EF_CAPS_LOCK_DOWN,
- false);
+ ui::EF_CAPS_LOCK_DOWN);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
@@ -361,8 +357,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::KeyEvent key_event(ui::ET_KEY_PRESSED,
ui::VKEY_A,
"KeyA",
- ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN,
- false);
+ ui::EF_ALT_DOWN | ui::EF_CONTROL_DOWN);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
@@ -380,8 +375,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ui::KeyEvent key_event(ui::ET_KEY_PRESSED,
ui::VKEY_A,
"KeyA",
- ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN,
- false);
+ ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN);
engine_handler->ProcessKeyEvent(key_event,
base::Bind(&KeyEventDoneCallback::Run,
base::Unretained(&callback)));
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
index 275dcdb..ee1cc92 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
@@ -1590,8 +1590,7 @@ IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ActivateAfterSessionRestore) {
controller_->GetLauncherItemController(shortcut_id);
item_controller->ItemSelected(ui::KeyEvent(ui::ET_KEY_RELEASED,
ui::VKEY_RETURN,
- 0,
- false));
+ ui::EF_NONE));
// Check that we have set focus on the existing application and nothing new
// was created.
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views_unittest.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views_unittest.cc
index eb810ab..660accd 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views_unittest.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views_unittest.cc
@@ -193,7 +193,7 @@ TEST_F(AutofillDialogViewsTest, ImeEventDoesntCrash) {
focused_view->GetClassName());
EXPECT_FALSE(dialog()->HandleKeyEvent(
static_cast<views::Textfield*>(focused_view),
- ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false)));
+ ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE)));
}
} // namespace autofill
diff --git a/chrome/browser/ui/views/extensions/media_galleries_dialog_views_unittest.cc b/chrome/browser/ui/views/extensions/media_galleries_dialog_views_unittest.cc
index 04afb9f..470eabd 100644
--- a/chrome/browser/ui/views/extensions/media_galleries_dialog_views_unittest.cc
+++ b/chrome/browser/ui/views/extensions/media_galleries_dialog_views_unittest.cc
@@ -95,7 +95,7 @@ TEST_F(MediaGalleriesDialogTest, ToggleCheckboxes) {
views::Checkbox* checkbox = dialog.checkbox_map_[1]->checkbox();
EXPECT_TRUE(checkbox->checked());
- ui::KeyEvent dummy_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
+ ui::KeyEvent dummy_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
EXPECT_CALL(*controller(), DidToggleEntry(1, false));
checkbox->SetChecked(false);
dialog.ButtonPressed(checkbox, dummy_event);
diff --git a/content/browser/renderer_host/web_input_event_aura_unittest.cc b/content/browser/renderer_host/web_input_event_aura_unittest.cc
index d67d0cd..15f9808 100644
--- a/content/browser/renderer_host/web_input_event_aura_unittest.cc
+++ b/content/browser/renderer_host/web_input_event_aura_unittest.cc
@@ -25,7 +25,7 @@ TEST(WebInputEventAuraTest, TestMakeWebKeyboardEvent) {
{
// Press Ctrl.
xev.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, 0);
- ui::KeyEvent event(xev, false /* is_char */);
+ ui::KeyEvent event(xev);
blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
// However, modifier bit for Control in |webkit_event| should be set.
EXPECT_EQ(webkit_event.modifiers, blink::WebInputEvent::ControlKey);
@@ -33,7 +33,7 @@ TEST(WebInputEventAuraTest, TestMakeWebKeyboardEvent) {
{
// Release Ctrl.
xev.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, ControlMask);
- ui::KeyEvent event(xev, false /* is_char */);
+ ui::KeyEvent event(xev);
blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
// However, modifier bit for Control in |webkit_event| shouldn't be set.
EXPECT_EQ(webkit_event.modifiers, 0);
@@ -50,7 +50,7 @@ TEST(WebInputEventAuraTest, TestMakeWebKeyboardEventWindowsKeyCode) {
xev.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, 0);
XEvent* xevent = xev;
xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), XK_Control_L);
- ui::KeyEvent event(xev, false /* is_char */);
+ ui::KeyEvent event(xev);
blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
// ui::VKEY_LCONTROL, instead of ui::VKEY_CONTROL, should be filled.
EXPECT_EQ(ui::VKEY_LCONTROL, webkit_event.windowsKeyCode);
@@ -60,7 +60,7 @@ TEST(WebInputEventAuraTest, TestMakeWebKeyboardEventWindowsKeyCode) {
xev.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, 0);
XEvent* xevent = xev;
xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), XK_Control_R);
- ui::KeyEvent event(xev, false /* is_char */);
+ ui::KeyEvent event(xev);
blink::WebKeyboardEvent webkit_event = MakeWebKeyboardEvent(&event);
// ui::VKEY_RCONTROL, instead of ui::VKEY_CONTROL, should be filled.
EXPECT_EQ(ui::VKEY_RCONTROL, webkit_event.windowsKeyCode);
diff --git a/content/browser/web_contents/aura/window_slider_unittest.cc b/content/browser/web_contents/aura/window_slider_unittest.cc
index 4a2d0a5..b6bd738 100644
--- a/content/browser/web_contents/aura/window_slider_unittest.cc
+++ b/content/browser/web_contents/aura/window_slider_unittest.cc
@@ -300,10 +300,7 @@ TEST_F(WindowSliderTest, WindowSlideIsCancelledOnEvent) {
gfx::Point(55, 10),
gfx::Point(55, 10),
0, 0),
- new ui::KeyEvent(ui::ET_KEY_PRESSED,
- ui::VKEY_A,
- 0,
- true),
+ new ui::KeyEvent('a', ui::VKEY_A, ui::EF_NONE),
NULL
};
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 27c5608..8160347 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -65,6 +65,7 @@
#include <X11/Xlib.h>
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
+#include "ui/events/test/events_test_utils.h"
#include "ui/events/test/events_test_utils_x11.h"
#endif
@@ -188,7 +189,7 @@ class RenderViewImplTest : public RenderViewTest {
// WM_CHAR sends a composed Unicode character.
MSG msg1 = { NULL, WM_KEYDOWN, key_code, 0 };
#if defined(USE_AURA)
- ui::KeyEvent evt1(msg1, false);
+ ui::KeyEvent evt1(msg1);
NativeWebKeyboardEvent keydown_event(&evt1);
#else
NativeWebKeyboardEvent keydown_event(msg1);
@@ -197,7 +198,7 @@ class RenderViewImplTest : public RenderViewTest {
MSG msg2 = { NULL, WM_CHAR, (*output)[0], 0 };
#if defined(USE_AURA)
- ui::KeyEvent evt2(msg2, true);
+ ui::KeyEvent evt2(msg2);
NativeWebKeyboardEvent char_event(&evt2);
#else
NativeWebKeyboardEvent char_event(msg2);
@@ -206,7 +207,7 @@ class RenderViewImplTest : public RenderViewTest {
MSG msg3 = { NULL, WM_KEYUP, key_code, 0 };
#if defined(USE_AURA)
- ui::KeyEvent evt3(msg3, false);
+ ui::KeyEvent evt3(msg3);
NativeWebKeyboardEvent keyup_event(&evt3);
#else
NativeWebKeyboardEvent keyup_event(msg3);
@@ -224,21 +225,25 @@ class RenderViewImplTest : public RenderViewTest {
xevent.InitKeyEvent(ui::ET_KEY_PRESSED,
static_cast<ui::KeyboardCode>(key_code),
flags);
- ui::KeyEvent event1(xevent, false);
+ ui::KeyEvent event1(xevent);
NativeWebKeyboardEvent keydown_event(&event1);
SendNativeKeyEvent(keydown_event);
+ // X11 doesn't actually have native character events, but give the test
+ // what it wants.
xevent.InitKeyEvent(ui::ET_KEY_PRESSED,
static_cast<ui::KeyboardCode>(key_code),
flags);
- ui::KeyEvent event2(xevent, true);
+ ui::KeyEvent event2(xevent);
+ ui::KeyEventTestApi test_event2(&event2);
+ test_event2.set_is_char(true);
NativeWebKeyboardEvent char_event(&event2);
SendNativeKeyEvent(char_event);
xevent.InitKeyEvent(ui::ET_KEY_RELEASED,
static_cast<ui::KeyboardCode>(key_code),
flags);
- ui::KeyEvent event3(xevent, false);
+ ui::KeyEvent event3(xevent);
NativeWebKeyboardEvent keyup_event(&event3);
SendNativeKeyEvent(keyup_event);
@@ -253,25 +258,22 @@ class RenderViewImplTest : public RenderViewTest {
// then create the actual ui::KeyEvent with the native event.
ui::KeyEvent keydown_native_event(ui::ET_KEY_PRESSED,
static_cast<ui::KeyboardCode>(key_code),
- flags,
- true);
- ui::KeyEvent keydown_event(&keydown_native_event, false);
+ flags);
+ ui::KeyEvent keydown_event(&keydown_native_event);
NativeWebKeyboardEvent keydown_web_event(&keydown_event);
SendNativeKeyEvent(keydown_web_event);
- ui::KeyEvent char_native_event(ui::ET_KEY_PRESSED,
+ ui::KeyEvent char_native_event(static_cast<base::char16>(key_code),
static_cast<ui::KeyboardCode>(key_code),
- flags,
- true);
- ui::KeyEvent char_event(&char_native_event, true);
+ flags);
+ ui::KeyEvent char_event(&char_native_event);
NativeWebKeyboardEvent char_web_event(&char_event);
SendNativeKeyEvent(char_web_event);
ui::KeyEvent keyup_native_event(ui::ET_KEY_RELEASED,
static_cast<ui::KeyboardCode>(key_code),
- flags,
- true);
- ui::KeyEvent keyup_event(&keyup_native_event, false);
+ flags);
+ ui::KeyEvent keyup_event(&keyup_native_event);
NativeWebKeyboardEvent keyup_web_event(&keyup_event);
SendNativeKeyEvent(keyup_web_event);
diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc
index 4ee5fd3..74c0245 100644
--- a/mojo/examples/window_manager/window_manager.cc
+++ b/mojo/examples/window_manager/window_manager.cc
@@ -130,16 +130,24 @@ class KeyboardManager : public KeyboardClient,
#else
const bool is_char = false;
#endif
- view_manager_->DispatchEvent(
- view,
- Event::From(ui::KeyEvent(ui::ET_KEY_PRESSED,
- static_cast<ui::KeyboardCode>(code),
- flags, is_char)));
+ if (is_char) {
+ view_manager_->DispatchEvent(
+ view,
+ Event::From(ui::KeyEvent(ui::ET_KEY_PRESSED,
+ static_cast<ui::KeyboardCode>(code),
+ flags)));
+ } else {
+ view_manager_->DispatchEvent(
+ view,
+ Event::From(ui::KeyEvent(static_cast<base::char16>(code),
+ static_cast<ui::KeyboardCode>(code),
+ flags)));
+ }
view_manager_->DispatchEvent(
view,
Event::From(ui::KeyEvent(ui::ET_KEY_RELEASED,
static_cast<ui::KeyboardCode>(code),
- flags, false)));
+ flags)));
}
// Overridden from NodeObserver:
diff --git a/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc b/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
index cff22d4..a5292d3 100644
--- a/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
+++ b/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
@@ -141,14 +141,21 @@ TypeConverter<EventPtr, scoped_ptr<ui::Event> >::ConvertTo(
ui::EventType ui_event_type =
TypeConverter<EventType, ui::EventType>::ConvertTo(input->action);
switch (input->action) {
- case EVENT_TYPE_KEY_PRESSED:
- case EVENT_TYPE_KEY_RELEASED:
- ui_event.reset(new ui::KeyEvent(
- ui_event_type,
- static_cast<ui::KeyboardCode>(
- input->key_data->key_code),
- ui::EventFlags(input->flags),
- input->key_data->is_char));
+ case ui::ET_KEY_PRESSED:
+ case ui::ET_KEY_RELEASED:
+ if (input->key_data->is_char) {
+ ui_event.reset(new ui::KeyEvent(
+ static_cast<base::char16>(input->key_data->key_code),
+ static_cast<ui::KeyboardCode>(
+ input->key_data->key_code),
+ input->flags));
+ } else {
+ ui_event.reset(new ui::KeyEvent(
+ ui_event_type,
+ static_cast<ui::KeyboardCode>(
+ input->key_data->key_code),
+ input->flags));
+ }
break;
case EVENT_TYPE_MOUSE_PRESSED:
case EVENT_TYPE_MOUSE_DRAGGED:
diff --git a/ui/app_list/views/apps_grid_view_unittest.cc b/ui/app_list/views/apps_grid_view_unittest.cc
index 643621d..a2ea2a0 100644
--- a/ui/app_list/views/apps_grid_view_unittest.cc
+++ b/ui/app_list/views/apps_grid_view_unittest.cc
@@ -171,7 +171,7 @@ class AppsGridViewTest : public views::ViewsTestBase {
}
void SimulateKeyPress(ui::KeyboardCode key_code) {
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, key_code, 0, false);
+ ui::KeyEvent key_event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
apps_grid_view_->OnKeyPressed(key_event);
}
diff --git a/ui/app_list/views/search_box_view_unittest.cc b/ui/app_list/views/search_box_view_unittest.cc
index 3d3ca35..cc7354e 100644
--- a/ui/app_list/views/search_box_view_unittest.cc
+++ b/ui/app_list/views/search_box_view_unittest.cc
@@ -84,7 +84,7 @@ class SearchBoxViewTest : public views::test::WidgetTest,
}
void KeyPress(ui::KeyboardCode key_code) {
- ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE, true);
+ ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
view_->search_box()->OnKeyPressed(event);
// Emulates the input method.
if (::isalnum(static_cast<int>(key_code))) {
diff --git a/ui/app_list/views/search_result_list_view_unittest.cc b/ui/app_list/views/search_result_list_view_unittest.cc
index f42ce61..586ad8f 100644
--- a/ui/app_list/views/search_result_list_view_unittest.cc
+++ b/ui/app_list/views/search_result_list_view_unittest.cc
@@ -83,7 +83,7 @@ class SearchResultListViewTest : public views::ViewsTestBase,
}
bool KeyPress(ui::KeyboardCode key_code) {
- ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE, true);
+ ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
return view_->OnKeyPressed(event);
}
diff --git a/ui/app_list/views/test/apps_grid_view_test_api.cc b/ui/app_list/views/test/apps_grid_view_test_api.cc
index 01c6feaa..2251036 100644
--- a/ui/app_list/views/test/apps_grid_view_test_api.cc
+++ b/ui/app_list/views/test/apps_grid_view_test_api.cc
@@ -33,7 +33,7 @@ void AppsGridViewTestApi::SetPageFlipDelay(int page_flip_delay_in_ms) {
void AppsGridViewTestApi::PressItemAt(int index) {
GetViewAtModelIndex(index)->OnKeyPressed(
- ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false));
+ ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE));
}
void AppsGridViewTestApi::DisableSynchronousDrag() {
diff --git a/ui/aura/remote_window_tree_host_win.cc b/ui/aura/remote_window_tree_host_win.cc
index c3d09c3..06c0aee 100644
--- a/ui/aura/remote_window_tree_host_win.cc
+++ b/ui/aura/remote_window_tree_host_win.cc
@@ -499,11 +499,15 @@ void RemoteWindowTreeHostWin::DispatchKeyboardMessage(ui::EventType type,
message,
vkey,
repeat_count | scan_code >> 15);
+ } else if (is_character) {
+ ui::KeyEvent event(static_cast<base::char16>(vkey),
+ ui::KeyboardCodeForWindowsKeyCode(vkey),
+ flags);
+ SendEventToProcessor(&event);
} else {
ui::KeyEvent event(type,
ui::KeyboardCodeForWindowsKeyCode(vkey),
- flags,
- is_character);
+ flags);
SendEventToProcessor(&event);
}
}
diff --git a/ui/aura/window_event_dispatcher_unittest.cc b/ui/aura/window_event_dispatcher_unittest.cc
index 55b7eaa..8b97aa4 100644
--- a/ui/aura/window_event_dispatcher_unittest.cc
+++ b/ui/aura/window_event_dispatcher_unittest.cc
@@ -346,27 +346,27 @@ TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) {
ConsumeKeyHandler handler;
root_window()->AddPreTargetHandler(&handler);
- ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false);
+ ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, ui::EF_NONE);
DispatchEventUsingWindowDispatcher(&unknown_event);
EXPECT_FALSE(unknown_event.handled());
EXPECT_EQ(0, handler.num_key_events());
handler.Reset();
- ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
+ ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
DispatchEventUsingWindowDispatcher(&known_event);
EXPECT_TRUE(known_event.handled());
EXPECT_EQ(1, handler.num_key_events());
handler.Reset();
ui::KeyEvent ime_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN,
- ui::EF_IME_FABRICATED_KEY, false);
+ ui::EF_IME_FABRICATED_KEY);
DispatchEventUsingWindowDispatcher(&ime_event);
EXPECT_TRUE(ime_event.handled());
EXPECT_EQ(1, handler.num_key_events());
handler.Reset();
ui::KeyEvent unknown_key_with_char_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN,
- 0, false);
+ ui::EF_NONE);
unknown_key_with_char_event.set_character(0x00e4 /* "ä" */);
DispatchEventUsingWindowDispatcher(&unknown_key_with_char_event);
EXPECT_TRUE(unknown_key_with_char_event.handled());
@@ -380,7 +380,7 @@ TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) {
ui::test::TestEventHandler handler;
w1->AddPreTargetHandler(&handler);
- ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
+ ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
DispatchEventUsingWindowDispatcher(&key_press);
EXPECT_TRUE(key_press.handled());
EXPECT_EQ(1, handler.num_key_events());
diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc
index 36e7156..35ebb1e 100644
--- a/ui/aura/window_tree_host_x11.cc
+++ b/ui/aura/window_tree_host_x11.cc
@@ -366,7 +366,7 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
switch (ui::EventTypeFromNative(xev)) {
case ui::ET_KEY_PRESSED:
case ui::ET_KEY_RELEASED: {
- ui::KeyEvent keydown_event(xev, false);
+ ui::KeyEvent keydown_event(xev);
SendEventToProcessor(&keydown_event);
break;
}
@@ -687,7 +687,7 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
}
case ui::ET_KEY_PRESSED:
case ui::ET_KEY_RELEASED: {
- ui::KeyEvent key_event(xev, false);
+ ui::KeyEvent key_event(xev);
SendEventToProcessor(&key_event);
break;
}
diff --git a/ui/base/ime/input_method_auralinux.cc b/ui/base/ime/input_method_auralinux.cc
index a1c1b74..f5d4bee 100644
--- a/ui/base/ime/input_method_auralinux.cc
+++ b/ui/base/ime/input_method_auralinux.cc
@@ -169,8 +169,7 @@ void InputMethodAuraLinux::MaybeFireProcessKey() {
const ui::KeyEvent fabricated_event(ET_KEY_PRESSED,
VKEY_PROCESSKEY,
- vkey_processkey_flags_,
- false); // is_char
+ vkey_processkey_flags_);
DispatchKeyEventPostIME(fabricated_event);
StopFiringProcessKey();
}
diff --git a/ui/base/ime/input_method_chromeos.cc b/ui/base/ime/input_method_chromeos.cc
index a37cb72..b3df071 100644
--- a/ui/base/ime/input_method_chromeos.cc
+++ b/ui/base/ime/input_method_chromeos.cc
@@ -367,8 +367,7 @@ void InputMethodChromeOS::ProcessFilteredKeyPressEvent(
} else {
const ui::KeyEvent fabricated_event(ET_KEY_PRESSED,
VKEY_PROCESSKEY,
- event.flags(),
- false); // is_char
+ event.flags());
DispatchKeyEventPostIME(fabricated_event);
}
}
@@ -444,8 +443,7 @@ void InputMethodChromeOS::SendFakeProcessKeyEvent(bool pressed) const {
return;
KeyEvent evt(pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED,
pressed ? VKEY_PROCESSKEY : VKEY_UNKNOWN,
- EF_IME_FABRICATED_KEY,
- false); // is_char
+ EF_IME_FABRICATED_KEY);
DispatchKeyEventPostIME(evt);
}
diff --git a/ui/base/ime/input_method_chromeos_unittest.cc b/ui/base/ime/input_method_chromeos_unittest.cc
index 0470f0c..1db29e9 100644
--- a/ui/base/ime/input_method_chromeos_unittest.cc
+++ b/ui/base/ime/input_method_chromeos_unittest.cc
@@ -203,7 +203,7 @@ class InputMethodChromeOSTest : public internal::InputMethodDelegate,
public TextInputClient {
public:
InputMethodChromeOSTest()
- : dispatched_key_event_(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN, 0, false) {
+ : dispatched_key_event_(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN, ui::EF_NONE) {
ResetFlags();
}
@@ -335,8 +335,8 @@ class InputMethodChromeOSTest : public internal::InputMethodDelegate,
}
void ResetFlags() {
- dispatched_key_event_ = ui::KeyEvent(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN, 0,
- false);
+ dispatched_key_event_ = ui::KeyEvent(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN,
+ ui::EF_NONE);
composition_text_.Clear();
confirmed_text_.Clear();
@@ -957,7 +957,7 @@ TEST_F(InputMethodChromeOSKeyEventTest, KeyEventDelayResponseTest) {
const int kFlags = ui::EF_SHIFT_DOWN;
ScopedXI2Event xevent;
xevent.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, kFlags);
- const ui::KeyEvent event(xevent, true);
+ const ui::KeyEvent event(xevent);
// Do key event.
input_type_ = TEXT_INPUT_TYPE_TEXT;
@@ -993,7 +993,7 @@ TEST_F(InputMethodChromeOSKeyEventTest, MultiKeyEventDelayResponseTest) {
const int kFlags = ui::EF_SHIFT_DOWN;
ScopedXI2Event xevent;
xevent.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_B, kFlags);
- const ui::KeyEvent event(xevent, true);
+ const ui::KeyEvent event(xevent);
// Do key event.
ime_->DispatchKeyEvent(event);
@@ -1009,7 +1009,7 @@ TEST_F(InputMethodChromeOSKeyEventTest, MultiKeyEventDelayResponseTest) {
// Do key event again.
ScopedXI2Event xevent2;
xevent2.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_C, kFlags);
- const ui::KeyEvent event2(xevent2, true);
+ const ui::KeyEvent event2(xevent2);
ime_->DispatchKeyEvent(event2);
const ui::KeyEvent* key_event2 =
@@ -1048,7 +1048,7 @@ TEST_F(InputMethodChromeOSKeyEventTest, MultiKeyEventDelayResponseTest) {
TEST_F(InputMethodChromeOSKeyEventTest, KeyEventDelayResponseResetTest) {
ScopedXI2Event xevent;
xevent.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_SHIFT_DOWN);
- const ui::KeyEvent event(xevent, true);
+ const ui::KeyEvent event(xevent);
// Do key event.
input_type_ = TEXT_INPUT_TYPE_TEXT;
diff --git a/ui/base/ime/input_method_win.cc b/ui/base/ime/input_method_win.cc
index 9b23c1a..33e3ca6 100644
--- a/ui/base/ime/input_method_win.cc
+++ b/ui/base/ime/input_method_win.cc
@@ -119,8 +119,7 @@ bool InputMethodWin::DispatchKeyEvent(const ui::KeyEvent& event) {
if (ui::IMM32Manager::IsRTLKeyboardLayoutInstalled() &&
!IsTextInputTypeNone()) {
// TODO: shouldn't need to generate a KeyEvent here.
- const ui::KeyEvent key(native_key_event,
- native_key_event.message == WM_CHAR);
+ const ui::KeyEvent key(native_key_event);
ui::KeyboardCode code = key.key_code();
if (key.type() == ui::ET_KEY_PRESSED) {
if (code == ui::VKEY_SHIFT) {
diff --git a/ui/base/ime/remote_input_method_win_unittest.cc b/ui/base/ime/remote_input_method_win_unittest.cc
index 3fa8be0..40269de 100644
--- a/ui/base/ime/remote_input_method_win_unittest.cc
+++ b/ui/base/ime/remote_input_method_win_unittest.cc
@@ -548,7 +548,7 @@ TEST(RemoteInputMethodWinTest, DispatchKeyEvent_NativeKeyEvent) {
scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_));
const MSG wm_keydown = { NULL, WM_KEYDOWN, ui::VKEY_A };
- ui::KeyEvent native_keydown(wm_keydown, false);
+ ui::KeyEvent native_keydown(wm_keydown);
// This must not cause a crash.
EXPECT_FALSE(input_method->DispatchKeyEvent(native_keydown));
@@ -590,7 +590,7 @@ TEST(RemoteInputMethodWinTest, DispatchKeyEvent_NativeCharEvent) {
scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_));
const MSG wm_char = { NULL, WM_CHAR, 'A', 0 };
- ui::KeyEvent native_char(wm_char, true);
+ ui::KeyEvent native_char(wm_char);
// This must not cause a crash.
EXPECT_FALSE(input_method->DispatchKeyEvent(native_char));
@@ -633,7 +633,7 @@ TEST(RemoteInputMethodWinTest, DispatchKeyEvent_FabricatedKeyDown) {
MockTextInputClient mock_text_input_client;
scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_));
- ui::KeyEvent fabricated_keydown(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
+ ui::KeyEvent fabricated_keydown(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
fabricated_keydown.set_character(L'A');
// This must not cause a crash.
@@ -684,8 +684,7 @@ TEST(RemoteInputMethodWinTest, DispatchKeyEvent_FabricatedChar) {
MockTextInputClient mock_text_input_client;
scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_));
- ui::KeyEvent fabricated_char(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true);
- fabricated_char.set_character(L'A');
+ ui::KeyEvent fabricated_char(L'A', ui::VKEY_A, ui::EF_NONE);
// This must not cause a crash.
EXPECT_TRUE(input_method->DispatchKeyEvent(fabricated_char));
diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc
index 0a63014..cc2820f 100644
--- a/ui/chromeos/touch_exploration_controller.cc
+++ b/ui/chromeos/touch_exploration_controller.cc
@@ -748,18 +748,18 @@ void TouchExplorationController::DispatchShiftSearchKeyEvent(
// three KeyPressed events must be dispatched in succession along
// with three KeyReleased events.
ui::KeyEvent shift_down = ui::KeyEvent(
- ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN);
ui::KeyEvent search_down = ui::KeyEvent(
- ui::ET_KEY_PRESSED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_PRESSED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN);
ui::KeyEvent direction_down =
- ui::KeyEvent(ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN, false);
+ ui::KeyEvent(ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN);
ui::KeyEvent direction_up =
- ui::KeyEvent(ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN, false);
+ ui::KeyEvent(ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN);
ui::KeyEvent search_up = ui::KeyEvent(
- ui::ET_KEY_RELEASED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_RELEASED, kChromeOSSearchKey, ui::EF_SHIFT_DOWN);
ui::KeyEvent shift_up =
- ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE, false);
+ ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE);
DispatchEvent(&shift_down);
DispatchEvent(&search_down);
diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc
index b00814b..127a5cf 100644
--- a/ui/chromeos/touch_exploration_controller_unittest.cc
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc
@@ -389,17 +389,17 @@ void AssertDirectionalNavigationEvents(const ScopedVector<ui::Event>& events,
ui::KeyboardCode direction) {
ASSERT_EQ(6U, events.size());
ui::KeyEvent shift_pressed(
- ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN);
ui::KeyEvent search_pressed(
- ui::ET_KEY_PRESSED, ui::VKEY_LWIN, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_LWIN, ui::EF_SHIFT_DOWN);
ui::KeyEvent direction_pressed(
- ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN);
ui::KeyEvent direction_released(
- ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN);
ui::KeyEvent search_released(
- ui::ET_KEY_RELEASED, VKEY_LWIN, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_RELEASED, VKEY_LWIN, ui::EF_SHIFT_DOWN);
ui::KeyEvent shift_released(
- ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE, false);
+ ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE);
CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&shift_pressed, events[0]);
CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&search_pressed, events[1]);
CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&direction_pressed, events[2]);
diff --git a/ui/events/cocoa/events_mac.mm b/ui/events/cocoa/events_mac.mm
index 43d941c..6b908f0 100644
--- a/ui/events/cocoa/events_mac.mm
+++ b/ui/events/cocoa/events_mac.mm
@@ -220,4 +220,8 @@ uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) {
return native_event.keyCode;
}
+bool IsCharFromNative(const base::NativeEvent& native_event) {
+ return false;
+}
+
} // namespace ui
diff --git a/ui/events/event.cc b/ui/events/event.cc
index f03b943..4a8370b 100644
--- a/ui/events/event.cc
+++ b/ui/events/event.cc
@@ -576,13 +576,13 @@ bool KeyEvent::IsRepeated(const KeyEvent& event) {
return false;
}
-KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char)
+KeyEvent::KeyEvent(const base::NativeEvent& native_event)
: Event(native_event,
EventTypeFromNative(native_event),
EventFlagsFromNative(native_event)),
key_code_(KeyboardCodeFromNative(native_event)),
code_(CodeFromNative(native_event)),
- is_char_(is_char),
+ is_char_(IsCharFromNative(native_event)),
platform_keycode_(PlatformKeycodeFromNative(native_event)),
character_(0) {
if (IsRepeated(*this))
@@ -595,11 +595,10 @@ KeyEvent::KeyEvent(const base::NativeEvent& native_event, bool is_char)
KeyEvent::KeyEvent(EventType type,
KeyboardCode key_code,
- int flags,
- bool is_char)
+ int flags)
: Event(type, EventTimeForNow(), flags),
key_code_(key_code),
- is_char_(is_char),
+ is_char_(false),
platform_keycode_(0),
character_(GetCharacterFromKeyCode(key_code, flags)) {
}
@@ -607,17 +606,24 @@ KeyEvent::KeyEvent(EventType type,
KeyEvent::KeyEvent(EventType type,
KeyboardCode key_code,
const std::string& code,
- int flags,
- bool is_char)
+ int flags)
: Event(type, EventTimeForNow(), flags),
key_code_(key_code),
code_(code),
- is_char_(is_char),
+ is_char_(false),
platform_keycode_(0),
character_(GetCharacterFromKeyCode(key_code, flags)) {
}
-uint16 KeyEvent::GetCharacter() const {
+KeyEvent::KeyEvent(base::char16 character, KeyboardCode key_code, int flags)
+ : Event(ET_KEY_PRESSED, EventTimeForNow(), flags),
+ key_code_(key_code),
+ code_(""),
+ is_char_(true),
+ character_(character) {
+}
+
+base::char16 KeyEvent::GetCharacter() const {
if (character_)
return character_;
diff --git a/ui/events/event.h b/ui/events/event.h
index 64a3a01..ea826f9 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -543,30 +543,66 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
float force_;
};
+// A KeyEvent is really two distinct classes, melded together due to the
+// DOM legacy of Windows key events: a keystroke event (is_char_ == false),
+// or a character event (is_char_ == true).
+//
+// For a keystroke event,
+// -- is_char_ is false.
+// -- type() can be any one of ET_KEY_PRESSED, ET_KEY_RELEASED,
+// ET_TRANSLATED_KEY_PRESS, or ET_TRANSLATED_KEY_RELEASE.
+// -- character_ functions as a bypass or cache for GetCharacter().
+// -- key_code_ is a VKEY_ value associated with the key. For printable
+// characters, this may or may not be a mapped value, imitating MS Windows:
+// if the mapped key generates a character that has an associated VKEY_
+// code, then key_code_ is that code; if not, then key_code_ is the unmapped
+// VKEY_ code. For example, US, Greek, Cyrillic, Japanese, etc. all use
+// VKEY_Q for the key beside Tab, while French uses VKEY_A.
+// -- code_ is in one-to-one correspondence with a physical keyboard
+// location, and does not vary depending on key layout.
+//
+// For a character event,
+// -- is_char_ is true.
+// -- type() is ET_KEY_PRESSED.
+// -- character_ is a UTF-16 character value.
+// -- key_code_ is conflated with character_ by some code, because both
+// arrive in the wParam field of a Windows event.
+// -- code_ is "".
+//
class EVENTS_EXPORT KeyEvent : public Event {
public:
- KeyEvent(const base::NativeEvent& native_event, bool is_char);
+ // Create a KeyEvent from a NativeEvent. For Windows this native event can
+ // be either a keystroke message (WM_KEYUP/WM_KEYDOWN) or a character message
+ // (WM_CHAR). Other systems have only keystroke events.
+ explicit KeyEvent(const base::NativeEvent& native_event);
- // Used for synthetic events.
- KeyEvent(EventType type, KeyboardCode key_code, int flags, bool is_char);
+ // Create a keystroke event.
+ KeyEvent(EventType type, KeyboardCode key_code, int flags);
+
+ // Create a character event.
+ KeyEvent(base::char16 character, KeyboardCode key_code, int flags);
// Used for synthetic events with code of DOM KeyboardEvent (e.g. 'KeyA')
// See also: ui/events/keycodes/dom4/keycode_converter_data.h
- KeyEvent(EventType type, KeyboardCode key_code, const std::string& code,
- int flags, bool is_char);
+ KeyEvent(EventType type,
+ KeyboardCode key_code,
+ const std::string& code,
+ int flags);
// This allows an I18N virtual keyboard to fabricate a keyboard event that
// does not have a corresponding KeyboardCode (example: U+00E1 Latin small
// letter A with acute, U+0410 Cyrillic capital letter A).
- void set_character(uint16 character) { character_ = character; }
+ void set_character(base::char16 character) { character_ = character; }
// Gets the character generated by this key event. It only supports Unicode
// BMP characters.
- uint16 GetCharacter() const;
+ base::char16 GetCharacter() const;
// Gets the platform key code. For XKB, this is the xksym value.
uint32 platform_keycode() const { return platform_keycode_; }
KeyboardCode key_code() const { return key_code_; }
+
+ // True if this is a character event, false if this is a keystroke event.
bool is_char() const { return is_char_; }
// This is only intended to be used externally by classes that are modifying
@@ -580,9 +616,8 @@ class EVENTS_EXPORT KeyEvent : public Event {
std::string code() const { return code_; }
- // Normalizes flags_ to make it Windows/Mac compatible. Since the way
- // of setting modifier mask on X is very different than Windows/Mac as shown
- // in http://crbug.com/127142#c8, the normalization is necessary.
+ // Normalizes flags_ so that it describes the state after the event.
+ // (Native X11 event flags describe the state before the event.)
void NormalizeFlags();
// Returns true if the key event has already been processed by an input method
@@ -592,6 +627,8 @@ class EVENTS_EXPORT KeyEvent : public Event {
void SetTranslated(bool translated);
protected:
+ friend class KeyEventTestApi;
+
// This allows a subclass TranslatedKeyEvent to be a non character event.
void set_is_char(bool is_char) { is_char_ = is_char; }
@@ -605,8 +642,7 @@ class EVENTS_EXPORT KeyEvent : public Event {
// converted from / to keyboard scan code like XKB.
std::string code_;
- // True if this is a translated character event (vs. a raw key down). Both
- // share the same type: ET_KEY_PRESSED.
+ // True if this is a character event, false if this is a keystroke event.
bool is_char_;
// The platform related keycode value. For XKB, it's keysym value.
@@ -619,7 +655,7 @@ class EVENTS_EXPORT KeyEvent : public Event {
// This value represents the text that the key event will insert to input
// field. For key with modifier key, it may have specifial text.
// e.g. CTRL+A has '\x01'.
- uint16 character_;
+ base::char16 character_;
static bool IsRepeated(const KeyEvent& event);
diff --git a/ui/events/event_processor_unittest.cc b/ui/events/event_processor_unittest.cc
index 048a4cd..b50f24d 100644
--- a/ui/events/event_processor_unittest.cc
+++ b/ui/events/event_processor_unittest.cc
@@ -252,7 +252,7 @@ TEST_F(EventProcessorTest, DispatchToNextBestTarget) {
// When the root has a BubblingEventTargeter installed, events targeted
// at the grandchild target should be dispatched to all three targets.
- KeyEvent key_event(ET_KEY_PRESSED, VKEY_ESCAPE, 0, false);
+ KeyEvent key_event(ET_KEY_PRESSED, VKEY_ESCAPE, EF_NONE);
DispatchEvent(&key_event);
EXPECT_TRUE(root()->DidReceiveEvent(ET_KEY_PRESSED));
EXPECT_TRUE(child_r->DidReceiveEvent(ET_KEY_PRESSED));
@@ -265,7 +265,7 @@ TEST_F(EventProcessorTest, DispatchToNextBestTarget) {
// as handled. No targets in the hierarchy should receive the event.
TestEventHandler handler;
child_r->AddPreTargetHandler(&handler);
- key_event = KeyEvent(ET_KEY_PRESSED, VKEY_ESCAPE, 0, false);
+ key_event = KeyEvent(ET_KEY_PRESSED, VKEY_ESCAPE, EF_NONE);
DispatchEvent(&key_event);
EXPECT_FALSE(root()->DidReceiveEvent(ET_KEY_PRESSED));
EXPECT_FALSE(child_r->DidReceiveEvent(ET_KEY_PRESSED));
@@ -278,7 +278,7 @@ TEST_F(EventProcessorTest, DispatchToNextBestTarget) {
// event.
child_r->RemovePreTargetHandler(&handler);
child_r->AddPostTargetHandler(&handler);
- key_event = KeyEvent(ET_KEY_PRESSED, VKEY_ESCAPE, 0, false);
+ key_event = KeyEvent(ET_KEY_PRESSED, VKEY_ESCAPE, EF_NONE);
DispatchEvent(&key_event);
EXPECT_FALSE(root()->DidReceiveEvent(ET_KEY_PRESSED));
EXPECT_FALSE(child_r->DidReceiveEvent(ET_KEY_PRESSED));
@@ -292,7 +292,7 @@ TEST_F(EventProcessorTest, DispatchToNextBestTarget) {
// dispatch at the child of the root. The child and grandchild
// targets should both receive the event, but the root should not.
child_r->set_mark_events_as_handled(true);
- key_event = KeyEvent(ET_KEY_PRESSED, VKEY_ESCAPE, 0, false);
+ key_event = KeyEvent(ET_KEY_PRESSED, VKEY_ESCAPE, EF_NONE);
DispatchEvent(&key_event);
EXPECT_FALSE(root()->DidReceiveEvent(ET_KEY_PRESSED));
EXPECT_TRUE(child_r->DidReceiveEvent(ET_KEY_PRESSED));
diff --git a/ui/events/event_unittest.cc b/ui/events/event_unittest.cc
index 1866779..7cc95e2 100644
--- a/ui/events/event_unittest.cc
+++ b/ui/events/event_unittest.cc
@@ -18,40 +18,40 @@
namespace ui {
TEST(EventTest, NoNativeEvent) {
- KeyEvent keyev(ET_KEY_PRESSED, VKEY_SPACE, 0, false);
+ KeyEvent keyev(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE);
EXPECT_FALSE(keyev.HasNativeEvent());
}
TEST(EventTest, NativeEvent) {
#if defined(OS_WIN)
MSG native_event = { NULL, WM_KEYUP, VKEY_A, 0 };
- KeyEvent keyev(native_event, false);
+ KeyEvent keyev(native_event);
EXPECT_TRUE(keyev.HasNativeEvent());
#elif defined(USE_X11)
ScopedXI2Event event;
- event.InitKeyEvent(ET_KEY_RELEASED, VKEY_A, 0);
- KeyEvent keyev(event, false);
+ event.InitKeyEvent(ET_KEY_RELEASED, VKEY_A, EF_NONE);
+ KeyEvent keyev(event);
EXPECT_TRUE(keyev.HasNativeEvent());
#endif
}
TEST(EventTest, GetCharacter) {
// Check if Control+Enter returns 10.
- KeyEvent keyev1(ET_KEY_PRESSED, VKEY_RETURN, EF_CONTROL_DOWN, false);
+ KeyEvent keyev1(ET_KEY_PRESSED, VKEY_RETURN, EF_CONTROL_DOWN);
EXPECT_EQ(10, keyev1.GetCharacter());
// Check if Enter returns 13.
- KeyEvent keyev2(ET_KEY_PRESSED, VKEY_RETURN, 0, false);
+ KeyEvent keyev2(ET_KEY_PRESSED, VKEY_RETURN, EF_NONE);
EXPECT_EQ(13, keyev2.GetCharacter());
#if defined(USE_X11)
// For X11, test the functions with native_event() as well. crbug.com/107837
ScopedXI2Event event;
event.InitKeyEvent(ET_KEY_PRESSED, VKEY_RETURN, EF_CONTROL_DOWN);
- KeyEvent keyev3(event, false);
+ KeyEvent keyev3(event);
EXPECT_EQ(10, keyev3.GetCharacter());
- event.InitKeyEvent(ET_KEY_PRESSED, VKEY_RETURN, 0);
- KeyEvent keyev4(event, false);
+ event.InitKeyEvent(ET_KEY_PRESSED, VKEY_RETURN, EF_NONE);
+ KeyEvent keyev4(event);
EXPECT_EQ(13, keyev4.GetCharacter());
#endif
}
@@ -238,20 +238,17 @@ TEST(EventTest, KeyEvent) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestData); ++i) {
KeyEvent key(ET_KEY_PRESSED,
kTestData[i].key_code,
- kTestData[i].flags,
- false);
+ kTestData[i].flags);
EXPECT_EQ(kTestData[i].character, key.GetCharacter())
<< " Index:" << i << " key_code:" << kTestData[i].key_code;
}
}
TEST(EventTest, KeyEventDirectUnicode) {
- KeyEvent key(ET_KEY_PRESSED, VKEY_UNKNOWN, EF_SHIFT_DOWN, false);
- key.set_character(0x1234U);
+ KeyEvent key(0x1234U, ui::VKEY_UNKNOWN, ui::EF_NONE);
EXPECT_EQ(0x1234U, key.GetCharacter());
- KeyEvent key2(ET_KEY_RELEASED, VKEY_UNKNOWN, EF_CONTROL_DOWN, false);
- key2.set_character(0x4321U);
- EXPECT_EQ(0x4321U, key2.GetCharacter());
+ EXPECT_EQ(ET_KEY_PRESSED, key.type());
+ EXPECT_TRUE(key.is_char());
}
TEST(EventTest, NormalizeKeyEventFlags) {
@@ -260,32 +257,32 @@ TEST(EventTest, NormalizeKeyEventFlags) {
ScopedXI2Event event;
{
event.InitKeyEvent(ET_KEY_PRESSED, VKEY_SHIFT, EF_SHIFT_DOWN);
- KeyEvent keyev(event, false);
+ KeyEvent keyev(event);
EXPECT_EQ(EF_SHIFT_DOWN, keyev.flags());
}
{
event.InitKeyEvent(ET_KEY_RELEASED, VKEY_SHIFT, EF_SHIFT_DOWN);
- KeyEvent keyev(event, false);
+ KeyEvent keyev(event);
EXPECT_EQ(EF_NONE, keyev.flags());
}
{
event.InitKeyEvent(ET_KEY_PRESSED, VKEY_CONTROL, EF_CONTROL_DOWN);
- KeyEvent keyev(event, false);
+ KeyEvent keyev(event);
EXPECT_EQ(EF_CONTROL_DOWN, keyev.flags());
}
{
event.InitKeyEvent(ET_KEY_RELEASED, VKEY_CONTROL, EF_CONTROL_DOWN);
- KeyEvent keyev(event, false);
+ KeyEvent keyev(event);
EXPECT_EQ(EF_NONE, keyev.flags());
}
{
event.InitKeyEvent(ET_KEY_PRESSED, VKEY_MENU, EF_ALT_DOWN);
- KeyEvent keyev(event, false);
+ KeyEvent keyev(event);
EXPECT_EQ(EF_ALT_DOWN, keyev.flags());
}
{
event.InitKeyEvent(ET_KEY_RELEASED, VKEY_MENU, EF_ALT_DOWN);
- KeyEvent keyev(event, false);
+ KeyEvent keyev(event);
EXPECT_EQ(EF_NONE, keyev.flags());
}
#endif
@@ -293,31 +290,31 @@ TEST(EventTest, NormalizeKeyEventFlags) {
// Do not normalize flags for synthesized events without
// KeyEvent::NormalizeFlags called explicitly.
{
- KeyEvent keyev(ET_KEY_PRESSED, VKEY_SHIFT, EF_SHIFT_DOWN, false);
+ KeyEvent keyev(ET_KEY_PRESSED, VKEY_SHIFT, EF_SHIFT_DOWN);
EXPECT_EQ(EF_SHIFT_DOWN, keyev.flags());
}
{
- KeyEvent keyev(ET_KEY_RELEASED, VKEY_SHIFT, EF_SHIFT_DOWN, false);
+ KeyEvent keyev(ET_KEY_RELEASED, VKEY_SHIFT, EF_SHIFT_DOWN);
EXPECT_EQ(EF_SHIFT_DOWN, keyev.flags());
keyev.NormalizeFlags();
EXPECT_EQ(EF_NONE, keyev.flags());
}
{
- KeyEvent keyev(ET_KEY_PRESSED, VKEY_CONTROL, EF_CONTROL_DOWN, false);
+ KeyEvent keyev(ET_KEY_PRESSED, VKEY_CONTROL, EF_CONTROL_DOWN);
EXPECT_EQ(EF_CONTROL_DOWN, keyev.flags());
}
{
- KeyEvent keyev(ET_KEY_RELEASED, VKEY_CONTROL, EF_CONTROL_DOWN, false);
+ KeyEvent keyev(ET_KEY_RELEASED, VKEY_CONTROL, EF_CONTROL_DOWN);
EXPECT_EQ(EF_CONTROL_DOWN, keyev.flags());
keyev.NormalizeFlags();
EXPECT_EQ(EF_NONE, keyev.flags());
}
{
- KeyEvent keyev(ET_KEY_PRESSED, VKEY_MENU, EF_ALT_DOWN, false);
+ KeyEvent keyev(ET_KEY_PRESSED, VKEY_MENU, EF_ALT_DOWN);
EXPECT_EQ(EF_ALT_DOWN, keyev.flags());
}
{
- KeyEvent keyev(ET_KEY_RELEASED, VKEY_MENU, EF_ALT_DOWN, false);
+ KeyEvent keyev(ET_KEY_RELEASED, VKEY_MENU, EF_ALT_DOWN);
EXPECT_EQ(EF_ALT_DOWN, keyev.flags());
keyev.NormalizeFlags();
EXPECT_EQ(EF_NONE, keyev.flags());
@@ -325,7 +322,7 @@ TEST(EventTest, NormalizeKeyEventFlags) {
}
TEST(EventTest, KeyEventCopy) {
- KeyEvent key(ET_KEY_PRESSED, VKEY_A, EF_NONE, false);
+ KeyEvent key(ET_KEY_PRESSED, VKEY_A, EF_NONE);
scoped_ptr<KeyEvent> copied_key(new KeyEvent(key));
EXPECT_EQ(copied_key->type(), key.type());
EXPECT_EQ(copied_key->key_code(), key.key_code());
@@ -339,20 +336,20 @@ TEST(EventTest, KeyEventCode) {
ASSERT_NE(conv->InvalidNativeKeycode(), kNativeCodeSpace);
{
- KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kCodeForSpace, EF_NONE, false);
+ KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, kCodeForSpace, EF_NONE);
EXPECT_EQ(kCodeForSpace, key.code());
}
{
// Regardless the KeyEvent.key_code (VKEY_RETURN), code should be
// the specified value.
- KeyEvent key(ET_KEY_PRESSED, VKEY_RETURN, kCodeForSpace, EF_NONE, false);
+ KeyEvent key(ET_KEY_PRESSED, VKEY_RETURN, kCodeForSpace, EF_NONE);
EXPECT_EQ(kCodeForSpace, key.code());
}
{
// If the synthetic event is initialized without code, it returns
// an empty string.
// TODO(komatsu): Fill a fallback value assuming the US keyboard layout.
- KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE, false);
+ KeyEvent key(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE);
EXPECT_TRUE(key.code().empty());
}
#if defined(USE_X11)
@@ -360,7 +357,7 @@ TEST(EventTest, KeyEventCode) {
// KeyEvent converts from the native keycode (XKB) to the code.
ScopedXI2Event xevent;
xevent.InitKeyEvent(ET_KEY_PRESSED, VKEY_SPACE, kNativeCodeSpace);
- KeyEvent key(xevent, false);
+ KeyEvent key(xevent);
EXPECT_EQ(kCodeForSpace, key.code());
}
#endif // USE_X11
@@ -371,7 +368,7 @@ TEST(EventTest, KeyEventCode) {
const LPARAM lParam = GetLParamFromScanCode(kNativeCodeSpace);
MSG native_event = { NULL, WM_KEYUP, VKEY_SPACE, lParam };
- KeyEvent key(native_event, false);
+ KeyEvent key(native_event);
// KeyEvent converts from the native keycode (scan code) to the code.
EXPECT_EQ(kCodeForSpace, key.code());
@@ -385,7 +382,7 @@ TEST(EventTest, KeyEventCode) {
const LPARAM lParam = GetLParamFromScanCode(kNativeCodeHome);
MSG native_event = { NULL, WM_KEYUP, VKEY_HOME, lParam };
- KeyEvent key(native_event, false);
+ KeyEvent key(native_event);
// KeyEvent converts from the native keycode (scan code) to the code.
EXPECT_EQ(kCodeForHome, key.code());
@@ -419,37 +416,37 @@ TEST(EventTest, AutoRepeat) {
MSG native_event_a_released = { NULL, WM_KEYUP, VKEY_A, lParam_a };
MSG native_event_b_pressed = { NULL, WM_KEYUP, VKEY_B, lParam_b };
#endif
- KeyEvent key_a1(native_event_a_pressed, false);
+ KeyEvent key_a1(native_event_a_pressed);
EXPECT_FALSE(key_a1.IsRepeat());
- KeyEvent key_a1_released(native_event_a_released, false);
+ KeyEvent key_a1_released(native_event_a_released);
EXPECT_FALSE(key_a1_released.IsRepeat());
- KeyEvent key_a2(native_event_a_pressed, false);
+ KeyEvent key_a2(native_event_a_pressed);
EXPECT_FALSE(key_a2.IsRepeat());
- KeyEvent key_a2_repeated(native_event_a_pressed, false);
+ KeyEvent key_a2_repeated(native_event_a_pressed);
EXPECT_TRUE(key_a2_repeated.IsRepeat());
- KeyEvent key_a2_released(native_event_a_released, false);
+ KeyEvent key_a2_released(native_event_a_released);
EXPECT_FALSE(key_a2_released.IsRepeat());
- KeyEvent key_a3(native_event_a_pressed, false);
+ KeyEvent key_a3(native_event_a_pressed);
EXPECT_FALSE(key_a3.IsRepeat());
- KeyEvent key_b(native_event_b_pressed, false);
+ KeyEvent key_b(native_event_b_pressed);
EXPECT_FALSE(key_b.IsRepeat());
- KeyEvent key_a3_again(native_event_a_pressed, false);
+ KeyEvent key_a3_again(native_event_a_pressed);
EXPECT_FALSE(key_a3_again.IsRepeat());
- KeyEvent key_a3_repeated(native_event_a_pressed, false);
+ KeyEvent key_a3_repeated(native_event_a_pressed);
EXPECT_TRUE(key_a3_repeated.IsRepeat());
- KeyEvent key_a3_repeated2(native_event_a_pressed, false);
+ KeyEvent key_a3_repeated2(native_event_a_pressed);
EXPECT_TRUE(key_a3_repeated2.IsRepeat());
- KeyEvent key_a3_released(native_event_a_released, false);
+ KeyEvent key_a3_released(native_event_a_released);
EXPECT_FALSE(key_a3_released.IsRepeat());
#if defined(USE_X11)
- KeyEvent key_a4_pressed(native_event_a_pressed, false);
+ KeyEvent key_a4_pressed(native_event_a_pressed);
EXPECT_FALSE(key_a4_pressed.IsRepeat());
KeyEvent key_a4_pressed_nonstandard_state(
- native_event_a_pressed_nonstandard_state, false);
+ native_event_a_pressed_nonstandard_state);
EXPECT_FALSE(key_a4_pressed_nonstandard_state.IsRepeat());
#endif
}
diff --git a/ui/events/event_utils.cc b/ui/events/event_utils.cc
index e4b384a..021ac27 100644
--- a/ui/events/event_utils.cc
+++ b/ui/events/event_utils.cc
@@ -22,7 +22,7 @@ scoped_ptr<Event> EventFromNative(const base::NativeEvent& native_event) {
switch(type) {
case ET_KEY_PRESSED:
case ET_KEY_RELEASED:
- event.reset(new KeyEvent(native_event, false));
+ event.reset(new KeyEvent(native_event));
break;
case ET_TRANSLATED_KEY_PRESS:
diff --git a/ui/events/event_utils.h b/ui/events/event_utils.h
index 820c7f6..d7d5f9a 100644
--- a/ui/events/event_utils.h
+++ b/ui/events/event_utils.h
@@ -86,6 +86,10 @@ EVENTS_EXPORT const char* CodeFromNative(
EVENTS_EXPORT uint32 PlatformKeycodeFromNative(
const base::NativeEvent& native_event);
+// Returns true if the keyboard event is a character event rather than
+// a keystroke event.
+EVENTS_EXPORT bool IsCharFromNative(const base::NativeEvent& native_event);
+
// Returns the flags of the button that changed during a press/release.
EVENTS_EXPORT int GetChangedMouseButtonFlagsFromNative(
const base::NativeEvent& native_event);
diff --git a/ui/events/events_stub.cc b/ui/events/events_stub.cc
index 20d13e5..8c60e38 100644
--- a/ui/events/events_stub.cc
+++ b/ui/events/events_stub.cc
@@ -144,4 +144,9 @@ uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) {
return 0;
}
+bool IsCharFromNative(const base::NativeEvent& native_event) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
} // namespace ui
diff --git a/ui/events/ozone/evdev/key_event_converter_evdev.cc b/ui/events/ozone/evdev/key_event_converter_evdev.cc
index 2e6f31e..d56a640 100644
--- a/ui/events/ozone/evdev/key_event_converter_evdev.cc
+++ b/ui/events/ozone/evdev/key_event_converter_evdev.cc
@@ -263,8 +263,7 @@ void KeyEventConverterEvdev::ConvertKeyEvent(int key, int value) {
int flags = modifiers_->GetModifierFlags();
- KeyEvent key_event(
- down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags, false);
+ KeyEvent key_event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, code, flags);
DispatchEventToCallback(&key_event);
}
diff --git a/ui/events/ozone/events_ozone.cc b/ui/events/ozone/events_ozone.cc
index 8434314..b309deb 100644
--- a/ui/events/ozone/events_ozone.cc
+++ b/ui/events/ozone/events_ozone.cc
@@ -64,6 +64,12 @@ uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) {
return event->platform_keycode();
}
+bool IsCharFromNative(const base::NativeEvent& native_event) {
+ const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event);
+ DCHECK(event->IsKeyEvent());
+ return event->is_char();
+}
+
gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) {
const ui::MouseWheelEvent* event =
static_cast<const ui::MouseWheelEvent*>(native_event);
diff --git a/ui/events/test/event_generator.cc b/ui/events/test/event_generator.cc
index 6eff2d1..b4772e5 100644
--- a/ui/events/test/event_generator.cc
+++ b/ui/events/test/event_generator.cc
@@ -33,8 +33,8 @@ void DummyCallback(EventType, const gfx::Vector2dF&) {
class TestKeyEvent : public ui::KeyEvent {
public:
- TestKeyEvent(const base::NativeEvent& native_event, int flags, bool is_char)
- : KeyEvent(native_event, is_char) {
+ TestKeyEvent(const base::NativeEvent& native_event, int flags)
+ : KeyEvent(native_event) {
set_flags(flags);
}
};
@@ -502,7 +502,7 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
uint16 character = ui::GetCharacterFromKeyCode(key_code, flags);
if (is_press && character) {
MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 };
- TestKeyEvent keyev(native_event, flags, false);
+ TestKeyEvent keyev(native_event, flags);
Dispatch(&keyev);
// On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character
// if the key event cooresponds to a real character.
@@ -511,16 +511,16 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
}
MSG native_event =
{ NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 };
- TestKeyEvent keyev(native_event, flags, key_press == WM_CHAR);
+ TestKeyEvent keyev(native_event, flags);
#elif defined(USE_X11)
ui::ScopedXI2Event xevent;
xevent.InitKeyEvent(is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED,
key_code,
flags);
- ui::KeyEvent keyev(xevent, false);
+ ui::KeyEvent keyev(xevent);
#else
ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
- ui::KeyEvent keyev(type, key_code, flags, false);
+ ui::KeyEvent keyev(type, key_code, flags);
#endif // OS_WIN
Dispatch(&keyev);
}
diff --git a/ui/events/test/events_test_utils.cc b/ui/events/test/events_test_utils.cc
index 5b5b1ba..8c3f1b6 100644
--- a/ui/events/test/events_test_utils.cc
+++ b/ui/events/test/events_test_utils.cc
@@ -16,6 +16,11 @@ LocatedEventTestApi::LocatedEventTestApi(LocatedEvent* event)
located_event_(event) {}
LocatedEventTestApi::~LocatedEventTestApi() {}
+KeyEventTestApi::KeyEventTestApi(KeyEvent* event)
+ : EventTestApi(event),
+ key_event_(event) {}
+KeyEventTestApi::~KeyEventTestApi() {}
+
EventTargetTestApi::EventTargetTestApi(EventTarget* target)
: target_(target) {}
diff --git a/ui/events/test/events_test_utils.h b/ui/events/test/events_test_utils.h
index c14bf32..3ed6fa3 100644
--- a/ui/events/test/events_test_utils.h
+++ b/ui/events/test/events_test_utils.h
@@ -51,6 +51,23 @@ class LocatedEventTestApi : public EventTestApi {
DISALLOW_COPY_AND_ASSIGN(LocatedEventTestApi);
};
+class KeyEventTestApi : public EventTestApi {
+ public:
+ explicit KeyEventTestApi(KeyEvent* key_event);
+ virtual ~KeyEventTestApi();
+
+ void set_is_char(bool is_char) {
+ key_event_->set_is_char(is_char);
+ }
+
+ private:
+ KeyEventTestApi();
+
+ KeyEvent* key_event_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyEventTestApi);
+};
+
class EventTargetTestApi {
public:
explicit EventTargetTestApi(EventTarget* target);
diff --git a/ui/events/win/events_win.cc b/ui/events/win/events_win.cc
index 7f98412..5a2c7d7 100644
--- a/ui/events/win/events_win.cc
+++ b/ui/events/win/events_win.cc
@@ -259,6 +259,10 @@ uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) {
return static_cast<uint32>(native_event.wParam);
}
+bool IsCharFromNative(const base::NativeEvent& native_event) {
+ return native_event.message == WM_CHAR;
+}
+
int GetChangedMouseButtonFlagsFromNative(
const base::NativeEvent& native_event) {
switch (GetNativeMouseKey(native_event)) {
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index 57198c0..fb6bed8 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -622,6 +622,10 @@ uint32 PlatformKeycodeFromNative(const base::NativeEvent& native_event) {
return keysym;
}
+bool IsCharFromNative(const base::NativeEvent& native_event) {
+ return false;
+}
+
int GetChangedMouseButtonFlagsFromNative(
const base::NativeEvent& native_event) {
switch (native_event->type) {
diff --git a/ui/events/x/events_x_unittest.cc b/ui/events/x/events_x_unittest.cc
index bb03177..096ee95 100644
--- a/ui/events/x/events_x_unittest.cc
+++ b/ui/events/x/events_x_unittest.cc
@@ -19,6 +19,7 @@
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
+#include "ui/events/test/events_test_utils.h"
#include "ui/events/test/events_test_utils_x11.h"
#include "ui/events/x/device_data_manager_x11.h"
#include "ui/events/x/touch_factory_x11.h"
@@ -71,7 +72,7 @@ bool HasFunctionKeyFlagSetIfSupported(Display* display, int x_keysym) {
// Exclude keysyms for which the server has no corresponding keycode.
if (x_keycode) {
InitKeyEvent(display, &event, true, x_keycode, 0);
- ui::KeyEvent ui_key_event(&event, false);
+ ui::KeyEvent ui_key_event(&event);
return (ui_key_event.flags() & ui::EF_FUNCTION_KEY);
}
return true;
@@ -454,7 +455,7 @@ TEST_F(EventsXTest, NumpadKeyEvents) {
InitKeyEvent(display, &event, true, x_keycode, 0);
// int keysym = XLookupKeysym(&event.xkey, 0);
// if (keysym) {
- ui::KeyEvent ui_key_event(&event, false);
+ ui::KeyEvent ui_key_event(&event);
EXPECT_EQ(keys[k].is_numpad_key ? ui::EF_NUMPAD_KEY : 0,
ui_key_event.flags() & ui::EF_NUMPAD_KEY);
}
@@ -578,7 +579,11 @@ TEST_F(EventsXTest, ImeFabricatedKeyEvents) {
for (int is_char = 0; is_char < 2; ++is_char) {
XEvent x_event;
InitKeyEvent(display, &x_event, true, 0, state);
- ui::KeyEvent key_event(&x_event, is_char);
+ ui::KeyEvent key_event(&x_event);
+ if (is_char) {
+ KeyEventTestApi test_event(&key_event);
+ test_event.set_is_char(true);
+ }
EXPECT_TRUE(key_event.flags() & ui::EF_IME_FABRICATED_KEY);
}
}
@@ -591,7 +596,11 @@ TEST_F(EventsXTest, ImeFabricatedKeyEvents) {
for (int is_char = 0; is_char < 2; ++is_char) {
XEvent x_event;
InitKeyEvent(display, &x_event, true, 0, state);
- ui::KeyEvent key_event(&x_event, is_char);
+ ui::KeyEvent key_event(&x_event);
+ if (is_char) {
+ KeyEventTestApi test_event(&key_event);
+ test_event.set_is_char(true);
+ }
EXPECT_FALSE(key_event.flags() & ui::EF_IME_FABRICATED_KEY);
}
}
diff --git a/ui/keyboard/keyboard_util.cc b/ui/keyboard/keyboard_util.cc
index de9e2e4..0be99e2 100644
--- a/ui/keyboard/keyboard_util.cc
+++ b/ui/keyboard/keyboard_util.cc
@@ -28,7 +28,7 @@ const char kKeyUp[] = "keyup";
void SendProcessKeyEvent(ui::EventType type,
aura::WindowTreeHost* host) {
- ui::KeyEvent event(type, ui::VKEY_PROCESSKEY, ui::EF_NONE, false);
+ ui::KeyEvent event(type, ui::VKEY_PROCESSKEY, ui::EF_NONE);
event.SetTranslated(true);
ui::EventDispatchDetails details =
host->event_processor()->OnEventFromSource(&event);
@@ -208,22 +208,22 @@ bool MoveCursor(int swipe_direction,
// First deal with the x movement.
if (codex != ui::VKEY_UNKNOWN) {
- ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags, 0);
+ ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codex, modifier_flags);
ui::EventDispatchDetails details =
host->event_processor()->OnEventFromSource(&press_event);
CHECK(!details.dispatcher_destroyed);
- ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags, 0);
+ ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codex, modifier_flags);
details = host->event_processor()->OnEventFromSource(&release_event);
CHECK(!details.dispatcher_destroyed);
}
// Then deal with the y movement.
if (codey != ui::VKEY_UNKNOWN) {
- ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags, 0);
+ ui::KeyEvent press_event(ui::ET_KEY_PRESSED, codey, modifier_flags);
ui::EventDispatchDetails details =
host->event_processor()->OnEventFromSource(&press_event);
CHECK(!details.dispatcher_destroyed);
- ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags, 0);
+ ui::KeyEvent release_event(ui::ET_KEY_RELEASED, codey, modifier_flags);
details = host->event_processor()->OnEventFromSource(&release_event);
CHECK(!details.dispatcher_destroyed);
}
@@ -277,7 +277,7 @@ bool SendKeyEvent(const std::string type,
}
}
- ui::KeyEvent event(event_type, code, key_name, modifiers, false);
+ ui::KeyEvent event(event_type, code, key_name, modifiers);
ui::EventDispatchDetails details =
host->event_processor()->OnEventFromSource(&event);
CHECK(!details.dispatcher_destroyed);
diff --git a/ui/platform_window/win/win_window.cc b/ui/platform_window/win/win_window.cc
index 89ff683..ff29e16 100644
--- a/ui/platform_window/win/win_window.cc
+++ b/ui/platform_window/win/win_window.cc
@@ -123,7 +123,7 @@ LRESULT WinWindow::OnCaptureChanged(UINT message,
LRESULT WinWindow::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) {
MSG msg = { hwnd(), message, w_param, l_param };
- KeyEvent event(msg, message == WM_CHAR);
+ KeyEvent event(msg);
delegate_->DispatchEvent(&event);
SetMsgHandled(event.handled());
return 0;
diff --git a/ui/platform_window/x11/x11_window.cc b/ui/platform_window/x11/x11_window.cc
index 8738fca..43de9f0 100644
--- a/ui/platform_window/x11/x11_window.cc
+++ b/ui/platform_window/x11/x11_window.cc
@@ -72,7 +72,7 @@ void X11Window::ProcessXInput2Event(XEvent* xev) {
switch (event_type) {
case ET_KEY_PRESSED:
case ET_KEY_RELEASED: {
- KeyEvent key_event(xev, false);
+ KeyEvent key_event(xev);
delegate_->DispatchEvent(&key_event);
break;
}
@@ -278,7 +278,7 @@ uint32_t X11Window::DispatchEvent(const PlatformEvent& event) {
case KeyPress:
case KeyRelease: {
- KeyEvent key_event(xev, false);
+ KeyEvent key_event(xev);
delegate_->DispatchEvent(&key_event);
break;
}
diff --git a/ui/views/controls/combobox/combobox_unittest.cc b/ui/views/controls/combobox/combobox_unittest.cc
index e7df215..5621525 100644
--- a/ui/views/controls/combobox/combobox_unittest.cc
+++ b/ui/views/controls/combobox/combobox_unittest.cc
@@ -245,7 +245,7 @@ class ComboboxTest : public ViewsTestBase {
}
void SendKeyEventWithType(ui::KeyboardCode key_code, ui::EventType type) {
- ui::KeyEvent event(type, key_code, 0, false);
+ ui::KeyEvent event(type, key_code, ui::EF_NONE);
widget_->GetInputMethod()->DispatchKeyEvent(event);
}
@@ -624,17 +624,17 @@ TEST_F(ComboboxTest, ConsumingPressKeyEvents) {
InitCombobox(NULL);
EXPECT_FALSE(combobox_->OnKeyPressed(
- ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false)));
+ ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE)));
EXPECT_FALSE(combobox_->OnKeyPressed(
- ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, 0, false)));
+ ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE)));
// When the combobox's style is STYLE_ACTION, pressing events of a space key
// or an enter key will be consumed.
combobox_->SetStyle(Combobox::STYLE_ACTION);
EXPECT_TRUE(combobox_->OnKeyPressed(
- ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false)));
+ ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE)));
EXPECT_TRUE(combobox_->OnKeyPressed(
- ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, 0, false)));
+ ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE)));
}
TEST_F(ComboboxTest, ContentWidth) {
diff --git a/ui/views/controls/menu/menu_controller_unittest.cc b/ui/views/controls/menu/menu_controller_unittest.cc
index 95fd669..6ecc7315 100644
--- a/ui/views/controls/menu/menu_controller_unittest.cc
+++ b/ui/views/controls/menu/menu_controller_unittest.cc
@@ -201,7 +201,7 @@ class MenuControllerTest : public ViewsTestBase {
memset(&msg, 0, sizeof(MSG));
dispatcher_client_.dispatcher()->Dispatch(msg);
#elif defined(USE_OZONE)
- ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, 0, true);
+ ui::KeyEvent event(' ', ui::VKEY_SPACE, ui::EF_NONE);
dispatcher_client_.dispatcher()->Dispatch(&event);
#else
#error Unsupported platform
diff --git a/ui/views/controls/table/table_view_unittest.cc b/ui/views/controls/table/table_view_unittest.cc
index 76661c7..e592f2e 100644
--- a/ui/views/controls/table/table_view_unittest.cc
+++ b/ui/views/controls/table/table_view_unittest.cc
@@ -222,7 +222,7 @@ class TableViewTest : public testing::Test {
}
void PressKey(ui::KeyboardCode code) {
- ui::KeyEvent event(ui::ET_KEY_PRESSED, code, 0, false);
+ ui::KeyEvent event(ui::ET_KEY_PRESSED, code, ui::EF_NONE);
table_->OnKeyPressed(event);
}
diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
index c41bb9b..ec4b578 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -252,7 +252,7 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
(shift ? ui::EF_SHIFT_DOWN : 0) |
(control ? ui::EF_CONTROL_DOWN : 0) |
(caps_lock ? ui::EF_CAPS_LOCK_DOWN : 0);
- ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, flags, false);
+ ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, flags);
input_method_->DispatchKeyEvent(event);
}
@@ -271,8 +271,7 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
static_cast<ui::KeyboardCode>(ui::VKEY_A + ch - 'a');
SendKeyEvent(code);
} else {
- ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false);
- event.set_character(ch);
+ ui::KeyEvent event(ch, ui::VKEY_UNKNOWN, ui::EF_NONE);
input_method_->DispatchKeyEvent(event);
}
}
diff --git a/ui/views/focus/focus_manager_unittest.cc b/ui/views/focus/focus_manager_unittest.cc
index 3513e2b..8249254 100644
--- a/ui/views/focus/focus_manager_unittest.cc
+++ b/ui/views/focus/focus_manager_unittest.cc
@@ -728,14 +728,10 @@ class FocusManagerArrowKeyTraversalTest : public FocusManagerTest {
TEST_F(FocusManagerArrowKeyTraversalTest, ArrowKeyTraversal) {
FocusManager* focus_manager = GetFocusManager();
- const ui::KeyEvent left_key(
- ui::ET_KEY_PRESSED, ui::VKEY_LEFT, ui::EF_NONE, false);
- const ui::KeyEvent right_key(
- ui::ET_KEY_PRESSED, ui::VKEY_RIGHT, ui::EF_NONE, false);
- const ui::KeyEvent up_key(
- ui::ET_KEY_PRESSED, ui::VKEY_UP, ui::EF_NONE, false);
- const ui::KeyEvent down_key(
- ui::ET_KEY_PRESSED, ui::VKEY_DOWN, ui::EF_NONE, false);
+ const ui::KeyEvent left_key(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, ui::EF_NONE);
+ const ui::KeyEvent right_key(ui::ET_KEY_PRESSED, ui::VKEY_RIGHT, ui::EF_NONE);
+ const ui::KeyEvent up_key(ui::ET_KEY_PRESSED, ui::VKEY_UP, ui::EF_NONE);
+ const ui::KeyEvent down_key(ui::ET_KEY_PRESSED, ui::VKEY_DOWN, ui::EF_NONE);
std::vector<views::View*> v;
for (size_t i = 0; i < 2; ++i) {
diff --git a/ui/views/ime/mock_input_method.cc b/ui/views/ime/mock_input_method.cc
index ccc054d..b7611da 100644
--- a/ui/views/ime/mock_input_method.cc
+++ b/ui/views/ime/mock_input_method.cc
@@ -64,10 +64,10 @@ void MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& key) {
ClearStates();
if (handled) {
+ DCHECK(!key.is_char());
ui::KeyEvent mock_key(ui::ET_KEY_PRESSED,
ui::VKEY_PROCESSKEY,
- key.flags(),
- key.is_char());
+ key.flags());
DispatchKeyEventPostIME(mock_key);
} else {
DispatchKeyEventPostIME(key);
diff --git a/ui/views/view_targeter_unittest.cc b/ui/views/view_targeter_unittest.cc
index 24cfb55..e6f7eeb 100644
--- a/ui/views/view_targeter_unittest.cc
+++ b/ui/views/view_targeter_unittest.cc
@@ -121,7 +121,7 @@ TEST_F(ViewTargeterTest, ViewTargeterForKeyEvents) {
ui::EventTargeter* targeter = view_targeter;
root_view->SetEventTargeter(make_scoped_ptr(view_targeter));
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true);
+ ui::KeyEvent key_event('a', ui::VKEY_A, ui::EF_NONE);
// The focused view should be the initial target of the event.
ui::EventTarget* current_target = targeter->FindTargetForEvent(root_view,
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 002d20b..d121387 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -1582,7 +1582,11 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
compositor()->ScheduleRedrawRect(damage_rect);
break;
}
- case KeyPress:
+ case KeyPress: {
+ ui::KeyEvent keydown_event(xev);
+ SendEventToProcessor(&keydown_event);
+ break;
+ }
case KeyRelease: {
// There is no way to deactivate a window in X11 so ignore input if
// window is supposed to be 'inactive'. See comments in
@@ -1590,7 +1594,7 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent(
if (!IsActive() && !HasCapture())
break;
- ui::KeyEvent key_event(xev, false);
+ ui::KeyEvent key_event(xev);
SendEventToProcessor(&key_event);
break;
}
diff --git a/ui/views/widget/root_view_unittest.cc b/ui/views/widget/root_view_unittest.cc
index 049d765..376fa6d 100644
--- a/ui/views/widget/root_view_unittest.cc
+++ b/ui/views/widget/root_view_unittest.cc
@@ -58,7 +58,7 @@ TEST_F(RootViewTest, DeleteViewDuringKeyEventDispatch) {
ViewTargeter* view_targeter = new ViewTargeter(root_view);
root_view->SetEventTargeter(make_scoped_ptr(view_targeter));
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, 0, false);
+ ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE);
ui::EventDispatchDetails details = root_view->OnEventFromSource(&key_event);
EXPECT_TRUE(details.target_destroyed);
EXPECT_FALSE(details.dispatcher_destroyed);
@@ -122,7 +122,7 @@ TEST_F(RootViewTest, ContextMenuFromKeyEvent) {
focused_view->RequestFocus();
// No context menu should be shown for a keypress of 'A'.
- ui::KeyEvent nomenu_key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true);
+ ui::KeyEvent nomenu_key_event('a', ui::VKEY_A, ui::EF_NONE);
ui::EventDispatchDetails details =
root_view->OnEventFromSource(&nomenu_key_event);
EXPECT_FALSE(details.target_destroyed);
@@ -134,7 +134,7 @@ TEST_F(RootViewTest, ContextMenuFromKeyEvent) {
// A context menu should be shown for a keypress of Shift+F10.
ui::KeyEvent menu_key_event(
- ui::ET_KEY_PRESSED, ui::VKEY_F10, ui::EF_SHIFT_DOWN, false);
+ ui::ET_KEY_PRESSED, ui::VKEY_F10, ui::EF_SHIFT_DOWN);
details = root_view->OnEventFromSource(&menu_key_event);
EXPECT_FALSE(details.target_destroyed);
EXPECT_FALSE(details.dispatcher_destroyed);
@@ -144,7 +144,7 @@ TEST_F(RootViewTest, ContextMenuFromKeyEvent) {
controller.Reset();
// A context menu should be shown for a keypress of VKEY_APPS.
- ui::KeyEvent menu_key_event2(ui::ET_KEY_PRESSED, ui::VKEY_APPS, 0, false);
+ ui::KeyEvent menu_key_event2(ui::ET_KEY_PRESSED, ui::VKEY_APPS, ui::EF_NONE);
details = root_view->OnEventFromSource(&menu_key_event2);
EXPECT_FALSE(details.target_destroyed);
EXPECT_FALSE(details.dispatcher_destroyed);
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index a4ac6e4..f6d1ea2 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -993,10 +993,10 @@ TEST_F(WidgetTest, KeyboardInputEvent) {
textfield->RequestFocus();
// The press gets handled. The release doesn't have an effect.
- ui::KeyEvent backspace_p(ui::ET_KEY_PRESSED, ui::VKEY_DELETE, 0, false);
+ ui::KeyEvent backspace_p(ui::ET_KEY_PRESSED, ui::VKEY_DELETE, ui::EF_NONE);
toplevel->OnKeyEvent(&backspace_p);
EXPECT_TRUE(backspace_p.stopped_propagation());
- ui::KeyEvent backspace_r(ui::ET_KEY_RELEASED, ui::VKEY_DELETE, 0, false);
+ ui::KeyEvent backspace_r(ui::ET_KEY_RELEASED, ui::VKEY_DELETE, ui::EF_NONE);
toplevel->OnKeyEvent(&backspace_r);
EXPECT_FALSE(backspace_r.handled());
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index f8b7f86a..0e513db 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -1491,7 +1491,7 @@ LRESULT HWNDMessageHandler::OnKeyEvent(UINT message,
WPARAM w_param,
LPARAM l_param) {
MSG msg = { hwnd(), message, w_param, l_param, GetMessageTime() };
- ui::KeyEvent key(msg, message == WM_CHAR);
+ ui::KeyEvent key(msg);
if (!delegate_->HandleUntranslatedKeyEvent(key))
DispatchKeyEventPostIME(key);
return 0;
diff --git a/ui/views/window/dialog_delegate_unittest.cc b/ui/views/window/dialog_delegate_unittest.cc
index fedb698..b355104 100644
--- a/ui/views/window/dialog_delegate_unittest.cc
+++ b/ui/views/window/dialog_delegate_unittest.cc
@@ -51,7 +51,7 @@ class TestDialog : public DialogDelegateView, public ButtonListener {
Button* last_pressed_button() const { return last_pressed_button_; }
void PressEnterAndCheckStates(Button* button) {
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false);
+ ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE);
GetFocusManager()->OnKeyEvent(key_event);
const DialogClientView* client_view = GetDialogClientView();
EXPECT_EQ(canceled_, client_view->cancel_button()->is_default());
@@ -158,10 +158,12 @@ TEST_F(DialogTest, AcceptAndCancel) {
LabelButton* cancel_button = client_view->cancel_button();
// Check that return/escape accelerators accept/cancel dialogs.
- const ui::KeyEvent return_key(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false);
+ const ui::KeyEvent return_key(
+ ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE);
dialog()->GetFocusManager()->OnKeyEvent(return_key);
dialog()->CheckAndResetStates(false, true, NULL);
- const ui::KeyEvent escape_key(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, 0, false);
+ const ui::KeyEvent escape_key(
+ ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE);
dialog()->GetFocusManager()->OnKeyEvent(escape_key);
dialog()->CheckAndResetStates(true, false, NULL);
diff --git a/ui/wm/core/compound_event_filter_unittest.cc b/ui/wm/core/compound_event_filter_unittest.cc
index afd3bcb..0ecea95 100644
--- a/ui/wm/core/compound_event_filter_unittest.cc
+++ b/ui/wm/core/compound_event_filter_unittest.cc
@@ -64,7 +64,7 @@ TEST_F(CompoundEventFilterTest, CursorVisibilityChange) {
aura::test::TestCursorClient cursor_client(root_window());
// Send key event to hide the cursor.
- ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true);
+ ui::KeyEvent key('a', ui::VKEY_A, ui::EF_NONE);
DispatchEventUsingWindowDispatcher(&key);
EXPECT_FALSE(cursor_client.IsCursorVisible());
@@ -89,13 +89,13 @@ TEST_F(CompoundEventFilterTest, CursorVisibilityChange) {
// Disallow hiding the cursor on keypress.
cursor_client.set_should_hide_cursor_on_key_event(false);
- key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true);
+ key = ui::KeyEvent('a', ui::VKEY_A, ui::EF_NONE);
DispatchEventUsingWindowDispatcher(&key);
EXPECT_TRUE(cursor_client.IsCursorVisible());
// Allow hiding the cursor on keypress.
cursor_client.set_should_hide_cursor_on_key_event(true);
- key = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true);
+ key = ui::KeyEvent('a', ui::VKEY_A, ui::EF_NONE);
DispatchEventUsingWindowDispatcher(&key);
EXPECT_FALSE(cursor_client.IsCursorVisible());
diff --git a/ui/wm/core/input_method_event_filter_unittest.cc b/ui/wm/core/input_method_event_filter_unittest.cc
index 50c1fbc..4a96745 100644
--- a/ui/wm/core/input_method_event_filter_unittest.cc
+++ b/ui/wm/core/input_method_event_filter_unittest.cc
@@ -114,8 +114,7 @@ TEST_F(InputMethodEventFilterTest, TestInputMethodKeyEventPropagation) {
TEST_F(InputMethodEventFilterTest, TestEventDispatching) {
ui::KeyEvent evt(ui::ET_KEY_PRESSED,
ui::VKEY_PROCESSKEY,
- ui::EF_IME_FABRICATED_KEY,
- false);
+ ui::EF_IME_FABRICATED_KEY);
// Calls DispatchKeyEventPostIME() without a focused text input client.
if (switches::IsTextInputFocusManagerEnabled())
ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
diff --git a/ui/wm/core/nested_accelerator_dispatcher_linux.cc b/ui/wm/core/nested_accelerator_dispatcher_linux.cc
index 12340b6..3379419 100644
--- a/ui/wm/core/nested_accelerator_dispatcher_linux.cc
+++ b/ui/wm/core/nested_accelerator_dispatcher_linux.cc
@@ -66,7 +66,7 @@ class NestedAcceleratorDispatcherLinux : public NestedAcceleratorDispatcher,
virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE {
if (IsKeyEvent(event)) {
- ui::KeyEvent key_event(event, false);
+ ui::KeyEvent key_event(event);
ui::Accelerator accelerator = CreateAcceleratorFromKeyEvent(key_event);
switch (delegate_->ProcessAccelerator(accelerator)) {
diff --git a/ui/wm/core/nested_accelerator_dispatcher_win.cc b/ui/wm/core/nested_accelerator_dispatcher_win.cc
index a810bb9..3b3fb2d 100644
--- a/ui/wm/core/nested_accelerator_dispatcher_win.cc
+++ b/ui/wm/core/nested_accelerator_dispatcher_win.cc
@@ -42,7 +42,7 @@ class NestedAcceleratorDispatcherWin : public NestedAcceleratorDispatcher,
// MessagePumpDispatcher:
virtual uint32_t Dispatch(const MSG& event) OVERRIDE {
if (IsKeyEvent(event)) {
- ui::KeyEvent key_event(event, false);
+ ui::KeyEvent key_event(event);
ui::Accelerator accelerator = CreateAcceleratorFromKeyEvent(key_event);
switch (delegate_->ProcessAccelerator(accelerator)) {
diff --git a/ui/wm/core/user_activity_detector_unittest.cc b/ui/wm/core/user_activity_detector_unittest.cc
index 8e2793a..df669c7 100644
--- a/ui/wm/core/user_activity_detector_unittest.cc
+++ b/ui/wm/core/user_activity_detector_unittest.cc
@@ -76,7 +76,7 @@ class UserActivityDetectorTest : public aura::test::AuraTestBase {
// Checks that the observer is notified in response to different types of input
// events.
TEST_F(UserActivityDetectorTest, Basic) {
- ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
+ ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
detector_->OnKeyEvent(&key_event);
EXPECT_FALSE(key_event.handled());
EXPECT_EQ(now_.ToInternalValue(),
@@ -153,7 +153,7 @@ TEST_F(UserActivityDetectorTest, Basic) {
// Checks that observers aren't notified too frequently.
TEST_F(UserActivityDetectorTest, RateLimitNotifications) {
// The observer should be notified about a key event.
- ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
+ ui::KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
detector_->OnKeyEvent(&event);
EXPECT_FALSE(event.handled());
EXPECT_EQ(1, observer_->num_invocations());