summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-23 04:52:28 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-23 04:52:28 +0000
commitad4d54e931fe3b556cdd9e859a8654e4e6caed68 (patch)
tree21c52ff5eb99a9307cb8fb69d619ac9367581bef /base
parentffa3e486354ee6492eca27852a168506d285a8ad (diff)
downloadchromium_src-ad4d54e931fe3b556cdd9e859a8654e4e6caed68.zip
chromium_src-ad4d54e931fe3b556cdd9e859a8654e4e6caed68.tar.gz
chromium_src-ad4d54e931fe3b556cdd9e859a8654e4e6caed68.tar.bz2
check xinput2 capability so that it runs on the system that doesn't support xinput2
BUG=none TEST=none Review URL: http://codereview.chromium.org/7495013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/message_pump_x.cc59
-rw-r--r--base/message_pump_x.h9
2 files changed, 35 insertions, 33 deletions
diff --git a/base/message_pump_x.cc b/base/message_pump_x.cc
index 1174e4b..ada3fa3 100644
--- a/base/message_pump_x.cc
+++ b/base/message_pump_x.cc
@@ -12,22 +12,45 @@
namespace {
+// A flag to disable GTK's message pump. This is intermediate step
+// to remove gtk and will be removed once migration is complete.
+bool use_gtk_message_pump = true;
+
+// The opcode used for checking events.
+int xiopcode = -1;
+
gboolean PlaceholderDispatch(GSource* source,
GSourceFunc cb,
gpointer data) {
return TRUE;
}
-// A flag to disable GTK's message pump. This is intermediate step
-// to remove gtk and will be removed once migration is complete.
-bool use_gtk_message_pump = true;
+void InitializeXInput2(void) {
+ Display* display = base::MessagePumpX::GetDefaultXDisplay();
+ if (!display)
+ return;
+
+ int event, err;
+
+ if (!XQueryExtension(display, "XInputExtension", &xiopcode, &event, &err)) {
+ VLOG(1) << "X Input extension not available.";
+ xiopcode = -1;
+ return;
+ }
+
+ int major = 2, minor = 0;
+ if (XIQueryVersion(display, &major, &minor) == BadRequest) {
+ VLOG(1) << "XInput2 not supported in the server.";
+ xiopcode = -1;
+ return;
+ }
+}
} // namespace
namespace base {
MessagePumpX::MessagePumpX() : MessagePumpGlib(),
- xiopcode_(-1),
gdksource_(NULL),
dispatching_event_(false),
capture_x_events_(0),
@@ -57,11 +80,14 @@ Display* MessagePumpX::GetDefaultXDisplay() {
return display ? GDK_DISPLAY_XDISPLAY(display) : NULL;
}
+// static
+bool MessagePumpX::HasXInput2() {
+ return xiopcode != -1;
+}
bool MessagePumpX::ShouldCaptureXEvent(XEvent* xev) {
return (!use_gtk_message_pump || capture_x_events_[xev->type])
- && (xev->type != GenericEvent || xev->xcookie.extension == xiopcode_)
- ;
+ && (xev->type != GenericEvent || xev->xcookie.extension == xiopcode);
}
bool MessagePumpX::ProcessXEvent(XEvent* xev) {
@@ -198,27 +224,6 @@ void MessagePumpX::InitializeEventsToCapture(void) {
capture_x_events_[GenericEvent] = true;
}
-void MessagePumpX::InitializeXInput2(void) {
- Display* display = GetDefaultXDisplay();
- if (!display)
- return;
-
- int event, err;
-
- if (!XQueryExtension(display, "XInputExtension", &xiopcode_, &event, &err)) {
- VLOG(1) << "X Input extension not available.";
- xiopcode_ = -1;
- return;
- }
-
- int major = 2, minor = 0;
- if (XIQueryVersion(display, &major, &minor) == BadRequest) {
- VLOG(1) << "XInput2 not supported in the server.";
- xiopcode_ = -1;
- return;
- }
-}
-
MessagePumpObserver::EventStatus
MessagePumpObserver::WillProcessXEvent(XEvent* xev) {
return EVENT_CONTINUE;
diff --git a/base/message_pump_x.h b/base/message_pump_x.h
index fdd1de8..49a8251 100644
--- a/base/message_pump_x.h
+++ b/base/message_pump_x.h
@@ -78,6 +78,9 @@ class BASE_API MessagePumpX : public MessagePumpGlib {
// Returns default X Display.
static Display* GetDefaultXDisplay();
+ // Returns true if the system supports XINPUT2.
+ static bool HasXInput2();
+
private:
// Some XEvent's can't be directly read from X event queue and will go
// through GDK's dispatching process and may get discarded. This function
@@ -105,12 +108,6 @@ class BASE_API MessagePumpX : public MessagePumpGlib {
// processed so that GDK doesn't get to them.
void InitializeEventsToCapture(void);
- // Initialize X2 input.
- void InitializeXInput2(void);
-
- // The opcode used for checking events.
- int xiopcode_;
-
// The event source for GDK events.
GSource* gdksource_;