Skip to content

Commit

Permalink
enhance electron support if compiled with '-DMANUAL_AX' (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKratz committed Aug 10, 2022
1 parent d91f11f commit acda553
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION = "1.0.8"
CC = clang
DEFINES = -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN #-DGUI_MOVES
DEFINES = -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN # -DMANUAL_AX -DGUI_MOVES
LIBS = lib/libvim.a -lm -lncurses -liconv -framework Carbon -framework Cocoa
WARN_FLAGS = -Wall -Wno-array-bounds \
-Wno-unknown-warning-option \
Expand Down
12 changes: 12 additions & 0 deletions src/ax.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ bool ax_process_selected_element(struct ax* ax) {
return ax->is_supported && success;
}

void ax_front_app_changed(struct ax* ax, pid_t pid) {
#ifdef MANUAL_AX
AXUIElementRef app = AXUIElementCreateApplication(pid);
if (app) {
AXUIElementSetAttributeValue(app,
CFSTR("AXManualAccessibility"),
kCFBooleanTrue );
CFRelease(app);
}
#endif
}

CGEventRef ax_process_event(struct ax* ax, CGEventRef event) {
if (!ax_process_selected_element(ax)) return event;

Expand Down
1 change: 1 addition & 0 deletions src/ax.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ void ax_begin(struct ax* ax);
void ax_clear(struct ax* ax);

CGEventRef ax_process_event(struct ax* ax, CGEventRef event);
void ax_front_app_changed(struct ax* ax, pid_t pid);
5 changes: 4 additions & 1 deletion src/workspace.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ - (void)dealloc {
- (void)appSwitched:(NSNotification *)notification {
char* name = NULL;
char* bundle_id = NULL;
pid_t pid = 0;
if (notification && notification.userInfo) {
NSRunningApplication* app = [notification.userInfo objectForKey:NSWorkspaceApplicationKey];
if (app) {
name = (char*)[[app localizedName] UTF8String];
bundle_id = (char*)[[app bundleIdentifier] UTF8String];
pid = app.processIdentifier;
}
}

g_event_tap.front_app_ignored = event_tap_check_blacklist(&g_event_tap,
name,
bundle_id);
bundle_id );
ax_front_app_changed(&g_ax, pid);
}

@end

0 comments on commit acda553

Please sign in to comment.