Skip to content

Commit c08fbe8

Browse files
author
kenta.hatano
committed
微修正
1 parent da73187 commit c08fbe8

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

SwitchMenu/AppDelegate.m

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,24 @@ - (void)menuSelected:(id)sender {
397397

398398
NSRunningApplication *app = [self.apps objectAtIndex:tag];
399399
if ((modifierFlags & NSAlternateKeyMask) && (modifierFlags & NSCommandKeyMask)) {
400-
[app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
401-
400+
NSInteger shownApps = 0;
402401
for (NSRunningApplication *anApp in self.apps) {
403-
if (![anApp isEqual:app]) {
404-
[anApp hide];
402+
if (![anApp isEqual:app] && ![anApp isHidden]) {
403+
shownApps++;
404+
}
405+
}
406+
407+
if (shownApps <= 0) {
408+
for (NSRunningApplication *anApp in self.apps) {
409+
[anApp unhide];
410+
}
411+
} else {
412+
[app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
413+
414+
for (NSRunningApplication *anApp in self.apps) {
415+
if (![anApp isEqual:app]) {
416+
[anApp hide];
417+
}
405418
}
406419
}
407420
} else if (modifierFlags & NSAlternateKeyMask) {
@@ -424,6 +437,8 @@ - (void)menuSelected:(id)sender {
424437
}
425438

426439
if (modifierFlags & NSControlKeyMask) {
440+
[app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
441+
427442
NSTask *task = [[NSTask alloc] init];
428443
task.launchPath = @"/usr/bin/open";
429444
task.arguments = @[@"-a", @"mission control", @"--args", @"2"];

0 commit comments

Comments
 (0)