forked from shadowfacts/Tusker
Fix Cmd+W closing sometimes closing non-foreground window on macOS
Closes #444
This commit is contained in:
parent
34e57c297b
commit
dcdfe853e1
|
@ -162,13 +162,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
@objc func closeWindow() {
|
||||
guard let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) else {
|
||||
return
|
||||
}
|
||||
UIApplication.shared.requestSceneSessionDestruction(scene.session, options: nil)
|
||||
}
|
||||
|
||||
private func swizzleStatusBar() {
|
||||
let selector = Selector(("handleTapAction:"))
|
||||
var originalIMP: IMP?
|
||||
|
|
|
@ -41,22 +41,25 @@ struct MenuController {
|
|||
static let prevSubTabCommand = UIKeyCommand(title: "Previous Sub Tab", action: #selector(TabbedPageViewController.selectPrevPage), input: "[", modifierFlags: [.command, .shift])
|
||||
|
||||
static func buildMainMenu(builder: UIMenuBuilder) {
|
||||
builder.replace(menu: .file, with: buildFileMenu())
|
||||
builder.replace(menu: .file, with: buildFileMenu(builder: builder))
|
||||
builder.insertChild(buildSubTabMenu(), atStartOfMenu: .view)
|
||||
builder.insertChild(buildSidebarShortcuts(), atStartOfMenu: .view)
|
||||
}
|
||||
|
||||
private static func buildFileMenu() -> UIMenu {
|
||||
private static func buildFileMenu(builder: UIMenuBuilder) -> UIMenu {
|
||||
var children: [UIMenuElement] = [
|
||||
composeCommand,
|
||||
refreshCommand(discoverabilityTitle: nil),
|
||||
]
|
||||
if let close = builder.menu(for: .close) {
|
||||
children.append(close)
|
||||
}
|
||||
return UIMenu(
|
||||
title: "File",
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
options: [],
|
||||
children: [
|
||||
composeCommand,
|
||||
refreshCommand(discoverabilityTitle: nil),
|
||||
UIKeyCommand(title: "Close", action: #selector(AppDelegate.closeWindow), input: "w", modifierFlags: .command),
|
||||
]
|
||||
children: children
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue