-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement macOS modules using ScriptingBridge (#152)
* Implement macOS modules using ScriptingBridge * Fix reviewed issues
- Loading branch information
1 parent
b50ce6f
commit 8c43436
Showing
50 changed files
with
384 additions
and
250 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
all: clean build | ||
clean: | ||
rm "${DEST}/bring-to-front.scpt" || true | ||
rm "${DEST}/bring-to-front" || true | ||
build: | ||
mkdir "${DEST}" || true | ||
osacompile -o "${DEST}/bring-to-front.scpt" bring-to-front.applescript | ||
clang -o "${DEST}/bring-to-front" -framework Cocoa -framework ScriptingBridge -framework AppKit bring-to-front.m |
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
// | ||
// bring-to-front.m | ||
// Place a window in foreground | ||
// | ||
|
||
#import "AppKit/AppKit.h" | ||
#include "../../utils/mac/utils.h" | ||
|
||
|
||
const int APP_ACTIVATION_DELAY = 100000; | ||
|
||
int main (int argc, const char * argv[]) { | ||
if (argc < 3) { | ||
printf("Incorrect arguments\n"); | ||
return 1; | ||
} | ||
|
||
@autoreleasepool { | ||
NSString *processId = [NSString stringWithUTF8String:argv[1]]; | ||
NSString *windowId = [NSString stringWithUTF8String:argv[2]]; | ||
|
||
@try { | ||
[[NSRunningApplication runningApplicationWithProcessIdentifier: [processId intValue]] activateWithOptions: NSApplicationActivateAllWindows|NSApplicationActivateIgnoringOtherApps]; | ||
|
||
usleep(APP_ACTIVATION_DELAY); | ||
|
||
[getWindowOfProcess(processId, windowId) setIndex: 1]; | ||
} | ||
@catch (NSException *exception) { | ||
return 0; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
all: clean build | ||
clean: | ||
rm "${DEST}/close.scpt" || true | ||
rm "${DEST}/close" || true | ||
build: | ||
mkdir "${DEST}" || true | ||
osacompile -o "${DEST}/close.scpt" close.applescript | ||
clang -o "${DEST}/close" -framework Cocoa -framework ScriptingBridge close.m |
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
// | ||
// close.m | ||
// Close a window | ||
// | ||
|
||
#include "../../utils/mac/utils.h" | ||
|
||
enum CloseOptions { | ||
CloseOptionsYes = 'yes ' /* Save the file. */, | ||
CloseOptionsNo = 'no ' /* Do not save the file. */, | ||
CloseOptionsAsk = 'ask ' /* Ask the user whether or not to save the file. */ | ||
}; | ||
|
||
int main (int argc, const char * argv[]) { | ||
if (argc < 3) { | ||
printf("Incorrect arguments\n"); | ||
return 1; | ||
} | ||
|
||
@autoreleasepool { | ||
NSString *processId = [NSString stringWithUTF8String:argv[1]]; | ||
NSString *windowId = [NSString stringWithUTF8String:argv[2]]; | ||
|
||
id window = getWindowOfProcess(processId, windowId); | ||
|
||
@try { | ||
[window closeSaving:CloseOptionsNo savingIn: nil]; | ||
return 0; | ||
} | ||
@catch (NSException *e) { | ||
|
||
} | ||
|
||
@try { | ||
[window close]; | ||
return 0; | ||
} | ||
@catch (NSException *e) { | ||
|
||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
all: clean build | ||
clean: | ||
rm "${DEST}/find-window.scpt" || true | ||
rm "${DEST}/find-window-cocoa" || true | ||
rm "${DEST}/find-window" || true | ||
build: | ||
mkdir "${DEST}" || true | ||
osacompile -o "${DEST}/find-window.scpt" find-window.applescript | ||
clang -o "${DEST}/find-window-cocoa" -framework Cocoa find-window-cocoa.m | ||
clang -o "${DEST}/find-window" -framework Cocoa -framework ScriptingBridge find-window.m |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.