From 82326f9f3e2bcbf7eca407944a7a77387d79f0b8 Mon Sep 17 00:00:00 2001 From: sabetts Date: Fri, 11 Apr 2003 22:25:19 +0000 Subject: * src/window.c (window_name): use WIN_NAME_* defines for possible defaults.win_name values. (window_name): remove case WIN_NAME_TITLE and glob it with the default switch. * src/main.c (init_defaults): use WIN_NAME_* defines for possible defaults.win_name values. * src/actions.c (cmd_defwinname): use WIN_NAME_* defines for possible defaults.win_name values. (cmd_defwinname): likewise * src/data.h (WIN_NAME_TITLE): new define (WIN_NAME_RES_CLASS): new define (WIN_NAME_RES_NAME): new define * src/window.c (add_to_window_list): use xstrdup to create the default value for user_name. --- ChangeLog | 21 +++++++++++++++++++++ src/actions.c | 12 ++++++------ src/data.h | 6 ++++++ src/main.c | 2 +- src/manage.c | 3 --- src/window.c | 18 ++++++++---------- 6 files changed, 42 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1865040..84a593e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2003-04-11 Shawn Betts + + * src/window.c (window_name): use WIN_NAME_* defines for possible + defaults.win_name values. + (window_name): remove case WIN_NAME_TITLE and glob it with the + default switch. + + * src/main.c (init_defaults): use WIN_NAME_* defines for + possible defaults.win_name values. + + * src/actions.c (cmd_defwinname): use WIN_NAME_* defines for + possible defaults.win_name values. + (cmd_defwinname): likewise + + * src/data.h (WIN_NAME_TITLE): new define + (WIN_NAME_RES_CLASS): new define + (WIN_NAME_RES_NAME): new define + + * src/window.c (add_to_window_list): use xstrdup to create the + default value for user_name. + 2003-04-10 Shawn Betts * src/events.c (unmap_notify): fix crash bug in NormalState case. diff --git a/src/actions.c b/src/actions.c index 1bd0930..4c4f221 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2222,11 +2222,11 @@ cmd_defwinname (int interactive, char *data) if (data == NULL && !interactive) switch (defaults.win_name) { - case 0: + case WIN_NAME_TITLE: return xstrdup ("title"); - case 1: + case WIN_NAME_RES_NAME: return xstrdup ("name"); - case 2: + case WIN_NAME_RES_CLASS: return xstrdup ("class"); default: PRINT_DEBUG (("Unknown win_name\n")); @@ -2244,11 +2244,11 @@ cmd_defwinname (int interactive, char *data) /* FIXME: Using strncmp is sorta dirty since `title' and `titlefoobar' would both match. But its quick and dirty. */ if (!strncmp (name, "title", 5)) - defaults.win_name = 0; + defaults.win_name = WIN_NAME_TITLE; else if (!strncmp (name, "name", 4)) - defaults.win_name = 1; + defaults.win_name = WIN_NAME_RES_NAME; else if (!strncmp (name, "class", 5)) - defaults.win_name = 2; + defaults.win_name = WIN_NAME_RES_CLASS; else message (" defwinname: invalid argument "); diff --git a/src/data.h b/src/data.h index b29b3e7..db54432 100644 --- a/src/data.h +++ b/src/data.h @@ -37,9 +37,15 @@ window/frame/screen/etc, Use EMPTY to denote a lack there of. */ #define EMPTY -1 +/* Possible values for defaults.window_list_style */ #define STYLE_ROW 0 #define STYLE_COLUMN 1 +/* Possible values for defaults.win_name */ +#define WIN_NAME_TITLE 0 +#define WIN_NAME_RES_CLASS 1 +#define WIN_NAME_RES_NAME 2 + typedef struct rp_window rp_window; typedef struct screen_info screen_info; typedef struct rp_action rp_action; diff --git a/src/main.c b/src/main.c index 3374ece..71189f5 100644 --- a/src/main.c +++ b/src/main.c @@ -485,7 +485,7 @@ init_defaults () defaults.window_fmt = xstrdup ("%n%s%t"); - defaults.win_name = 0; + defaults.win_name = WIN_NAME_TITLE; defaults.startup_message = 1; defaults.warp = 1; defaults.window_list_style = STYLE_ROW; diff --git a/src/manage.c b/src/manage.c index 28e6ab3..1be4e7a 100644 --- a/src/manage.c +++ b/src/manage.c @@ -192,9 +192,6 @@ update_window_name (rp_window *win) { char *newstr; - /* Don't overwrite the window name if the user specified one. */ -/* if (win->named) return 0; */ - newstr = get_wmname (win->w); if (newstr != NULL) { diff --git a/src/window.c b/src/window.c index 8815b71..ef1b280 100644 --- a/src/window.c +++ b/src/window.c @@ -85,23 +85,22 @@ window_name (rp_window *win) switch (defaults.win_name) { - case 0: - if (win->wm_name) - return win->wm_name; - else return win->user_name; - - case 1: + case WIN_NAME_RES_NAME: if (win->res_name) return win->res_name; else return win->user_name; - case 2: + case WIN_NAME_RES_CLASS: if (win->res_class) return win->res_class; else return win->user_name; + /* if we're not looking for the res name or res class, then + we're looking for the window title. */ default: - return win->wm_name; + if (win->wm_name) + return win->wm_name; + else return win->user_name; } return NULL; @@ -133,9 +132,8 @@ add_to_window_list (screen_info *s, Window w) XSelectInput (dpy, new_window->w, WIN_EVENTS); - new_window->user_name = xmalloc (strlen ("Unnamed") + 1); + new_window->user_name = xstrdup ("Unnamed"); - strcpy (new_window->user_name, "Unnamed"); new_window->wm_name = NULL; new_window->res_name = NULL; new_window->res_class = NULL; -- cgit v1.2.3