b=576933 ignore BadDevice errors from XCloseDevice (for GDK2) r=roc
--- a/toolkit/xre/nsX11ErrorHandler.cpp
+++ b/toolkit/xre/nsX11ErrorHandler.cpp
@@ -51,19 +51,16 @@ using mozilla::plugins::PluginProcessChi
#include "mozilla/X11Util.h"
#include <X11/Xlib.h>
#define BUFSIZE 2048 // What Xlib uses with XGetErrorDatabaseText
extern "C" {
static int
X11Error(Display *display, XErrorEvent *event) {
- nsCAutoString notes;
- char buffer[BUFSIZE];
-
// Get an indication of how long ago the request that caused the error was
// made.
unsigned long age = NextRequest(display) - event->serial;
// Get a string to represent the request that caused the error.
nsCAutoString message;
if (event->request_code < 128) {
// Core protocol request
@@ -76,42 +73,56 @@ X11Error(Display *display, XErrorEvent *
// protocol requests or that will look for input events" so we use another
// temporary Display to request extension information. This assumes on
// the DISPLAY environment variable has been set and matches what was used
// to open |display|.
Display *tmpDisplay = XOpenDisplay(NULL);
if (tmpDisplay) {
int nExts;
char** extNames = XListExtensions(tmpDisplay, &nExts);
+ int first_error;
if (extNames) {
for (int i = 0; i < nExts; ++i) {
- int major_opcode, first_event, first_error;
+ int major_opcode, first_event;
if (XQueryExtension(tmpDisplay, extNames[i],
&major_opcode, &first_event, &first_error)
&& major_opcode == event->request_code) {
message.Append(extNames[i]);
message.Append('.');
message.AppendInt(event->minor_code);
break;
}
}
XFreeExtensionList(extNames);
}
XCloseDisplay(tmpDisplay);
+
+#ifdef MOZ_WIDGET_GTK2
+ // GDK2 calls XCloseDevice the devices that it opened on startup, but
+ // the XI protocol no longer ensures that the devices will still exist.
+ // If they have been removed, then a BadDevice error results. Ignore
+ // this error.
+ if (message.EqualsLiteral("XInputExtension.4") &&
+ event->error_code == first_error + 0) {
+ return 0;
+ }
+#endif
}
}
+ char buffer[BUFSIZE];
if (message.IsEmpty()) {
buffer[0] = '\0';
} else {
XGetErrorDatabaseText(display, "XRequest", message.get(), "",
buffer, sizeof(buffer));
}
+ nsCAutoString notes;
if (buffer[0]) {
notes.Append(buffer);
} else {
notes.Append("Request ");
notes.AppendInt(event->request_code);
notes.Append('.');
notes.AppendInt(event->minor_code);
}