Stop opening timeline articles when activate-window click is counted (erroneously, we think) as a double-click. Fixes #5584. Fixes #5581.

This commit is contained in:
Brent Simmons committed 2026-12-03 11:17:12 -08:00
1 parent dd32f044aa
commit 18d6a4d62a
2 files changed
+34 -10

No files matched your search

@@ -20,12 +20,35 @@ final class TimelineTableView: NSTableView {
weak var keyboardDelegate: KeyboardDelegate?
weak var rowHeightDelegate: TimelineTableViewRowHeightDelegate?
private var lastMouseDownClickCount = 0
private var lastMouseDownTimestamp: TimeInterval = 0
private var uncountedClicks = 0
override func accessibilityLabel() -> String? {
return NSLocalizedString("Timeline", comment: "Timeline")
}
// MARK: - NSResponder
/// On macOS 27 the click that activates an inactive window doesn’t reach the table,
/// but the next click still counts it — so selecting an article would also open it.
/// Subtract clicks the table never received from `clickCount`.
/// <https://github.com/Ranchero-Software/NetNewsWire/issues/5584>
override func mouseDown(with event: NSEvent) {
let continuesClickSequence = event.clickCount == lastMouseDownClickCount + 1 && event.timestamp - lastMouseDownTimestamp <= NSEvent.doubleClickInterval
if !continuesClickSequence {
uncountedClicks = event.clickCount - 1
}
lastMouseDownClickCount = event.clickCount
lastMouseDownTimestamp = event.timestamp
guard uncountedClicks > 0, let adjustedEvent = NSEvent.mouseEvent(with: event.type, location: event.locationInWindow, modifierFlags: event.modifierFlags, timestamp: event.timestamp, windowNumber: event.windowNumber, context: nil, eventNumber: event.eventNumber, clickCount: event.clickCount - uncountedClicks, pressure: event.pressure) else {
super.mouseDown(with: event)
return
}
super.mouseDown(with: adjustedEvent)
}
override func keyDown(with event: NSEvent) {
if keyboardDelegate?.keydown(event, in: self) ?? false {
return
@@ -458,18 +458,19 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
// MARK: - Actions
@objc func openArticleInBrowser(_ sender: Any?) {
let article: Article?
if let tableView = sender as? NSTableView, tableView === self.tableView, let clickedArticle = articles.articleAtRow(tableView.clickedRow) {
article = clickedArticle
if !clickedArticle.status.read {
markArticles(Set([clickedArticle]), statusKey: .read, flag: true)
}
} else {
article = oneSelectedArticle
guard let article = oneSelectedArticle else {
return
}
if let link = article?.preferredLink {
// A ⌘- or ⇧-double-click can leave a different article, or several, selected.
// <https://github.com/Ranchero-Software/NetNewsWire/issues/5581>
if let tableView = sender as? NSTableView, tableView === self.tableView {
guard let clickedArticle = articles.articleAtRow(tableView.clickedRow), ArticleIdentityKey(clickedArticle) == ArticleIdentityKey(article) else {
return
}
}
if let link = article.preferredLink {
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
}
}