Skip to content

Commit

Permalink
Correct macOS window activation from hidden state (keepassxreboot#6575)
Browse files Browse the repository at this point in the history
* Fix keepassxreboot#6234 - properly set NSApplication activation policies when the window is hidden and shown
  • Loading branch information
droidmonkey authored Jun 1, 2021
1 parent 33bf6eb commit 11afd73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/gui/osutils/macutils/AppKitImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,10 @@ - (bool) enableScreenRecording

- (void) toggleForegroundApp:(bool) foreground
{
ProcessSerialNumber psn = {0, kCurrentProcess};
if (foreground) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
} else {
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
[NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited];
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/osutils/macutils/MacUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ bool MacUtils::raiseWindow(WId pid)

bool MacUtils::raiseOwnWindow()
{
m_appkit->toggleForegroundApp(true);
return m_appkit->activateProcess(m_appkit->ownProcessId());
}

Expand Down

0 comments on commit 11afd73

Please sign in to comment.