diff options
-rw-r--r-- | ui/aura/dispatcher_linux.cc | 29 | ||||
-rw-r--r-- | ui/base/x/events_x.cc | 23 |
2 files changed, 29 insertions, 23 deletions
diff --git a/ui/aura/dispatcher_linux.cc b/ui/aura/dispatcher_linux.cc index b580be8..e6e70d0 100644 --- a/ui/aura/dispatcher_linux.cc +++ b/ui/aura/dispatcher_linux.cc @@ -8,6 +8,33 @@ #include "ui/base/events.h" +namespace { + +// Pro-processes an XEvent before it is handled. The pre-processings include: +// - Map Alt+Button1 to Button3 +void PreprocessXEvent(XEvent* xevent) { + if (!xevent || xevent->type != GenericEvent) + return; + + XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xevent->xcookie.data); + if ((xievent->evtype == XI_ButtonPress || + xievent->evtype == XI_ButtonRelease) && + (xievent->mods.effective & Mod1Mask) && + xievent->detail == 1) { + xievent->mods.effective &= ~Mod1Mask; + xievent->detail = 3; + if (xievent->evtype == XI_ButtonRelease) { + // On the release clear the left button from the existing state and the + // mods, and set the right button. + XISetMask(xievent->buttons.mask, 3); + XIClearMask(xievent->buttons.mask, 1); + xievent->mods.effective &= ~Button1Mask; + } + } +} + +} // namespace + namespace aura { DispatcherLinux::DispatcherLinux() { @@ -29,6 +56,8 @@ void DispatcherLinux::WindowDispatcherDestroying(::Window window) { } bool DispatcherLinux::Dispatch(const base::NativeEvent& xev) { + PreprocessXEvent(xev); + // XI_HierarchyChanged events are special. There is no window associated with // these events. So process them directly from here. if (xev->type == GenericEvent && diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc index 1beb58f..6c57af0 100644 --- a/ui/base/x/events_x.cc +++ b/ui/base/x/events_x.cc @@ -409,23 +409,6 @@ int GetEventFlagsForButton(int button) { } } -void DetectAltClick(XIDeviceEvent* xievent) { - if ((xievent->evtype == XI_ButtonPress || - xievent->evtype == XI_ButtonRelease) && - (xievent->mods.effective & Mod1Mask) && - xievent->detail == 1) { - xievent->mods.effective &= ~Mod1Mask; - xievent->detail = 3; - if (xievent->evtype == XI_ButtonRelease) { - // On the release clear the left button from the existing state and the - // mods, and set the right button. - XISetMask(xievent->buttons.mask, 3); - XIClearMask(xievent->buttons.mask, 1); - xievent->mods.effective &= ~Button1Mask; - } - } -} - int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { int buttonflags = 0; for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) { @@ -616,9 +599,6 @@ EventType EventTypeFromNative(const base::NativeEvent& native_event) { XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(native_event->xcookie.data); - // Map Alt+Button1 to Button3 - DetectAltClick(xievent); - if (factory->IsTouchDevice(xievent->sourceid)) return GetTouchEventType(native_event); @@ -677,9 +657,6 @@ int EventFlagsFromNative(const base::NativeEvent& native_event) { XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(native_event->xcookie.data); - // Map Alt+Button1 to Button3. - DetectAltClick(xievent); - const bool touch = TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid); switch (xievent->evtype) { |