Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Dismiss Pinned Tab Previews when exiting full screen or hovering the semaphore buttons #2788

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion DuckDuckGo/TabBar/View/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,32 @@ final class TabBarViewController: NSViewController {
}

private func pinnedTabsViewDidUpdateHoveredItem(to index: Int?) {
func shouldDismissPinnedTabPreview() -> Bool {
// If the point is not within the view we can safely dismiss the preview
guard let pointWithinView = self.view.mouseLocationInsideBounds(nil) else {
return true
}

// Calculate the rect of the standard tabs
let standardTabsTotalWidth = self.collectionView.visibleItems().reduce(into: 0.0) { partial, item in
partial += item.view.bounds.width
}

// Create a rect with the width of pinned and non pinned tabs
var standardAndPinnedTabsContainerRect = self.pinnedTabsContainerView.frame
standardAndPinnedTabsContainerRect.size.width += standardTabsTotalWidth

// If the point is not within the rect dismiss the preview
return !standardAndPinnedTabsContainerRect.contains(pointWithinView)
}

if let index = index {
showPinnedTabPreview(at: index)
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
if self.view.isMouseLocationInsideBounds() == false {
// When the mouse hover on top of the semaphore view we want to dismiss the preview to avoid the preview get stuck on screen when the popover to choose the screen size is shown.
// We don't want to dismiss the preview if the location of the mouse is within the rect that encompasses the pinned and standard tabs
if shouldDismissPinnedTabPreview() {
self.hideTabPreview(allowQuickRedisplay: true)
}
}
Expand Down
Loading