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

Unified Diff: base/message_pump_x.cc

Issue 10386175: Initialize XInput2 on demand (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge with trunk Created 8 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_x.cc
diff --git a/base/message_pump_x.cc b/base/message_pump_x.cc
index e7deff0f602316625093be29971493743f3acf22..67e0b6c824a2bb057344d5512ccbec628f1bbf86 100644
--- a/base/message_pump_x.cc
+++ b/base/message_pump_x.cc
@@ -37,9 +37,6 @@ GSourceFuncs XSourceFuncs = {
NULL
};
-// The opcode used for checking events.
-int xiopcode = -1;
-
// The message-pump opens a connection to the display and owns it.
Display* g_xdisplay = NULL;
@@ -47,17 +44,17 @@ Display* g_xdisplay = NULL;
// is specified.
base::MessagePumpDispatcher* g_default_dispatcher = NULL;
-void InitializeXInput2(void) {
+bool InitializeXInput2Internal() {
Display* display = base::MessagePumpX::GetDefaultXDisplay();
if (!display)
- return;
+ return false;
int event, err;
+ int xiopcode;
if (!XQueryExtension(display, "XInputExtension", &xiopcode, &event, &err)) {
DVLOG(1) << "X Input extension not available.";
- xiopcode = -1;
- return;
+ return false;
}
#if defined(USE_XI2_MT)
@@ -68,17 +65,22 @@ void InitializeXInput2(void) {
#endif
if (XIQueryVersion(display, &major, &minor) == BadRequest) {
DVLOG(1) << "XInput2 not supported in the server.";
- xiopcode = -1;
- return;
+ return false;
}
#if defined(USE_XI2_MT)
if (major < 2 || (major == 2 && minor < USE_XI2_MT)) {
DVLOG(1) << "XI version on server is " << major << "." << minor << ". "
<< "But 2." << USE_XI2_MT << " is required.";
- xiopcode = -1;
- return;
+ return false;
}
#endif
+
+ return true;
+}
+
+bool InitializeXInput2() {
+ static bool xinput2_supported = InitializeXInput2Internal();
+ return xinput2_supported;
}
} // namespace
@@ -107,7 +109,7 @@ Display* MessagePumpX::GetDefaultXDisplay() {
// static
bool MessagePumpX::HasXInput2() {
- return xiopcode != -1;
+ return InitializeXInput2();
}
// static
« 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