Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix M1 support by using int32 instead of int64 #7

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions axlib/src/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ napi_value AXGetElementAtPosition (napi_env env, napi_callback_info info) {
// Get X and Y params
int x;
int y;
napi_get_value_int64(env, args[0], &x);
napi_get_value_int64(env, args[1], &y);
napi_get_value_int32(env, args[0], &x);
napi_get_value_int32(env, args[1], &y);

// This element will contain whatever we are hovering over.
AXUIElementRef element = NULL;
Expand Down Expand Up @@ -254,7 +254,7 @@ napi_value AXGetWindowList (napi_env env, napi_callback_info info) {

// Get the layer of the Window.
napi_value result_entry_layer;
napi_create_int64(env, [[dict objectForKey:@"kCGWindowLayer"] intValue], &result_entry_layer);
napi_create_int32(env, [[dict objectForKey:@"kCGWindowLayer"] intValue], &result_entry_layer);
napi_set_named_property(env, result_entry, "layer", result_entry_layer);

// Get the PID of the Window
Expand Down Expand Up @@ -293,7 +293,7 @@ napi_value AXGetWindowPreview (napi_env env, napi_callback_info info) {

// Extract the window ID parameter
int wid;
napi_get_value_int64(env, args[0], &wid);
napi_get_value_int32(env, args[0], &wid);

// Generate the image. This will trigger permission request.
CGImageRef img = NULL;
Expand Down Expand Up @@ -482,9 +482,9 @@ napi_value AXPerformActionOnWindow (napi_env env, napi_callback_info info) {
int pid;
int wid;
int action;
napi_get_value_int64(env, args[0], &pid);
napi_get_value_int64(env, args[1], &wid);
napi_get_value_int64(env, args[2], &action);
napi_get_value_int32(env, args[0], &pid);
napi_get_value_int32(env, args[1], &wid);
napi_get_value_int32(env, args[2], &action);

// This might look bizarre. Why create a separate class?
// I think there's an C/ObjC interop issue? If I inline all of the code from this class into this function, the pid value will reset to 0.
Expand Down Expand Up @@ -515,8 +515,8 @@ napi_value AXCheckIfStandardWindow (napi_env env, napi_callback_info info) {
// Extract the parameters
int pid;
int wid;
napi_get_value_int64(env, args[0], &pid);
napi_get_value_int64(env, args[1], &wid);
napi_get_value_int32(env, args[0], &pid);
napi_get_value_int32(env, args[1], &wid);

AXUIElementRef element = AXUIElementCreateApplication(pid);

Expand Down