Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 14 additions & 11 deletions src/ferry.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#ifndef FERRY_VERSION
#define FERRY_VERSION "dev"
Expand Down Expand Up @@ -68,6 +67,16 @@ static double elapsed_ms(uint64_t start_ns)
return (clock_gettime_nsec_np(CLOCK_UPTIME_RAW) - start_ns) / 1e6;
}

// GetProcessPID is deprecated, but SkyLight still identifies processes by PSN.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
static pid_t process_pid(ProcessSerialNumber *psn)
{
pid_t pid = 0;
return GetProcessPID(psn, &pid) == noErr ? pid : 0;
}
#pragma clang diagnostic pop

//
// Symbol lookup for functions that SkyLight does not export (yabai: misc/macho_dlsym.h).
//
Expand Down Expand Up @@ -312,11 +321,9 @@ static long parse_positive(const char *text, long max)
{
char *end = NULL;
long value = strtol(text, &end, 10);
return (end && *end == '\0' && value > 0 && value <= max) ? value : 0;
return (*end == '\0' && value > 0 && value <= max) ? value : 0;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
int main(int argc, char **argv)
{
@autoreleasepool {
Expand Down Expand Up @@ -375,9 +382,8 @@ int main(int argc, char **argv)

if (!wid) {
ProcessSerialNumber front = {0};
pid_t pid = 0;
_SLPSGetFrontProcess(&front);
GetProcessPID(&front, &pid);
pid_t pid = process_pid(&front);

source = "accessibility";
wid = ax_focused_window(pid, &window_ref);
Expand All @@ -398,10 +404,8 @@ int main(int argc, char **argv)
// AX may omit windows on inactive Spaces. Resolve the reference before
// moving so explicit window IDs can use yabai's full focus/raise path.
if (follow && !window_ref) {
pid_t pid = 0;
if (GetProcessPID(&psn, &pid) == noErr && pid > 0) {
window_ref = ax_window_for_id(pid, wid);
}
pid_t pid = process_pid(&psn);
if (pid > 0) window_ref = ax_window_for_id(pid, wid);
}

bool moved = false;
Expand Down Expand Up @@ -438,4 +442,3 @@ int main(int argc, char **argv)

return 0;
}
#pragma clang diagnostic pop
2 changes: 1 addition & 1 deletion tests/follow.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static void restore_app(NSRunningApplication *app, AXUIElementRef window)
if (window) AXUIElementPerformAction(window, kAXRaiseAction);
pump(0.3);
}
#pragma clang diagnostic pop

int main(int argc, char **argv)
{
Expand Down Expand Up @@ -186,4 +187,3 @@ int main(int argc, char **argv)
return result;
}
}
#pragma clang diagnostic pop
Loading