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

Side by Side Diff: base/message_pump_aurax11.cc

Issue 10800050: Call XkbSetDetectableAutoRepeat() on Chrome start-up (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_pump_aurax11.h" 5 #include "base/message_pump_aurax11.h"
6 6
7 #include <glib.h> 7 #include <glib.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/XKBlib.h>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 13
13 namespace { 14 namespace {
14 15
15 gboolean XSourcePrepare(GSource* source, gint* timeout_ms) { 16 gboolean XSourcePrepare(GSource* source, gint* timeout_ms) {
16 if (XPending(base::MessagePumpAuraX11::GetDefaultXDisplay())) 17 if (XPending(base::MessagePumpAuraX11::GetDefaultXDisplay()))
17 *timeout_ms = 0; 18 *timeout_ms = 0;
18 else 19 else
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #endif 78 #endif
78 79
79 return true; 80 return true;
80 } 81 }
81 82
82 bool InitializeXInput2() { 83 bool InitializeXInput2() {
83 static bool xinput2_supported = InitializeXInput2Internal(); 84 static bool xinput2_supported = InitializeXInput2Internal();
84 return xinput2_supported; 85 return xinput2_supported;
85 } 86 }
86 87
88 bool InitializeXkb() {
89 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
90 if (!display)
91 return false;
92
93 int opcode, event, error;
94 int major = XkbMajorVersion;
95 int minor = XkbMinorVersion;
96 if (!XkbQueryExtension(display, &opcode, &event, &error, &major, &minor)) {
97 DVLOG(1) << "Xkb extension not available.";
98 return false;
99 }
100
101 // Ask the server not to send KeyRelease event when the user holds down a key.
102 // crbug.com/138092
103 Bool supported_return;
104 if (!XkbSetDetectableAutoRepeat(display, True, &supported_return)) {
105 DVLOG(1) << "XKB not supported in the server.";
106 return false;
107 }
108
109 return true;
110 }
111
87 } // namespace 112 } // namespace
88 113
89 namespace base { 114 namespace base {
90 115
91 MessagePumpAuraX11::MessagePumpAuraX11() : MessagePumpGlib(), 116 MessagePumpAuraX11::MessagePumpAuraX11() : MessagePumpGlib(),
92 x_source_(NULL) { 117 x_source_(NULL) {
93 InitializeXInput2(); 118 InitializeXInput2();
119 InitializeXkb();
94 InitXSource(); 120 InitXSource();
95 } 121 }
96 122
97 // static 123 // static
98 Display* MessagePumpAuraX11::GetDefaultXDisplay() { 124 Display* MessagePumpAuraX11::GetDefaultXDisplay() {
99 if (!g_xdisplay) 125 if (!g_xdisplay)
100 g_xdisplay = XOpenDisplay(NULL); 126 g_xdisplay = XOpenDisplay(NULL);
101 return g_xdisplay; 127 return g_xdisplay;
102 } 128 }
103 129
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return true; 215 return true;
190 } 216 }
191 return false; 217 return false;
192 } 218 }
193 219
194 void MessagePumpAuraX11::DidProcessXEvent(XEvent* xevent) { 220 void MessagePumpAuraX11::DidProcessXEvent(XEvent* xevent) {
195 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(xevent)); 221 FOR_EACH_OBSERVER(MessagePumpObserver, observers(), DidProcessEvent(xevent));
196 } 222 }
197 223
198 } // namespace base 224 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698