Skip to content

Commit 553ad89

Browse files
committed
Fix Command-W behavior according to tab count
* Change tab count to behave similarly whether using old or new browser * Fix occurence of shortcut adaptations: - Command-W closes the window if tab count is 0 or 1. - If tab count is greater, Command-W closes tab, Command-Option-W closes all tabs except the primary one and Command-Shift-W closes the window * Send missing notification. Cherry-pick of commit 4ffdd65 Issue #1664
1 parent 09545f2 commit 553ad89

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Vienna/Sources/Application/AppController.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ -(void)selectFolder:(NSInteger)folderId
16391639
*/
16401640
-(void)updateCloseCommands
16411641
{
1642-
if (self.browser.browserTabCount == 0 || !self.mainWindow.keyWindow)
1642+
if (self.browser.browserTabCount <= 1 || !self.mainWindow.keyWindow)
16431643
{
16441644
closeTabItem.keyEquivalent = @"";
16451645
closeAllTabsItem.keyEquivalent = @"";
@@ -3634,7 +3634,7 @@ -(BOOL)validateMenuItem:(NSMenuItem *)menuItem
36343634
}
36353635
else if (theAction == @selector(previousTab:))
36363636
{
3637-
return isMainWindowVisible && self.browser.browserTabCount > 0;
3637+
return isMainWindowVisible && self.browser.browserTabCount > 1;
36383638
}
36393639
else if (theAction == @selector(nextTab:))
36403640
{

Vienna/Sources/Main window/TabbedBrowserViewController.swift

+4
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ extension TabbedBrowserViewController: MMTabBarViewDelegate {
312312
func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) {
313313
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_TabChanged"), object: tabViewItem?.view)
314314
}
315+
316+
func tabViewDidChangeNumberOfTabViewItems(_ tabView: NSTabView) {
317+
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_TabCountChanged"), object: tabView)
318+
}
315319
}
316320

317321
// MARK: WKUIDelegate + BrowserContextMenuDelegate

Vienna/Sources/Main window/WebViewBrowser.m

+1-5
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ -(void)closeTab:(NSTabViewItem *)tabViewItem
210210
*/
211211
-(NSInteger)browserTabCount
212212
{
213-
if (self.primaryTab) {
214-
return self.tabBarControl.numberOfTabViewItems - 1;
215-
} else {
216-
return self.tabBarControl.numberOfTabViewItems;
217-
}
213+
return self.tabBarControl.numberOfTabViewItems;
218214
}
219215

220216
/* showPreviousTab

0 commit comments

Comments
 (0)