diff options
-rw-r--r-- | ChangeLog | 32 | ||||
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | src/actions.c | 91 | ||||
-rw-r--r-- | src/actions.h | 3 | ||||
-rw-r--r-- | src/bar.c | 2 | ||||
-rw-r--r-- | src/data.h | 6 | ||||
-rw-r--r-- | src/events.c | 58 | ||||
-rw-r--r-- | src/list.c | 1 | ||||
-rw-r--r-- | src/main.c | 16 | ||||
-rw-r--r-- | src/manage.c | 4 | ||||
-rw-r--r-- | src/messages.h | 2 |
11 files changed, 177 insertions, 44 deletions
@@ -1,3 +1,35 @@ +2001-04-15 shawn <sabetts@diggin.lamenet.tmp> + + * src/messages.h (MESSAGE_WELCOME): new define + + * src/manage.c (scanwins): ignore the help window + (hide_window): increment window's iconizing variable + + * src/main.c (main): display welcoming message + (init_screen): create the help window + (init_screen): don't map the frame indicator window + (clean_up): destroy the help window + + * src/list.c (add_to_window_list): initialize iconizing to 0 + + * src/events.c (new_window): skip help_window + (unmap_notify): skip normal processing if the event is from + iconizing the window. + (unmap_notify): clean up the window's frame if it is being + withdrawn. + + * src/data.h (struct screen_info): new variable help_window + + * src/bar.c (update_window_names): only print the window list if + the bar is already displaying the window list. + + * src/actions.h (cmd_help): new prototype + (cmd_quit): likewise + + * src/actions.c (initialize_default_keybindings): new keybinding for "help" + (cmd_quit): new function + (cmd_help): likewise + 2001-04-13 shawn <sabetts@diggin.lamenet.tmp> * src/actions.c (cmd_clock): doesn't allocate memory. displays the @@ -2,6 +2,12 @@ ratpoison NEWS --- history of user-visible changes. -*- outline -*- * Changes since 0.1.1 +** new command 'help' +help brings up a key binding listing. it is bound to C-t ?. + +** new command 'quit' +This command quits ratpoison + ** windows not residing in a frame are hidden This gets rid of annoying flickers around the edges of active windows as windows in the back update. diff --git a/src/actions.c b/src/actions.c index e77f632..1968ae7 100644 --- a/src/actions.c +++ b/src/actions.c @@ -134,6 +134,7 @@ initialize_default_keybindings (void) add_keybinding (XK_R, 0, "remove"); add_keybinding (XK_f, 0, "curframe"); add_keybinding (XK_f, ControlMask, "curframe"); + add_keybinding (XK_question, 0, "help"); } user_command user_commands[] = @@ -165,6 +166,8 @@ user_command user_commands[] = {"remove", cmd_remove, arg_VOID}, {"banish", cmd_banish, arg_VOID}, {"curframe", cmd_curframe, arg_VOID}, + {"help", cmd_help, arg_VOID}, + {"quit", cmd_quit, arg_VOID}, /* the following screen commands may or may not be able to be implemented. See the screen documentation for what should be @@ -173,7 +176,6 @@ user_command user_commands[] = {"stuff", cmd_unimplemented, arg_VOID}, {"number", cmd_unimplemented, arg_VOID}, {"hardcopy", cmd_unimplemented, arg_VOID}, - {"help", cmd_unimplemented, arg_VOID}, {"lastmsg", cmd_unimplemented, arg_VOID}, {"license", cmd_unimplemented, arg_VOID}, {"lockscreen", cmd_unimplemented, arg_VOID}, @@ -181,7 +183,6 @@ user_command user_commands[] = {"msgwait", cmd_unimplemented, arg_VOID}, {"msgminwait", cmd_unimplemented, arg_VOID}, {"nethack", cmd_unimplemented, arg_VOID}, - {"quit", cmd_unimplemented, arg_VOID}, {"redisplay", cmd_unimplemented, arg_VOID}, {"screen", cmd_unimplemented, arg_VOID}, {"setenv", cmd_unimplemented, arg_VOID}, @@ -691,13 +692,13 @@ cmd_newwm(void *data) /* Quit ratpoison. Thanks to "Chr. v. Stuckrad" <stucki@math.fu-berlin.de> for the patch. */ -/* static void */ -/* bye(void *dummy) */ -/* { */ -/* PRINT_DEBUG ("Exiting\n"); */ -/* clean_up (); */ -/* exit (EXIT_SUCCESS); */ -/* } */ +void +cmd_quit(void *data) +{ + PRINT_DEBUG ("Exiting\n"); + clean_up (); + exit (EXIT_SUCCESS); +} /* Show the current time on the bar. Thanks to Martin Samuelsson <cosis@lysator.liu.se> for the patch. Thanks to Jonathan Walther @@ -866,3 +867,75 @@ cmd_curframe (void *data) { show_frame_indicator(); } + +void +cmd_help (void *data) +{ + screen_info *s = current_screen(); + XEvent ev; + Window fwin; /* Window currently in focus */ + int revert; + int i; + int x = 10; + int y = 0; + int max_width = 0; + char *keysym_name; + + XMapRaised (dpy, s->help_window); + + XGetInputFocus (dpy, &fwin, &revert); + XSetInputFocus (dpy, s->help_window, RevertToPointerRoot, CurrentTime); + + XDrawString (dpy, s->help_window, s->normal_gc, + 10, y + s->font->max_bounds.ascent, + "ratpoison key bindings", strlen ("ratpoison key bindings")); + + y += FONT_HEIGHT (s->font) * 2; + + XDrawString (dpy, s->help_window, s->normal_gc, + 10, y + s->font->max_bounds.ascent, + "Command key: ", strlen ("Command key: ")); + + keysym_name = keysym_to_string (prefix_key.sym, prefix_key.state); + XDrawString (dpy, s->help_window, s->normal_gc, + 10 + XTextWidth (s->font, "Command key: ", strlen ("Command key: ")), + y + s->font->max_bounds.ascent, + keysym_name, strlen (keysym_name)); + free (keysym_name); + + y += FONT_HEIGHT (s->font) * 2; + + for (i=0; i<key_actions_last; i++) + { + keysym_name = keysym_to_string (key_actions[i].key, key_actions[i].state); + + XDrawString (dpy, s->help_window, s->normal_gc, + x, y + s->font->max_bounds.ascent, + keysym_name, strlen (keysym_name)); + + if (XTextWidth (s->font, key_actions[i].data, strlen (key_actions[i].data)) + + XTextWidth (s->font, keysym_name, strlen (keysym_name)) > max_width) + { + max_width = XTextWidth (s->font, key_actions[i].data, strlen (key_actions[i].data)) + + XTextWidth (s->font, keysym_name, strlen (keysym_name)); + } + + XDrawString (dpy, s->help_window, s->normal_gc, + x + 90, y + s->font->max_bounds.ascent, + key_actions[i].data, strlen (key_actions[i].data)); + + free (keysym_name); + + y += FONT_HEIGHT (s->font); + if (y > s->root_attr.height) + { + x += max_width + 10 + 90; + y = FONT_HEIGHT (s->font) * 4; + max_width = 0; + } + } + + XMaskEvent (dpy, KeyPressMask, &ev); + XUnmapWindow (dpy, s->help_window); + XSetInputFocus (dpy, fwin, revert, CurrentTime); +} diff --git a/src/actions.h b/src/actions.h index b479ab1..e0b2cb8 100644 --- a/src/actions.h +++ b/src/actions.h @@ -37,7 +37,6 @@ user_command int argtype; }; -void bye(void *dummy); void spawn(void *data); void command (char *data); @@ -71,6 +70,8 @@ void cmd_only (void *data); void cmd_remove (void *data); void cmd_banish (void *data); void cmd_curframe (void *data); +void cmd_help (void *data); +void cmd_quit(void *data); /* void cmd_xterm (void *data); */ @@ -99,7 +99,7 @@ update_window_names (screen_info *s) int mark_start = 0; int mark_end = 0; - if (!s->bar_is_raised) return; + if (s->bar_is_raised != BAR_IS_WINDOW_LIST) return; if (bar_buffer == NULL) bar_buffer = sbuf_new (0); @@ -52,6 +52,10 @@ struct rp_window int last_access; int named; + /* An indication to unmap_notify that the event was produced by + iconizing a window. */ + int iconizing; + /* Dimensions */ int x, y, width, height, border; @@ -76,7 +80,7 @@ struct screen_info GC normal_gc; XFontStruct *font; /* The font we want to use. */ XWindowAttributes root_attr; - Window root, bar_window, key_window, input_window, frame_window; + Window root, bar_window, key_window, input_window, frame_window, help_window; int bar_is_raised; int screen_num; /* Our screen number as dictated my X */ Colormap def_cmap; diff --git a/src/events.c b/src/events.c index 8d48fdb..b6ba3e9 100644 --- a/src/events.c +++ b/src/events.c @@ -48,7 +48,7 @@ new_window (XCreateWindowEvent *e) win = find_window (e->window); if (s && !win && e->window != s->key_window && e->window != s->bar_window - && e->window != s->input_window && e->window != s->frame_window) + && e->window != s->input_window && e->window != s->frame_window && e->window != s->help_window) { win = add_to_window_list (s, e->window); update_window_information (win); @@ -81,24 +81,30 @@ unmap_notify (XEvent *ev) { rp_window_frame *frame; - /* If the window was inside a frame, fill the frame with another - window. */ - frame = find_windows_frame (win); - if (frame) cleanup_frame (frame); - - switch (win->state) + if (win->iconizing) { - case IconicState: - /* This shouldn't actually happen, since the window is - already unmapped, so do nothing */ - PRINT_DEBUG ("Iconizing iconized window '%s'\n", win->name); - break; - case NormalState: - PRINT_DEBUG ("Withdrawing window '%s'\n", win->name); - withdraw_window (win); -/* hide_window (win); */ - if (frame == rp_current_frame) set_active_frame (frame); - break; + /* This event is due to our hiding the window. */ + win->iconizing--; + } + else + { + switch (win->state) + { + case IconicState: + PRINT_DEBUG ("Withdrawing iconized window '%s'\n", win->name); + if (ev->xunmap.send_event) withdraw_window (win); + break; + case NormalState: + PRINT_DEBUG ("Withdrawing normal window '%s'\n", win->name); + /* If the window was inside a frame, fill the frame with another + window. */ + frame = find_windows_frame (win); + if (frame) cleanup_frame (frame); + if (frame == rp_current_frame) set_active_frame (frame); + + withdraw_window (win); + break; + } } update_window_names (s); @@ -138,10 +144,10 @@ map_request (XEvent *ev) PRINT_DEBUG ("Mapped Window\n"); /* Its already mapped, so we don't have to do anything */ -/* maximize (win); */ -/* XMapRaised (dpy, win->w); */ -/* set_state (win, NormalState); */ -/* set_active_window (win); */ + /* maximize (win); */ + /* XMapRaised (dpy, win->w); */ + /* set_state (win, NormalState); */ + /* set_active_window (win); */ break; case IconicState: PRINT_DEBUG ("Mapped iconic window\n"); @@ -233,11 +239,11 @@ configure_request (XConfigureRequestEvent *e) { if (e->detail == Above) { - goto_window (win); +/* goto_window (win); */ } else if (e->detail == Below) { - set_active_window (find_window_other ()); +/* set_active_window (find_window_other ()); */ } PRINT_DEBUG("request CWStackMode %d\n", e->detail); @@ -344,9 +350,9 @@ handle_key (screen_info *s) PRINT_DEBUG ("handling key...\n"); - /* All functions hide the program bar. Unless the bar doesn't time - out. */ + /* All functions hide the program bar and the frame indicator. */ if (BAR_TIMEOUT > 0) hide_bar (s); + hide_frame_indicator(); XGetInputFocus (dpy, &fwin, &revert); XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); @@ -65,6 +65,7 @@ add_to_window_list (screen_info *s, Window w) new_window->last_access = 0; new_window->prev = NULL; new_window->state = WithdrawnState; + new_window->iconizing = 0; new_window->number = -1; new_window->named = 0; new_window->hints = XAllocSizeHints (); @@ -442,6 +442,9 @@ main (int argc, char *argv[]) } read_startup_files (); + + /* Indicate to the user that ratpoison has booted */ + message (MESSAGE_WELCOME); handle_events (); @@ -544,13 +547,15 @@ init_screen (screen_info *s, int screen_num) 1, 1, 1, fg_color.pixel, bg_color.pixel); XSelectInput (dpy, s->input_window, KeyPressMask ); - s->frame_window = XCreateSimpleWindow (dpy, s->root, - s->root_attr.width / 2 - 5, - s->root_attr.height / 2 - 5, - 10, 10, 1, + /* Create the frame indicator window */ + s->frame_window = XCreateSimpleWindow (dpy, s->root, 1, 1, 1, 1, 1, fg_color.pixel, bg_color.pixel); XSelectInput (dpy, s->frame_window, KeyPressMask ); - XMapRaised (dpy, s->frame_window); + + /* Create the help window */ + s->help_window = XCreateSimpleWindow (dpy, s->root, 0, 0, s->root_attr.width, + s->root_attr.height, 1, fg_color.pixel, bg_color.pixel); + XSelectInput (dpy, s->help_window, KeyPressMask); XSync (dpy, 0); @@ -582,6 +587,7 @@ clean_up () XDestroyWindow (dpy, screens[i].key_window); XDestroyWindow (dpy, screens[i].input_window); XDestroyWindow (dpy, screens[i].frame_window); + XDestroyWindow (dpy, screens[i].help_window); XFreeCursor (dpy, screens[i].rat); XFreeColormap (dpy, screens[i].def_cmap); diff --git a/src/manage.c b/src/manage.c index e5bfa4d..638087b 100644 --- a/src/manage.c +++ b/src/manage.c @@ -234,6 +234,7 @@ scanwins(screen_info *s) || wins[i] == s->key_window || wins[i] == s->input_window || wins[i] == s->frame_window + || wins[i] == s->help_window || attr.override_redirect == True || unmanaged_window (wins[i])) continue; @@ -499,8 +500,9 @@ hide_window (rp_window *win) { if (win == NULL) return; - set_state (win, IconicState); XUnmapWindow (dpy, win->w); + set_state (win, IconicState); + win->iconizing++; } void diff --git a/src/messages.h b/src/messages.h index 36de9c1..0d8cbe6 100644 --- a/src/messages.h +++ b/src/messages.h @@ -35,4 +35,6 @@ #define MESSAGE_PROMPT_SWITCH_WM " Switch to wm: " #define MESSAGE_PROMPT_XTERM_COMMAND MESSAGE_PROMPT_SHELL_COMMAND TERM_PROG " -e " +#define MESSAGE_WELCOME "Welcome to ratpoison! Hit C-t ? for help." + #endif /* ! _RATPOISON_MESSAGES_H */ |