OLD | NEW |
---|---|
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 10 matching lines...) Expand all Loading... | |
21 #include <X11/extensions/Xrandr.h> | 21 #include <X11/extensions/Xrandr.h> |
22 #include <X11/extensions/randr.h> | 22 #include <X11/extensions/randr.h> |
23 #include <X11/extensions/shape.h> | 23 #include <X11/extensions/shape.h> |
24 | 24 |
25 #include "base/bind.h" | 25 #include "base/bind.h" |
26 #include "base/command_line.h" | 26 #include "base/command_line.h" |
27 #include "base/logging.h" | 27 #include "base/logging.h" |
28 #include "base/memory/scoped_ptr.h" | 28 #include "base/memory/scoped_ptr.h" |
29 #include "base/memory/singleton.h" | 29 #include "base/memory/singleton.h" |
30 #include "base/message_loop.h" | 30 #include "base/message_loop.h" |
31 #include "base/metrics/histogram.h" | |
31 #include "base/string_number_conversions.h" | 32 #include "base/string_number_conversions.h" |
32 #include "base/string_util.h" | 33 #include "base/string_util.h" |
33 #include "base/stringprintf.h" | 34 #include "base/stringprintf.h" |
34 #include "base/sys_byteorder.h" | 35 #include "base/sys_byteorder.h" |
35 #include "base/threading/thread.h" | 36 #include "base/threading/thread.h" |
36 #include "ui/base/events/event_utils.h" | 37 #include "ui/base/events/event_utils.h" |
37 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 38 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
38 #include "ui/base/touch/touch_factory.h" | 39 #include "ui/base/touch/touch_factory.h" |
39 #include "ui/base/x/valuators.h" | 40 #include "ui/base/x/valuators.h" |
40 #include "ui/base/x/x11_util_internal.h" | 41 #include "ui/base/x/x11_util_internal.h" |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 | 558 |
558 #if defined(USE_XI2_MT) | 559 #if defined(USE_XI2_MT) |
559 float tracking_id = -1; | 560 float tracking_id = -1; |
560 if (event_type == XI_TouchUpdate) { | 561 if (event_type == XI_TouchUpdate) { |
561 if (!ui::ValuatorTracker::GetInstance()->ExtractValuator(*xev, | 562 if (!ui::ValuatorTracker::GetInstance()->ExtractValuator(*xev, |
562 ui::ValuatorTracker::VAL_TRACKING_ID, &tracking_id)) | 563 ui::ValuatorTracker::VAL_TRACKING_ID, &tracking_id)) |
563 tracking_id = -1; | 564 tracking_id = -1; |
564 } | 565 } |
565 #endif | 566 #endif |
566 | 567 |
568 base::TimeDelta first_coalesed_time; | |
567 while (XPending(display)) { | 569 while (XPending(display)) { |
568 XEvent next_event; | 570 XEvent next_event; |
569 XPeekEvent(display, &next_event); | 571 XPeekEvent(display, &next_event); |
570 | 572 |
571 // If we can't get the cookie, abort the check. | 573 // If we can't get the cookie, abort the check. |
572 if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie)) | 574 if (!XGetEventData(next_event.xgeneric.display, &next_event.xcookie)) |
573 return num_coalesed; | 575 return num_coalesed; |
574 | 576 |
575 // If this isn't from a valid device, throw the event away, as | 577 // If this isn't from a valid device, throw the event away, as |
576 // that's what the message pump would do. Device events come in pairs | 578 // that's what the message pump would do. Device events come in pairs |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 xievent->mods.latched == next_xievent->mods.latched && | 615 xievent->mods.latched == next_xievent->mods.latched && |
614 xievent->mods.locked == next_xievent->mods.locked && | 616 xievent->mods.locked == next_xievent->mods.locked && |
615 xievent->mods.effective == next_xievent->mods.effective) { | 617 xievent->mods.effective == next_xievent->mods.effective) { |
616 XFreeEventData(display, &next_event.xcookie); | 618 XFreeEventData(display, &next_event.xcookie); |
617 // Free the previous cookie. | 619 // Free the previous cookie. |
618 if (num_coalesed > 0) | 620 if (num_coalesed > 0) |
619 XFreeEventData(display, &last_event->xcookie); | 621 XFreeEventData(display, &last_event->xcookie); |
620 // Get the event and its cookie data. | 622 // Get the event and its cookie data. |
621 XNextEvent(display, last_event); | 623 XNextEvent(display, last_event); |
622 XGetEventData(display, &last_event->xcookie); | 624 XGetEventData(display, &last_event->xcookie); |
625 | |
626 if (num_coalesed == 0) | |
627 first_coalesed_time = ui::EventTimeFromNative(last_event); | |
Rick Byers
2013/04/05 15:30:35
I think the first coalesced event is really xev, w
varunjain
2013/04/05 19:22:58
Done.
| |
623 ++num_coalesed; | 628 ++num_coalesed; |
624 continue; | 629 continue; |
625 } else { | 630 } else { |
626 // This isn't an event we want so free its cookie data. | 631 // This isn't an event we want so free its cookie data. |
627 XFreeEventData(display, &next_event.xcookie); | 632 XFreeEventData(display, &next_event.xcookie); |
628 } | 633 } |
629 } | 634 } |
630 break; | 635 break; |
631 } | 636 } |
637 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.Browser.CoalesedCount", | |
Rick Byers
2013/04/05 15:30:35
UMA_HISTOGRAM_COUNTS_10000 should be sufficient (5
Rick Byers
2013/04/05 15:30:35
Event.Latency.Browser has an existing common meani
varunjain
2013/04/05 19:22:58
Done.
varunjain
2013/04/05 19:22:58
Done.
| |
638 num_coalesed, 0, 10000, 100); | |
639 std::string name_for_event = base::StringPrintf( | |
640 "Event.Latency.Browser.Coalesed.%s", | |
641 (ui::IsMouseEvent(const_cast<XEvent*>(xev)) ? "Mouse" : "Touch")); | |
Rick Byers
2013/04/05 15:30:35
Please add a CHECK that verifies all events here a
Rick Byers
2013/04/05 15:30:35
If we're going to separate Mouse and Touch here, t
flackr
2013/04/05 16:10:56
Drive-by, wouldn't it be better / more efficient t
varunjain
2013/04/05 19:22:58
Done.
varunjain
2013/04/05 19:22:58
Done.
varunjain
2013/04/05 19:22:58
Done.
| |
642 base::TimeDelta delta = EventTimeForNow() - first_coalesed_time; | |
Rick Byers
2013/04/05 15:30:35
The Event.Latency.Browser metrics already track th
varunjain
2013/04/05 19:22:58
Done.
| |
643 base::HistogramBase* counter_for_type = | |
644 base::Histogram::FactoryGet( | |
Rick Byers
2013/04/05 15:30:35
Isn't this fully dynamic histogram generation over
DaveMoore
2013/04/05 16:46:15
The macros don't support this...they get confused
varunjain
2013/04/05 19:22:58
Done.
varunjain
2013/04/05 19:22:58
Done.
| |
645 name_for_event, | |
646 0, | |
647 1000000, | |
648 100, | |
649 base::HistogramBase::kUmaTargetedHistogramFlag); | |
650 counter_for_type->Add(delta.InMicroseconds()); | |
632 return num_coalesed; | 651 return num_coalesed; |
633 } | 652 } |
634 #endif | 653 #endif |
635 | 654 |
636 void HideHostCursor() { | 655 void HideHostCursor() { |
637 CR_DEFINE_STATIC_LOCAL(XScopedCursor, invisible_cursor, | 656 CR_DEFINE_STATIC_LOCAL(XScopedCursor, invisible_cursor, |
638 (CreateInvisibleCursor(), ui::GetXDisplay())); | 657 (CreateInvisibleCursor(), ui::GetXDisplay())); |
639 XDefineCursor(ui::GetXDisplay(), DefaultRootWindow(ui::GetXDisplay()), | 658 XDefineCursor(ui::GetXDisplay(), DefaultRootWindow(ui::GetXDisplay()), |
640 invisible_cursor.get()); | 659 invisible_cursor.get()); |
641 } | 660 } |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1794 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1813 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1795 << "minor_code " << static_cast<int>(error_event.minor_code) | 1814 << "minor_code " << static_cast<int>(error_event.minor_code) |
1796 << " (" << request_str << ")"; | 1815 << " (" << request_str << ")"; |
1797 } | 1816 } |
1798 | 1817 |
1799 // ---------------------------------------------------------------------------- | 1818 // ---------------------------------------------------------------------------- |
1800 // End of x11_util_internal.h | 1819 // End of x11_util_internal.h |
1801 | 1820 |
1802 | 1821 |
1803 } // namespace ui | 1822 } // namespace ui |
OLD | NEW |