Post

Replies

Boosts

Views

Activity

Reply to Why is Xcode 15 giving me deprecated code errors?
The warnings tell you that they are triggered by the compiler flag -Wdeprecated-builtins, so if you compile with the flag -Wno-deprecated-builtins, they should go away. Possibly Xcode 15 might have a checkbox for that flag; I’m not at a Mac right now. But if there’s no checkbox, you can use an “other c++ flags“ or something in the build settings.
Sep ’23
Reply to CGDisplayRotation Hangs.
The fact that CGDirectDisplayID is the same type as uint32_t does not mean that every uint32_t value is a legitimate display ID. If you want to find out something about displays, you should first get the display IDs of interest, with calls such as CGGetActiveDisplayList, CGGetOnlineDisplayList, or CGGetDisplaysWithPoint. By the way, since CGDisplayRotation is not behaving as documented, I filed a bug report, FB13202169.
Topic: Graphics & Games SubTopic: General Tags:
Sep ’23
Reply to CGDisplayRotation Hangs.
When I tried your code in Xcode, it hung in the CGDisplayRotation(0) call. But when I changed that to CGDisplayRotation( CGMainDisplayID() ), it ran fine. What are you trying to accomplish by passing 0 as the display ID? Granted, the documentation says that it should return 0 if you pass an invalid display ID, but why tempt fate?
Topic: Graphics & Games SubTopic: General Tags:
Sep ’23
Reply to macOS application hangs if accessibility changed while using CGEventTap
@eskimo: Neither requires the full Accessibility privilege. That may be true under the hood, but while Listen access is (I think) reflected in System Settings > Privacy & Security > Input Monitoring, PostEvent access is shown as System Settings > Privacy & Security > Accessibility. Honestly, I think the best option there is to accept the quit and relaunch. It might be OK to repeatedly quit and relaunch while waiting for accessibility permission to be granted, but I wouldn't want to constantly be quitting and relaunching to detect the rare case of permission being revoked. Which was the OP's concern.
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’23
Reply to macOS application hangs if accessibility changed while using CGEventTap
You don’t need ‘full’ accessibility access to listen for events. There’s a specific TCC service for that, namely ListenEvent. You can check where you have that privilege using CGPreflightListenEventAccess. Is there some reason that doesn’t work for you? In my case, I do need to post events as well as listen, and the original poster of this thread also indicates a need to do more than just listen. I'm aware that there is also a function CGPreflightPostEventAccess, but in my experience that does not update while my process is running.
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’23
Reply to macOS application hangs if accessibility changed while using CGEventTap
The only reliable way I've found to detect accessibility access is to try creating a new event tap with kCGEventTapOptionDefault. If the permission is missing, CGEventTapCreate will return NULL. In my case I was dealing with keyboard events, not mouse events, but I expect it will work the same. Here's the code I use: bool EventListener::CanFilterEvents() { CFMachPortRef thePort = CGEventTapCreate( kCGSessionEventTap, kCGTailAppendEventTap, kCGEventTapOptionDefault, // active filter, not passive listener CGEventMaskBit(kCGEventKeyDown), CTapListener::MyTapCallback, NULL ); bool madeTap = (thePort != NULL); if (madeTap) { CFMachPortInvalidate( thePort ); CFRelease( thePort ); } return madeTap; }
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’23