Bug#276575: Please support setting X's URGENCY hint upon terminal beep [hacky patch attached]

Jeroen van Wolffelaar Jeroen van Wolffelaar <jeroen@wolffelaar.nl>, 276575@bugs.debian.org
Thu, 14 Oct 2004 23:18:53 +0200


Package: libvte4
Version: 1:0.11.11-5
Severity: wishlist

Hi,

When one has opened a lot of terminals, it can be tricky to find the one
terminal that made your system beep, or maybe you were away while that
happened. Therefore, it'd be nice if gnome-terminal could set the
urgency hint on the X window, so that the window manager in use can
alert the user. This is particularly interesting using ion2
windowmanager, but others also support this hint.

This patch will enable this feature, it works to my satisfaction, but it
has the following caveats:

- it doesn't clear the urgency hint, I don't know how it gets cleared
  (window manager? gnome-terminal itself upon focus?), but anyway, it
  gets somehow cleared when it has focus (and seems to not get set if
  having focus)
- it is always-enabled. The code is easily moved to be enabled with
  either the visible-bell or audible-bell options
- It will segfault if widget->window doesn't exist, or has no TopLevel
  GdkWindow, or that TopLevel GdkWindow doesn't have hints (TTBOMK, this
  should never-happen[tm])

Of course, feel free to drop the BEGIN/END added comments, I used that
for my own convenience locally managing this unofficial patch. I submit
this code under whatever licence this library is under, as long as it
remains Debian Free Software Guidelines-Free.

--- vte-0.11.11/src/vte.c	2004-05-02 08:43:01.000000000 +0200
+++ vte.c	2004-10-14 22:59:44.000000000 +0200
@@ -68,6 +68,10 @@
 #include "vtetc.h"
 #include <fontconfig/fontconfig.h>
 
+/* For NOTIFY */
+#include <X11/Xutil.h>
+#include <gdk/gdkx.h>
+
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
@@ -2276,6 +2280,21 @@
 		/* Visual bell. */
 		vte_sequence_handler_vb(terminal, match, match_quark, params);
 	}
+
+	/* BEGIN added by Jeroen van Wolffelaar <jeroen@wolffelaar.nl> */
+	/* Set the X windows urgency hint, based on the Gaim buddy notification plugin */
+	XWMHints *hints;
+	GdkWindow *window;
+
+	window = gdk_window_get_toplevel((GTK_WIDGET(terminal))->window);
+
+	hints = XGetWMHints(GDK_WINDOW_XDISPLAY(window), GDK_WINDOW_XWINDOW(window));
+	hints->flags |= XUrgencyHint;
+	XSetWMHints(GDK_WINDOW_XDISPLAY(window),
+				GDK_WINDOW_XWINDOW(window), hints);
+	XFree(hints);
+	/* END added by Jeroen van Wolffelaar <jeroen@wolffelaar.nl> */
+
 	return FALSE;
 }
 

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.7
Locale: LANG=nl_NL.UTF-8, LC_CTYPE=nl_NL.UTF-8

Versions of packages libvte4 depends on:
ii  libatk1.0-0               1.6.1-4        The ATK accessibility toolkit
ii  libc6                     2.3.2.ds1-16   GNU C Library: Shared libraries an
ii  libfontconfig1            2.2.3-1        generic font configuration library
ii  libfreetype6              2.1.7-2.2      FreeType 2 font engine, shared lib
ii  libglib2.0-0              2.4.6-3        The GLib library of C routines
ii  libgtk2.0-0               2.4.10-1       The GTK+ graphical user interface 
ii  libncurses5               5.4-4          Shared libraries for terminal hand
ii  libpango1.0-0             1.4.1-3        Layout and rendering of internatio
ii  libvte-common             1:0.11.11-5    Terminal emulator widget for GTK+ 
ii  libx11-6                  4.3.0.dfsg.1-8 X Window System protocol client li
ii  libxft2                   2.1.2-6        FreeType-based font drawing librar
ii  libxrender1               0.8.3-7        X Rendering Extension client libra
ii  xlibs                     4.3.0.dfsg.1-8 X Window System client libraries m
ii  zlib1g                    1:1.2.1.1-7    compression library - runtime

-- no debconf information

-- 
Jeroen van Wolffelaar
jeroen@wolffelaar.nl
http://jeroen.A-Eskwadraat.nl