summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-03 14:45:39 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-03 14:55:56 +0100
commite200c0efde7c6da7cd3357dd4c322a5dd6846518 (patch)
treea7c77a7531ed8fdcfb497b83ef604af4a5a12c50
parent838d28ab5d5a3c9177e43e66df088f70cc243303 (diff)
downloadratpoison-e200c0efde7c6da7cd3357dd4c322a5dd6846518.zip
Search windows names for exact match then for fuzzy match
* Contrary to the recent find_group change, windows are still searched by number first. This is inconsistent and a choice has to be made.
-rw-r--r--src/actions.c9
-rw-r--r--src/window.c19
-rw-r--r--src/window.h2
3 files changed, 23 insertions, 7 deletions
diff --git a/src/actions.c b/src/actions.c
index 7e4fdc3..c6f70d0 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1410,7 +1410,10 @@ cmd_select (int interactive UNUSED, struct cmdarg **args)
else
/* try by name */
{
- rp_window *win = find_window_name (str);
+ rp_window *win = find_window_name (str, 1);
+
+ if (!win)
+ win = find_window_name (str, 0);
if (win)
{
@@ -1901,7 +1904,9 @@ read_window (struct argspec *spec, struct sbuf *s, struct cmdarg **arg)
else
/* try by name */
{
- win = find_window_name (name);
+ win = find_window_name (name, 1);
+ if (win == NULL)
+ win = find_window_name (name, 0);
}
if (win)
diff --git a/src/window.c b/src/window.c
index a383c72..1caf8e9 100644
--- a/src/window.c
+++ b/src/window.c
@@ -283,14 +283,25 @@ find_window_number (int n)
}
rp_window *
-find_window_name (char *name)
+find_window_name (char *name, int exact_match)
{
rp_window_elem *cur;
- list_for_each_entry (cur, &rp_current_group->mapped_windows, node)
+ if (!exact_match)
{
- if (str_comp (name, window_name (cur->win), strlen (name)))
- return cur->win;
+ list_for_each_entry (cur, &rp_current_group->mapped_windows, node)
+ {
+ if (str_comp (name, window_name (cur->win), strlen (name)))
+ return cur->win;
+ }
+ }
+ else
+ {
+ list_for_each_entry (cur, &rp_current_group->mapped_windows, node)
+ {
+ if (!strcmp (name, window_name (cur->win)))
+ return cur->win;
+ }
}
/* didn't find it */
diff --git a/src/window.h b/src/window.h
index 922200b..0b81e6f 100644
--- a/src/window.h
+++ b/src/window.h
@@ -47,7 +47,7 @@ int is_transient_ancestor (rp_window *win, rp_window *transient_for);
/* int goto_window_name (char *name); */
rp_window *find_window_other (rp_screen *screen);
rp_window *find_window_by_number (int n);
-rp_window *find_window_name (char *name);
+rp_window *find_window_name (char *name, int exact_match);
rp_window *find_window_prev (rp_window *w);
rp_window *find_window_prev_with_frame (rp_window *w);
rp_window *find_window_next (rp_window *w);