diff --git a/Rakefile b/Rakefile
index c0dc051e9..cf326a6a2 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,4 +1,4 @@
-require 'fileutils'
+require 'timeout'
$ATOM_ARGS = []
@@ -9,9 +9,11 @@ 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 2> /dev/null`
- `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
+ # `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)
+ Timeout::timeout(10) do
+ sleep 0 while `xcodebuild -list` =~ /This project contains no schemes./ # Give xcode some time to open
+ end
end
desc "Build Atom via `xcodebuild`"
@@ -32,9 +34,9 @@ end
desc "Create the Atom.app for distribution"
task :package => :build do
if path = application_path()
- FileUtils.rm_rf "pkg"
- FileUtils.mkdir_p "pkg"
- FileUtils.cp_r path, "pkg/"
+ rm_rf "pkg"
+ mkdir_p "pkg"
+ cp_r path, "pkg/"
`cd pkg && zip -r atom.zip .`
else
exit(1)
@@ -44,12 +46,13 @@ end
desc "Creates symlink from `application_path() to /Applications/Atom and creates a CLI at /usr/local/bin/atom"
task :install => :build do
if path = application_path()
- FileUtils.ln_sf File.expand_path(path), "/Applications"
+ ln_sf File.expand_path(path), "/Applications"
usr_bin = "/usr/local/bin"
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\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
@@ -121,5 +124,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
diff --git a/native/atom_application.mm b/native/atom_application.mm
index 7fc6bf730..280ff8635 100644
--- a/native/atom_application.mm
+++ b/native/atom_application.mm
@@ -51,7 +51,6 @@
}
- (void)open:(NSString *)path {
- NSLog(@"%@", path);
[[AtomWindowController alloc] initWithPath:path];
}
@@ -139,6 +138,11 @@
CefShutdown();
}
+- (BOOL)applicationShouldHandleReopen:(NSApplication *)application hasVisibleWindows:(BOOL)flag {
+ NSLog(@"%@", @"OK OK OK");
+ return YES;
+}
+
# pragma mark CefAppProtocol
- (BOOL)isHandlingSendEvent {
diff --git a/native/mac/info.plist b/native/mac/info.plist
index b21953721..9dd8973e8 100644
--- a/native/mac/info.plist
+++ b/native/mac/info.plist
@@ -2,27 +2,27 @@
- CFBundleDevelopmentRegion
- English
- CFBundleExecutable
- ${EXECUTABLE_NAME}
- CFBundleIconFile
- atom.icns
- CFBundleIdentifier
- com.github.atom
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- ${PRODUCT_NAME}
- CFBundlePackageType
- APPL
- CFBundleSignature
- ????
- CFBundleVersion
- 1.0
- NSMainNibFile
- MainMenu
- NSPrincipalClass
- AtomApp
+ CFBundleDevelopmentRegion
+ English
+ CFBundleExecutable
+ ${EXECUTABLE_NAME}
+ CFBundleIconFile
+ atom.icns
+ CFBundleIdentifier
+ com.github.atom
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ ${PRODUCT_NAME}
+ CFBundlePackageType
+ APPL
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0
+ NSMainNibFile
+ MainMenu
+ NSPrincipalClass
+ AtomApp
diff --git a/native/main_mac.mm b/native/main_mac.mm
index bbed2bd8a..4ba718c37 100644
--- a/native/main_mac.mm
+++ b/native/main_mac.mm
@@ -1,16 +1,69 @@
#import "include/cef_application_mac.h"
#import "native/atom_application.h"
+#include
+#include
+#include
int main(int argc, char* argv[]) {
@autoreleasepool {
+ NSString *socketPath = [NSString stringWithFormat:@"/tmp/atom-%d.sock", getuid()];
+
+ int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+
+ for (NSRunningApplication *app in [[NSWorkspace sharedWorkspace] runningApplications]) {
+ BOOL hasSameBundleId = [app.bundleIdentifier isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
+ BOOL hasSameProcessesId = app.processIdentifier == [[NSProcessInfo processInfo] processIdentifier];
+ if (hasSameBundleId && !hasSameProcessesId) {
+ struct sockaddr_un send_addr;
+ send_addr.sun_family = AF_UNIX;
+ strcpy(send_addr.sun_path, [socketPath UTF8String]);
+
+ char buf[] = "WE JUMPED THE PROCESS";
+ if (sendto(fd, buf, sizeof(buf), 0, (sockaddr *)&send_addr, sizeof(send_addr)) < 0) {
+ NSLog(@"Send failure");
+ exit(1);
+ }
+ exit(0);
+ }
+ }
+
+ struct sockaddr_un addr;
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, [socketPath UTF8String]);
+
+ unlink([socketPath UTF8String]);
+ if (bind(fd, (sockaddr*)&addr, sizeof(addr)) < 0) {
+ perror("ERROR: Binding to socket");
+ }
+ 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_un listen_addr;
+ listen_addr.sun_family = AF_UNIX;
+ strcpy(listen_addr.sun_path, [socketPath UTF8String]);
+ socklen_t listen_addr_length;
+ if (recvfrom(fd, &buf, sizeof(buf), 0, (sockaddr *)&listen_addr, &listen_addr_length) < 0) {
+ perror("ERROR: Receiving from socket");
+ }
+ else {
+ NSLog(@"GOOD! Got %s from %s", buf, listen_addr.sun_path);
+ }
+ });
+ }
+
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;
diff --git a/src/app/directory.coffee b/src/app/directory.coffee
index d0bef88c2..571979495 100644
--- a/src/app/directory.coffee
+++ b/src/app/directory.coffee
@@ -18,8 +18,11 @@ class Directory
for path in fs.list(@path)
if fs.isDirectory(path)
directories.push(new Directory(path))
- else
+ else if fs.isFile(path)
files.push(new File(path))
+ else
+ console.error "#{path} is neither a file nor a directory."
+
directories.concat(files)
afterSubscribe: ->
diff --git a/static/atom.css b/static/atom.css
index 7cb1ed961..95a04745c 100644
--- a/static/atom.css
+++ b/static/atom.css
@@ -3,8 +3,10 @@
padding: 0;
}
-body {
+html, body {
font: 16px Inconsolata, Monaco, Courier !important;
+ width: 100%;
+ height: 100%;
}
#root-view {