diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 21:37:46 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 21:37:46 +0000 |
commit | 15c73e6e1f883c600d246779e63334c76ed6f8c3 (patch) | |
tree | ba2cbb96f1fc4072ccf07b7e1bbce945940fa0f0 /ui/base/x | |
parent | e0c595d3713dfbccce790b9e41ca8563732f69ff (diff) | |
download | chromium_src-15c73e6e1f883c600d246779e63334c76ed6f8c3.zip chromium_src-15c73e6e1f883c600d246779e63334c76ed6f8c3.tar.gz chromium_src-15c73e6e1f883c600d246779e63334c76ed6f8c3.tar.bz2 |
Speculative compile fix for the valgrind bots.
Try moving the new CoalescePendingMotionEvents function into the USE_AURA
section.
BUG=146077
TBR=sadrul
Review URL: https://codereview.chromium.org/11199004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162536 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/x')
-rw-r--r-- | ui/base/x/x11_util.cc | 167 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 12 |
2 files changed, 90 insertions, 89 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 402b6f6..94cf4e1 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -496,6 +496,90 @@ XcursorImage* SkBitmapToXcursorImage(const SkBitmap* cursor_image, return image; } + + +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; +} #endif void HideHostCursor() { @@ -1437,89 +1521,6 @@ bool IsMotionEvent(XEvent* event) { 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) { return XButtonMap::GetInstance()->GetMappedButton(button); } diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index 0b6653f..b3f2545 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -96,6 +96,12 @@ UI_EXPORT void UnrefCustomXCursor(::Cursor cursor); // should be non-null. Caller owns the returned object. UI_EXPORT XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, const gfx::Point& hotspot); + +// 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); #endif // Hides the host cursor. @@ -305,12 +311,6 @@ UI_EXPORT bool IsX11WindowFullScreen(XID window); // Return true if event type is MotionNotify. 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. int GetMappedButton(int button); |