summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 15:41:38 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 15:41:38 +0000
commitb0055b9c2fb9713631930dfa95d1112b0c7ec590 (patch)
treec7dc841a7910376ce2702be56719c069c5e5061d
parent5f19571f496e421ff45352fc8ec4a157bf8f631a (diff)
downloadchromium_src-b0055b9c2fb9713631930dfa95d1112b0c7ec590.zip
chromium_src-b0055b9c2fb9713631930dfa95d1112b0c7ec590.tar.gz
chromium_src-b0055b9c2fb9713631930dfa95d1112b0c7ec590.tar.bz2
aura: Preprocess an XEvent to make changes for 'alt-click to right-click' before dispatching begins.
This fixes a crash that happens from converting an alt-click to right-click. BUG=126529 TEST=manually Review URL: https://chromiumcodereview.appspot.com/10377071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136311 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/aura/dispatcher_linux.cc29
-rw-r--r--ui/base/x/events_x.cc23
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) {