Permalink
Browse files

added hard hotkey CMD+OPT+F to expand visor temporarily to fullscreen…

… and back (close #24)

CMD+OPT+F is consistent with new Lion FullScreen mode hotkey. Lion FullScreen toggle does not work for our visor window (probably because it is chrome-less window). This is workaround. It expands visor window to whole screen, it does not try to enter real full-screen mode.
  • Loading branch information...
1 parent 4773a82 commit f7916cd367d3023b106ca8827799eb5f25f3185b @darwin darwin committed Feb 19, 2012
@@ -84,6 +84,15 @@ -(IBAction) toggleVisor:(id)sender {
}
}
+-(IBAction) fullScreenToggle:(id)sender {
+ AUTO_LOGGERF(@"sender=%@", sender);
+ if (!window_) return;
+
+ NSUserDefaults* ud = [NSUserDefaults standardUserDefaults];
+ BOOL val = [ud boolForKey:@"TotalTerminalVisorFullScreen"];
+ [ud setBool:(val ? NO:YES) forKey:@"TotalTerminalVisorFullScreen"];
+}
+
-(IBAction) showPrefs:(id)sender {
AUTO_LOGGERF(@"sender=%@", sender);
[NSApp activateIgnoringOtherApps:YES];
@@ -129,6 +129,9 @@ +(void) sanitizeDefaults:(NSUserDefaults*)ud {
if (![ud objectForKey:@"TotalTerminalVisorPinned"]) {
[ud setBool:NO forKey:@"TotalTerminalVisorPinned"];
}
+ if (![ud objectForKey:@"TotalTerminalVisorFullScreen"]) {
+ [ud setBool:NO forKey:@"TotalTerminalVisorFullScreen"];
+ }
if (![ud objectForKey:@"TotalTerminalVisorWindowOnHighLevel"]) {
[ud setBool:NO forKey:@"TotalTerminalVisorWindowOnHighLevel"];
}
@@ -32,6 +32,7 @@ -(void) registerObservers {
[udc addObserver:self forKeyPath:@"values.TotalTerminalShortcuts" options:0 context:nil];
[udc addObserver:self forKeyPath:@"values.TotalTerminalUsePreReleases" options:0 context:nil];
[udc addObserver:self forKeyPath:@"values.TotalTerminalVisorPinned" options:0 context:nil];
+ [udc addObserver:self forKeyPath:@"values.TotalTerminalVisorFullScreen" options:0 context:nil];
[udc addObserver:self forKeyPath:@"values.TotalTerminalVisorWindowOnHighLevel" options:0 context:nil];
// ----------
@@ -76,6 +77,9 @@ -(void) observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NS
if ([keyPath isEqualToString:@"values.TotalTerminalVisorPinned"]) {
[[NSNotificationCenter defaultCenter] postNotificationName:VisorPinStateDidChangeNotification object:self];
}
+ if ([keyPath isEqualToString:@"values.TotalTerminalVisorFullScreen"]) {
+ [self resetWindowPlacement];
+ }
if ([keyPath isEqualToString:@"values.TotalTerminalUsePreReleases"]) {
[self refreshFeedURLInUpdater];
}
@@ -537,7 +537,7 @@ -(void) applyVisorPositioning {
NSString* position = [[NSUserDefaults standardUserDefaults] stringForKey:@"TotalTerminalVisorPosition"];
if (![position isEqualToString:lastPosition_]) {
// note: cursor may jump during this operation, so do it only in rare cases when position changes
- // for more info see http://github.com/darwindow/visor/issues#issue/27
+ // for more info see http://github.com/darwin/visor/issues#issue/27
[self resetVisorWindowSize];
}
[lastPosition_ release];
@@ -646,7 +646,8 @@ -(void) applyVisorPositioning {
frame.origin.y = screenRect.origin.y - NSHeight(frame);
[window_ setFrame:frame display:YES];
}
- if ([position isEqualToString:@"Full Screen"]) {
+ BOOL shouldForceFullScreenWindow = [[NSUserDefaults standardUserDefaults] boolForKey:@"TotalTerminalVisorFullScreen"];
+ if ([position isEqualToString:@"Full Screen"] || shouldForceFullScreenWindow) {
NSRect frame = [window_ frame];
frame.size.width = screenRect.size.width;
frame.size.height = screenRect.size.height - shift;
@@ -778,6 +779,7 @@ -(void) resignKey:(id)sender {
LOG(@"resignKey %@", sender);
isKey = false;
[self updateEscapeHotKeyRegistration];
+ [self updateFullScreenHotKeyRegistration];
if (!isMain && !isKey && !isHidden && ![self isPinned]) {
[self hideVisor:false];
}
@@ -795,6 +797,7 @@ -(void) becomeKey:(id)sender {
LOG(@"becomeKey %@", sender);
isKey = true;
[self updateEscapeHotKeyRegistration];
+ [self updateFullScreenHotKeyRegistration];
}
-(void) becomeMain:(id)sender {
@@ -882,7 +885,7 @@ -(void) updateEscapeHotKeyRegistration {
if (hideOnEscape && isKey) {
if (!escapeHotKey) {
GTMCarbonEventDispatcherHandler* dispatcher = [NSClassFromString (@"GTMCarbonEventDispatcherHandler")sharedEventDispatcherHandler];
- escapeHotKey = [dispatcher registerHotKey:53
+ escapeHotKey = [dispatcher registerHotKey:53 // ESC
modifiers:0
target:self
action:@selector(hideOnEscape)
@@ -898,6 +901,28 @@ -(void) updateEscapeHotKeyRegistration {
}
}
+-(void) updateFullScreenHotKeyRegistration {
+ AUTO_LOGGER();
+ if (isKey) {
+ if (!fullScreenKey_) {
+ // setting hotModifiers_ means we're not looking for a double tap
+ GTMCarbonEventDispatcherHandler* dispatcher = [NSClassFromString (@"GTMCarbonEventDispatcherHandler")sharedEventDispatcherHandler];
+ fullScreenKey_ = [dispatcher registerHotKey:0x3 // F
+ modifiers:NSCommandKeyMask|NSAlternateKeyMask
+ target:self
+ action:@selector(fullScreenToggle:)
+ userInfo:nil
+ whenPressed:YES];
+ }
+ } else {
+ if (fullScreenKey_) {
+ GTMCarbonEventDispatcherHandler* dispatcher = [NSClassFromString (@"GTMCarbonEventDispatcherHandler")sharedEventDispatcherHandler];
+ [dispatcher unregisterHotKey:fullScreenKey_];
+ fullScreenKey_ = nil;
+ }
+ }
+}
+
// Returns the amount of time between two clicks to be considered a double click
-(NSTimeInterval) doubleClickTime {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
@@ -35,6 +35,7 @@ KeyCombo makeKeyComboFromDictionary(NSDictionary* hotkey);
IBOutlet NSButton* createProfileButton_;
GTMCarbonHotKey* hotKey_;
GTMCarbonHotKey* escapeHotKey;
+ GTMCarbonHotKey* fullScreenKey_;
NSUInteger hotModifiers_;
NSUInteger hotModifiersState_;
NSTimeInterval lastHotModifiersEventCheckedTime_;
@@ -70,6 +70,9 @@ -(id) init {
preventShortcutUpdates_ = FALSE;
originalPreferencesSize.width = 0;
lastPosition_ = nil;
+ hotKey_ = nil;
+ escapeHotKey = nil;
+ fullScreenKey_ = nil;
[self refreshFeedURLInUpdater];
@@ -106,6 +109,7 @@ -(id) init {
[self updateStatusMenu];
[self updateHotKeyRegistration];
[self updateEscapeHotKeyRegistration];
+ [self updateFullScreenHotKeyRegistration];
[self startEventMonitoring];
if ([ud boolForKey:@"TotalTerminalShowStatusItem"]) {
@@ -124,4 +128,6 @@ -(id) init {
return self;
}
+
+
@end

0 comments on commit f7916cd

Please sign in to comment.