Skip to content

Commit

Permalink
Don't move items if already shown
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbaird committed Sep 1, 2024
1 parent 70baa12 commit 190e2fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Ice/MenuBar/MenuBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ struct MenuBarItem {
/// the initializer will fail.
///
/// - Parameter itemWindow: A window that contains information about the item.
private init?(itemWindow: WindowInfo) {
init?(itemWindow: WindowInfo) {
guard itemWindow.isMenuBarItem else {
return nil
}
Expand All @@ -152,7 +152,7 @@ struct MenuBarItem {
///
/// - Parameter windowID: An identifier for a window that contains information
/// about the item.
private init?(windowID: CGWindowID) {
init?(windowID: CGWindowID) {
guard let window = WindowInfo(windowID: windowID) else {
return nil
}
Expand Down
25 changes: 25 additions & 0 deletions Ice/MenuBar/MenuBarItemManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,31 @@ extension MenuBarItemManager {
/// movement has finished.
/// - mouseButton: The mouse button of the click.
func tempShowItem(_ item: MenuBarItem, clickWhenFinished: Bool, mouseButton: CGMouseButton) {
if
let latest = MenuBarItem(windowID: item.windowID),
latest.isOnScreen
{
Task {
if clickWhenFinished {
do {
switch mouseButton {
case .left:
try await leftClick(item: latest)
case .right:
try await rightClick(item: latest)
case .center:
try await centerClick(item: latest)
@unknown default:
assertionFailure("Unknown mouse button \(mouseButton)")
}
} catch {
Logger.itemManager.error("ERROR: \(error)")
}
}
}
return
}

let rehideInterval: TimeInterval = 20

guard
Expand Down

0 comments on commit 190e2fd

Please sign in to comment.