summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions.c24
-rw-r--r--src/actions.h2
-rw-r--r--src/bar.c86
-rw-r--r--src/main.c9
-rw-r--r--src/manage.c90
-rw-r--r--src/manage.h3
-rw-r--r--src/window.c14
7 files changed, 164 insertions, 64 deletions
diff --git a/src/actions.c b/src/actions.c
index 3b54b76..9f1cdeb 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -96,6 +96,8 @@ static user_command user_commands[] =
{"fdump", cmd_fdump, arg_STRING},
{"frestore", cmd_frestore, arg_STRING},
{"verbexec", cmd_verbexec, arg_STRING},
+ {"unmanage", cmd_unmanage, arg_STRING},
+ {"clrunmanaged", cmd_clrunmanaged, arg_VOID},
/* Commands to set default behavior. */
{"defbargravity", cmd_defbargravity, arg_STRING},
@@ -486,6 +488,28 @@ parse_keydesc (char *s)
return p;
}
+/* Unmanage window */
+char *
+cmd_unmanage (int interactive, char *data)
+{
+ if (data == NULL && !interactive)
+ return list_unmanaged_windows();
+
+ if (data)
+ add_unmanaged_window(data);
+ else message(" unmanage: at least one argument required ");
+
+ return NULL;
+}
+
+/* Clear the unmanaged window list */
+char *
+cmd_clrunmanaged (int interactive, char *data)
+{
+ clear_unmanaged_list();
+ return NULL;
+}
+
char *
cmd_bind (int interactive, char *data)
{
diff --git a/src/actions.h b/src/actions.h
index 7fc4cf5..168d56a 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -116,6 +116,8 @@ char *cmd_togglewrapwinlist ();
char *cmd_unalias (int interactive, char *data);
char *cmd_unbind (int interactive, char *data);
char *cmd_unimplemented (int interactive, char *data);
+char *cmd_unmanage (int interactive, char *data);
+char *cmd_clrunmanaged (int interactive, char *data);
char *cmd_unsetenv (int interactive, char *data);
char *cmd_v_split (int interactive, char *data);
char *cmd_verbexec (int interactive, char *data);
diff --git a/src/bar.c b/src/bar.c
index 39363eb..6e4ceb2 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -199,9 +199,10 @@ count_lines (char* msg, int len)
{
int ret=1;
int i=0;
- for(; i<len; ++i) {
- if(msg[i]=='\n') ret++;
- }
+ for(; i<len; ++i)
+ {
+ if(msg[i]=='\n') ret++;
+ }
PRINT_DEBUG(("count_lines: %d\n", ret));
return ret;
}
@@ -217,15 +218,17 @@ max_line_length (char* msg)
int current_width=0;
char tmp_buf[100];
- for(; i<=len; ++j, ++i) {
- if(msg[i]=='\n' || msg[i]=='\0') {
- tmp_buf[j]='\0';
- current_width = XTextWidth (defaults.font, tmp_buf, strlen (tmp_buf));
- if(current_width>ret) ret=current_width;
- j=0;
+ for(; i<=len; ++j, ++i)
+ {
+ if(msg[i]=='\n' || msg[i]=='\0')
+ {
+ tmp_buf[j]='\0';
+ current_width = XTextWidth (defaults.font, tmp_buf, strlen (tmp_buf));
+ if(current_width>ret) ret=current_width;
+ j=0;
+ }
+ else tmp_buf[j]=msg[i];
}
- else tmp_buf[j]=msg[i];
- }
PRINT_DEBUG(("max_line_length: %d\n", ret));
return ret;
}
@@ -235,7 +238,8 @@ pos_in_line (char* msg, int pos)
{
int i=pos - 1;
int ret=0;
- if(i>=0) {
+ if(i>=0)
+ {
for(; i<=pos && i>=0; ++ret, --i) if(msg[i]=='\n') break;
}
PRINT_DEBUG (("pos_in_line(\"%s\", %d) = %d\n", msg, pos, ret));
@@ -247,15 +251,18 @@ line_beginning (char* msg, int pos)
{
int ret=0;
int i=pos-1;
- if(i) {
- for(; i>=0; --i) {
- /* PRINT_DEBUG("pos = %d, i = %d, msg[i] = '%c'\n", pos, i, msg[i]); */
- if (msg[i]=='\n') {
- ret=i+1;
- break;
- }
+ if(i)
+ {
+ for(; i>=0; --i)
+ {
+ /* PRINT_DEBUG("pos = %d, i = %d, msg[i] = '%c'\n", pos, i, msg[i]); */
+ if (msg[i]=='\n')
+ {
+ ret=i+1;
+ break;
+ }
+ }
}
- }
PRINT_DEBUG (("line_beginning(\"%s\", %d) = %d\n", msg, pos, ret));
return ret;
@@ -309,24 +316,25 @@ marked_wrapped_message (char *msg, int mark_start, int mark_end)
defaults.bar_y_padding + defaults.font->max_bounds.ascent,
msg, strlen (msg));
} else { */
- for(i=0; i<=strlen(msg); ++i) {
- if (msg[i]!='\0' && msg[i]!='\n')
- {
- tmp_buf[j]=msg[i];
- j++;
- }
- else
- {
- tmp_buf[j]='\0';
- XDrawString (dpy, s->bar_window, s->normal_gc,
- defaults.bar_x_padding,
- defaults.bar_y_padding + defaults.font->max_bounds.ascent
- + line_no * line_height,
- tmp_buf, strlen(tmp_buf));
- j=0;
- line_no++;
- }
- }
+ for(i=0; i<=strlen(msg); ++i)
+ {
+ if (msg[i]!='\0' && msg[i]!='\n')
+ {
+ tmp_buf[j]=msg[i];
+ j++;
+ }
+ else
+ {
+ tmp_buf[j]='\0';
+ XDrawString (dpy, s->bar_window, s->normal_gc,
+ defaults.bar_x_padding,
+ defaults.bar_y_padding + defaults.font->max_bounds.ascent
+ + line_no * line_height,
+ tmp_buf, strlen(tmp_buf));
+ j=0;
+ line_no++;
+ }
+ }
@@ -388,7 +396,7 @@ marked_wrapped_message (char *msg, int mark_start, int mark_end)
if (mark_end != strlen (msg)) end -= defaults.bar_x_padding;
-/* width = end - start; */
+ /* width = end - start; */
width = max_line_length(msg);
PRINT_DEBUG (("start = %d, end = %d, width = %d\n", start, end, width));
diff --git a/src/main.c b/src/main.c
index 8c3b98b..7a03eba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -245,10 +245,11 @@ handler (Display *d, XErrorEvent *e)
{
char error_msg[100];
- if (e->request_code == X_ChangeWindowAttributes && e->error_code == BadAccess) {
- fprintf(stderr, "ratpoison: There can be only ONE.\n");
- exit(EXIT_FAILURE);
- }
+ if (e->request_code == X_ChangeWindowAttributes && e->error_code == BadAccess)
+ {
+ fprintf(stderr, "ratpoison: There can be only ONE.\n");
+ exit(EXIT_FAILURE);
+ }
#ifdef IGNORE_BADWINDOW
return 0;
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;
}
diff --git a/src/manage.h b/src/manage.h
index 02dbbe3..c85067b 100644
--- a/src/manage.h
+++ b/src/manage.h
@@ -24,6 +24,9 @@
#include "data.h"
+void clear_unmanaged_list ();
+char *list_unmanaged_windows ();
+void add_unmanaged_window (char *name);
int unmanaged_window (Window w);
screen_info* current_screen ();
void scanwins(screen_info *s);
diff --git a/src/window.c b/src/window.c
index ef1b280..8e939b7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -663,13 +663,15 @@ get_window_list (char *fmt, char *delim, struct sbuf *buffer,
if (delim && w->node.next != &rp_mapped_window)
sbuf_concat (buffer, delim);
- if (w == current_window()) {
- if(defaults.window_list_style == STYLE_ROW){
- *mark_end = strlen (sbuf_get (buffer));
- } else {
- *mark_end = strlen (sbuf_get(buffer)) - *mark_start;
+ if (w == current_window())
+ {
+ if(defaults.window_list_style == STYLE_ROW)
+ {
+ *mark_end = strlen (sbuf_get (buffer));
+ } else {
+ *mark_end = strlen (sbuf_get(buffer)) - *mark_start;
+ }
}
- }
}
if (!strcmp (sbuf_get (buffer), ""))