Currently any change of window name causes two requests for the
window's class name, as get_class_hints is called two times.
Attached patch makes it only one call (and also avoid uncessary
shoveling those values in memory).
Hochachtungsvoll,
Bernhard R. Link
Index: src/manage.c
===================================================================
RCS file: /sources/ratpoison/ratpoison/src/manage.c,v
retrieving revision 1.103
diff -u -r1.103 manage.c
--- src/manage.c 19 May 2007 12:34:58 -0000 1.103
+++ src/manage.c 7 Jul 2007 10:03:58 -0000
@@ -251,56 +239,6 @@
return class;
}
-static char *
-get_res_name (Window w)
-{
- XClassHint *class;
- char *name;
-
- class = get_class_hints (w);
-
- if (class->res_name)
- {
- name = (char *)xmalloc (strlen (class->res_name) + 1);
- strcpy (name, class->res_name);
- }
- else
- {
- name = NULL;
- }
-
- XFree (class->res_name);
- XFree (class->res_class);
- XFree (class);
-
- return name;
-}
-
-static char *
-get_res_class (Window w)
-{
- XClassHint *class;
- char *name;
-
- class = get_class_hints (w);
-
- if (class->res_class)
- {
- name = (char *)xmalloc (strlen (class->res_class) + 1);
- strcpy (name, class->res_class);
- }
- else
- {
- name = NULL;
- }
-
- XFree (class->res_name);
- XFree (class->res_class);
- XFree (class);
-
- return name;
-}
-
/* Reget the WM_NAME property for the window and update its
name. Return 1 if the name changed. */
int
@@ -308,6 +246,7 @@
{
char *newstr;
int changed = 0;
+ XClassHint *class;
newstr = get_wmname (win->w);
if (newstr != NULL)
@@ -317,22 +256,26 @@
win->wm_name = newstr;
}
- newstr = get_res_class (win->w);
- if (newstr != NULL)
+ class = get_class_hints (w);
+
+ if (class->res_name != NULL
+ && (win->res_class == NULL || strcmp (newstr, win->res_class)))
{
- changed = changed || win->res_class == NULL || strcmp (newstr,
win->res_class);
- free (win->res_class);
- win->res_class = newstr;
+ changed = 1;
+ win->res_class = xstrdup(class->res_name);
}
- newstr = get_res_name (win->w);
- if (newstr != NULL)
+ if (class->res_class != NULL
+ && (win->res_name == NULL || strcmp (newstr, win->res_name)));
{
- changed = changed || win->res_name == NULL || strcmp (newstr,
win->res_name);
+ changes = 1;
free (win->res_name);
- win->res_name = newstr;
+ win->res_name = xstrdup(class->res_class);
}
+ XFree (class->res_name);
+ XFree (class->res_class);
+ XFree (class);
return changed;
}
_______________________________________________
Ratpoison-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/ratpoison-devel