optimize darwin check accessibility not loop

This commit is contained in:
vcaesar 2019-02-19 11:47:56 -04:00
parent 9fa8b6c408
commit 3f023c292f

View File

@ -1110,15 +1110,15 @@ CGEventRef hook_event_proc(CGEventTapProxy tap_proxy, CGEventType type, CGEventR
IOHOOK_API int hook_run() { IOHOOK_API int hook_run() {
int status = IOHOOK_SUCCESS; int status = IOHOOK_SUCCESS;
do {
// Reset the restart flag...
restart_tap = false;
// Check for accessibility each time we start the loop. // Check for accessibility each time we start the loop.
if (is_accessibility_enabled()) { if (is_accessibility_enabled()) {
logger(LOG_LEVEL_DEBUG, "%s [%u]: Accessibility API is enabled.\n", logger(LOG_LEVEL_DEBUG, "%s [%u]: Accessibility API is enabled.\n",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
do {
// Reset the restart flag...
restart_tap = false;
// Initialize starting modifiers. // Initialize starting modifiers.
initialize_modifiers(); initialize_modifiers();
@ -1330,15 +1330,14 @@ IOHOOK_API int hook_run() {
else { else {
status = IOHOOK_ERROR_OUT_OF_MEMORY; status = IOHOOK_ERROR_OUT_OF_MEMORY;
} }
} } while (restart_tap);
else { } else {
logger(LOG_LEVEL_ERROR, "%s [%u]: Accessibility API is disabled!\n", logger(LOG_LEVEL_ERROR, "%s [%u]: Accessibility API is disabled!\n",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);
// Set the exit status. // Set the exit status.
status = IOHOOK_ERROR_AXAPI_DISABLED; status = IOHOOK_ERROR_AXAPI_DISABLED;
} }
} while (restart_tap);
logger(LOG_LEVEL_DEBUG, "%s [%u]: Something, something, something, complete.\n", logger(LOG_LEVEL_DEBUG, "%s [%u]: Something, something, something, complete.\n",
__FUNCTION__, __LINE__); __FUNCTION__, __LINE__);