mirror of
https://github.com/termux/termux-packages.git
synced 2024-11-13 14:09:19 +00:00
49 lines
1.1 KiB
Diff
49 lines
1.1 KiB
Diff
--- 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 @@
|
|
|
|
static void* threadedXIKeyListenner(void* data)
|
|
{
|
|
+#ifndef __ANDROID__
|
|
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, nullptr);
|
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr);
|
|
+#else
|
|
+ struct sigaction actions;
|
|
+ memset(&actions, 0, sizeof(actions));
|
|
+ sigemptyset(&actions.sa_mask);
|
|
+ actions.sa_flags = 0;
|
|
+ actions.sa_handler = threadSignalHandler;
|
|
+ sigaction(SIGUSR2, &actions, nullptr);
|
|
+#endif
|
|
|
|
Display* display = XOpenDisplay(nullptr);
|
|
|
|
@@ -162,7 +180,11 @@
|
|
pthread_create(&mThread, nullptr, threadedXIKeyListenner, nullptr);
|
|
else if (mThread)
|
|
{
|
|
+#ifndef __ANDROID__
|
|
pthread_cancel(mThread); //also close the XDisplay in the thread
|
|
+#else
|
|
+ pthread_kill(mThread, SIGUSR2);
|
|
+#endif
|
|
void* ret = nullptr;
|
|
pthread_join(mThread, &ret);
|
|
mThread = 0;
|