From e62c770a1ea5d89bb91d9b84ac4a4593bc32ef71 Mon Sep 17 00:00:00 2001 From: sabetts Date: Fri, 29 Aug 2003 21:17:42 +0000 Subject: * src/window.c (give_window_focus): use set_rp_window_focus. * src/split.c (set_active_frame): use set_window_focus. (blank_frame): likewise * src/main.c (main): use set_window_focus. * src/input.c (get_more_input): use set_window_focus * src/globals.h (set_window_focus): new prototype (set_rp_window_focus): likewise * src/events.c (handle_key): use set_window_focus. * src/actions.c (cmd_resize): use set_window_focus. (cmd_license): likewise (cmd_help): likewise (cmd_tmpwm): likewise (cmd_fselect): likewise * src/globals.c (set_rp_window_focus): new function (set_window_focus): likewise --- ChangeLog | 25 +++++++++++++++++++++++++ src/actions.c | 19 +++++++++---------- src/events.c | 4 ++-- src/globals.c | 15 +++++++++++++++ src/globals.h | 3 +++ src/input.c | 4 ++-- src/main.c | 3 +-- src/split.c | 6 ++---- src/window.c | 3 +-- 9 files changed, 60 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6184b63..fc067e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2003-08-29 Shawn Betts + + * src/window.c (give_window_focus): use set_rp_window_focus. + + * src/split.c (set_active_frame): use set_window_focus. + (blank_frame): likewise + + * src/main.c (main): use set_window_focus. + + * src/input.c (get_more_input): use set_window_focus + + * src/globals.h (set_window_focus): new prototype + (set_rp_window_focus): likewise + + * src/events.c (handle_key): use set_window_focus. + + * src/actions.c (cmd_resize): use set_window_focus. + (cmd_license): likewise + (cmd_help): likewise + (cmd_tmpwm): likewise + (cmd_fselect): likewise + + * src/globals.c (set_rp_window_focus): new function + (set_window_focus): likewise + 2003-08-24 Shawn Betts * src/window.c (goto_window): don't do anything if the window is diff --git a/src/actions.c b/src/actions.c index 700ffd1..f3485bb 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1577,7 +1577,7 @@ cmd_resize (int interactive, char *data) if (num_frames (s) < 2) return NULL; XGetInputFocus (dpy, &fwin, &revert); - XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); + set_window_focus (s->key_window); /* Save the frameset in case the user aborts. */ bk = screen_copy_frameset (s); @@ -1623,7 +1623,7 @@ cmd_resize (int interactive, char *data) free (bk); hide_frame_indicator (); - XSetInputFocus (dpy, fwin, RevertToPointerRoot, CurrentTime); + set_window_focus (fwin); } else { @@ -1731,7 +1731,7 @@ cmd_license (int interactive, char *data) XMapRaised (dpy, s->help_window); XGetInputFocus (dpy, &fwin, &revert); - XSetInputFocus (dpy, s->help_window, RevertToPointerRoot, CurrentTime); + set_window_focus (s->help_window); /* Find the longest line. */ for(i=0; license_text[i]; i++) @@ -1762,7 +1762,7 @@ cmd_license (int interactive, char *data) /* Wait for a key press. */ XMaskEvent (dpy, KeyPressMask, &ev); XUnmapWindow (dpy, s->help_window); - XSetInputFocus (dpy, fwin, revert, CurrentTime); + set_window_focus (fwin); /* The help window overlaps the bar, so redraw it. */ if (current_screen()->bar_is_raised) @@ -1790,7 +1790,7 @@ cmd_help (int interactive, char *data) XMapRaised (dpy, s->help_window); XGetInputFocus (dpy, &fwin, &revert); - XSetInputFocus (dpy, s->help_window, RevertToPointerRoot, CurrentTime); + set_window_focus (s->help_window); XDrawString (dpy, s->help_window, s->normal_gc, 10, y + defaults.font->max_bounds.ascent, @@ -1877,7 +1877,7 @@ cmd_help (int interactive, char *data) XMaskEvent (dpy, KeyPressMask, &ev); XUnmapWindow (dpy, s->help_window); - XSetInputFocus (dpy, fwin, revert, CurrentTime); + set_window_focus (fwin); /* The help window overlaps the bar, so redraw it. */ if (current_screen()->bar_is_raised) @@ -3151,8 +3151,7 @@ cmd_tmpwm (int interactive, char *data) /* If no window has focus, give the key_window focus. */ if (current_window() == NULL) - XSetInputFocus (dpy, current_screen()->key_window, - RevertToPointerRoot, CurrentTime); + set_window_focus (current_screen()->key_window); /* And we're back in ratpoison. */ return NULL; @@ -3241,9 +3240,9 @@ cmd_fselect (int interactive, char *data) /* Read a key. */ XGetInputFocus (dpy, &fwin, &revert); - XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); + set_window_focus (s->key_window); read_key (&c, &mod, NULL, 0); - XSetInputFocus (dpy, fwin, RevertToPointerRoot, CurrentTime); + set_window_focus (fwin); /* Destroy our number windows and free the array. */ for (i=0; ikey_window, RevertToPointerRoot, CurrentTime); + set_window_focus (s->key_window); /* Change the mouse icon to indicate to the user we are waiting for more keystrokes */ @@ -399,7 +399,7 @@ handle_key (rp_screen *s) read_key (&keysym, &mod, NULL, 0); - XSetInputFocus (dpy, fwin, revert, CurrentTime); + set_window_focus (fwin); if (rat_grabbed) ungrab_rat(); diff --git a/src/globals.c b/src/globals.c index 2cc7d78..6284a66 100644 --- a/src/globals.c +++ b/src/globals.c @@ -81,3 +81,18 @@ struct rp_hook_db_entry rp_hook_db[]= {"switchgroup", &rp_switch_group_hook}, {NULL, NULL}}; +void +set_rp_window_focus (rp_window *win) +{ + PRINT_DEBUG (("Giving focus to '%s'\n", window_name (win))); + XSetInputFocus (dpy, win->w, + RevertToPointerRoot, CurrentTime); +} + +void +set_window_focus (Window window) +{ + PRINT_DEBUG (("Giving focus to %ld\n", window)); + XSetInputFocus (dpy, window, + RevertToPointerRoot, CurrentTime); +} diff --git a/src/globals.h b/src/globals.h index 0bb5ba2..c2166b1 100644 --- a/src/globals.h +++ b/src/globals.h @@ -136,4 +136,7 @@ extern struct list_head rp_switch_group_hook; extern struct rp_hook_db_entry rp_hook_db[]; +void set_rp_window_focus (rp_window *win); +void set_window_focus (Window window); + #endif diff --git a/src/input.c b/src/input.c index 31c901d..a0ee12c 100644 --- a/src/input.c +++ b/src/input.c @@ -397,7 +397,7 @@ get_more_input (char *prompt, char *preinput, update_input_window (s, line); XGetInputFocus (dpy, &fwin, &revert); - XSetInputFocus (dpy, s->input_window, RevertToPointerRoot, CurrentTime); + set_window_focus (s->input_window); /* XSync (dpy, False); */ for (;;) @@ -437,7 +437,7 @@ get_more_input (char *prompt, char *preinput, /* Clean up our line structure */ input_line_free (line); - XSetInputFocus (dpy, fwin, RevertToPointerRoot, CurrentTime); + set_window_focus (fwin); XUnmapWindow (dpy, s->input_window); return final_input; diff --git a/src/main.c b/src/main.c index 0173ef4..33433ee 100644 --- a/src/main.c +++ b/src/main.c @@ -640,8 +640,7 @@ main (int argc, char *argv[]) /* If no window has focus, give the key_window focus. */ if (current_window() == NULL) - XSetInputFocus (dpy, current_screen()->key_window, - RevertToPointerRoot, CurrentTime); + set_window_focus (current_screen()->key_window); listen_for_events (); diff --git a/src/split.c b/src/split.c index 3345523..dfda926 100644 --- a/src/split.c +++ b/src/split.c @@ -859,8 +859,7 @@ set_active_frame (rp_frame *frame) focus. */ if(frame->win_number == EMPTY) { - XSetInputFocus (dpy, s->key_window, - RevertToPointerRoot, CurrentTime); + set_window_focus (s->key_window); } } @@ -883,8 +882,7 @@ blank_frame (rp_frame *frame) update_bar (s); /* Give the key window focus. */ - XSetInputFocus (dpy, current_screen()->key_window, - RevertToPointerRoot, CurrentTime); + set_window_focus (current_screen()->key_window); } void diff --git a/src/window.c b/src/window.c index 17098fe..1ac063c 100644 --- a/src/window.c +++ b/src/window.c @@ -345,8 +345,7 @@ give_window_focus (rp_window *win, rp_window *last_win) /* Finally, give the window focus */ rp_current_screen = win->scr->screen_num; - XSetInputFocus (dpy, win->w, - RevertToPointerRoot, CurrentTime); + set_rp_window_focus (win); XSync (dpy, False); } -- cgit v1.2.3