diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-14 02:36:33 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-14 02:36:33 +0000 |
commit | dc8f69b66cfb34ef331a9ac058f831cee8f0a6b6 (patch) | |
tree | bcf8490e6de5375d447a8ec761655f5a4dd7d552 | |
parent | f5305d84292ddfa2dbd7a7512dd58d096fc7547d (diff) | |
download | chromium_src-dc8f69b66cfb34ef331a9ac058f831cee8f0a6b6.zip chromium_src-dc8f69b66cfb34ef331a9ac058f831cee8f0a6b6.tar.gz chromium_src-dc8f69b66cfb34ef331a9ac058f831cee8f0a6b6.tar.bz2 |
aura: More fixes for touch-event calibration in multi-monitor setting.
BUG=133721
Review URL: https://codereview.chromium.org/10933080
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156720 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/aura/root_window_host_linux.cc | 42 | ||||
-rw-r--r-- | ui/aura/root_window_host_linux.h | 6 |
2 files changed, 48 insertions, 0 deletions
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc index 76ab200..6c8a313 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); +}; + +} // namespace internal + 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)); diff --git a/ui/aura/root_window_host_linux.h b/ui/aura/root_window_host_linux.h index ec41cc1..c8436c2 100644 --- a/ui/aura/root_window_host_linux.h +++ b/ui/aura/root_window_host_linux.h @@ -22,6 +22,10 @@ class ViewProp; namespace aura { +namespace internal { +class TouchEventCalibrate; +} + class RootWindowHostLinux : public RootWindowHost, public MessageLoop::Dispatcher { public: @@ -101,6 +105,8 @@ class RootWindowHostLinux : public RootWindowHost, scoped_ptr<ui::ViewProp> prop_; + scoped_ptr<internal::TouchEventCalibrate> touch_calibrate_; + ui::X11AtomCache atom_cache_; DISALLOW_COPY_AND_ASSIGN(RootWindowHostLinux); |