Commit 7cf43268 authored by tommi@chromium.org's avatar tommi@chromium.org

Revert 162381 - linux_aura: Fix tab dragging performance.

###
Reason:
chromeos-chrome-24.0.1300.0_alpha-r1: ui/base/x/x11_util.cc: In function 'int ui::CoalescePendingMotionEvents(const XEvent*, XEvent*)':
chromeos-chrome-24.0.1300.0_alpha-r1: ui/base/x/x11_util.cc:1449:14: error: 'ui::ValuatorTracker' has not been declared
chromeos-chrome-24.0.1300.0_alpha-r1: ui/base/x/x11_util.cc:1450:15: error: 'ui::ValuatorTracker' has not been declared
chromeos-chrome-24.0.1300.0_alpha-r1: ui/base/x/x11_util.cc:1483:18: error: 'ui::ValuatorTracker' has not been declared
chromeos-chrome-24.0.1300.0_alpha-r1: ui/base/x/x11_util.cc:1484:19: error: 'ui::ValuatorTracker' has not been declared
chromeos-chrome-24.0.1300.0_alpha-r1: make: *** [c/Release/obj.target/ui/ui/base/x/x11_util.o] Error 1
###

This shares the movement event coalescing from RootWindowHostLinux, which
was disabled to make initial bringup easier.

BUG=146077


Review URL: https://chromiumcodereview.appspot.com/11192009

