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

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: Fixed device hotplugging, initialised variable Created 5 years 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // The |bitmap| contains ARGB image, so just copy it. 364 // The |bitmap| contains ARGB image, so just copy it.
365 memcpy(image->pixels, 365 memcpy(image->pixels,
366 bitmap->getPixels(), 366 bitmap->getPixels(),
367 bitmap->width() * bitmap->height() * 4); 367 bitmap->width() * bitmap->height() * 4);
368 bitmap->unlockPixels(); 368 bitmap->unlockPixels();
369 } 369 }
370 370
371 return image; 371 return image;
372 } 372 }
373 373
374 374 int CoalescePendingMotionEvents(const XEvent* xev, XEvent* last_event) {
375 int CoalescePendingMotionEvents(const XEvent* xev,
376 XEvent* last_event) {
377 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); 375 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
378 int num_coalesced = 0; 376 int num_coalesced = 0;
379 XDisplay* display = xev->xany.display; 377 XDisplay* display = xev->xany.display;
380 int event_type = xev->xgeneric.evtype; 378 int event_type = xev->xgeneric.evtype;
381 379
382 DCHECK(event_type == XI_Motion || event_type == XI_TouchUpdate); 380 DCHECK(event_type == XI_Motion || event_type == XI_TouchUpdate);
383 381
384 while (XPending(display)) { 382 while (XPending(display)) {
385 XEvent next_event; 383 XEvent next_event;
386 XPeekEvent(display, &next_event); 384 XPeekEvent(display, &next_event);
387 385
388 // If we can't get the cookie, abort the check. 386 // If we can't get the cookie, abort the check.
389 if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie)) 387 if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie))
390 return num_coalesced; 388 return num_coalesced;
391 389
392 // If this isn't from a valid device, throw the event away, as 390 // If this isn't from a valid device, throw the event away, as
393 // that's what the message pump would do. Device events come in pairs 391 // that's what the message pump would do. Device events come in pairs
394 // with one from the master and one from the slave so there will 392 // with one from the master and one from the slave so there will
395 // always be at least one pending. 393 // always be at least one pending.
396 if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) { 394 if (!ui::TouchFactory::GetInstance()->ShouldProcessXI2Event(&next_event)) {
397 XFreeEventData(display, &next_event.xcookie); 395 XFreeEventData(display, &next_event.xcookie);
398 XNextEvent(display, &next_event); 396 XNextEvent(display, &next_event);
399 continue; 397 continue;
400 } 398 }
401 399
402 if (next_event.type == GenericEvent && 400 if (next_event.type == GenericEvent &&
403 next_event.xgeneric.evtype == event_type && 401 next_event.xgeneric.evtype == event_type &&
404 !ui::DeviceDataManagerX11::GetInstance()->IsCMTGestureEvent( 402 !ui::DeviceDataManagerX11::GetInstance()->IsCMTGestureEvent(
405 &next_event)) { 403 &next_event) &&
404 ui::DeviceDataManagerX11::GetInstance()->GetScrollClassEventDetail(
405 &next_event) == SCROLL_TYPE_NO_SCROLL) {
406 XIDeviceEvent* next_xievent = 406 XIDeviceEvent* next_xievent =
407 static_cast<XIDeviceEvent*>(next_event.xcookie.data); 407 static_cast<XIDeviceEvent*>(next_event.xcookie.data);
408 // Confirm that the motion event is targeted at the same window 408 // Confirm that the motion event is targeted at the same window
409 // and that no buttons or modifiers have changed. 409 // and that no buttons or modifiers have changed.
410 if (xievent->event == next_xievent->event && 410 if (xievent->event == next_xievent->event &&
411 xievent->child == next_xievent->child && 411 xievent->child == next_xievent->child &&
412 xievent->detail == next_xievent->detail && 412 xievent->detail == next_xievent->detail &&
413 xievent->buttons.mask_len == next_xievent->buttons.mask_len && 413 xievent->buttons.mask_len == next_xievent->buttons.mask_len &&
414 (memcmp(xievent->buttons.mask, 414 (memcmp(xievent->buttons.mask, next_xievent->buttons.mask,
415 next_xievent->buttons.mask,
416 xievent->buttons.mask_len) == 0) && 415 xievent->buttons.mask_len) == 0) &&
417 xievent->mods.base == next_xievent->mods.base && 416 xievent->mods.base == next_xievent->mods.base &&
418 xievent->mods.latched == next_xievent->mods.latched && 417 xievent->mods.latched == next_xievent->mods.latched &&
419 xievent->mods.locked == next_xievent->mods.locked && 418 xievent->mods.locked == next_xievent->mods.locked &&
420 xievent->mods.effective == next_xievent->mods.effective) { 419 xievent->mods.effective == next_xievent->mods.effective) {
421 XFreeEventData(display, &next_event.xcookie); 420 XFreeEventData(display, &next_event.xcookie);
422 // Free the previous cookie. 421 // Free the previous cookie.
423 if (num_coalesced > 0) 422 if (num_coalesced > 0)
424 XFreeEventData(display, &last_event->xcookie); 423 XFreeEventData(display, &last_event->xcookie);
425 // Get the event and its cookie data. 424 // Get the event and its cookie data.
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 if (depth) 1469 if (depth)
1471 *depth = s_depth; 1470 *depth = s_depth;
1472 } 1471 }
1473 #endif 1472 #endif
1474 1473
1475 // ---------------------------------------------------------------------------- 1474 // ----------------------------------------------------------------------------
1476 // End of x11_util_internal.h 1475 // End of x11_util_internal.h
1477 1476
1478 1477
1479 } // namespace ui 1478 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698