Skip to content

Commit

Permalink
Fix Command-W behavior according to tab count
Browse files Browse the repository at this point in the history
* 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.

Issue #1664
  • Loading branch information
barijaona authored and TAKeanice committed Apr 10, 2023
1 parent 3909cbc commit 4ffdd65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Vienna/Sources/Application/AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ -(void)selectFolder:(NSInteger)folderId
*/
-(void)updateCloseCommands
{
if (self.browser.browserTabCount == 0 || !self.mainWindow.keyWindow)
if (self.browser.browserTabCount <= 1 || !self.mainWindow.keyWindow)
{
closeTabItem.keyEquivalent = @"";
closeAllTabsItem.keyEquivalent = @"";
Expand Down Expand Up @@ -3627,7 +3627,7 @@ -(BOOL)validateMenuItem:(NSMenuItem *)menuItem
}
else if (theAction == @selector(previousTab:))
{
return isMainWindowVisible && self.browser.browserTabCount > 0;
return isMainWindowVisible && self.browser.browserTabCount > 1;
}
else if (theAction == @selector(nextTab:))
{
Expand Down
4 changes: 4 additions & 0 deletions Vienna/Sources/Main window/TabbedBrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ extension TabbedBrowserViewController: MMTabBarViewDelegate {
func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_TabChanged"), object: tabViewItem?.view)
}

func tabViewDidChangeNumberOfTabViewItems(_ tabView: NSTabView) {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MA_Notify_TabCountChanged"), object: tabView)
}
}

// MARK: WKUIDelegate + BrowserContextMenuDelegate
Expand Down
6 changes: 1 addition & 5 deletions Vienna/Sources/Main window/WebViewBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,7 @@ -(void)closeTab:(NSTabViewItem *)tabViewItem
*/
-(NSInteger)browserTabCount
{
if (self.primaryTab) {
return self.tabBarControl.numberOfTabViewItems - 1;
} else {
return self.tabBarControl.numberOfTabViewItems;
}
return self.tabBarControl.numberOfTabViewItems;
}

/* showPreviousTab
Expand Down

0 comments on commit 4ffdd65

Please sign in to comment.