summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uisimulator/x11/screenhack.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/uisimulator/x11/screenhack.c b/uisimulator/x11/screenhack.c
index d8731e4125..fb0f5637e5 100644
--- a/uisimulator/x11/screenhack.c
+++ b/uisimulator/x11/screenhack.c
@@ -241,7 +241,7 @@ static Bool MapNotify_event_p (Display *dpy, XEvent *event, XPointer window)
static Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW;
-void kb_disable_auto_repeat(bool on)
+static void kb_disable_auto_repeat(bool on)
{
XKeyboardControl kb;
@@ -249,6 +249,12 @@ void kb_disable_auto_repeat(bool on)
XChangeKeyboardControl(dpy, KBAutoRepeatMode, &kb);
}
+static void kb_restore_auto_repeat(void) /* registered as an exit handler */
+{
+ kb_disable_auto_repeat(false);
+ XSync(dpy, false); /* force the X server to process that */
+}
+
/* Dead-trivial event handling.
Exit if the WM_PROTOCOLS WM_DELETE_WINDOW ClientMessage is received.
*/
@@ -312,8 +318,6 @@ int screenhack_handle_event(XEvent *event, bool *release)
progname, s1, s2);
}
else {
- kb_disable_auto_repeat(false);
- XSync(dpy, false); /* force the X server to process that */
exit (0);
}
break;
@@ -569,6 +573,7 @@ int main (int argc, char **argv)
XSync (dpy, False);
+ atexit(kb_restore_auto_repeat);
kb_disable_auto_repeat(true);
screenhack(); /* doesn't return */
return 0;