From dc1d6e529ffb88dcdf5307ab22e7b01864eea046 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 08:14:50 -0700 Subject: [PATCH 1/8] Remove debug.xcconfig No longer using $RESOURCE_PATH in rake file. --- atom.gyp | 3 +-- native/mac/debug.xcconfig | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 native/mac/debug.xcconfig diff --git a/atom.gyp b/atom.gyp index 51435b920..6c03d9b38 100644 --- a/atom.gyp +++ b/atom.gyp @@ -24,8 +24,7 @@ 'default_configuration': 'Debug', 'configurations': { 'Debug': { - 'xcode_config_file': 'native/mac/debug.xcconfig', - 'defines': ['DEBUG=1', 'RESOURCE_PATH=\"$RESOURCE_PATH\"'], + 'defines': ['DEBUG=1', 'RESOURCE_PATH="$PROJECT_DIR"'], }, 'Release': { }, diff --git a/native/mac/debug.xcconfig b/native/mac/debug.xcconfig deleted file mode 100644 index 77ce46e34..000000000 --- a/native/mac/debug.xcconfig +++ /dev/null @@ -1 +0,0 @@ -RESOURCE_PATH=$PROJECT_DIR From ad9b204b0af02a27faff7177ebb8a6e00e7e63fd Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 08:43:50 -0700 Subject: [PATCH 2/8] Adding the doctype tag makes the HTML layout strangely --- static/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/static/index.html b/static/index.html index e55a9502e..0db31d1fe 100644 --- a/static/index.html +++ b/static/index.html @@ -1,4 +1,3 @@ - From 3026c7767ba8b40748e03c452437ce18fddbf13a Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 08:45:47 -0700 Subject: [PATCH 3/8] Add doctype to index.html and css styles to make html take up 100% of the screen. --- static/atom.css | 4 +++- static/index.html | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) 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 { diff --git a/static/index.html b/static/index.html index 0db31d1fe..e55a9502e 100644 --- a/static/index.html +++ b/static/index.html @@ -1,3 +1,4 @@ + From 528f6ce96799d5f84396ac2a5390fd438c9b2cde Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 09:08:50 -0700 Subject: [PATCH 4/8] Remove NSLog --- native/atom_application.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/native/atom_application.mm b/native/atom_application.mm index a9ec07a16..3cf3391b7 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]; } From 71562a6c33d61930b1071bc707e9ab86ba5ae866 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 11:07:59 -0700 Subject: [PATCH 5/8] Directory entries can only be files or other directories. Does not handle file like broken symlinks for now --- src/app/directory.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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: -> From d92564673a9caf6863487dec53397f0a14bb62b3 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 11:08:38 -0700 Subject: [PATCH 6/8] Kill Xcode hard. This is a bad idea, but for now we need to make sure Xcode is REALLY killed. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index c0dc051e9..593e3854a 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,7 @@ 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` + `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 From 852b5e3ceb9184b74379892bf3e020d54339436e Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 11:08:49 -0700 Subject: [PATCH 7/8] Cleanup Rakefile --- Rakefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index 593e3854a..9262384a5 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,3 @@ -require 'fileutils' - $ATOM_ARGS = [] ENV['PATH'] = "#{ENV['PATH']}:/usr/local/bin/" @@ -32,9 +30,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,7 +42,7 @@ 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 From 28bd8ea459c7c499841154725de1326905f70a41 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 11 Sep 2012 17:38:27 -0700 Subject: [PATCH 8/8] wip --- Rakefile | 9 ++++--- native/atom_application.mm | 5 ++++ native/mac/info.plist | 46 ++++++++++++++++++---------------- native/main_mac.mm | 51 +++++++++++++++++++++++++++++++++++++- 4 files changed, 84 insertions(+), 27 deletions(-) diff --git a/Rakefile b/Rakefile index 9262384a5..76ec0c76b 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/native/atom_application.mm b/native/atom_application.mm index 3cf3391b7..e38da41be 100644 --- a/native/atom_application.mm +++ b/native/atom_application.mm @@ -137,6 +137,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..e7d56bf78 100644 --- a/native/mac/info.plist +++ b/native/mac/info.plist @@ -2,27 +2,29 @@ - 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 + LSMultipleInstancesProhibited + + 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..7857e6b86 100644 --- a/native/main_mac.mm +++ b/native/main_mac.mm @@ -1,16 +1,65 @@ #import "include/cef_application_mac.h" #import "native/atom_application.h" +#include +#include +#include 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;