summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxant <xant@xant.net>2013-09-26 17:11:42 (GMT)
committer xant <xant@xant.net>2013-09-26 17:11:42 (GMT)
commitcd001f7ea0eca1cdf8709f3950336badc1228fe8 (patch)
treecf8364bdaf00855154b9fc86546f585adc26610a
parenta66d258f95368e943cb46a9bf6bcd237348095c5 (diff)
ensure propagating mouse events to the cli application (NSApplication needed to be initialized properly)
+ various fixes along the way while testing the cli interface
-rw-r--r--JMX-Info.plist2
-rw-r--r--JMX.xcodeproj/project.pbxproj2
-rw-r--r--core/JMXByteArray.mm1
-rw-r--r--entities/JMXScriptEntity.mm30
-rw-r--r--entities/video_outputs/JMXOpenGLScreen.mm1
-rw-r--r--gui/JMXConnectorLayer.m7
-rw-r--r--jmx/main.m39
-rw-r--r--node.js/lib/_third_party_main.js3
8 files changed, 75 insertions, 10 deletions
diff --git a/JMX-Info.plist b/JMX-Info.plist
index c82801b..a9a987c 100644
--- a/JMX-Info.plist
+++ b/JMX-Info.plist
@@ -29,7 +29,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>0.6.1</string>
+ <string>0.7</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
diff --git a/JMX.xcodeproj/project.pbxproj b/JMX.xcodeproj/project.pbxproj
index 3b7ab50..de91b29 100644
--- a/JMX.xcodeproj/project.pbxproj
+++ b/JMX.xcodeproj/project.pbxproj
@@ -2002,6 +2002,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LIBRARY = "compiler-default";
+ CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -2055,6 +2056,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LIBRARY = "compiler-default";
+ CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
diff --git a/core/JMXByteArray.mm b/core/JMXByteArray.mm
index 38cff8a..10b630f 100644
--- a/core/JMXByteArray.mm
+++ b/core/JMXByteArray.mm
@@ -57,6 +57,7 @@ using namespace v8;
size = length;
if (!buffer) {
// TODO - log an error
+ [self release];
return nil;
}
mustFreeOnRelease = freeOnRelease;
diff --git a/entities/JMXScriptEntity.mm b/entities/JMXScriptEntity.mm
index 37db55b..f9383e9 100644
--- a/entities/JMXScriptEntity.mm
+++ b/entities/JMXScriptEntity.mm
@@ -18,6 +18,7 @@
#import "JMXScriptPinWrapper.h"
#import "JMXByteArray.h"
#import "NSDictionary+V8.h"
+#import "JMXScriptFile.h"
using namespace v8;
@@ -196,6 +197,14 @@ using namespace v8;
}
}
+- (JMXScriptFile *)load:(NSString *)path
+{
+ JMXScriptFile *script = [[JMXScriptFile alloc] init];
+ script.path = path;
+ [self hookEntity:script];
+ return script;
+}
+
#pragma mark -
#pragma JMXPinOwner
- (id)provideDataToPin:(JMXOutputPin *)aPin
@@ -290,6 +299,24 @@ using namespace v8;
static Persistent<FunctionTemplate> objectTemplate;
+static v8::Handle<Value>LoadScript(const Arguments& args)
+{
+ //v8::Locker lock;
+ BOOL ret = NO;
+ HandleScope handleScope;
+ JMXScriptEntity *entity = (JMXScriptEntity *)args.Holder()->GetPointerFromInternalField(0);
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ if (args[0]->IsString()) {
+ String::Utf8Value str(args[0]->ToString());
+ if ([entity load:[NSString stringWithUTF8String:*str]])
+ ret = YES;
+ } else {
+ NSLog(@"ScriptEntity::load(): argument is not a string");
+ }
+ [pool release];
+ return handleScope.Close(v8::Boolean::New(ret ? 1 : 0));
+}
+
static v8::Handle<Value>Exec(const Arguments& args)
{
//v8::Locker lock;
@@ -341,7 +368,8 @@ static v8::Handle<Value>GetEntities(Local<String> name, const AccessorInfo& info
v8::Handle<ObjectTemplate> classProto = objectTemplate->PrototypeTemplate();
classProto->Set("exec", FunctionTemplate::New(Exec));
-
+ classProto->Set("load", FunctionTemplate::New(LoadScript));
+
v8::Handle<ObjectTemplate> instanceTemplate = objectTemplate->InstanceTemplate();
instanceTemplate->SetAccessor(String::NewSymbol("frequency"), GetNumberProperty, SetNumberProperty);
instanceTemplate->SetAccessor(String::NewSymbol("entities"), GetEntities);
diff --git a/entities/video_outputs/JMXOpenGLScreen.mm b/entities/video_outputs/JMXOpenGLScreen.mm
index de405bc..a23f2f6 100644
--- a/entities/video_outputs/JMXOpenGLScreen.mm
+++ b/entities/video_outputs/JMXOpenGLScreen.mm
@@ -432,6 +432,7 @@ static CVReturn renderCallback(CVDisplayLinkRef displayLink,
mousePositionPin = [self registerOutputPin:@"mousePosition" withType:kJMXPointPin];
controller = [[JMXScreenController alloc] initWithView:view delegate:self];
self.label = @"OpenGLScreen";
+ [window makeKeyAndOrderFront:[NSApplication sharedApplication]];
//[window orderBack:self];
}
return self;
diff --git a/gui/JMXConnectorLayer.m b/gui/JMXConnectorLayer.m
index ee614f4..d940ac0 100644
--- a/gui/JMXConnectorLayer.m
+++ b/gui/JMXConnectorLayer.m
@@ -186,8 +186,13 @@
- (void)setSelected:(BOOL)isSelected
{
selected = isSelected;
- self.foregroundColor = selected ? CGColorCreateGenericRGB(1.0f, 0.0f, 0.0f, 1.0f) : CGColorCreateGenericRGB(0.0f, 0.0f, 0.0f, 0.5f);
+ CGColorRef color = selected
+ ? CGColorCreateGenericRGB(1.0f, 0.0f, 0.0f, 1.0f)
+ : CGColorCreateGenericRGB(0.0f, 0.0f, 0.0f, 0.5f);
+ self.foregroundColor = color;
+ CFRelease(color);
[self setNeedsDisplay];
+
}
- (void)setForegroundColor:(CGColorRef)aColor
diff --git a/jmx/main.m b/jmx/main.m
index 23dc00c..940913e 100644
--- a/jmx/main.m
+++ b/jmx/main.m
@@ -13,6 +13,7 @@
#import <JMXContext.h>
#import <JMXGraph.h>
+#
static JMXScriptEntity *scriptController = nil;
int main(int argc, const char * argv[])
@@ -21,10 +22,11 @@ int main(int argc, const char * argv[])
@autoreleasepool {
JMXApplication *app =[[JMXApplication alloc] init];
app.appName = @"jmx-cli";
- [NSApplication sharedApplication].delegate = app;
- openlog("jmx-cli", LOG_PERROR, LOG_USER);
- [app applicationWillFinishLaunching:[NSNotification notificationWithName:@"applicationWillFinishLaunching" object:nil]];
- [app applicationDidFinishLaunching:[NSNotification notificationWithName:@"applicationDidFinishLaunching" object:nil]];
+ [NSApplication sharedApplication];
+
+ [NSApp setDelegate:app];
+ openlog(app.appName.UTF8String, LOG_PERROR, LOG_USER);
+
scriptController = [[JMXScriptEntity alloc] init];
scriptController.name = @"scriptController";
NSXMLElement *rootElement = [[[JMXContext sharedContext] dom] rootElement];
@@ -33,8 +35,33 @@ int main(int argc, const char * argv[])
}
scriptController.active = YES;
[scriptController exec:@""];
- NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
- [runLoop run];
+
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+
+ NSMenu *menubar = [NSMenu new];
+ NSMenuItem *appMenuItem = [NSMenuItem new];
+
+ [menubar addItem:appMenuItem];
+ [NSApp setMainMenu:menubar];
+
+ NSMenu *appMenu = [NSMenu new];
+
+ NSString *quitTitle = [@"Quit " stringByAppendingString:app.appName];
+ NSMenuItem *quitMenuItem = [[NSMenuItem alloc] initWithTitle:quitTitle
+ action:@selector(terminate:) keyEquivalent:@"q"];
+ [appMenu addItem:quitMenuItem];
+ [appMenuItem setSubmenu:appMenu];
+
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:NSZeroRect
+ styleMask:NSTitledWindowMask
+ backing:NSBackingStoreBuffered defer:NO];
+ //[window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
+ window.title = app.appName;
+ window.isVisible = NO;
+ [window makeKeyAndOrderFront:nil];
+// [NSApp activateIgnoringOtherApps:YES];
+
+ [NSApp run];
}
return 0;
}
diff --git a/node.js/lib/_third_party_main.js b/node.js/lib/_third_party_main.js
index f10c045..bc4e961 100644
--- a/node.js/lib/_third_party_main.js
+++ b/node.js/lib/_third_party_main.js
@@ -17,7 +17,8 @@ if (process.argv[0] == 'jmx-cli' && require('tty').isatty(0)) {
repl.on('exit', function() {
process.exit();
});
-
+ process.stdin._readableState.objectMode = true;
+ process.stdout._writableState.objectMode = true;
} else {
// Read all of stdin - execute it.
process.stdin.setEncoding('utf8');