finch/plugins/gntgf.c

changeset 16399
8f21225e5e95
parent 15924
1e6022a75ba9
child 16748
f8e1573bfde0
--- a/finch/plugins/gntgf.c	Sun Apr 22 23:56:41 2007 +0000
+++ b/finch/plugins/gntgf.c	Mon Apr 23 06:28:18 2007 +0000
@@ -111,6 +111,15 @@
 }
 
 #ifdef HAVE_X11
+static int
+error_handler(Display *dpy, XErrorEvent *error)
+{
+	char buffer[1024];
+	XGetErrorText(dpy, error->error_code, buffer, sizeof(buffer));
+	purple_debug_error("gntgf", "Could not set urgent to the window: %s.\n", buffer);
+	return 0;
+}
+
 static void
 urgent()
 {
@@ -130,9 +139,14 @@
 	if (dpy == NULL)
 		return;
 
+	XSetErrorHandler(error_handler);
 	hints = XGetWMHints(dpy, id);
-	hints->flags|=XUrgencyHint;
-	XSetWMHints(dpy, id, hints);
+	if (hints) {
+		hints->flags|=XUrgencyHint;
+		XSetWMHints(dpy, id, hints);
+		XFree(hints);
+	}
+	XSetErrorHandler(NULL);
 
 	XFlush(dpy);
 	XCloseDisplay(dpy);

mercurial