Skip to content

Commit 00a39cd

Browse files
committed
Removed extra link flags.
Fixed runtime error in the hook callback log statement. Fixed function definitions for dlsym().
1 parent 1cc6658 commit 00a39cd

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

configure.ac

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ AS_IF(
191191
PKG_PROG_PKG_CONFIG
192192
193193
PKG_CHECK_MODULES([X11], [x11])
194-
LIBS="$X11_LIBS $LIBS"
195-
CFLAGS="$X11_CFLAGS $CFLAGS"
194+
#LIBS="$X11_LIBS $LIBS"
195+
#CFLAGS="$X11_CFLAGS $CFLAGS"
196196
REQUIRE="$REQUIRE x11"
197197
198198
PKG_CHECK_MODULES([XTST], [xtst])
199-
LIBS="$XTST_LIBS $LIBS"
200-
CFLAGS="$XTST_CFLAGS $CFLAGS"
199+
#LIBS="$XTST_LIBS $LIBS"
200+
#CFLAGS="$XTST_CFLAGS $CFLAGS"
201201
REQUIRE="$REQUIRE xtst"
202202
203203
# Check for XRecord.
@@ -216,16 +216,16 @@ AS_IF(
216216
AS_IF([test "x$enable_xt" = "xyes"], [
217217
AC_DEFINE([USE_XT], 1, [Enable X Toolkit Intrinsics])
218218
PKG_CHECK_MODULES([XT], [xt])
219-
LIBS="$XT_LIBS $LIBS"
220-
CFLAGS="$XT_CFLAGS $CFLAGS"
219+
#LIBS="$XT_LIBS $LIBS"
220+
#CFLAGS="$XT_CFLAGS $CFLAGS"
221221
REQUIRE="$REQUIRE xt"
222222
])
223223
224224
AS_IF([test "x$enable_xf86misc" = "xyes"], [
225225
AC_DEFINE([USE_XF86MISC], 1, [Enable XFree86-Misc X Extension])
226226
PKG_CHECK_MODULES([XF86MISC], [xxf86misc])
227-
LIBS="$XF86MISC_LIBS $LIBS"
228-
CFLAGS="$XF86MISC_CFLAGS $CFLAGS"
227+
#LIBS="$XF86MISC_LIBS $LIBS"
228+
#CFLAGS="$XF86MISC_CFLAGS $CFLAGS"
229229
REQUIRE="$REQUIRE xxf86misc"
230230
])
231231

darwin/hook_callback.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ CGEventRef hook_event_proc(CGEventTapProxy tap_proxy, CGEventType type_ref, CGEv
222222
if (pthread_mutex_lock(&hook_control_mutex) == 0) {
223223
pthread_mutex_unlock(&hook_control_mutex);
224224
}
225-
225+
226226
if (info->length == 1) {
227227
// Fire key typed event.
228228
event.type = EVENT_KEY_TYPED;
229229

230230
event.data.keyboard.keycode = VC_UNDEFINED;
231231
event.data.keyboard.keychar = info->buffer[0];
232232

233-
logger(LOG_LEVEL_INFO, "%s [%u]: Key %#X typed. (%ls)\n",
233+
logger(LOG_LEVEL_INFO, "%s [%u]: Key %#X typed. (%lc)\n",
234234
__FUNCTION__, __LINE__, event.data.keyboard.keycode, event.data.keyboard.keychar);
235235
dispatch_event(&event);
236236
}

darwin/hook_thread.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ static pthread_attr_t hook_thread_attr;
4949
extern Boolean AXIsProcessTrustedWithOptions(CFDictionaryRef options) __attribute__((weak_import));
5050
extern CFStringRef kAXTrustedCheckOptionPrompt __attribute__((weak_import));
5151
#else
52-
typedef Boolean (*AXIsProcessTrustedWithOptions_t)(CFDictionaryRef options);
53-
typedef Boolean (*AXAPIEnabled_t)(void);
52+
Boolean (*AXIsProcessTrustedWithOptions_t)(CFDictionaryRef);
53+
Boolean (*AXAPIEnabled_t)(void);
5454
#endif
5555

5656
static void *hook_thread_proc(void *arg) {
@@ -87,11 +87,11 @@ static void *hook_thread_proc(void *arg) {
8787
dlError = dlerror();
8888
if (libApplicaitonServices != NULL && dlError == NULL) {
8989
// Check for the new function AXIsProcessTrustedWithOptions().
90-
AXIsProcessTrustedWithOptions_t fpAXIsProcessTrustedWithOptions = (AXIsProcessTrustedWithOptions_t) dlsym(libApplicaitonServices, "AXIsProcessTrustedWithOptions");
90+
*(void **) (&AXIsProcessTrustedWithOptions_t) = dlsym(libApplicaitonServices, "AXIsProcessTrustedWithOptions");
9191
dlError = dlerror();
92-
if (fpAXIsProcessTrustedWithOptions != NULL && dlError == NULL) {
92+
if (AXIsProcessTrustedWithOptions_t != NULL && dlError == NULL) {
9393
// New accessibility API 10.9 and later.
94-
const void * keys[] = { kAXTrustedCheckOptionPrompt };
94+
const void * keys[] = { dlsym(libApplicaitonServices, "kAXTrustedCheckOptionPrompt") };
9595
const void * values[] = { kCFBooleanTrue };
9696

9797
CFDictionaryRef options = CFDictionaryCreate(
@@ -102,18 +102,18 @@ static void *hook_thread_proc(void *arg) {
102102
&kCFCopyStringDictionaryKeyCallBacks,
103103
&kCFTypeDictionaryValueCallBacks);
104104

105-
accessibilityEnabled = (*fpAXIsProcessTrustedWithOptions)(options);
105+
accessibilityEnabled = (*AXIsProcessTrustedWithOptions_t)(options);
106106
}
107107
else {
108108
logger(LOG_LEVEL_DEBUG, "%s [%u]: Failed to locate AXIsProcessTrustedWithOptions(). (%s)\n",
109109
__FUNCTION__, __LINE__, dlError);
110110

111111
// Check for the fallback function AXAPIEnabled().
112-
AXAPIEnabled_t fpAXAPIEnabled = (AXAPIEnabled_t) dlsym(libApplicaitonServices, "AXAPIEnabled");
112+
*(void **) (&AXAPIEnabled_t) = dlsym(libApplicaitonServices, "AXAPIEnabled");
113113
dlError = dlerror();
114-
if (fpAXAPIEnabled != NULL && dlError == NULL) {
114+
if (AXAPIEnabled_t != NULL && dlError == NULL) {
115115
// Old accessibility check 10.8 and older.
116-
accessibilityEnabled = (*fpAXAPIEnabled)();
116+
accessibilityEnabled = (*AXAPIEnabled_t)();
117117
}
118118
else {
119119
// Could not load the AXAPIEnabled function!

0 commit comments

Comments
 (0)