This commit is contained in:
Corey Johnson 2012-09-11 17:38:27 -07:00
parent 852b5e3ceb
commit 28bd8ea459
4 changed files with 84 additions and 27 deletions

View File

@ -7,8 +7,8 @@ desc "Create xcode project from gpy file"
task "create-project" do
`rm -rf atom.xcodeproj`
`python tools/gyp/gyp --depth=. atom.gyp`
`killall -c Xcode -9`
`open atom.xcodeproj` # In order for the xcodebuild to know about the schemes, the project needs to have been opened once. This is xcode bullshit and is a bug on Apple's end (No radar has been file because I have no faith in radar's)
# `killall -c Xcode -9`
# `open atom.xcodeproj` # In order for the xcodebuild to know about the schemes, the project needs to have been opened once. This is xcode bullshit and is a bug on Apple's end (No radar has been file because I have no faith in radar's)
sleep 0 while `xcodebuild -list` =~ /This project contains no schemes./ # Give xcode some time to open
end
@ -47,7 +47,8 @@ task :install => :build do
usr_bin_exists = ENV["PATH"].split(":").include?(usr_bin)
if usr_bin_exists
cli_path = "#{usr_bin}/atom"
`echo '#!/bin/sh\nopen #{path.strip} --args $@' > #{cli_path} && chmod 755 #{cli_path}`
# `echo '#!/bin/sh\nopen #{path.strip} --args $@' > #{cli_path} && chmod 755 #{cli_path}`
`echo '#!/bin/sh\n#{path}/Contents/MacOS/Atom $@' > #{cli_path} && chmod 755 #{cli_path}`
else
stderr.puts "ERROR: Did not add cli tool for `atom` because /usr/local/bin does not exist"
end
@ -119,5 +120,5 @@ def application_path
$stderr.puts "Error: No .xcodebuild-info file found. This file is created when the `build` raketask is run"
end
return path
return path.strip()
end

View File

@ -137,6 +137,11 @@
CefShutdown();
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)application hasVisibleWindows:(BOOL)flag {
NSLog(@"%@", @"OK OK OK");
return YES;
}
# pragma mark CefAppProtocol
- (BOOL)isHandlingSendEvent {

View File

@ -2,27 +2,29 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>atom.icns</string>
<key>CFBundleIdentifier</key>
<string>com.github.atom</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>AtomApp</string>
<key>LSMultipleInstancesProhibited</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>atom.icns</string>
<key>CFBundleIdentifier</key>
<string>com.github.atom</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>AtomApp</string>
</dict>
</plist>

View File

@ -1,16 +1,65 @@
#import "include/cef_application_mac.h"
#import "native/atom_application.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
int main(int argc, char* argv[]) {
@autoreleasepool {
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
struct sockaddr_un addr = { 0, AF_UNIX };
NSString *socketPath = [NSString stringWithFormat:@"/tmp/atom-%d.sock", getuid()];
strcpy(addr.sun_path, [socketPath UTF8String]);
addr.sun_len = SUN_LEN(&addr);
for (NSRunningApplication *app in [[NSWorkspace sharedWorkspace] runningApplications]) {
if ([[app bundleIdentifier] isEqualToString:[[NSBundle mainBundle] bundleIdentifier]]) {
NSLog(@"%@", @"Well fuck dude, there are two apps open, better send the other one a message!");
struct sockaddr to_addr;
to_addr.sa_family = AF_UNIX;
strcpy(to_addr.sa_data, [socketPath UTF8String]);
char buf[] = "WE JUMPED THE PROCESS";
if (sendto(fd, buf, sizeof(buf), 0, &to_addr, sizeof(to_addr)) < 0) {
NSLog(@"Send failure");
exit(1);
}
exit(0);
}
}
if (connect(fd, (sockaddr*)&addr, sizeof(addr)) < 0) {
NSLog(@"EVERYTHING FUCKED UP");
}
else {
NSLog(@"I AM LISTENING");
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
char buf[1000];
struct sockaddr from_addr;
from_addr.sa_family = AF_UNIX;
strcpy(from_addr.sa_data, [socketPath UTF8String]);
if (recvfrom(fd, &buf, sizeof(buf), 0, &from_addr, sizeof(from_addr)) < 0) {
NSLog(@"NO GOOD, RECEIVE FAILURE");
}
else {
NSLog(@"GOOD! Got %s", buf);
}
});
}
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
AtomApplication *application = [AtomApplication applicationWithArguments:argv count:argc];
NSString *mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
NSNib *mainNib = [[NSNib alloc] initWithNibNamed:mainNibName bundle:[NSBundle mainBundle]];
[mainNib instantiateNibWithOwner:application topLevelObjects:nil];
CefRunMessageLoop();
close(fd);
}
return 0;