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

Side by Side Diff: ui/base/x/x11_util.cc

Issue 688253002: Implemented smooth scrolling using xinput2 in X11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed duplicate AUTHORS entry Created 4 years, 11 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "ui/base/x/x11_util.h" 9 #include "ui/base/x/x11_util.h"
10 10
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // The |bitmap| contains ARGB image, so just copy it. 367 // The |bitmap| contains ARGB image, so just copy it.
368 memcpy(image->pixels, 368 memcpy(image->pixels,
369 bitmap->getPixels(), 369 bitmap->getPixels(),
370 bitmap->width() * bitmap->height() * 4); 370 bitmap->width() * bitmap->height() * 4);
371 bitmap->unlockPixels(); 371 bitmap->unlockPixels();
372 } 372 }
373 373
374 return image; 374 return image;
375 } 375 }
376 376
377 377 int CoalescePendingMotionEvents(const XEvent* xev, XEvent* last_event) {
378 int CoalescePendingMotionEvents(const XEvent* xev,
379 XEvent* last_event) {
380 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); 378 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
381 int num_coalesced = 0; 379 int num_coalesced = 0;
382 XDisplay* display = xev->xany.display; 380 XDisplay* display = xev->xany.display;
383 int event_type = xev->xgeneric.evtype; 381 int event_type = xev->xgeneric.evtype;
384 382
385 DCHECK(event_type == XI_Motion || event_type == XI_TouchUpdate); 383 DCHECK(event_type == XI_Motion || event_type == XI_TouchUpdate);
386 384
387 while (XPending(display)) { 385 while (XPending(display)) {
388 XEvent next_event; 386 XEvent next_event;
389 XPeekEvent(display, &next_event); 387 XPeekEvent(display, &next_event);
390 388
391 // If we can't get the cookie, abort the check. 389 // If we can't get the cookie, abort the check.
392 if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie)) 390 if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie))
393 return num_coalesced; 391 return num_coalesced;
394 392
395 // If this isn't from a valid device, throw the event away, as 393 // If this isn't from a valid device, throw the event away, as
396 // that's what the message pump would do. Device events come in pairs 394 // that's what the message pump would do. Device events come in pairs
397 // with one from the master and one from the slave so there will 395 // with one from the master and one from the slave so there will
398 // always be at least one pending. 396 // always be at least one pending.
399 if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) { 397 if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) {
400 XFreeEventData(display, &next_event.xcookie); 398 XFreeEventData(display, &next_event.xcookie);
401 XNextEvent(display, &next_event); 399 XNextEvent(display, &next_event);
402 continue; 400 continue;
403 } 401 }
404 402
405 if (next_event.type == GenericEvent && 403 if (next_event.type == GenericEvent &&
406 next_event.xgeneric.evtype == event_type && 404 next_event.xgeneric.evtype == event_type &&
407 !ui::DeviceDataManagerX11::GetInstance()->IsCMTGestureEvent( 405 !ui::DeviceDataManagerX11::GetInstance()->IsCMTGestureEvent(
408 &next_event)) { 406 &next_event) &&
407 ui::DeviceDataManagerX11::GetInstance()->GetScrollClassEventDetail(
408 &next_event) == SCROLL_TYPE_NO_SCROLL) {
409 XIDeviceEvent* next_xievent = 409 XIDeviceEvent* next_xievent =
410 static_cast<XIDeviceEvent*>(next_event.xcookie.data); 410 static_cast<XIDeviceEvent*>(next_event.xcookie.data);
411 // Confirm that the motion event is targeted at the same window 411 // Confirm that the motion event is targeted at the same window
412 // and that no buttons or modifiers have changed. 412 // and that no buttons or modifiers have changed.
413 if (xievent->event == next_xievent->event && 413 if (xievent->event == next_xievent->event &&
414 xievent->child == next_xievent->child && 414 xievent->child == next_xievent->child &&
415 xievent->detail == next_xievent->detail && 415 xievent->detail == next_xievent->detail &&
416 xievent->buttons.mask_len == next_xievent->buttons.mask_len && 416 xievent->buttons.mask_len == next_xievent->buttons.mask_len &&
417 (memcmp(xievent->buttons.mask, 417 (memcmp(xievent->buttons.mask, next_xievent->buttons.mask,
418 next_xievent->buttons.mask,
419 xievent->buttons.mask_len) == 0) && 418 xievent->buttons.mask_len) == 0) &&
420 xievent->mods.base == next_xievent->mods.base && 419 xievent->mods.base == next_xievent->mods.base &&
421 xievent->mods.latched == next_xievent->mods.latched && 420 xievent->mods.latched == next_xievent->mods.latched &&
422 xievent->mods.locked == next_xievent->mods.locked && 421 xievent->mods.locked == next_xievent->mods.locked &&
423 xievent->mods.effective == next_xievent->mods.effective) { 422 xievent->mods.effective == next_xievent->mods.effective) {
424 XFreeEventData(display, &next_event.xcookie); 423 XFreeEventData(display, &next_event.xcookie);
425 // Free the previous cookie. 424 // Free the previous cookie.
426 if (num_coalesced > 0) 425 if (num_coalesced > 0)
427 XFreeEventData(display, &last_event->xcookie); 426 XFreeEventData(display, &last_event->xcookie);
428 // Get the event and its cookie data. 427 // Get the event and its cookie data.
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 if (depth) 1470 if (depth)
1472 *depth = s_depth; 1471 *depth = s_depth;
1473 } 1472 }
1474 #endif 1473 #endif
1475 1474
1476 // ---------------------------------------------------------------------------- 1475 // ----------------------------------------------------------------------------
1477 // End of x11_util_internal.h 1476 // End of x11_util_internal.h
1478 1477
1479 1478
1480 } // namespace ui 1479 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698