Chromium Code Reviews| Index: ui/aura/root_window_host_linux.cc |
| diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc |
| index 76ab200d0a47fabbad9d6ca1a218e29cd7736aff..8330652f91761d8bd250c18d80c593d92ef9dcef 100644 |
| --- a/ui/aura/root_window_host_linux.cc |
| +++ b/ui/aura/root_window_host_linux.cc |
| @@ -14,6 +14,7 @@ |
| #include <algorithm> |
| #include "base/command_line.h" |
| +#include "base/message_loop.h" |
| #include "base/message_pump_aurax11.h" |
| #include "base/stl_util.h" |
| #include "base/stringprintf.h" |
| @@ -280,6 +281,46 @@ bool ShouldSendCharEventForKeyboardCode(ui::KeyboardCode keycode) { |
| } // namespace |
| +namespace internal { |
| + |
| +// A very lightweight message-pump observer that routes all the touch events to |
| +// the X root window so that they can be calibrated properly. |
| +class TouchEventCalibrate : public base::MessagePumpObserver { |
| + public: |
| + TouchEventCalibrate() { |
| + MessageLoopForUI::current()->AddObserver(this); |
| + } |
| + |
| + virtual ~TouchEventCalibrate() { |
| + MessageLoopForUI::current()->RemoveObserver(this); |
| + } |
| + |
| + private: |
| + // Overridden from base::MessagePumpObserver: |
| + virtual base::EventStatus WillProcessEvent( |
| + const base::NativeEvent& event) OVERRIDE { |
| +#if defined(USE_XI2_MT) |
| + if (event->type == GenericEvent && |
| + (event->xgeneric.evtype == XI_TouchBegin || |
| + event->xgeneric.evtype == XI_TouchUpdate || |
| + event->xgeneric.evtype == XI_TouchEnd)) { |
| + XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data); |
| + xievent->event = xievent->root; |
| + xievent->event_x = xievent->root_x; |
| + xievent->event_y = xievent->root_y; |
| + } |
| +#endif |
| + return base::EVENT_CONTINUE; |
| + } |
| + |
| + virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { |
| + } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TouchEventCalibrate); |
| +}; |
| + |
| +} |
|
Daniel Erat
2012/09/14 00:28:56
nit: // namespace internal
sadrul
2012/09/14 01:43:59
Done.
|
| + |
| RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, |
| const gfx::Rect& bounds) |
| : delegate_(delegate), |
| @@ -292,6 +333,7 @@ RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, |
| bounds_(bounds), |
| focus_when_shown_(false), |
| pointer_barriers_(NULL), |
| + touch_calibrate_(new internal::TouchEventCalibrate), |
| atom_cache_(xdisplay_, kAtomsToCache) { |
| XSetWindowAttributes swa; |
| memset(&swa, 0, sizeof(swa)); |