diff options
author | sabetts <sabetts> | 2000-08-27 21:34:27 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2000-08-27 21:34:27 +0000 |
commit | e1306eafc699df1358faa9860ebf2fc6440274dd (patch) | |
tree | 4bf24dca4072105c00c22d6d110f0e845fcddf31 | |
parent | e324b974b06b54e9e568caa0b61535ad46baceba (diff) | |
download | ratpoison-e1306eafc699df1358faa9860ebf2fc6440274dd.zip |
Fixed the ClassHints crashes by using the GetWMName function instead
(The way we're supposed to do it).
-rw-r--r-- | events.c | 17 | ||||
-rw-r--r-- | manage.c | 78 | ||||
-rw-r--r-- | manage.h | 2 |
3 files changed, 75 insertions, 22 deletions
@@ -285,6 +285,22 @@ key_press (XEvent *ev) } } +/* Not complete. I just update the name everytime, but I should really + check what kind of property update it is. */ +void +property_notify (XEvent *ev) +{ + rp_window *win; + + win = find_window (ev->xproperty.window); + + if (win) + { + printf ("updating window name\n"); + update_window_name (win); + } +} + /* Given an event, call the correct function to handle it. */ void delegate_event (XEvent *ev) @@ -314,6 +330,7 @@ delegate_event (XEvent *ev) printf ("ColormapNotify\n"); break; case PropertyNotify: + property_notify (ev); printf ("PropertyNotify\n"); break; case SelectionClear: @@ -26,6 +26,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "ratpoison.h" @@ -65,37 +66,72 @@ grab_prefix_key (Window w) GrabModeAsync, GrabModeAsync); } +/* Reget the WM_NAME property for the window and update its name. */ +int +update_window_name (rp_window *win) +{ + XTextProperty text; + char **name_list; + int list_len; + int i; + + if (!XGetWMName (dpy, win->w, &text)) + { + fprintf (stderr, "ratpoison:manage.c: I can't get the WMName.\n"); + return 0; + } + + if (!XTextPropertyToStringList (&text, &name_list, &list_len)) + { + fprintf (stderr, "ratpoison:manage.c:Error retrieving TextList.\n"); + return 0; + } + + for (i=0; i<list_len; i++) + { + printf ("WMName: %s\n", name_list[i]); + } + + /* Set the window's name to the first in the name_list */ + if (list_len > 0) + { + char *loc; + + free (win->name); + if ((win->name = malloc (strlen (name_list[0]) + 1)) == NULL) + { + fprintf (stderr, "manage.c:update_window_name():Out of memory!\n"); + exit (EXIT_FAILURE); + } + strcpy (win->name, name_list[0]); + + /* A bit of a hack. If there's a : in the string, crop the + string off there. This is mostly brought on by netscape's + disgusting tendency to put its current URL in the WMName!! + arg! */ + loc = strchr (win->name, ':'); + if (loc) loc[0] = '\0'; + } + + /* Its our responsibility to free this. */ + XFreeStringList (name_list); + + return 1; +} + void manage (rp_window *win, screen_info *s) { - XClassHint hint; + if (!update_window_name (win)) return; + /* We successfully got the name, which means we can start managing! */ XMapWindow (dpy, win->w); XMoveResizeWindow (dpy, win->w, 0, 0, s->root_attr.width, s->root_attr.height); XSelectInput (dpy, win->w, PropertyChangeMask); XAddToSaveSet(dpy, win->w); grab_prefix_key (win->w); - win->state = STATE_MAPPED; - if (!XGetClassHint (dpy, win->w, &hint)) - { - fprintf (stderr, "ratpoison: I can't get the ClassHint, I don't what to do!\n"); - exit (EXIT_FAILURE); - } - - free (win->name); - if ((win->name = malloc (strlen (hint.res_name) + 1)) == NULL) - { - fprintf (stderr, "manage.c:manage():Out of memory!\n"); - exit (EXIT_FAILURE); - } - strcpy (win->name, hint.res_name); - - /* Its our responsibility to free these. */ - XFree (hint.res_name); - XFree (hint.res_class); - #ifdef DEBUG printf ("window '%s' managed.\n", win->name); #endif @@ -127,7 +163,7 @@ scanwins(screen_info *s) if (wins[i] == s->bar_window || wins[i] == s->key_window) continue; win = add_to_window_list (s, wins[i]); - manage (win, s); + if (attr.map_state == IsViewable) manage (win, s); } XFree((void *) wins); /* cast is to shut stoopid compiler up */ } @@ -26,5 +26,5 @@ void grab_keys (); void scanwins(screen_info *s); void manage (rp_window *w, screen_info *s); void unmanage (rp_window *w); - +int update_window_name (rp_window *win); #endif /* _MANAGE_H */ |