Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a8b97ca99b
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (29 sloc) 1.525 kb
#import "ProxiAppWindowBringerUpper.h"
#import <Carbon/Carbon.h>
static OSStatus handleAppFrontSwitched(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
static OSStatus mouseActivated(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData);
EventHandlerRef MySkankyGlobalFrontAppSwitchedHandlerRef;
@implementation ProxiAppWindowBringerUpper
+ (void) load
{
debug(@"%s:%d", __FUNCTION__, __LINE__);
EventTypeSpec spec = { kEventClassApplication, kEventAppFrontSwitched };
OSStatus err = InstallApplicationEventHandler(NewEventHandlerUPP(handleAppFrontSwitched), 1, &spec, nil, &MySkankyGlobalFrontAppSwitchedHandlerRef);
if (err) {
NSLog(@"Error looking for front app.");
}
}
static OSStatus handleAppFrontSwitched(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) {
debug(@"%s:%d", __FUNCTION__, __LINE__);
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSDictionary *activeAppDict = [workspace activeApplication];
ProcessSerialNumber psn;
psn.highLongOfPSN = [[activeAppDict objectForKey:@"NSApplicationProcessSerialNumberHigh"] intValue];
psn.lowLongOfPSN = [[activeAppDict objectForKey:@"NSApplicationProcessSerialNumberLow"] intValue];
SetFrontProcess( &psn );
// this .. causes a bit o' recursion for some reason.
//ProcessSerialNumber xpsn = { 0, kCurrentProcess };
//SetFrontProcess( & xpsn );
return 0;
}
@end
Jump to Line
Something went wrong with that request. Please try again.