diff options
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/actions.c b/src/actions.c index 62107bb..84fdd49 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1742,9 +1742,7 @@ read_frame (struct argspec *spec, struct sbuf *s, struct cmdarg **arg) XSync (dpy, False); /* Read a key. */ - XGrabKeyboard (dpy, current_screen()->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime); - read_key (&c, &mod, keysym_buf, keysym_bufsize); - XUngrabKeyboard (dpy, CurrentTime); + read_single_key (&c, &mod, keysym_buf, keysym_bufsize); /* Destroy our number windows and free the array. */ for (i=0; i<frames; i++) @@ -2969,17 +2967,21 @@ cmd_resize (int interactive, struct cmdarg **args) unsigned int mod; KeySym c; struct list_head *bk; + Window focus; + int revert; /* If we haven't got at least 2 frames, there isn't anything to scale. */ if (num_frames (s) < 2) return cmdret_new (RET_FAILURE, NULL); - XGrabKeyboard (dpy, s->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime); - /* Save the frameset in case the user aborts. */ bk = screen_copy_frameset (s); + /* Get ready to read keys. */ + XGetInputFocus (dpy, &focus, &revert); + set_window_focus (s->key_window); + while (1) { struct resize_binding *binding; @@ -3028,7 +3030,7 @@ cmd_resize (int interactive, struct cmdarg **args) free (bk); hide_frame_indicator (); - XUngrabKeyboard (dpy, CurrentTime); + set_window_focus (focus); } else { @@ -3155,7 +3157,6 @@ cmdret * cmd_license (int interactive, struct cmdarg **args) { rp_screen *s = current_screen(); - XEvent ev; int x = 10; int y = 10; int i; @@ -3192,7 +3193,6 @@ cmd_license (int interactive, struct cmdarg **args) XInstallColormap (dpy, s->def_cmap); XMapRaised (dpy, s->help_window); - XGrabKeyboard (dpy, s->help_window, False, GrabModeSync, GrabModeAsync, CurrentTime); /* Find the longest line. */ for(i=0; license_text[i]; i++) @@ -3221,10 +3221,7 @@ cmd_license (int interactive, struct cmdarg **args) } /* Wait for a key press. */ - XMaskEvent (dpy, KeyPressMask, &ev); - - /* Revert focus. */ - XUngrabKeyboard (dpy, CurrentTime); + read_any_key (); XUnmapWindow (dpy, s->help_window); /* Possibly restore colormap. */ @@ -3254,7 +3251,6 @@ cmd_help (int interactive, struct cmdarg **args) if (interactive) { rp_screen *s = current_screen(); - XEvent ev; int i, old_i; int x = 10; int y = 0; @@ -3268,7 +3264,6 @@ cmd_help (int interactive, struct cmdarg **args) XInstallColormap (dpy, s->def_cmap); XMapRaised (dpy, s->help_window); - XGrabKeyboard (dpy, s->help_window, False, GrabModeSync, GrabModeAsync, CurrentTime); XmbDrawString (dpy, s->help_window, defaults.font, s->normal_gc, 10, y + rp_font_ascent, @@ -3353,8 +3348,7 @@ cmd_help (int interactive, struct cmdarg **args) } } - XMaskEvent (dpy, KeyPressMask, &ev); - XUngrabKeyboard (dpy, CurrentTime); + read_any_key(); XUnmapWindow (dpy, s->help_window); /* Possibly restore colormap. */ @@ -4964,8 +4958,6 @@ cmd_readkey (int interactive, struct cmdarg **args) map = ARG(0,keymap); - XGrabKeyboard (dpy, current_screen()->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime); - /* Change the mouse icon to indicate to the user we are waiting for more keystrokes */ if (defaults.wait_for_key_cursor) @@ -4974,8 +4966,7 @@ cmd_readkey (int interactive, struct cmdarg **args) rat_grabbed = 1; } - read_key (&keysym, &mod, NULL, 0); - XUngrabKeyboard (dpy, CurrentTime); + read_single_key (&keysym, &mod, NULL, 0); if (rat_grabbed) ungrab_rat(); @@ -5517,8 +5508,6 @@ cmd_describekey (int interactive, struct cmdarg **args) map = ARG(0,keymap); - XGrabKeyboard (dpy, current_screen()->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime); - /* Change the mouse icon to indicate to the user we are waiting for more keystrokes */ if (defaults.wait_for_key_cursor) @@ -5527,8 +5516,7 @@ cmd_describekey (int interactive, struct cmdarg **args) rat_grabbed = 1; } - read_key (&keysym, &mod, NULL, 0); - XUngrabKeyboard (dpy, CurrentTime); + read_single_key (&keysym, &mod, NULL, 0); if (rat_grabbed) ungrab_rat(); |