forked from unixpickle/JamWiFi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Nichol
authored and
Alex Nichol
committed
Jul 27, 2012
1 parent
dc5caf8
commit a911df0
Showing
7 changed files
with
124 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "CarbonAppProcess.h" | ||
|
||
typedef enum { | ||
ANViewSlideDirectionForward, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// CarbonAppProcess.h | ||
// AutoConvert | ||
// | ||
// Created by Alex Nichol on 7/3/11. | ||
// Copyright 2011 Alex Nichol. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <Carbon/Carbon.h> | ||
|
||
@interface CarbonAppProcess : NSObject { | ||
ProcessSerialNumber processSerial; | ||
} | ||
|
||
- (id)initWithProcessSerial:(ProcessSerialNumber)num; | ||
+ (CarbonAppProcess *)currentProcess; | ||
+ (CarbonAppProcess *)frontmostProcess; | ||
+ (CarbonAppProcess *)nextProcess; | ||
- (void)makeFrontmost; | ||
- (void)setHidden:(BOOL)hide; | ||
- (BOOL)isFrontmost; | ||
- (ProcessSerialNumber)serial; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// CarbonAppProcess.m | ||
// AutoConvert | ||
// | ||
// Created by Alex Nichol on 7/3/11. | ||
// Copyright 2011 Alex Nichol. All rights reserved. | ||
// | ||
|
||
#import "CarbonAppProcess.h" | ||
|
||
|
||
@implementation CarbonAppProcess | ||
|
||
- (id)init { | ||
if ((self = [super init])) { | ||
// Initialization code here. | ||
} | ||
return self; | ||
} | ||
|
||
- (id)initWithProcessSerial:(ProcessSerialNumber)num { | ||
if ((self = [super init])) { | ||
processSerial = num; | ||
} | ||
return self; | ||
} | ||
|
||
+ (CarbonAppProcess *)currentProcess { | ||
ProcessSerialNumber frontmost; | ||
GetCurrentProcess(&frontmost); | ||
return [[CarbonAppProcess alloc] initWithProcessSerial:frontmost]; | ||
} | ||
|
||
+ (CarbonAppProcess *)frontmostProcess { | ||
ProcessSerialNumber frontmost; | ||
GetFrontProcess(&frontmost); | ||
return [[CarbonAppProcess alloc] initWithProcessSerial:frontmost]; | ||
} | ||
|
||
+ (CarbonAppProcess *)nextProcess { | ||
ProcessSerialNumber next; | ||
if (GetNextProcess(&next) != noErr) { | ||
NSLog(@"No next process"); | ||
return nil; | ||
} | ||
return [[CarbonAppProcess alloc] initWithProcessSerial:next]; | ||
} | ||
|
||
- (void)makeFrontmost { | ||
SetFrontProcessWithOptions(&processSerial, kSetFrontProcessFrontWindowOnly); | ||
} | ||
|
||
- (void)setHidden:(BOOL)hide { | ||
ShowHideProcess(&processSerial, hide^1); | ||
} | ||
|
||
- (BOOL)isFrontmost { | ||
ProcessSerialNumber psn; | ||
GetFrontProcess(&psn); | ||
|
||
Boolean result = FALSE; | ||
SameProcess(&psn, &processSerial, &result); | ||
return (BOOL)result; | ||
} | ||
|
||
- (BOOL)isEqual:(id)object { | ||
if ([object isKindOfClass:[CarbonAppProcess class]]) { | ||
ProcessSerialNumber mySerial = processSerial; | ||
ProcessSerialNumber theirSerial = (ProcessSerialNumber)([(CarbonAppProcess *)object serial]); | ||
if (mySerial.lowLongOfPSN == theirSerial.lowLongOfPSN) { | ||
if (mySerial.highLongOfPSN == theirSerial.highLongOfPSN) { | ||
return YES; | ||
} | ||
} | ||
} | ||
return NO; | ||
} | ||
|
||
- (ProcessSerialNumber)serial { | ||
return processSerial; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.