Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1397)

Unified Diff: ui/events/x/events_x.cc

Issue 239313004: EF_NUMPAD_KEY flag for ui::KeyEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit_tests.EventRewriterTest.TestRewriteNumPadKeys* Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/event_constants.h ('k') | ui/events/x/events_x_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/x/events_x.cc
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index bf8b04ee58b0cde6d9036d3d5840b84869b8672a..a540690797bfec0fc33021cfb2ea818e9bba797c 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -9,6 +9,7 @@
#include <X11/extensions/XInput.h>
#include <X11/extensions/XInput2.h>
#include <X11/Xlib.h>
+#include <X11/Xutil.h>
#include "base/logging.h"
#include "base/memory/singleton.h"
@@ -148,6 +149,11 @@ int GetEventFlagsFromXState(unsigned int state) {
return flags;
}
+int GetEventFlagsFromXKeyEvent(XEvent* xevent) {
+ return GetEventFlagsFromXState(xevent->xkey.state) |
+ (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY : 0);
+}
+
// Get the event flag for the button in XButtonEvent. During a ButtonPress
// event, |state| in XButtonEvent does not include the button that has just been
// pressed. Instead |state| contains flags for the buttons (if any) that had
@@ -328,7 +334,7 @@ int EventFlagsFromNative(const base::NativeEvent& native_event) {
case KeyPress:
case KeyRelease: {
XModifierStateWatcher::GetInstance()->UpdateStateFromEvent(native_event);
- return GetEventFlagsFromXState(native_event->xkey.state);
+ return GetEventFlagsFromXKeyEvent(native_event);
}
case ButtonPress:
case ButtonRelease: {
« no previous file with comments | « ui/events/event_constants.h ('k') | ui/events/x/events_x_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698