Browse files

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.
  • Loading branch information...
1 parent 0f1ee64 commit 0430474168889760bdc7afddc8a11cb8e660d8aa @b4winckler committed May 20, 2008
Showing with 23 additions and 15 deletions.
  1. +1 −0 src/MacVim/MMAppController.h
  2. +22 −15 src/MacVim/MMAppController.m
View
1 src/MacVim/MMAppController.h
@@ -16,6 +16,7 @@
@interface MMAppController : NSObject <MMAppProtocol> {
+ NSConnection *connection;
NSMutableArray *vimControllers;
NSString *openSelectionString;
ATSFontContainerRef fontContainerRef;
View
37 src/MacVim/MMAppController.m
@@ -140,24 +140,30 @@ - (id)init
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 @@ - (void)dealloc
{
//NSLog(@"MMAppController dealloc");
+ [connection release]; connection = nil;
[pidArguments release]; pidArguments = nil;
[vimControllers release]; vimControllers = nil;
[openSelectionString release]; openSelectionString = nil;
@@ -456,9 +463,9 @@ - (void)applicationWillTerminate:(NSNotification *)notification
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

0 comments on commit 0430474

Please sign in to comment.