Tag: carbon

What API can be used to hide OSX Dock when you drag a window towards it

Idea is simple(stolen from Ubuntu): autohide Dock when you drag window toward it and begin to overlap it. Turn autohiding off and show Dock when window is moved out of area when Dock is located. What API can be used to achieve that ? update: managing autohide possible from command line this way but it’s […]

How can I stop HIToolbox from catching my exceptions?

This question follows on from my other question on why my app isn’t being brought down by exceptions. The Problem When an exception is thrown on the main thread via an Action, the app still doesn’t crash. As per Dave’s answer to my original question, I’ve implemented the reportException category on NSApplication and set the […]

Using `CGEventSourceSetLocalEventsSuppressionInterval` instead of the deprecated `CGSetLocalEventsSuppressionInterval`

When programmatically moving the mouse cursor, you must set CGSetLocalEventsSuppressionInterval to 0 so the events come in in real-time as opposed to with a 250 millisecond delay. Unfortunately, CGSetLocalEventsSuppressionInterval is marked as deprecated in Snow Leopard. The alternative is CGEventSourceSetLocalEventsSuppressionInterval(CGEventSourceRef source, CFTimeInterval seconds); https://developer.apple.com/library/mac/#documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html#//apple_ref/c/func/CGEventSourceSetLocalEventsSuppressionInterval -(void) mouseMovement:(CGEventRef) newUserMouseMovement { //Move cursor to new position CGSetLocalEventsSuppressionInterval(0.0); //Deprecated […]

Strategies for porting Carbon code to Cocoa

I’m looking for strategies and articles on making Carbon code 64-bit ready. Carbon for 64-bit does not and will not exist. It’s pretty much a dead end. So in order to bring Carbon application and toolkits to 64-bit their GUI part will have to be re-written in Cocoa and Objective-C, right? How can I minimize […]

CGEventPostToPSN() not working for mouse clicking

I need to send mouse click events to an arbitrary process (not necessarily the front one) without bringing that process’s window to the front. This code works for sending a mouse click and letting the window server send it to whatever process it decides has focus: #include <ApplicationServices/ApplicationServices.h> int main() { CGEventRef down, up; down […]

Get Current User from root mode?

I am writing a login item and I am trying to find if its possible to get the current user. Lets say, I have logged in with user “Test” and when I execute the exe with root privileges and if I use char *user = getenv(“USER”); user is “root”. My expected answer is “Test”. How […]

A macro highlighted as keyword: pascal

While looking in the sample code for FunkyOverlayWindow, I just found a pretty interesting declaration: pascal OSStatus MyHotKeyHandler( EventHandlerCallRef nextHandler, EventRef theEvent, void *userData ); Here, pascal is highlighted as a keyword (pink in standard Xcode color scheme). But I just found it’s a macro, interestingly enough defined in file CarbonCore/ConditionalMacros.h as: #define pascal So, […]

How to refresh finder window?

I want to refresh icon for particular file/folder in Finder application. FNNotifyByPath( (const UInt8 *)folderPath, kFNDirectoryModifiedMessage, kNilOptions ); FNNotifyByPath is not working for this. Now i am trying with appleScript +(void) refreshIconForItem : (NSString *)itemPath { NSString *source=[NSString stringWithFormat:@”tell application \”Finder\” to update \”%@\””,[NSString stringWithUTF8String:itemPath]]; NSAppleScript *update=[[NSAppleScript alloc] initWithSource:source]; NSDictionary *err; [update executeAndReturnError:&err]; } but […]

How can i add icon overlay in finder?

When we open Dropbox folder, we can see icon on the left bottom of the folder. I am developing an application in which i also want the same behavior. If folder is syncing then it will show sync icon and for other operation it will show other icon. The marked files/folder when viewed in Finder […]

Set non-owned window always on top – Like the app “Afloat”

I have set up a global hotkey with RegisterEventHotkey. When the user presses it, it gets the currently focused window with CGWindowListCopyWindowInfo, and then I need to set it always on top. If the current window is in my process (from which I am executing the code) I can simply convert the windowNumber from CGWindowListCopyWindowInfo […]