| Index: ui/platform_window/x11/x11_window.cc
|
| diff --git a/ui/platform_window/x11/x11_window.cc b/ui/platform_window/x11/x11_window.cc
|
| index e86cf3c9a09cf6631f6ffd6f5672dd79190d4a21..ab4a9a5c28f9c703523fce714eac7c69dc5e1660 100644
|
| --- a/ui/platform_window/x11/x11_window.cc
|
| +++ b/ui/platform_window/x11/x11_window.cc
|
| @@ -9,9 +9,11 @@
|
| #include <X11/Xlib.h>
|
| #include <X11/Xutil.h>
|
|
|
| +#include "base/bind.h"
|
| #include "ui/events/devices/x11/touch_factory_x11.h"
|
| #include "ui/events/event.h"
|
| #include "ui/events/event_utils.h"
|
| +#include "ui/events/ozone/events_ozone.h"
|
| #include "ui/events/platform/platform_event_dispatcher.h"
|
| #include "ui/events/platform/platform_event_source.h"
|
| #include "ui/events/platform/x11/x11_event_source.h"
|
| @@ -31,13 +33,6 @@ const char* kAtomsToCache[] = {
|
| NULL
|
| };
|
|
|
| -XID FindXEventTarget(XEvent* xevent) {
|
| - XID target = xevent->xany.window;
|
| - if (xevent->type == GenericEvent)
|
| - target = static_cast<XIDeviceEvent*>(xevent->xcookie.data)->event;
|
| - return target;
|
| -}
|
| -
|
| } // namespace
|
|
|
| X11Window::X11Window(PlatformWindowDelegate* delegate)
|
| @@ -66,54 +61,7 @@ void X11Window::Destroy() {
|
| xwindow_ = None;
|
| }
|
|
|
| -void X11Window::ProcessXInput2Event(XEvent* xev) {
|
| - if (!TouchFactory::GetInstance()->ShouldProcessXI2Event(xev))
|
| - return;
|
| - EventType event_type = EventTypeFromNative(xev);
|
| - switch (event_type) {
|
| - case ET_KEY_PRESSED:
|
| - case ET_KEY_RELEASED: {
|
| - KeyEvent key_event(xev);
|
| - delegate_->DispatchEvent(&key_event);
|
| - break;
|
| - }
|
| - case ET_MOUSE_PRESSED:
|
| - case ET_MOUSE_MOVED:
|
| - case ET_MOUSE_DRAGGED:
|
| - case ET_MOUSE_RELEASED: {
|
| - MouseEvent mouse_event(xev);
|
| - delegate_->DispatchEvent(&mouse_event);
|
| - break;
|
| - }
|
| - case ET_MOUSEWHEEL: {
|
| - MouseWheelEvent wheel_event(xev);
|
| - delegate_->DispatchEvent(&wheel_event);
|
| - break;
|
| - }
|
| - case ET_SCROLL_FLING_START:
|
| - case ET_SCROLL_FLING_CANCEL:
|
| - case ET_SCROLL: {
|
| - ScrollEvent scroll_event(xev);
|
| - delegate_->DispatchEvent(&scroll_event);
|
| - break;
|
| - }
|
| - case ET_TOUCH_MOVED:
|
| - case ET_TOUCH_PRESSED:
|
| - case ET_TOUCH_CANCELLED:
|
| - case ET_TOUCH_RELEASED: {
|
| - TouchEvent touch_event(xev);
|
| - delegate_->DispatchEvent(&touch_event);
|
| - break;
|
| - }
|
| - default:
|
| - break;
|
| - }
|
| -}
|
| -
|
| -void X11Window::Show() {
|
| - if (window_mapped_)
|
| - return;
|
| -
|
| +void X11Window::Create() {
|
| CHECK(PlatformEventSource::GetInstance());
|
| PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
|
|
|
| @@ -195,6 +143,13 @@ void X11Window::Show() {
|
| XSetWMNormalHints(xdisplay_, xwindow_, &size_hints);
|
|
|
| delegate_->OnAcceleratedWidgetAvailable(xwindow_);
|
| +}
|
| +
|
| +void X11Window::Show() {
|
| + if (window_mapped_)
|
| + return;
|
| + if (xwindow_ == None)
|
| + Create();
|
|
|
| XMapWindow(xdisplay_, xwindow_);
|
|
|
| @@ -251,27 +206,11 @@ void X11Window::SetCursor(PlatformCursor cursor) {}
|
| void X11Window::MoveCursorTo(const gfx::Point& location) {}
|
|
|
| bool X11Window::CanDispatchEvent(const PlatformEvent& event) {
|
| - return FindXEventTarget(event) == xwindow_;
|
| + return true;
|
| }
|
|
|
| -uint32_t X11Window::DispatchEvent(const PlatformEvent& event) {
|
| - XEvent* xev = event;
|
| +void X11Window::DispatchXEvent(XEvent* xev) {
|
| switch (xev->type) {
|
| - case EnterNotify: {
|
| - // EnterNotify creates ET_MOUSE_MOVED. Mark as synthesized as this is
|
| - // not real mouse move event.
|
| - MouseEvent mouse_event(xev);
|
| - CHECK_EQ(ET_MOUSE_MOVED, mouse_event.type());
|
| - mouse_event.set_flags(mouse_event.flags() | EF_IS_SYNTHESIZED);
|
| - delegate_->DispatchEvent(&mouse_event);
|
| - break;
|
| - }
|
| - case LeaveNotify: {
|
| - MouseEvent mouse_event(xev);
|
| - delegate_->DispatchEvent(&mouse_event);
|
| - break;
|
| - }
|
| -
|
| case Expose: {
|
| gfx::Rect damage_rect(xev->xexpose.x,
|
| xev->xexpose.y,
|
| @@ -281,37 +220,6 @@ uint32_t X11Window::DispatchEvent(const PlatformEvent& event) {
|
| break;
|
| }
|
|
|
| - case KeyPress:
|
| - case KeyRelease: {
|
| - KeyEvent key_event(xev);
|
| - delegate_->DispatchEvent(&key_event);
|
| - break;
|
| - }
|
| -
|
| - case ButtonPress:
|
| - case ButtonRelease: {
|
| - switch (EventTypeFromNative(xev)) {
|
| - case ET_MOUSEWHEEL: {
|
| - MouseWheelEvent mouseev(xev);
|
| - delegate_->DispatchEvent(&mouseev);
|
| - break;
|
| - }
|
| - case ET_MOUSE_PRESSED:
|
| - case ET_MOUSE_RELEASED: {
|
| - MouseEvent mouseev(xev);
|
| - delegate_->DispatchEvent(&mouseev);
|
| - break;
|
| - }
|
| - case ET_UNKNOWN:
|
| - // No event is created for X11-release events for mouse-wheel
|
| - // buttons.
|
| - break;
|
| - default:
|
| - NOTREACHED();
|
| - }
|
| - break;
|
| - }
|
| -
|
| case FocusOut:
|
| if (xev->xfocus.mode != NotifyGrab)
|
| delegate_->OnLostCapture();
|
| @@ -348,12 +256,20 @@ uint32_t X11Window::DispatchEvent(const PlatformEvent& event) {
|
| }
|
| break;
|
| }
|
| + }
|
| +}
|
|
|
| - case GenericEvent: {
|
| - ProcessXInput2Event(xev);
|
| - break;
|
| - }
|
| +uint32_t X11Window::DispatchEvent(const PlatformEvent& event) {
|
| + if (EventTypeFromNative(event) == ET_X_RAW_EVENT) {
|
| + XEvent* xev = static_cast<XEvent*>(
|
| + static_cast<CustomEvent*>(event)->generic_event_data());
|
| + DispatchXEvent(xev);
|
| + } else {
|
| + DispatchEventFromNativeUiEvent(
|
| + event, base::Bind(&PlatformWindowDelegate::DispatchEvent,
|
| + base::Unretained(delegate_)));
|
| }
|
| +
|
| return POST_DISPATCH_STOP_PROPAGATION;
|
| }
|
|
|
|
|