summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2003-08-31 06:51:32 +0000
committersabetts <sabetts>2003-08-31 06:51:32 +0000
commit8122f90155b54a948bc062d496de373f891a43f6 (patch)
treef0ccbcde619d3db377ede191aa1458422f067a9b /src
parente62c770a1ea5d89bb91d9b84ac4a4593bc32ef71 (diff)
downloadratpoison-8122f90155b54a948bc062d496de373f891a43f6.zip
* src/input.c (get_more_input): use XGrabKeyboard and XUngrabKeyboard
for changing focus to read key presses. * src/events.c (handle_key): use XGrabKeyboard and XUngrabKeyboard for changing focus to read key presses. * src/actions.c (cmd_resize): use XGrabKeyboard and XUngrabKeyboard for changing focus to read key presses. (cmd_license): likewise (cmd_help): likewise (cmd_fselect): likewise
Diffstat (limited to 'src')
-rw-r--r--src/actions.c33
-rw-r--r--src/events.c7
-rw-r--r--src/input.c9
3 files changed, 16 insertions, 33 deletions
diff --git a/src/actions.c b/src/actions.c
index f3485bb..fa8dd42 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1565,19 +1565,17 @@ cmd_resize (int interactive, char *data)
non-interactive version. */
if (interactive && data == NULL)
{
- int nbytes, revert;
+ int nbytes;
char buffer[513];
unsigned int mod;
KeySym c;
- Window fwin;
struct list_head *bk;
/* If we haven't got at least 2 frames, there isn't anything to
scale. */
if (num_frames (s) < 2) return NULL;
- XGetInputFocus (dpy, &fwin, &revert);
- set_window_focus (s->key_window);
+ XGrabKeyboard (dpy, s->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime);
/* Save the frameset in case the user aborts. */
bk = screen_copy_frameset (s);
@@ -1623,7 +1621,7 @@ cmd_resize (int interactive, char *data)
free (bk);
hide_frame_indicator ();
- set_window_focus (fwin);
+ XUngrabKeyboard (dpy, CurrentTime);
}
else
{
@@ -1696,8 +1694,6 @@ cmd_license (int interactive, char *data)
{
rp_screen *s = current_screen();
XEvent ev;
- Window fwin; /* Window currently in focus */
- int revert;
int x = 10;
int y = 10;
int i;
@@ -1729,9 +1725,7 @@ cmd_license (int interactive, char *data)
NULL};
XMapRaised (dpy, s->help_window);
-
- XGetInputFocus (dpy, &fwin, &revert);
- set_window_focus (s->help_window);
+ XGrabKeyboard (dpy, s->help_window, False, GrabModeSync, GrabModeAsync, CurrentTime);
/* Find the longest line. */
for(i=0; license_text[i]; i++)
@@ -1761,8 +1755,10 @@ cmd_license (int interactive, char *data)
/* Wait for a key press. */
XMaskEvent (dpy, KeyPressMask, &ev);
+
+ /* Revert focus. */
+ XUngrabKeyboard (dpy, CurrentTime);
XUnmapWindow (dpy, s->help_window);
- set_window_focus (fwin);
/* The help window overlaps the bar, so redraw it. */
if (current_screen()->bar_is_raised)
@@ -1778,8 +1774,6 @@ cmd_help (int interactive, char *data)
{
rp_screen *s = current_screen();
XEvent ev;
- Window fwin; /* Window currently in focus */
- int revert;
int i, old_i;
int x = 10;
int y = 0;
@@ -1788,9 +1782,7 @@ cmd_help (int interactive, char *data)
char *keysym_name;
XMapRaised (dpy, s->help_window);
-
- XGetInputFocus (dpy, &fwin, &revert);
- set_window_focus (s->help_window);
+ XGrabKeyboard (dpy, s->help_window, False, GrabModeSync, GrabModeAsync, CurrentTime);
XDrawString (dpy, s->help_window, s->normal_gc,
10, y + defaults.font->max_bounds.ascent,
@@ -1876,8 +1868,8 @@ cmd_help (int interactive, char *data)
}
XMaskEvent (dpy, KeyPressMask, &ev);
+ XUngrabKeyboard (dpy, CurrentTime);
XUnmapWindow (dpy, s->help_window);
- set_window_focus (fwin);
/* The help window overlaps the bar, so redraw it. */
if (current_screen()->bar_is_raised)
@@ -3191,8 +3183,6 @@ cmd_fselect (int interactive, char *data)
{
KeySym c;
unsigned int mod;
- Window fwin;
- int revert;
Window *wins;
XSetWindowAttributes attr;
int i;
@@ -3239,10 +3229,9 @@ cmd_fselect (int interactive, char *data)
XSync (dpy, False);
/* Read a key. */
- XGetInputFocus (dpy, &fwin, &revert);
- set_window_focus (s->key_window);
+ XGrabKeyboard (dpy, s->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime);
read_key (&c, &mod, NULL, 0);
- set_window_focus (fwin);
+ XUngrabKeyboard (dpy, CurrentTime);
/* Destroy our number windows and free the array. */
for (i=0; i<num_frames (s); i++)
diff --git a/src/events.c b/src/events.c
index 666c8bf..0d69095 100644
--- a/src/events.c
+++ b/src/events.c
@@ -367,8 +367,6 @@ handle_key (rp_screen *s)
{
char *keysym_name;
rp_action *key_action;
- int revert;
- Window fwin; /* Window currently in focus */
KeySym keysym; /* Key pressed */
unsigned int mod; /* Modifiers */
int rat_grabbed = 0;
@@ -383,8 +381,7 @@ handle_key (rp_screen *s)
alarm (0);
alarm_signalled = 0;
- XGetInputFocus (dpy, &fwin, &revert);
- set_window_focus (s->key_window);
+ XGrabKeyboard (dpy, s->key_window, False, GrabModeSync, GrabModeAsync, CurrentTime);
/* Change the mouse icon to indicate to the user we are waiting for
more keystrokes */
@@ -398,8 +395,8 @@ handle_key (rp_screen *s)
hook_run (&rp_prefix_hook);
read_key (&keysym, &mod, NULL, 0);
+ XUngrabKeyboard (dpy, CurrentTime);
- set_window_focus (fwin);
if (rat_grabbed)
ungrab_rat();
diff --git a/src/input.c b/src/input.c
index a0ee12c..b069991 100644
--- a/src/input.c
+++ b/src/input.c
@@ -377,8 +377,6 @@ get_more_input (char *prompt, char *preinput,
rp_screen *s = current_screen ();
KeySym ch;
unsigned int modifier;
- int revert;
- Window fwin;
rp_input_line *line;
char *final_input;
edit_status status;
@@ -396,9 +394,7 @@ get_more_input (char *prompt, char *preinput,
update_input_window (s, line);
- XGetInputFocus (dpy, &fwin, &revert);
- set_window_focus (s->input_window);
- /* XSync (dpy, False); */
+ XGrabKeyboard (dpy, s->input_window, False, GrabModeSync, GrabModeAsync, CurrentTime);
for (;;)
{
@@ -437,7 +433,8 @@ get_more_input (char *prompt, char *preinput,
/* Clean up our line structure */
input_line_free (line);
- set_window_focus (fwin);
+ /* Revert focus. */
+ XUngrabKeyboard (dpy, CurrentTime);
XUnmapWindow (dpy, s->input_window);
return final_input;