summaryrefslogtreecommitdiffstats
path: root/ui/aura/dispatcher_linux.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/aura/dispatcher_linux.cc')
-rw-r--r--ui/aura/dispatcher_linux.cc29
1 files changed, 29 insertions, 0 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 &&