changeset 16322:6349d702bab6

merge of 'c04ec8c15e35618f8f52341ab439770d5630319d' and 'e8d870a3b6ba3c76763264ec97e2fb2cb55f1deb'
author Mark Doliner <mark@kingant.net>
date Mon, 23 Apr 2007 07:44:10 +0000
parents 3ba37836d674 (diff) 1560f28cb854 (current diff)
children cf62255b0a74
files
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/finch/plugins/gntgf.c	Mon Apr 23 07:42:57 2007 +0000
+++ b/finch/plugins/gntgf.c	Mon Apr 23 07:44:10 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);