I want to run a function of Cocoa's Quartz Window Services on Mac called CGWindowListCopyWindowInfo
using a library called objc
from Rust, is it possible?
I can't figure out how to run function it with send_msg!
.
CodePudding user response:
First, you're linking to the Swift version of the API, you really want the objective C version.
Second, Objective-C is for "methods" on objects, that is why send_msg!
takes a subject (obj
). CGWindowListCopyWindowInfo
is part of a "core" service, which means it's pretty much straight C. Now I don't know if there are bindings for that, apparently Servo once maintained CG bindings but it seems like they're deprecated. You can probably BYO as if you were binding to a regular C library (by hand or using bindgen).
I would recommend learning how macOS APIs and frameworks work first, though.