Skip to content
Snippets Groups Projects
Commit 2d390f5d authored by George Nachman's avatar George Nachman
Browse files

Change "Open in current space" for hotkey windows to move the hotkey window to...

Change "Open in current space" for hotkey windows to move the hotkey window to the current space if it's already open on another space when the hotkey is pressed. Issue 5622.
parent 11b8148f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -233,8 +233,9 @@ extern NSString *const iTermUnicodeVersionDidChangeNotification;
// Minimum time between sending anti-idle codes. "1" otherwise results in a flood.
extern const NSTimeInterval kMinimumAntiIdlePeriod;
 
// Special value for KEY_SPACE.
extern NSInteger iTermProfileJoinsAllSpaces;
// Special values for KEY_SPACE.
extern const NSInteger iTermProfileJoinsAllSpaces;
extern const NSInteger iTermProfileOpenInCurrentSpace;
 
// The numerical values for each enum matter because they are used in
// the UI as "tag" values for each select list item. They are also
Loading
Loading
Loading
Loading
@@ -45,7 +45,9 @@
NSString *const iTermUnicodeVersionDidChangeNotification = @"iTermUnicodeVersionDidChangeNotification";
 
const NSTimeInterval kMinimumAntiIdlePeriod = 1.0;
NSInteger iTermProfileJoinsAllSpaces = -1;
const NSInteger iTermProfileJoinsAllSpaces = -1;
const NSInteger iTermProfileOpenInCurrentSpace = 0;
static NSMutableArray<NSNotification *> *sDelayedNotifications;
 
@implementation ITAddressBookMgr {
Loading
Loading
Loading
Loading
@@ -185,7 +185,7 @@ static NSString *const kHotkeyWindowGeneratedProfileNameKey = @"Hotkey Window";
dict[KEY_BLUR_RADIUS] = @2.0;
dict[KEY_BLUR] = @YES;
dict[KEY_SCREEN] = @-1;
dict[KEY_SPACE] = @-1;
dict[KEY_SPACE] = @(iTermProfileJoinsAllSpaces);
dict[KEY_SHORTCUT] = @"";
NSString *newProfileName = kHotkeyWindowGeneratedProfileNameKey;
NSInteger number = 1;
Loading
Loading
Loading
Loading
@@ -81,6 +81,9 @@ extern NSString *const iTermDidDecodeWindowRestorableStateNotification;
// called yet.
@property(nonatomic) BOOL restorableStateDecodePending;
 
// Used only by hotkey windows. Indicate if it should move to the active space when opening.
@property(nonatomic, readonly) BOOL openInCurrentSpace;
// Draws a mock-up of a window arrangement into the current graphics context.
// |frames| gives an array of NSValue's having NSRect values for each screen,
// giving the screens' coordinates in the model.
Loading
Loading
Loading
Loading
@@ -2264,9 +2264,10 @@ ITERM_WEAKLY_REFERENCEABLE
}
 
Profile* addressbookEntry = [[[[[self tabs] objectAtIndex:0] sessions] objectAtIndex:0] profile];
if ([addressbookEntry objectForKey:KEY_SPACE] &&
[[addressbookEntry objectForKey:KEY_SPACE] intValue] == iTermProfileJoinsAllSpaces) {
if ([addressbookEntry[KEY_SPACE] intValue] == iTermProfileJoinsAllSpaces) {
[[self window] setCollectionBehavior:[[self window] collectionBehavior] | NSWindowCollectionBehaviorCanJoinAllSpaces];
} else if ([addressbookEntry[KEY_SPACE] intValue] == iTermProfileOpenInCurrentSpace) {
_openInCurrentSpace = YES;
}
if ([arrangement objectForKey:TERMINAL_GUID] &&
[[arrangement objectForKey:TERMINAL_GUID] isKindOfClass:[NSString class]]) {
Loading
Loading
@@ -7475,9 +7476,10 @@ ITERM_WEAKLY_REFERENCEABLE
 
// On Lion, a window that can join all spaces can't go fullscreen.
if ([self numberOfTabs] == 1 &&
profile[KEY_SPACE] &&
[profile[KEY_SPACE] intValue] == iTermProfileJoinsAllSpaces) {
[[self window] setCollectionBehavior:[[self window] collectionBehavior] | NSWindowCollectionBehaviorCanJoinAllSpaces];
} else if ([profile[KEY_SPACE] intValue] == iTermProfileOpenInCurrentSpace) {
_openInCurrentSpace = YES;
}
 
return aSession;
Loading
Loading
Loading
Loading
@@ -880,8 +880,8 @@ static iTermController *gSharedInstance;
}
 
+ (void)switchToSpaceInBookmark:(Profile *)aDict {
if ([aDict objectForKey:KEY_SPACE]) {
int spaceNum = [[aDict objectForKey:KEY_SPACE] intValue];
if (aDict[KEY_SPACE]) {
int spaceNum = [aDict[KEY_SPACE] intValue];
if (spaceNum > 0 && spaceNum < 10) {
// keycodes for digits 1-9. Send control-n to switch spaces.
// TODO: This would get remapped by the event tap. It requires universal access to be on and
Loading
Loading
Loading
Loading
@@ -571,6 +571,15 @@ static NSString *const kArrangement = @"Arrangement";
if (self.windowController.weaklyReferencedObject) {
DLog(@"already have a hotkey window created");
if (self.windowController.window.alphaValue == 1) {
if (self.windowController.openInCurrentSpace && !self.windowController.window.isOnActiveSpace) {
DLog(@"Move already-open hotkey window to current space");
NSWindow *window = self.windowController.window;
// I tested this on 10.12 and it's sufficient to move the window. Maybe not in older OS versions?
NSWindowCollectionBehavior collectionBehavior = window.collectionBehavior;
window.collectionBehavior = (collectionBehavior | NSWindowCollectionBehaviorCanJoinAllSpaces);
window.collectionBehavior = collectionBehavior;
return;
}
DLog(@"hotkey window opaque");
if (!allSiblingsOpen) {
DLog(@"Not all siblings open. Doing nothing.");
Loading
Loading
@@ -610,7 +619,7 @@ static NSString *const kArrangement = @"Arrangement";
 
- (iTermHotkeyWindowType)hotkeyWindowType {
if (self.floats) {
if ([iTermProfilePreferences unsignedIntegerForKey:KEY_SPACE inProfile:self.profile] == iTermProfileJoinsAllSpaces) {
if ([iTermProfilePreferences intForKey:KEY_SPACE inProfile:self.profile] == iTermProfileJoinsAllSpaces) {
// This makes it possible to overlap Lion fullscreen windows.
return iTermHotkeyWindowTypeFloatingPanel;
} else {
Loading
Loading
Loading
Loading
@@ -265,7 +265,7 @@ NSString *const kProfilePreferenceInitialDirectoryAdvancedValue = @"Advanced";
KEY_HIDE_AFTER_OPENING: @NO,
KEY_WINDOW_TYPE: @(WINDOW_TYPE_NORMAL),
KEY_SCREEN: @-1,
KEY_SPACE: @0,
KEY_SPACE: @(iTermProfileOpenInCurrentSpace),
KEY_SYNC_TITLE: @NO,
KEY_DISABLE_WINDOW_RESIZING: @NO,
KEY_PREVENT_TAB: @NO,
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment