Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: ui/aura/test/x11_event_sender.cc

Issue 710553002: aura: Remove WindowTreeHost::PostNativeEvent(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/test/x11_event_sender.h ('k') | ui/aura/window_tree_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/test/x11_event_sender.cc
diff --git a/ui/aura/test/x11_event_sender.cc b/ui/aura/test/x11_event_sender.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bc58502d18a91c2c0c051b7dc5c0807ef3f5c70c
--- /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
« no previous file with comments | « ui/aura/test/x11_event_sender.h ('k') | ui/aura/window_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698