summaryrefslogtreecommitdiff
path: root/src/manage.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2003-05-09 23:45:32 +0000
committersabetts <sabetts>2003-05-09 23:45:32 +0000
commit0956c8bdb9a4b01a0e7aafd173b452f613b9637d (patch)
tree27e9e18f039a53813abe13a1cef5c1efd4498874 /src/manage.c
parent24d5148b3ece4ff8d8c9ac1ec4be34fdd0b237bb (diff)
downloadratpoison-0956c8bdb9a4b01a0e7aafd173b452f613b9637d.zip
* src/manage.h (clear_unmanaged_list): new prototype
(list_unmanaged_windows): likewise (add_unmanaged_window): likewise * src/manage.c (unmanaged_window_list): no longer a const. (num_unmanaged_windows): new static global (clear_unmanaged_list): new function (list_unmanaged_windows): likewise (add_unmanaged_window): likewise (unmanaged_window): use num_unmanaged_windows to tell how many elements are in the unmanaged list. * src/actions.h (cmd_unmanage): new prototype (cmd_clrunmanaged): likewise * src/actions.c (user_commands): new commands unmanage, clrunmanaged. (cmd_unmanage): new function (cmd_clrunmanaged): likewise * src/bar.c (BAR_IS_HIDDEN): new define. (update_bar): new function. * src/actions.c (cmd_frestore): call update_bar() instead of update_window_names(). * src/actions.c (cmd_frestore): update the window list after restoring the frames.
Diffstat (limited to 'src/manage.c')
-rw-r--r--src/manage.c90
1 files changed, 75 insertions, 15 deletions
diff --git a/src/manage.c b/src/manage.c
index f66f723..f7df78a 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -32,12 +32,73 @@
#include "ratpoison.h"
-const char *unmanaged_window_list[] = {
-#ifdef UNMANAGED_WINDOW_LIST
- UNMANAGED_WINDOW_LIST,
-#endif
- NULL
-};
+static char **unmanaged_window_list = NULL;
+static int num_unmanaged_windows = 0;
+
+void
+clear_unmanaged_list ()
+{
+ if (unmanaged_window_list)
+ {
+ int i;
+
+ for (i = 0; i < num_unmanaged_windows; i++)
+ free(unmanaged_window_list[i]);
+
+ free(unmanaged_window_list);
+
+ unmanaged_window_list = NULL;
+ }
+ num_unmanaged_windows = 0;
+}
+
+char *
+list_unmanaged_windows ()
+{
+ char *tmp = NULL;
+ if (unmanaged_window_list)
+ {
+ char *tpos;
+ int len = 0;
+ int i;
+
+ for (i = 0; i < num_unmanaged_windows; i++)
+ len += (strlen(unmanaged_window_list[i]) + 1);
+
+ tmp = xmalloc(len + 1);
+ tpos = tmp;
+
+ for (i = 0; i < num_unmanaged_windows; i++)
+ {
+ sprintf(tpos, "%s\n", unmanaged_window_list[i]);
+ tpos += strlen(unmanaged_window_list[i])+1;
+ }
+ tpos--;
+ *tpos = '\0';
+ }
+ return tmp;
+}
+
+void
+add_unmanaged_window (char *name)
+{
+ char **tmp;
+
+ if (!name) return;
+
+ tmp = xmalloc((num_unmanaged_windows + 1) * sizeof(char *));
+
+ if (unmanaged_window_list)
+ {
+ memcpy(tmp, unmanaged_window_list, num_unmanaged_windows * sizeof(char *));
+ free(unmanaged_window_list);
+ }
+
+ tmp[num_unmanaged_windows] = xstrdup(name);
+ num_unmanaged_windows++;
+
+ unmanaged_window_list = tmp;
+}
extern Atom wm_state;
@@ -354,20 +415,19 @@ unmanaged_window (Window w)
char *wname;
int i;
- for (i = 0; unmanaged_window_list[i]; i++)
+ if (!unmanaged_window_list) return 0;
+
+ for (i = 0; i < num_unmanaged_windows; i++)
{
- wname = get_wmname (w);
- if (!wname)
- return 0;
- if (!strcmp (unmanaged_window_list[i], wname))
+ wname = get_wmname(w);
+ if (!wname) return 0;
+ if (!strcmp(unmanaged_window_list[i], wname))
{
- free (wname);
+ free(wname);
return 1;
}
-
- free (wname);
+ free(wname);
}
-
return 0;
}