TBR=erg@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11185026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162391 0039d316-1c4b-4281-b951-d872f2087c98
parent d4763e45
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/base/view_prop.h" #include "ui/base/view_prop.h"
#include "ui/base/x/valuators.h" #include "ui/base/x/valuators.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/dip_util.h" #include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
...@@ -75,6 +74,91 @@ const char* kAtomsToCache[] = { ...@@ -75,6 +74,91 @@ const char* kAtomsToCache[] = {
return target; return target;
} }
// Coalesce all pending motion events (touch or mouse) that are at the top of
// the queue, and return the number eliminated, storing the last one in
// |last_event|.
int CoalescePendingMotionEvents(const XEvent* xev, XEvent* last_event) {
XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
int num_coalesed = 0;
Display* display = xev->xany.display;
int event_type = xev->xgeneric.evtype;
#if defined(USE_XI2_MT)
float tracking_id = -1;
if (event_type == XI_TouchUpdate) {
if (!ui::ValuatorTracker::GetInstance()->ExtractValuator(*xev,
ui::ValuatorTracker::VAL_TRACKING_ID, &tracking_id))
tracking_id = -1;
}
#endif
while (XPending(display)) {
XEvent next_event;
XPeekEvent(display, &next_event);
// If we can't get the cookie, abort the check.
if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie))
return num_coalesed;
// If this isn't from a valid device, throw the event away, as
// that's what the message pump would do. Device events come in pairs
// with one from the master and one from the slave so there will
// always be at least one pending.
if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) {
XFreeEventData(display, &next_event.xcookie);
XNextEvent(display, &next_event);
continue;
}
if (next_event.type == GenericEvent &&
next_event.xgeneric.evtype == event_type &&
!ui::GetScrollOffsets(&next_event, NULL, NULL)) {
XIDeviceEvent* next_xievent =
static_cast<XIDeviceEvent*>(next_event.xcookie.data);
#if defined(USE_XI2_MT)
float next_tracking_id = -1;
if (event_type == XI_TouchUpdate) {
// If this is a touch motion event (as opposed to mouse motion event),
// then make sure the events are from the same touch-point.
if (!ui::ValuatorTracker::GetInstance()->ExtractValuator(next_event,
ui::ValuatorTracker::VAL_TRACKING_ID, &next_tracking_id))
next_tracking_id = -1;
}
#endif
// Confirm that the motion event is targeted at the same window
// and that no buttons or modifiers have changed.
if (xievent->event == next_xievent->event &&
xievent->child == next_xievent->child &&
#if defined(USE_XI2_MT)
(event_type == XI_Motion || tracking_id == next_tracking_id) &&
#endif
xievent->buttons.mask_len == next_xievent->buttons.mask_len &&
(memcmp(xievent->buttons.mask,
next_xievent->buttons.mask,
xievent->buttons.mask_len) == 0) &&
xievent->mods.base == next_xievent->mods.base &&
xievent->mods.latched == next_xievent->mods.latched &&
xievent->mods.locked == next_xievent->mods.locked &&
xievent->mods.effective == next_xievent->mods.effective) {
XFreeEventData(display, &next_event.xcookie);
// Free the previous cookie.
if (num_coalesed > 0)
XFreeEventData(display, &last_event->xcookie);
// Get the event and its cookie data.
XNextEvent(display, last_event);
XGetEventData(display, &last_event->xcookie);
++num_coalesed;
continue;
} else {
// This isn't an event we want so free its cookie data.
XFreeEventData(display, &next_event.xcookie);
}
}
break;
}
return num_coalesed;
}
void SelectEventsForRootWindow() { void SelectEventsForRootWindow() {
Display* display = ui::GetXDisplay(); Display* display = ui::GetXDisplay();
::Window root_window = ui::GetX11RootWindow(); ::Window root_window = ui::GetX11RootWindow();
...@@ -461,7 +545,7 @@ void RootWindowHostLinux::DispatchXI2Event(const base::NativeEvent& event) { ...@@ -461,7 +545,7 @@ void RootWindowHostLinux::DispatchXI2Event(const base::NativeEvent& event) {
switch (type) { switch (type) {
case ui::ET_TOUCH_MOVED: case ui::ET_TOUCH_MOVED:
num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); num_coalesced = CoalescePendingMotionEvents(xev, &last_event);
if (num_coalesced > 0) if (num_coalesced > 0)
xev = &last_event; xev = &last_event;
// fallthrough // fallthrough
...@@ -500,7 +584,7 @@ void RootWindowHostLinux::DispatchXI2Event(const base::NativeEvent& event) { ...@@ -500,7 +584,7 @@ void RootWindowHostLinux::DispatchXI2Event(const base::NativeEvent& event) {
if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) {
// If this is a motion event, we want to coalesce all pending motion // If this is a motion event, we want to coalesce all pending motion
// events that are at the top of the queue. // events that are at the top of the queue.
num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); num_coalesced = CoalescePendingMotionEvents(xev, &last_event);
if (num_coalesced > 0) if (num_coalesced > 0)
xev = &last_event; xev = &last_event;
} else if (type == ui::ET_MOUSE_PRESSED) { } else if (type == ui::ET_MOUSE_PRESSED) {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <X11/extensions/XInput2.h>
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
#include <X11/extensions/randr.h> #include <X11/extensions/randr.h>
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
...@@ -34,7 +33,6 @@ ...@@ -34,7 +33,6 @@
#include "base/sys_byteorder.h" #include "base/sys_byteorder.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "ui/base/keycodes/keyboard_code_conversion_x.h" #include "ui/base/keycodes/keyboard_code_conversion_x.h"
#include "ui/base/touch/touch_factory.h"
#include "ui/base/x/x11_util_internal.h" #include "ui/base/x/x11_util_internal.h"
#include "ui/gfx/point_conversions.h" #include "ui/gfx/point_conversions.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
...@@ -1436,89 +1434,6 @@ bool IsMotionEvent(XEvent* event) { ...@@ -1436,89 +1434,6 @@ bool IsMotionEvent(XEvent* event) {
return type == MotionNotify; return type == MotionNotify;
} }
int CoalescePendingMotionEvents(const XEvent* xev,
XEvent* last_event) {
XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
int num_coalesed = 0;
Display* display = xev->xany.display;
int event_type = xev->xgeneric.evtype;
#if defined(USE_XI2_MT)
float tracking_id = -1;
if (event_type == XI_TouchUpdate) {
if (!ui::ValuatorTracker::GetInstance()->ExtractValuator(*xev,
ui::ValuatorTracker::VAL_TRACKING_ID, &tracking_id))
tracking_id = -1;
}
#endif
while (XPending(display)) {
XEvent next_event;
XPeekEvent(display, &next_event);
// If we can't get the cookie, abort the check.
if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie))
return num_coalesed;
// If this isn't from a valid device, throw the event away, as
// that's what the message pump would do. Device events come in pairs
// with one from the master and one from the slave so there will
// always be at least one pending.
if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) {
XFreeEventData(display, &next_event.xcookie);
XNextEvent(display, &next_event);
continue;
}
if (next_event.type == GenericEvent &&
next_event.xgeneric.evtype == event_type &&
!ui::GetScrollOffsets(&next_event, NULL, NULL)) {
XIDeviceEvent* next_xievent =
static_cast<XIDeviceEvent*>(next_event.xcookie.data);
#if defined(USE_XI2_MT)
float next_tracking_id = -1;
if (event_type == XI_TouchUpdate) {
// If this is a touch motion event (as opposed to mouse motion event),
// then make sure the events are from the same touch-point.
if (!ui::ValuatorTracker::GetInstance()->ExtractValuator(next_event,
ui::ValuatorTracker::VAL_TRACKING_ID, &next_tracking_id))
next_tracking_id = -1;
}
#endif
// Confirm that the motion event is targeted at the same window
// and that no buttons or modifiers have changed.
if (xievent->event == next_xievent->event &&
xievent->child == next_xievent->child &&
#if defined(USE_XI2_MT)
(event_type == XI_Motion || tracking_id == next_tracking_id) &&
#endif
xievent->buttons.mask_len == next_xievent->buttons.mask_len &&
(memcmp(xievent->buttons.mask,
next_xievent->buttons.mask,
xievent->buttons.mask_len) == 0) &&
xievent->mods.base == next_xievent->mods.base &&
xievent->mods.latched == next_xievent->mods.latched &&
xievent->mods.locked == next_xievent->mods.locked &&
xievent->mods.effective == next_xievent->mods.effective) {
XFreeEventData(display, &next_event.xcookie);
// Free the previous cookie.
if (num_coalesed > 0)
XFreeEventData(display, &last_event->xcookie);
// Get the event and its cookie data.
XNextEvent(display, last_event);
XGetEventData(display, &last_event->xcookie);
++num_coalesed;
continue;
} else {
// This isn't an event we want so free its cookie data.
XFreeEventData(display, &next_event.xcookie);
}
}
break;
}
return num_coalesed;
}
int GetMappedButton(int button) { int GetMappedButton(int button) {
return XButtonMap::GetInstance()->GetMappedButton(button); return XButtonMap::GetInstance()->GetMappedButton(button);
} }
......
...@@ -305,12 +305,6 @@ UI_EXPORT bool IsX11WindowFullScreen(XID window); ...@@ -305,12 +305,6 @@ UI_EXPORT bool IsX11WindowFullScreen(XID window);
// Return true if event type is MotionNotify. // Return true if event type is MotionNotify.
UI_EXPORT bool IsMotionEvent(XEvent* event); UI_EXPORT bool IsMotionEvent(XEvent* event);
// Coalesce all pending motion events (touch or mouse) that are at the top of
// the queue, and return the number eliminated, storing the last one in
// |last_event|.
UI_EXPORT int CoalescePendingMotionEvents(const XEvent* xev,
XEvent* last_event);
// Returns the mapped button. // Returns the mapped button.
int GetMappedButton(int button); int GetMappedButton(int button);
......
...@@ -917,9 +917,9 @@ bool DesktopRootWindowHostLinux::Dispatch(const base::NativeEvent& event) { ...@@ -917,9 +917,9 @@ bool DesktopRootWindowHostLinux::Dispatch(const base::NativeEvent& event) {
if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) {
// If this is a motion event, we want to coalesce all pending motion // If this is a motion event, we want to coalesce all pending motion
// events that are at the top of the queue. // events that are at the top of the queue.
num_coalesced = ui::CoalescePendingMotionEvents(xev, &last_event); // num_coalesced = CoalescePendingMotionEvents(xev, &last_event);
if (num_coalesced > 0) // if (num_coalesced > 0)
xev = &last_event; // xev = &last_event;
} else if (type == ui::ET_MOUSE_PRESSED) { } else if (type == ui::ET_MOUSE_PRESSED) {
XIDeviceEvent* xievent = XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(xev->xcookie.data); static_cast<XIDeviceEvent*>(xev->xcookie.data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment