| Index: ui/aura/window_tree_host_x11.cc
|
| diff --git a/ui/aura/window_tree_host_x11.cc b/ui/aura/window_tree_host_x11.cc
|
| index f2604eb7999dcd31ec3306690011cc2edd237280..083b6ad3e689bc95219c920e51258690c917f3b4 100644
|
| --- a/ui/aura/window_tree_host_x11.cc
|
| +++ b/ui/aura/window_tree_host_x11.cc
|
| @@ -330,80 +330,94 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
|
| return ui::POST_DISPATCH_NONE;
|
| }
|
|
|
| - switch (xev->type) {
|
| - case EnterNotify: {
|
| - // Ignore EventNotify events from children of |xwindow_|.
|
| - // NativeViewGLSurfaceGLX adds a child to |xwindow_|.
|
| - // TODO(pkotwicz|tdanderson): Figure out whether the suppression is
|
| - // necessary. crbug.com/385716
|
| - if (xev->xcrossing.detail == NotifyInferior)
|
| + if (xev->type == MotionNotify) {
|
| + // Discard all but the most recent motion event that targets the same
|
| + // window with unchanged state.
|
| + XEvent last_event;
|
| + while (XPending(xev->xany.display)) {
|
| + XEvent next_event;
|
| + XPeekEvent(xev->xany.display, &next_event);
|
| + if (next_event.type == MotionNotify &&
|
| + next_event.xmotion.window == xev->xmotion.window &&
|
| + next_event.xmotion.subwindow == xev->xmotion.subwindow &&
|
| + next_event.xmotion.state == xev->xmotion.state) {
|
| + XNextEvent(xev->xany.display, &last_event);
|
| + xev = &last_event;
|
| + } else {
|
| break;
|
| -
|
| - aura::Window* root_window = window();
|
| - client::CursorClient* cursor_client =
|
| - client::GetCursorClient(root_window);
|
| - if (cursor_client) {
|
| - const gfx::Display display = gfx::Screen::GetScreenFor(root_window)->
|
| - GetDisplayNearestWindow(root_window);
|
| - cursor_client->SetDisplay(display);
|
| }
|
| - ui::MouseEvent mouse_event(xev);
|
| - // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is not
|
| - // real mouse move event.
|
| - mouse_event.set_flags(mouse_event.flags() | ui::EF_IS_SYNTHESIZED);
|
| - TranslateAndDispatchLocatedEvent(&mouse_event);
|
| - break;
|
| }
|
| - case LeaveNotify: {
|
| - // Ignore LeaveNotify events from children of |xwindow_|.
|
| - // NativeViewGLSurfaceGLX adds a child to |xwindow_|.
|
| - // TODO(pkotwicz|tdanderson): Figure out whether the suppression is
|
| - // necessary. crbug.com/385716
|
| - if (xev->xcrossing.detail == NotifyInferior)
|
| + }
|
| +
|
| + if ((xev->type == EnterNotify || xev->type == LeaveNotify) &&
|
| + xev->xcrossing.detail == NotifyInferior) {
|
| + // Ignore EventNotify and LeaveNotify events from children of |xwindow_|.
|
| + // NativeViewGLSurfaceGLX adds a child to |xwindow_|.
|
| + // TODO(pkotwicz|tdanderson): Figure out whether the suppression is
|
| + // necessary. crbug.com/385716
|
| + return ui::POST_DISPATCH_STOP_PROPAGATION;
|
| + }
|
| +
|
| + if (xev->type == EnterNotify ||
|
| + xev->type == LeaveNotify ||
|
| + xev->type == KeyPress ||
|
| + xev->type == KeyRelease ||
|
| + xev->type == ButtonPress ||
|
| + xev->type == ButtonRelease ||
|
| + xev->type == MotionNotify) {
|
| + switch (ui::EventTypeFromNative(xev)) {
|
| + case ui::ET_KEY_PRESSED:
|
| + case ui::ET_KEY_RELEASED: {
|
| + ui::KeyEvent keydown_event(xev, false);
|
| + SendEventToProcessor(&keydown_event);
|
| break;
|
| + }
|
| + case ui::ET_MOUSE_MOVED:
|
| + case ui::ET_MOUSE_DRAGGED:
|
| + case ui::ET_MOUSE_ENTERED:
|
| + case ui::ET_MOUSE_EXITED:
|
| + case ui::ET_MOUSE_PRESSED:
|
| + case ui::ET_MOUSE_RELEASED: {
|
| + ui::MouseEvent mouse_event(xev);
|
| + if (xev->type == EnterNotify) {
|
| + aura::Window* root_window = window();
|
| + client::CursorClient* cursor_client =
|
| + client::GetCursorClient(root_window);
|
| + if (cursor_client) {
|
| + const gfx::Display display = gfx::Screen::GetScreenFor(
|
| + root_window)->GetDisplayNearestWindow(root_window);
|
| + cursor_client->SetDisplay(display);
|
| + }
|
| + // EnterNotify creates ET_MOUSE_MOVE. Mark as synthesized as this is
|
| + // not a real mouse move event.
|
| + mouse_event.set_flags(mouse_event.flags() | ui::EF_IS_SYNTHESIZED);
|
| + }
|
|
|
| - ui::MouseEvent mouse_event(xev);
|
| - TranslateAndDispatchLocatedEvent(&mouse_event);
|
| - break;
|
| + TranslateAndDispatchLocatedEvent(&mouse_event);
|
| + break;
|
| + }
|
| + case ui::ET_MOUSEWHEEL: {
|
| + ui::MouseWheelEvent mouseev(xev);
|
| + TranslateAndDispatchLocatedEvent(&mouseev);
|
| + break;
|
| + }
|
| + case ui::ET_UNKNOWN:
|
| + // No event is created for X11-release events for mouse-wheel buttons.
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| }
|
| + return ui::POST_DISPATCH_STOP_PROPAGATION;
|
| + }
|
| +
|
| + switch (xev->type) {
|
| case Expose: {
|
| gfx::Rect damage_rect(xev->xexpose.x, xev->xexpose.y,
|
| xev->xexpose.width, xev->xexpose.height);
|
| compositor()->ScheduleRedrawRect(damage_rect);
|
| break;
|
| }
|
| - case KeyPress: {
|
| - ui::KeyEvent keydown_event(xev, false);
|
| - SendEventToProcessor(&keydown_event);
|
| - break;
|
| - }
|
| - case KeyRelease: {
|
| - ui::KeyEvent keyup_event(xev, false);
|
| - SendEventToProcessor(&keyup_event);
|
| - break;
|
| - }
|
| - case ButtonPress:
|
| - case ButtonRelease: {
|
| - switch (ui::EventTypeFromNative(xev)) {
|
| - case ui::ET_MOUSEWHEEL: {
|
| - ui::MouseWheelEvent mouseev(xev);
|
| - TranslateAndDispatchLocatedEvent(&mouseev);
|
| - break;
|
| - }
|
| - case ui::ET_MOUSE_PRESSED:
|
| - case ui::ET_MOUSE_RELEASED: {
|
| - ui::MouseEvent mouseev(xev);
|
| - TranslateAndDispatchLocatedEvent(&mouseev);
|
| - break;
|
| - }
|
| - case ui::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)
|
| OnHostLostWindowCapture();
|
| @@ -462,28 +476,6 @@ uint32_t WindowTreeHostX11::DispatchEvent(const ui::PlatformEvent& event) {
|
| }
|
| break;
|
| }
|
| - case MotionNotify: {
|
| - // Discard all but the most recent motion event that targets the same
|
| - // window with unchanged state.
|
| - XEvent last_event;
|
| - while (XPending(xev->xany.display)) {
|
| - XEvent next_event;
|
| - XPeekEvent(xev->xany.display, &next_event);
|
| - if (next_event.type == MotionNotify &&
|
| - next_event.xmotion.window == xev->xmotion.window &&
|
| - next_event.xmotion.subwindow == xev->xmotion.subwindow &&
|
| - next_event.xmotion.state == xev->xmotion.state) {
|
| - XNextEvent(xev->xany.display, &last_event);
|
| - xev = &last_event;
|
| - } else {
|
| - break;
|
| - }
|
| - }
|
| -
|
| - ui::MouseEvent mouseev(xev);
|
| - TranslateAndDispatchLocatedEvent(&mouseev);
|
| - break;
|
| - }
|
| }
|
| return ui::POST_DISPATCH_STOP_PROPAGATION;
|
| }
|
| @@ -653,9 +645,17 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
|
| (ui::EventTimeForNow() - ui::EventTimeFromNative(event)).
|
| InMicroseconds());
|
|
|
| - ui::EventType type = ui::EventTypeFromNative(xev);
|
| - XEvent last_event;
|
| int num_coalesced = 0;
|
| + XEvent last_event;
|
| + if (xev->xgeneric.evtype == XI_Motion) {
|
| + // If this is a motion event, we want to coalesce all pending motion
|
| + // events that are at the top of the queue. Note, we don't coalesce
|
| + // touch update events here.
|
| + num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event);
|
| + if (num_coalesced > 0)
|
| + xev = &last_event;
|
| + }
|
| + ui::EventType type = ui::EventTypeFromNative(xev);
|
|
|
| switch (type) {
|
| case ui::ET_TOUCH_MOVED:
|
| @@ -676,13 +676,6 @@ void WindowTreeHostX11::DispatchXI2Event(const base::NativeEvent& event) {
|
| case ui::ET_MOUSE_RELEASED:
|
| case ui::ET_MOUSE_ENTERED:
|
| case ui::ET_MOUSE_EXITED: {
|
| - if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) {
|
| - // If this is a motion event, we want to coalesce all pending motion
|
| - // events that are at the top of the queue.
|
| - num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event);
|
| - if (num_coalesced > 0)
|
| - xev = &last_event;
|
| - }
|
| ui::MouseEvent mouseev(xev);
|
| TranslateAndDispatchLocatedEvent(&mouseev);
|
| break;
|
|
|