summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadrul Habib Chowdhury <sadrul@chromium.org>2014-11-07 17:57:18 -0500
committerSadrul Habib Chowdhury <sadrul@chromium.org>2014-11-07 22:58:19 +0000
commitc332de7c1838b85e27685bed6c376c36ccb17287 (patch)
treeb8e32181eba16d61c59a576699bbb2f61eb876d0
parent24dff7c3f0e5760011e76db750294742f7e05ebb (diff)
downloadchromium_src-c332de7c1838b85e27685bed6c376c36ccb17287.zip
chromium_src-c332de7c1838b85e27685bed6c376c36ccb17287.tar.gz
chromium_src-c332de7c1838b85e27685bed6c376c36ccb17287.tar.bz2
aura: Remove WindowTreeHost::PostNativeEvent().
WindowTreeHost::PostNativeEvent() is only used in tests. So remove this from the public API. Instead: . For Win32, directly use PostMessage (this is used in only two places). . For Ozone, use EventSourceTestApi to inject the event (this is equivalent to current code, in terms of not doing the right thing when menus are open). . For X11, introduce aura::test::PostEventToWindowTreeHost() instead, and use it in tests. BUG=none R=sky@chromium.org Review URL: https://codereview.chromium.org/710553002 Cr-Commit-Position: refs/heads/master@{#303315}
-rw-r--r--ui/aura/BUILD.gn2
-rw-r--r--ui/aura/aura.gyp2
-rw-r--r--ui/aura/remote_window_tree_host_win.cc4
-rw-r--r--ui/aura/remote_window_tree_host_win.h1
-rw-r--r--ui/aura/test/ui_controls_factory_aurax11.cc17
-rw-r--r--ui/aura/test/ui_controls_factory_ozone.cc13
-rw-r--r--ui/aura/test/x11_event_sender.cc49
-rw-r--r--ui/aura/test/x11_event_sender.h23
-rw-r--r--ui/aura/window_tree_host.h3
-rw-r--r--ui/aura/window_tree_host_mac.h1
-rw-r--r--ui/aura/window_tree_host_mac.mm4
-rw-r--r--ui/aura/window_tree_host_ozone.cc5
-rw-r--r--ui/aura/window_tree_host_ozone.h1
-rw-r--r--ui/aura/window_tree_host_win.cc5
-rw-r--r--ui/aura/window_tree_host_win.h1
-rw-r--r--ui/aura/window_tree_host_x11.cc34
-rw-r--r--ui/aura/window_tree_host_x11.h1
-rw-r--r--ui/views/test/ui_controls_factory_desktop_aurax11.cc15
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc4
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_win.h1
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc33
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h1
-rw-r--r--ui/wm/core/nested_accelerator_controller_unittest.cc11
23 files changed, 110 insertions, 121 deletions
diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn
index 733a9c2..2acd411 100644
--- a/ui/aura/BUILD.gn
+++ b/ui/aura/BUILD.gn
@@ -175,6 +175,8 @@ source_set("test_support") {
"test/window_event_dispatcher_test_api.h",
"test/window_test_api.cc",
"test/window_test_api.h",
+ "test/x11_event_sender.cc",
+ "test/x11_event_sender.h",
]
public_deps = [
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 88ddcce..aceab85 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -191,6 +191,8 @@
'test/window_event_dispatcher_test_api.h',
'test/window_test_api.cc',
'test/window_test_api.h',
+ 'test/x11_event_sender.cc',
+ 'test/x11_event_sender.h',
],
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267, ],
diff --git a/ui/aura/remote_window_tree_host_win.cc b/ui/aura/remote_window_tree_host_win.cc
index 80ffc99..6d4367b 100644
--- a/ui/aura/remote_window_tree_host_win.cc
+++ b/ui/aura/remote_window_tree_host_win.cc
@@ -271,10 +271,6 @@ void RemoteWindowTreeHostWin::OnCursorVisibilityChangedNative(bool show) {
NOTIMPLEMENTED();
}
-void RemoteWindowTreeHostWin::PostNativeEvent(
- const base::NativeEvent& native_event) {
-}
-
ui::EventProcessor* RemoteWindowTreeHostWin::GetEventProcessor() {
return dispatcher();
}
diff --git a/ui/aura/remote_window_tree_host_win.h b/ui/aura/remote_window_tree_host_win.h
index d1454d2..b680cc8 100644
--- a/ui/aura/remote_window_tree_host_win.h
+++ b/ui/aura/remote_window_tree_host_win.h
@@ -125,7 +125,6 @@ class AURA_EXPORT RemoteWindowTreeHostWin
virtual gfx::Point GetLocationOnNativeScreen() const override;
virtual void SetCapture() override;
virtual void ReleaseCapture() override;
- virtual void PostNativeEvent(const base::NativeEvent& native_event) override;
virtual void SetCursorNative(gfx::NativeCursor cursor) override;
virtual void MoveCursorToNative(const gfx::Point& location) override;
virtual void OnCursorVisibilityChangedNative(bool show) override;
diff --git a/ui/aura/test/ui_controls_factory_aurax11.cc b/ui/aura/test/ui_controls_factory_aurax11.cc
index b89e86c..8999aa6 100644
--- a/ui/aura/test/ui_controls_factory_aurax11.cc
+++ b/ui/aura/test/ui_controls_factory_aurax11.cc
@@ -11,6 +11,7 @@
#include "ui/aura/env.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
+#include "ui/aura/test/x11_event_sender.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/test/ui_controls_aura.h"
@@ -79,11 +80,11 @@ class UIControlsX11 : public UIControlsAura {
xevent.xkey.keycode =
XKeysymToKeycode(gfx::GetXDisplay(),
ui::XKeysymForWindowsKeyCode(key, shift));
- host_->PostNativeEvent(&xevent);
+ PostEventToWindowTreeHost(xevent, host_);
// Send key release events.
xevent.xkey.type = KeyRelease;
- host_->PostNativeEvent(&xevent);
+ PostEventToWindowTreeHost(xevent, host_);
if (alt)
UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
if (shift)
@@ -127,7 +128,7 @@ class UIControlsX11 : public UIControlsAura {
xmotion->state = button_down_mask;
xmotion->same_screen = True;
// WindowTreeHost will take care of other necessary fields.
- host_->PostNativeEvent(&xevent);
+ PostEventToWindowTreeHost(xevent, host_);
}
RunClosureAfterAllPendingUIEvents(closure);
return true;
@@ -167,12 +168,12 @@ class UIControlsX11 : public UIControlsAura {
// WindowEventDispatcher will take care of other necessary fields.
if (state & DOWN) {
xevent.xbutton.type = ButtonPress;
- host_->PostNativeEvent(&xevent);
+ PostEventToWindowTreeHost(xevent, host_);
button_down_mask |= xbutton->state;
}
if (state & UP) {
xevent.xbutton.type = ButtonRelease;
- host_->PostNativeEvent(&xevent);
+ PostEventToWindowTreeHost(xevent, host_);
button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state;
}
RunClosureAfterAllPendingUIEvents(closure);
@@ -194,7 +195,7 @@ class UIControlsX11 : public UIControlsAura {
marker_event->xclient.format = 8;
}
marker_event->xclient.message_type = MarkerEventAtom();
- host_->PostNativeEvent(marker_event);
+ PostEventToWindowTreeHost(*marker_event, host_);
ui::PlatformEventWaiter::Create(closure, base::Bind(&Matcher));
}
private:
@@ -203,7 +204,7 @@ class UIControlsX11 : public UIControlsAura {
unsigned int mask) {
xevent->xkey.keycode =
XKeysymToKeycode(gfx::GetXDisplay(), keysym);
- host_->PostNativeEvent(xevent);
+ PostEventToWindowTreeHost(*xevent, host_);
xevent->xkey.state |= mask;
}
@@ -213,7 +214,7 @@ class UIControlsX11 : public UIControlsAura {
xevent->xkey.state ^= mask;
xevent->xkey.keycode =
XKeysymToKeycode(gfx::GetXDisplay(), keysym);
- host_->PostNativeEvent(xevent);
+ PostEventToWindowTreeHost(*xevent, host_);
}
WindowTreeHost* host_;
diff --git a/ui/aura/test/ui_controls_factory_ozone.cc b/ui/aura/test/ui_controls_factory_ozone.cc
index 5bd96bb..ff92cd6 100644
--- a/ui/aura/test/ui_controls_factory_ozone.cc
+++ b/ui/aura/test/ui_controls_factory_ozone.cc
@@ -10,6 +10,7 @@
#include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/test/ui_controls_aura.h"
+#include "ui/events/test/events_test_utils.h"
namespace aura {
namespace test {
@@ -165,6 +166,14 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
}
private:
+ void SendEventToProcessor(ui::Event* event) {
+ ui::EventSourceTestApi event_source_test(host_->GetEventSource());
+ ui::EventDispatchDetails details =
+ event_source_test.SendEventToProcessor(event);
+ if (details.dispatcher_destroyed)
+ return;
+ }
+
void PostKeyEvent(ui::EventType type, ui::KeyboardCode key_code, int flags) {
base::MessageLoop::current()->PostTask(
FROM_HERE,
@@ -182,7 +191,7 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
flags |= ui::EF_FINAL;
ui::KeyEvent key_event(type, key_code, flags);
- host_->PostNativeEvent(&key_event);
+ SendEventToProcessor(&key_event);
}
void PostMouseEvent(ui::EventType type,
@@ -209,7 +218,7 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
// This hack is necessary to set the repeat count for clicks.
ui::MouseEvent mouse_event2(&mouse_event);
- host_->PostNativeEvent(&mouse_event2);
+ SendEventToProcessor(&mouse_event2);
}
WindowTreeHost* host_;
diff --git a/ui/aura/test/x11_event_sender.cc b/ui/aura/test/x11_event_sender.cc
new file mode 100644
index 0000000..bc58502
--- /dev/null
+++ b/ui/aura/test/x11_event_sender.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/test/x11_event_sender.h"
+
+#include <X11/Xlib.h>
+
+#include "ui/aura/window_tree_host.h"
+#include "ui/gfx/geometry/point.h"
+
+namespace aura {
+namespace test {
+
+void PostEventToWindowTreeHost(const XEvent& xevent, WindowTreeHost* host) {
+ XDisplay* xdisplay = gfx::GetXDisplay();
+ XID xwindow = host->GetAcceleratedWidget();
+ XEvent event = xevent;
+ event.xany.display = xdisplay;
+ event.xany.window = xwindow;
+
+ switch (event.type) {
+ case EnterNotify:
+ case LeaveNotify:
+ case MotionNotify:
+ case KeyPress:
+ case KeyRelease:
+ case ButtonPress:
+ case ButtonRelease: {
+ // The fields used below are in the same place for all of events
+ // above. Using xmotion from XEvent's unions to avoid repeating
+ // the code.
+ event.xmotion.root = DefaultRootWindow(event.xany.display);
+ event.xmotion.time = CurrentTime;
+
+ gfx::Point point(event.xmotion.x, event.xmotion.y);
+ host->ConvertPointToNativeScreen(&point);
+ event.xmotion.x_root = point.x();
+ event.xmotion.y_root = point.y();
+ }
+ default:
+ break;
+ }
+ XSendEvent(xdisplay, xwindow, False, 0, &event);
+ XFlush(xdisplay);
+}
+
+} // namespace test
+} // namespace aura
diff --git a/ui/aura/test/x11_event_sender.h b/ui/aura/test/x11_event_sender.h
new file mode 100644
index 0000000..64720ac
--- /dev/null
+++ b/ui/aura/test/x11_event_sender.h
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_TEST_X11_EVENT_SENDER_H_
+#define UI_AURA_TEST_X11_EVENT_SENDER_H_
+
+#include "ui/gfx/x/x11_types.h"
+
+using XEvent = union _XEvent;
+
+namespace aura {
+
+class WindowTreeHost;
+
+namespace test {
+
+void PostEventToWindowTreeHost(const XEvent& xevent, WindowTreeHost* host);
+
+} // namespace test
+} // namespace aura
+
+#endif // UI_AURA_TEST_X11_EVENT_SENDER_H_
diff --git a/ui/aura/window_tree_host.h b/ui/aura/window_tree_host.h
index aaf0d3b2..b08391f 100644
--- a/ui/aura/window_tree_host.h
+++ b/ui/aura/window_tree_host.h
@@ -139,9 +139,6 @@ class AURA_EXPORT WindowTreeHost {
// Releases OS capture of the root window.
virtual void ReleaseCapture() = 0;
- // Posts |native_event| to the platform's event queue.
- virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0;
-
protected:
friend class TestScreen; // TODO(beng): see if we can remove/consolidate.
diff --git a/ui/aura/window_tree_host_mac.h b/ui/aura/window_tree_host_mac.h
index da502b5..f71f167 100644
--- a/ui/aura/window_tree_host_mac.h
+++ b/ui/aura/window_tree_host_mac.h
@@ -47,7 +47,6 @@ class AURA_EXPORT WindowTreeHostMac : public WindowTreeHost {
virtual void SetCursorNative(gfx::NativeCursor cursor_type) override;
virtual void MoveCursorToNative(const gfx::Point& location) override;
virtual void OnCursorVisibilityChangedNative(bool show) override;
- virtual void PostNativeEvent(const base::NativeEvent& event) override;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override;
private:
diff --git a/ui/aura/window_tree_host_mac.mm b/ui/aura/window_tree_host_mac.mm
index 7fb3f82..6a05b6a 100644
--- a/ui/aura/window_tree_host_mac.mm
+++ b/ui/aura/window_tree_host_mac.mm
@@ -92,10 +92,6 @@ void WindowTreeHostMac::OnCursorVisibilityChangedNative(bool show) {
NOTIMPLEMENTED();
}
-void WindowTreeHostMac::PostNativeEvent(const base::NativeEvent& event) {
- NOTIMPLEMENTED();
-}
-
void WindowTreeHostMac::OnDeviceScaleFactorChanged(float device_scale_factor) {
NOTIMPLEMENTED();
}
diff --git a/ui/aura/window_tree_host_ozone.cc b/ui/aura/window_tree_host_ozone.cc
index 6c332d75..77af0bc 100644
--- a/ui/aura/window_tree_host_ozone.cc
+++ b/ui/aura/window_tree_host_ozone.cc
@@ -94,11 +94,6 @@ void WindowTreeHostOzone::ReleaseCapture() {
platform_window_->ReleaseCapture();
}
-void WindowTreeHostOzone::PostNativeEvent(
- const base::NativeEvent& native_event) {
- SendEventToProcessor(static_cast<ui::Event*>(native_event));
-}
-
void WindowTreeHostOzone::SetCursorNative(gfx::NativeCursor cursor) {
platform_window_->SetCursor(cursor.platform());
}
diff --git a/ui/aura/window_tree_host_ozone.h b/ui/aura/window_tree_host_ozone.h
index f0e8c98..52d7ca8 100644
--- a/ui/aura/window_tree_host_ozone.h
+++ b/ui/aura/window_tree_host_ozone.h
@@ -47,7 +47,6 @@ class AURA_EXPORT WindowTreeHostOzone : public WindowTreeHost,
virtual gfx::Point GetLocationOnNativeScreen() const override;
virtual void SetCapture() override;
virtual void ReleaseCapture() override;
- virtual void PostNativeEvent(const base::NativeEvent& event) override;
virtual void SetCursorNative(gfx::NativeCursor cursor_type) override;
virtual void MoveCursorToNative(const gfx::Point& location) override;
virtual void OnCursorVisibilityChangedNative(bool show) override;
diff --git a/ui/aura/window_tree_host_win.cc b/ui/aura/window_tree_host_win.cc
index 51bbcc6..9a30344 100644
--- a/ui/aura/window_tree_host_win.cc
+++ b/ui/aura/window_tree_host_win.cc
@@ -112,11 +112,6 @@ void WindowTreeHostWin::OnCursorVisibilityChangedNative(bool show) {
NOTIMPLEMENTED();
}
-void WindowTreeHostWin::PostNativeEvent(const base::NativeEvent& native_event) {
- ::PostMessage(
- widget_, native_event.message, native_event.wParam, native_event.lParam);
-}
-
ui::EventProcessor* WindowTreeHostWin::GetEventProcessor() {
return dispatcher();
}
diff --git a/ui/aura/window_tree_host_win.h b/ui/aura/window_tree_host_win.h
index bfbdc07..a448a3f 100644
--- a/ui/aura/window_tree_host_win.h
+++ b/ui/aura/window_tree_host_win.h
@@ -36,7 +36,6 @@ class AURA_EXPORT WindowTreeHostWin
virtual void SetCursorNative(gfx::NativeCursor cursor) override;
virtual void MoveCursorToNative(const gfx::Point& location) override;
virtual void OnCursorVisibilityChangedNative(bool show) override;
- virtual void PostNativeEvent(const base::NativeEvent& native_event) override;
// ui::EventSource:
virtual ui::EventProcessor* GetEventProcessor() override;
diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc
index 4914b25..16096b7 100644
--- a/ui/aura/window_tree_host_x11.cc
+++ b/ui/aura/window_tree_host_x11.cc
@@ -572,40 +572,6 @@ void WindowTreeHostX11::ReleaseCapture() {
// TODO(oshima): Release x input.
}
-void WindowTreeHostX11::PostNativeEvent(
- const base::NativeEvent& native_event) {
- DCHECK(xwindow_);
- DCHECK(xdisplay_);
- XEvent xevent = *native_event;
- xevent.xany.display = xdisplay_;
- xevent.xany.window = xwindow_;
-
- switch (xevent.type) {
- case EnterNotify:
- case LeaveNotify:
- case MotionNotify:
- case KeyPress:
- case KeyRelease:
- case ButtonPress:
- case ButtonRelease: {
- // The fields used below are in the same place for all of events
- // above. Using xmotion from XEvent's unions to avoid repeating
- // the code.
- xevent.xmotion.root = x_root_window_;
- xevent.xmotion.time = CurrentTime;
-
- gfx::Point point(xevent.xmotion.x, xevent.xmotion.y);
- ConvertPointToNativeScreen(&point);
- xevent.xmotion.x_root = point.x();
- xevent.xmotion.y_root = point.y();
- }
- default:
- break;
- }
- XSendEvent(xdisplay_, xwindow_, False, 0, &xevent);
- XFlush(xdisplay_);
-}
-
void WindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) {
if (cursor == current_cursor_)
return;
diff --git a/ui/aura/window_tree_host_x11.h b/ui/aura/window_tree_host_x11.h
index 664e726..aff874c 100644
--- a/ui/aura/window_tree_host_x11.h
+++ b/ui/aura/window_tree_host_x11.h
@@ -51,7 +51,6 @@ class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost,
gfx::Point GetLocationOnNativeScreen() const override;
void SetCapture() override;
void ReleaseCapture() override;
- void PostNativeEvent(const base::NativeEvent& event) override;
void SetCursorNative(gfx::NativeCursor cursor_type) override;
void MoveCursorToNative(const gfx::Point& location) override;
void OnCursorVisibilityChangedNative(bool show) override;
diff --git a/ui/views/test/ui_controls_factory_desktop_aurax11.cc b/ui/views/test/ui_controls_factory_desktop_aurax11.cc
index 1c5fe85..7e52286 100644
--- a/ui/views/test/ui_controls_factory_desktop_aurax11.cc
+++ b/ui/views/test/ui_controls_factory_desktop_aurax11.cc
@@ -16,6 +16,7 @@
#include "ui/aura/env.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
+#include "ui/aura/test/x11_event_sender.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/test/ui_controls_aura.h"
#include "ui/base/x/x11_util.h"
@@ -104,11 +105,11 @@ class UIControlsDesktopX11 : public UIControlsAura {
xevent.xkey.keycode =
XKeysymToKeycode(x_display_,
ui::XKeysymForWindowsKeyCode(key, shift));
- host->PostNativeEvent(&xevent);
+ aura::test::PostEventToWindowTreeHost(xevent, host);
// Send key release events.
xevent.xkey.type = KeyRelease;
- host->PostNativeEvent(&xevent);
+ aura::test::PostEventToWindowTreeHost(xevent, host);
if (alt)
UnmaskAndSetKeycodeThenSend(host, &xevent, Mod1Mask, XK_Alt_L);
if (shift)
@@ -156,7 +157,7 @@ class UIControlsDesktopX11 : public UIControlsAura {
xmotion->state = button_down_mask;
xmotion->same_screen = True;
// RootWindow will take care of other necessary fields.
- host->PostNativeEvent(&xevent);
+ aura::test::PostEventToWindowTreeHost(xevent, host);
}
RunClosureAfterAllPendingUIEvents(closure);
return true;
@@ -195,12 +196,12 @@ class UIControlsDesktopX11 : public UIControlsAura {
// RootWindow will take care of other necessary fields.
if (state & DOWN) {
xevent.xbutton.type = ButtonPress;
- root_window->GetHost()->PostNativeEvent(&xevent);
+ aura::test::PostEventToWindowTreeHost(xevent, root_window->GetHost());
button_down_mask |= xbutton->state;
}
if (state & UP) {
xevent.xbutton.type = ButtonRelease;
- root_window->GetHost()->PostNativeEvent(&xevent);
+ aura::test::PostEventToWindowTreeHost(xevent, root_window->GetHost());
button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state;
}
RunClosureAfterAllPendingUIEvents(closure);
@@ -251,7 +252,7 @@ class UIControlsDesktopX11 : public UIControlsAura {
KeySym keysym,
unsigned int mask) {
xevent->xkey.keycode = XKeysymToKeycode(x_display_, keysym);
- host->PostNativeEvent(xevent);
+ aura::test::PostEventToWindowTreeHost(*xevent, host);
xevent->xkey.state |= mask;
}
@@ -261,7 +262,7 @@ class UIControlsDesktopX11 : public UIControlsAura {
KeySym keysym) {
xevent->xkey.state ^= mask;
xevent->xkey.keycode = XKeysymToKeycode(x_display_, keysym);
- host->PostNativeEvent(xevent);
+ aura::test::PostEventToWindowTreeHost(*xevent, host);
}
// Our X11 state.
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
index ac57a18..8fac698 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -532,10 +532,6 @@ void DesktopWindowTreeHostWin::ReleaseCapture() {
message_handler_->ReleaseCapture();
}
-void DesktopWindowTreeHostWin::PostNativeEvent(
- const base::NativeEvent& native_event) {
-}
-
void DesktopWindowTreeHostWin::SetCursorNative(gfx::NativeCursor cursor) {
ui::CursorLoaderWin cursor_loader;
cursor_loader.SetPlatformCursor(&cursor);
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
index 83ffd08..8e8aec2 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
@@ -116,7 +116,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
virtual gfx::Point GetLocationOnNativeScreen() const override;
virtual void SetCapture() override;
virtual void ReleaseCapture() override;
- virtual void PostNativeEvent(const base::NativeEvent& native_event) override;
virtual void SetCursorNative(gfx::NativeCursor cursor) override;
virtual void OnCursorVisibilityChangedNative(bool show) override;
virtual void MoveCursorToNative(const gfx::Point& location) override;
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 d2711cf..3c99281 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
@@ -988,39 +988,6 @@ void DesktopWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
// the same tap-to-click disabling here that chromeos does.
}
-void DesktopWindowTreeHostX11::PostNativeEvent(
- const base::NativeEvent& native_event) {
- DCHECK(xwindow_);
- DCHECK(xdisplay_);
- XEvent xevent = *native_event;
- xevent.xany.display = xdisplay_;
- xevent.xany.window = xwindow_;
-
- switch (xevent.type) {
- case EnterNotify:
- case LeaveNotify:
- case MotionNotify:
- case KeyPress:
- case KeyRelease:
- case ButtonPress:
- case ButtonRelease: {
- // The fields used below are in the same place for all of events
- // above. Using xmotion from XEvent's unions to avoid repeating
- // the code.
- xevent.xmotion.root = x_root_window_;
- xevent.xmotion.time = CurrentTime;
-
- gfx::Point point(xevent.xmotion.x, xevent.xmotion.y);
- ConvertPointToNativeScreen(&point);
- xevent.xmotion.x_root = point.x();
- xevent.xmotion.y_root = point.y();
- }
- default:
- break;
- }
- XSendEvent(xdisplay_, xwindow_, False, 0, &xevent);
-}
-
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11, ui::EventSource implementation:
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
index edfc9dc..1a4f725 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
@@ -156,7 +156,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
gfx::Point GetLocationOnNativeScreen() const override;
void SetCapture() override;
void ReleaseCapture() override;
- void PostNativeEvent(const base::NativeEvent& native_event) override;
void SetCursorNative(gfx::NativeCursor cursor) override;
void MoveCursorToNative(const gfx::Point& location) override;
void OnCursorVisibilityChangedNative(bool show) override;
diff --git a/ui/wm/core/nested_accelerator_controller_unittest.cc b/ui/wm/core/nested_accelerator_controller_unittest.cc
index 968bcba..ae8f5f5 100644
--- a/ui/wm/core/nested_accelerator_controller_unittest.cc
+++ b/ui/wm/core/nested_accelerator_controller_unittest.cc
@@ -24,6 +24,7 @@
#if defined(USE_X11)
#include <X11/Xlib.h>
+#include "ui/aura/test/x11_event_sender.h"
#include "ui/events/test/events_test_utils_x11.h"
#endif // USE_X11
@@ -79,18 +80,18 @@ void DispatchKeyReleaseA(aura::Window* root_window) {
// manager only checks a keyup event following a keydown event. See
// ShouldHandle() in ui/base/accelerators/accelerator_manager.cc for details.
#if defined(OS_WIN)
- MSG native_event_down = {NULL, WM_KEYDOWN, ui::VKEY_A, 0};
aura::WindowTreeHost* host = root_window->GetHost();
- host->PostNativeEvent(native_event_down);
+ HWND hwnd = host->GetAcceleratedWidget();
+ ::PostMessage(hwnd, WM_KEYDOWN, ui::VKEY_A, 0);
MSG native_event_up = {NULL, WM_KEYUP, ui::VKEY_A, 0};
- host->PostNativeEvent(native_event_up);
+ ::PostMessage(hwnd, WM_KEYUP, ui::VKEY_A, 0);
#elif defined(USE_X11)
ui::ScopedXI2Event native_event;
native_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0);
aura::WindowTreeHost* host = root_window->GetHost();
- host->PostNativeEvent(native_event);
+ aura::test::PostEventToWindowTreeHost(*native_event, host);
native_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0);
- host->PostNativeEvent(native_event);
+ aura::test::PostEventToWindowTreeHost(*native_event, host);
#endif
// Make sure the inner message-loop terminates after dispatching the events.
base::MessageLoop::current()->PostTask(