Coerce MacVim to work with LCC

The LCC (Logitech Control Center) comes with an input manager which
registers its own root object with the default NSConnection.  MacVim
uses the root object of the default connection to vend the frontend
object, so LCC would cause MacVim to never open any new windows.

To work around this problem the default connection is no longer used in
MacVim, instead a new connection is created and this connection is used
to vend the frontend object instead.
This commit is contained in:
Bjorn Winckler
2008-05-20 14:40:57 +02:00
parent 0f1ee64746
commit 0430474168
2 changed files with 23 additions and 15 deletions
+1
View File
@@ -16,6 +16,7 @@
@interface MMAppController : NSObject <MMAppProtocol> {
NSConnection *connection;
NSMutableArray *vimControllers;
NSString *openSelectionString;
ATSFontContainerRef fontContainerRef;
+22 -15
View File
@@ -140,24 +140,30 @@ static int executeInLoginShell(NSString *path, NSArray *args);
vimControllers = [NSMutableArray new];
pidArguments = [NSMutableDictionary new];
// NOTE: Do not use the default connection since the Logitech Control
// Center (LCC) input manager steals and this would cause MacVim to
// never open any windows. (This is a bug in LCC but since they are
// unlikely to fix it, we graciously give them the default connection.)
connection = [[NSConnection alloc] initWithReceivePort:[NSPort port]
sendPort:nil];
[connection setRootObject:self];
[connection setRequestTimeout:MMRequestTimeout];
[connection setReplyTimeout:MMReplyTimeout];
// NOTE: When the user is resizing the window the AppKit puts the run
// loop in event tracking mode. Unless the connection listens to
// request in this mode, live resizing won't work.
[connection addRequestMode:NSEventTrackingRunLoopMode];
// NOTE! If the name of the connection changes here it must also be
// updated in MMBackend.m.
NSConnection *connection = [NSConnection defaultConnection];
NSString *name = [NSString stringWithFormat:@"%@-connection",
[[NSBundle mainBundle] bundleIdentifier]];
//NSLog(@"Registering connection with name '%@'", name);
if ([connection registerName:name]) {
[connection setRequestTimeout:MMRequestTimeout];
[connection setReplyTimeout:MMReplyTimeout];
[connection setRootObject:self];
// NOTE: When the user is resizing the window the AppKit puts the
// run loop in event tracking mode. Unless the connection listens
// to request in this mode, live resizing won't work.
[connection addRequestMode:NSEventTrackingRunLoopMode];
} else {
NSLog(@"WARNING: Failed to register connection with name '%@'",
if (![connection registerName:name]) {
NSLog(@"FATAL ERROR: Failed to register connection with name '%@'",
name);
[connection release]; connection = nil;
}
}
@@ -168,6 +174,7 @@ static int executeInLoginShell(NSString *path, NSArray *args);
{
//NSLog(@"MMAppController dealloc");
[connection release]; connection = nil;
[pidArguments release]; pidArguments = nil;
[vimControllers release]; vimControllers = nil;
[openSelectionString release]; openSelectionString = nil;
@@ -456,9 +463,9 @@ static int executeInLoginShell(NSString *path, NSArray *args);
andEventID:'MOD '];
#endif
// This will invalidate all connections (since they were spawned from the
// default connection).
[[NSConnection defaultConnection] invalidate];
// This will invalidate all connections (since they were spawned from this
// connection).
[connection invalidate];
// Send a SIGINT to all running Vim processes, so that they are sure to
// receive the connectionDidDie: notification (a process has to be checking