diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-23 17:03:50 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-23 17:03:50 +0000 |
commit | 753296ca11c512e7f4382f0492937351d6404f97 (patch) | |
tree | e5f5d7ca0d3063ad01af025da5f75a21ebf20f74 /base/message_pump_aurax11.cc | |
parent | 04a0754f1de4d1a7ed0132542c489c630d918cf3 (diff) | |
download | chromium_src-753296ca11c512e7f4382f0492937351d6404f97.zip chromium_src-753296ca11c512e7f4382f0492937351d6404f97.tar.gz chromium_src-753296ca11c512e7f4382f0492937351d6404f97.tar.bz2 |
Call XkbSetDetectableAutoRepeat() on Chrome start-up so the server does not send KeyRelease events when the user holds a key.
Without this, superfluous DOM key event might be sent to a page, which is bad for compatibility reasons. Note that Gdk (used by Chrome for Linux) calls the Xkb function during its initialization.
BUG=138092
TEST=see the bug for demo html; confirmed only one KeyUp DOM event is sent to the page even when a key is long-pressed.
Review URL: https://chromiumcodereview.appspot.com/10800050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_aurax11.cc')
-rw-r--r-- | base/message_pump_aurax11.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/base/message_pump_aurax11.cc b/base/message_pump_aurax11.cc index 3e21903..10f95cb 100644 --- a/base/message_pump_aurax11.cc +++ b/base/message_pump_aurax11.cc @@ -6,6 +6,7 @@ #include <glib.h> #include <X11/extensions/XInput2.h> +#include <X11/XKBlib.h> #include "base/basictypes.h" #include "base/message_loop.h" @@ -84,6 +85,30 @@ bool InitializeXInput2() { return xinput2_supported; } +bool InitializeXkb() { + Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); + if (!display) + return false; + + int opcode, event, error; + int major = XkbMajorVersion; + int minor = XkbMinorVersion; + if (!XkbQueryExtension(display, &opcode, &event, &error, &major, &minor)) { + DVLOG(1) << "Xkb extension not available."; + return false; + } + + // Ask the server not to send KeyRelease event when the user holds down a key. + // crbug.com/138092 + Bool supported_return; + if (!XkbSetDetectableAutoRepeat(display, True, &supported_return)) { + DVLOG(1) << "XKB not supported in the server."; + return false; + } + + return true; +} + } // namespace namespace base { @@ -91,6 +116,7 @@ namespace base { MessagePumpAuraX11::MessagePumpAuraX11() : MessagePumpGlib(), x_source_(NULL) { InitializeXInput2(); + InitializeXkb(); InitXSource(); } |