summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2000-08-31 02:38:10 +0000
committersabetts <sabetts>2000-08-31 02:38:10 +0000
commitb86e0c298d6881fe1a79ab4bb592aefb47147817 (patch)
tree82154a33d2be3b801c7ae9d4443fc5480ef9a6f0
parent51b0db69e403175301fc381dbad55357c1ca4622 (diff)
downloadratpoison-b86e0c298d6881fe1a79ab4bb592aefb47147817.zip
Added an input_window to allow the user to type data. This is used to
jump to a window by name. Added functionality to jump to a window by name.
-rw-r--r--Makefile4
-rw-r--r--conf.h2
-rw-r--r--data.h2
-rw-r--r--events.c21
-rw-r--r--list.c41
-rw-r--r--list.h1
-rw-r--r--main.c4
-rw-r--r--manage.c5
-rw-r--r--ratpoison.h1
9 files changed, 75 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index f68a2cc..0ff3854 100644
--- a/Makefile
+++ b/Makefile
@@ -10,8 +10,8 @@ LIBS = -lX11
LDFLAGS = -L/usr/X11R6/lib
CFLAGS = -g -Wall -I/usr/X11R6/include
-SRC = main.o events.o manage.o list.o bar.o number.o
-HEADERS = bar.h conf.h data.h events.h list.h manage.h ratpoison.h number.h
+SRC = main.o events.o manage.o list.o bar.o number.o input.o
+HEADERS = bar.h conf.h data.h events.h list.h manage.h ratpoison.h number.h input.h
all: ratpoison ratpoison.info
diff --git a/conf.h b/conf.h
index 269aa22..e44f542 100644
--- a/conf.h
+++ b/conf.h
@@ -27,6 +27,7 @@
#define KEY_LASTWINDOW 't' /* key to toggle between the current window and the last visitted one */
#define KEY_TOGGLEBAR 'w' /* key to toggle the display of the program bar */
#define KEY_DELETE 'k' /* delete a window SHIFT+key will Destroy the window */
+#define KEY_WINBYNAME '\'' /* key to jump to a window by name */
#define TERM_PROG "rxvt" /* command to boot an xterm */
#define EMACS_PROG "emacs" /* command to boot emacs */
@@ -39,3 +40,4 @@
#define BAR_PADDING 3 /* The amount of padding on the top and bottom of the program bar */
#define BAR_LOCATION 3 /* 0=bottom-left 1=top-left 2=bottom-right 3=top-right */
#define BAR_TIMEOUT 5 /* Number of seconds before the progam bar autohides 0=don't autohide */
+
diff --git a/data.h b/data.h
index 98da37d..36c9883 100644
--- a/data.h
+++ b/data.h
@@ -49,7 +49,7 @@ struct screen_info
GC bold_gc;
XFontStruct *font; /* The font we want to use. */
XWindowAttributes root_attr;
- Window root, bar_window, key_window;
+ Window root, bar_window, key_window, input_window;
int bar_is_raised;
int screen_num; /* Our screen number as dictated my X */
Colormap def_cmap;
diff --git a/events.c b/events.c
index 6848782..b5b1564 100644
--- a/events.c
+++ b/events.c
@@ -64,7 +64,8 @@ new_window (XCreateWindowEvent *e)
s = find_screen (e->parent);
win = find_window (e->window);
- if (s && !win && e->window != s->key_window && e->window != s->bar_window)
+ if (s && !win && e->window != s->key_window && e->window != s->bar_window
+ && e->window != s->input_window)
{
win = add_to_window_list (s, e->window);
win->state = STATE_UNMAPPED;
@@ -82,6 +83,10 @@ unmap_notify (XEvent *ev)
if (s && win)
{
+ /* Give back the window number. the window will get another one,
+ if it in remapped. */
+ return_window_number (win->number);
+ win->number = -1;
win->state = STATE_UNMAPPED;
update_window_names (s);
}
@@ -241,6 +246,17 @@ client_msg (XClientMessageEvent *ev)
}
static void
+goto_win_by_name (screen_info *s)
+{
+ char winname[100];
+
+ get_input (s, "Window: ", winname, 100);
+ printf ("user entered: %s\n", winname);
+
+ goto_window_name (winname);
+}
+
+static void
handle_key (screen_info *s)
{
int revert;
@@ -293,6 +309,9 @@ handle_key (screen_info *s)
case KEY_LASTWINDOW:
last_window ();
break;
+ case KEY_WINBYNAME:
+ goto_win_by_name (s);
+ break;
case KEY_DELETE:
if (ev.xkey.state & ShiftMask) kill_window ();
else delete_window ();
diff --git a/list.c b/list.c
index 4ffbfe9..51cefd3 100644
--- a/list.c
+++ b/list.c
@@ -19,6 +19,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
#include "ratpoison.h"
@@ -155,6 +157,45 @@ find_window_by_number (int n)
return NULL;
}
+/* A case insensitive strncmp. */
+static int
+str_comp (char *s1, char *s2, int len)
+{
+ int i;
+
+ for (i=0; i<len; i++)
+ if (toupper (s1[i]) != toupper (s2[i])) return 0;
+
+ return 1;
+}
+
+static rp_window *
+find_window_by_name (char *name)
+{
+ rp_window *cur;
+
+ for (cur=rp_window_head; cur; cur=cur->next)
+ {
+ if (str_comp (name, cur->name, strlen (name))) return cur;
+ }
+
+ return NULL;
+}
+
+void
+goto_window_name (char *name)
+{
+ rp_window *win;
+
+ if ((win = find_window_by_name (name)) == NULL)
+ {
+ return;
+ }
+
+ rp_current_window = win;
+ set_active_window (rp_current_window);
+}
+
void
goto_window_number (int n)
{
diff --git a/list.h b/list.h
index cc68e73..170c2e2 100644
--- a/list.h
+++ b/list.h
@@ -31,4 +31,5 @@ void maximize_current_window ();
void set_active_window (rp_window *rp_w);
void set_current_window (rp_window *win);
void goto_window_number (int n);
+void goto_window_name (char *name);
#endif /* _LIST_H */
diff --git a/main.c b/main.c
index ef1a211..56f7984 100644
--- a/main.c
+++ b/main.c
@@ -233,6 +233,10 @@ init_screen (screen_info *s, int screen_num)
XMapWindow (dpy, s->key_window);
grab_keys (s);
+ /* Create the input window. */
+ s->input_window = XCreateSimpleWindow (dpy, s->root, 0, 0,
+ 1, 1, 1, fg_color.pixel, bg_color.pixel);
+ XSelectInput (dpy, s->input_window, KeyPressMask);
scanwins (s);
}
diff --git a/manage.c b/manage.c
index 8a96a06..6c4881d 100644
--- a/manage.c
+++ b/manage.c
@@ -57,6 +57,8 @@ grab_keys (screen_info *s)
GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, XKeysymToKeycode (dpy, KEY_PREFIX ), AnyModifier, s->key_window, True,
GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy, XKeysymToKeycode (dpy, KEY_WINBYNAME ), AnyModifier, s->key_window, True,
+ GrabModeAsync, GrabModeAsync);
}
static void
@@ -163,9 +165,8 @@ scanwins(screen_info *s)
for (i = 0; i < nwins; i++)
{
XGetWindowAttributes(dpy, wins[i], &attr);
- if (wins[i] == s->bar_window || wins[i] == s->key_window) continue;
+ if (wins[i] == s->bar_window || wins[i] == s->key_window || wins[i] == s->input_window) continue;
-
if (attr.override_redirect != True)
{
win = add_to_window_list (s, wins[i]);
diff --git a/ratpoison.h b/ratpoison.h
index b683196..3528422 100644
--- a/ratpoison.h
+++ b/ratpoison.h
@@ -28,6 +28,7 @@
#include "bar.h"
#include "events.h"
#include "number.h"
+#include "input.h"
void clean_up ();
screen_info *find_screen (Window w);