/
src-Hotkeys.cpp.patch
48 lines (43 loc) · 1.11 KB
/
src-Hotkeys.cpp.patch
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- a/src/Hotkeys.cpp
+++ b/src/Hotkeys.cpp
@@ -9,6 +9,15 @@
#define ModifierChange 85 //? this event type isn't listed in libX11
+#ifdef __ANDROID__
+#include <signal.h>
+#include <string.h>
+static void threadSignalHandler(int signum)
+{
+ pthread_exit(0);
+}
+#endif
+
namespace Hotkeys
{
int mGrabbedKeys;
@@ -113,8 +122,17 @@
void* threadedXIKeyListenner(void* data)
{
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#else
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = threadSignalHandler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
Display* display = XOpenDisplay(NULL);
@@ -159,7 +177,11 @@
pthread_create(&mThread, NULL, threadedXIKeyListenner, NULL);
else if (mThread)
{
+#ifndef __ANDROID__
pthread_cancel(mThread); //also close the XDisplay in the thread
+#else
+ pthread_kill(mThread, SIGUSR2);
+#endif
void* ret = NULL;
pthread_join(mThread, &ret);
mThread = 0;