[patch] to set WM_CLASS property
- From: Raph Levien <raph acm org>
- To: gtk-list redhat com
- Subject: [patch] to set WM_CLASS property
- Date: Tue, 17 Jun 1997 14:46:13 -0700 (PDT)
I thought it would be nice for gtk applications to set the WM_CLASS
property on their windows. Among other things, this helps fvwm95 find the
correct mini-icon to display. Following is a patch that adds the
gtk_window_set_wmclass () function to gtk. I've also added a call to this
function in the Gimp for testing, but it's only for the main window. To
add the feature properly, calls should also be inserted for all the other
windows that the Gimp pops up (grep for set_title to find them).
Raph
diff -u --recursive gimp-0.99.10/app/interface.c gimp-0.99.10-patched/app/interface.c
--- gimp-0.99.10/app/interface.c Fri Jun 6 00:01:28 1997
+++ gimp-0.99.10-patched/app/interface.c Tue Jun 17 14:17:37 1997
@@ -480,6 +480,7 @@
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "The GIMP");
+ gtk_window_set_wmclass (GTK_WINDOW (window), "gimp", "Gimp");
gtk_widget_set_uposition (window, toolbox_x, toolbox_y);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
(GtkSignalFunc) toolbox_destroy,
diff -u --recursive gimp-0.99.10/gtk+/gdk/gdktypes.h gimp-0.99.10-patched/gtk+/gdk/gdktypes.h
--- gimp-0.99.10/gtk+/gdk/gdktypes.h Fri Jun 6 01:52:31 1997
+++ gimp-0.99.10-patched/gtk+/gdk/gdktypes.h Tue Jun 17 14:11:23 1997
@@ -166,7 +166,8 @@
GDK_WA_Y = 1 << 3,
GDK_WA_CURSOR = 1 << 4,
GDK_WA_COLORMAP = 1 << 5,
- GDK_WA_VISUAL = 1 << 6
+ GDK_WA_VISUAL = 1 << 6,
+ GDK_WA_WMCLASS = 1 << 7
} GdkWindowAttributesType;
/* Size restriction enumeration.
@@ -489,6 +490,8 @@
struct _GdkWindowAttr
{
gchar *title;
+ gchar *wmclass_name;
+ gchar *wmclass_class;
gint event_mask;
gint16 x, y;
gint16 width;
diff -u --recursive gimp-0.99.10/gtk+/gdk/gdkwindow.c gimp-0.99.10-patched/gtk+/gdk/gdkwindow.c
--- gimp-0.99.10/gtk+/gdk/gdkwindow.c Fri Jun 6 18:20:28 1997
+++ gimp-0.99.10-patched/gtk+/gdk/gdkwindow.c Tue Jun 17 14:22:09 1997
@@ -80,6 +80,7 @@
XSizeHints size_hints;
XWMHints wm_hints;
XTextProperty text_property;
+ XClassHint *class_hint;
int x, y, depth;
unsigned int class;
char *title;
@@ -248,6 +249,15 @@
{
XSetWMName (private->xdisplay, private->xwindow, &text_property);
XFree (text_property.value);
+ }
+
+ if (attributes_mask & GDK_WA_WMCLASS)
+ {
+ class_hint = XAllocClassHint ();
+ class_hint->res_name = attributes->wmclass_name;
+ class_hint->res_class = attributes->wmclass_class;
+ XSetClassHint (private->xdisplay, private->xwindow, class_hint);
+ XFree (class_hint);
}
gdk_window_set_cursor (window, ((attributes_mask & GDK_WA_CURSOR) ?
Only in gimp-0.99.10/gtk+/glib: glibconfig.h
diff -u --recursive gimp-0.99.10/gtk+/gtk/gtkwindow.c gimp-0.99.10-patched/gtk+/gtk/gtkwindow.c
--- gimp-0.99.10/gtk+/gtk/gtkwindow.c Tue Jun 3 17:34:34 1997
+++ gimp-0.99.10-patched/gtk+/gtk/gtkwindow.c Tue Jun 17 14:16:36 1997
@@ -171,6 +171,8 @@
GTK_WIDGET_SET_FLAGS (window, GTK_ANCHORED);
window->title = NULL;
+ window->wmclass_name = NULL;
+ window->wmclass_class = NULL;
window->type = GTK_WINDOW_TOPLEVEL;
window->accelerator_tables = NULL;
window->focus_widget = NULL;
@@ -239,6 +241,26 @@
}
void
+gtk_window_set_wmclass (GtkWindow *window,
+ gchar *wmclass_name,
+ gchar *wmclass_class)
+{
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ if (window->wmclass_name)
+ g_free (window->wmclass_name);
+ window->wmclass_name = g_strdup (wmclass_name);
+
+ if (window->wmclass_class)
+ g_free (window->wmclass_class);
+ window->wmclass_class = g_strdup (wmclass_class);
+
+ if (GTK_WIDGET_REALIZED (window))
+ g_warning ("shouldn't set wmclass after window is realized!\n");
+}
+
+void
gtk_window_set_focus (GtkWindow *window,
GtkWidget *focus)
{
@@ -462,6 +484,8 @@
}
attributes.title = window->title;
+ attributes.wmclass_name = window->wmclass_name;
+ attributes.wmclass_class = window->wmclass_class;
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
@@ -477,6 +501,7 @@
attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP;
attributes_mask |= (window->title ? GDK_WA_TITLE : 0);
+ attributes_mask |= (window->wmclass_name ? GDK_WA_WMCLASS : 0);
widget->window = gdk_window_new (NULL, &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, window);
diff -u --recursive gimp-0.99.10/gtk+/gtk/gtkwindow.h gimp-0.99.10-patched/gtk+/gtk/gtkwindow.h
--- gimp-0.99.10/gtk+/gtk/gtkwindow.h Thu Apr 17 17:20:10 1997
+++ gimp-0.99.10-patched/gtk+/gtk/gtkwindow.h Tue Jun 17 14:24:21 1997
@@ -39,6 +39,8 @@
GtkBin bin;
gchar *title;
+ gchar *wmclass_name;
+ gchar *wmclass_class;
GtkWindowType type;
GList *accelerator_tables;
@@ -76,6 +78,9 @@
GtkWidget* gtk_window_new (GtkWindowType type);
void gtk_window_set_title (GtkWindow *window,
gchar *title);
+void gtk_window_set_wmclass (GtkWindow *window,
+ gchar *wmclass_name,
+ gchar *wmclass_class);
void gtk_window_set_focus (GtkWindow *window,
GtkWidget *focus);
void gtk_window_set_default (GtkWindow *window,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]