1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
$NetBSD: patch-ab,v 1.2 2015/04/23 09:17:48 abs Exp $
Remember to always ungrab on exit
--- x.c.orig 2006-06-14 05:34:41.000000000 +0200
+++ x.c
@@ -173,6 +173,14 @@ int warn_about_hotkey(Display *dpy, XErr
*/
static Bool mouseOnScreen;
+static void atexit_ungrab(void) {
+ if (grabbed) {
+ fprintf(stderr, "%s: exit while grabbed, ungrabbing input devices\n",
+ programName);
+ ungrabit(-1, -1, DefaultRootWindow(dpy));
+ }
+}
+
/*
* CreateXWindow.
*/
@@ -534,6 +542,7 @@ Bool CreateXWindow(void)
dumpcoord(&origo2);
fprintf(stderr,"offset=%d, %d\n",x_offset,y_offset);
*/
+ atexit(atexit_ungrab);
return True;
}
|