Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Open the preference window when relaunching the app while it already running. #756

Open
megabitsenmzq opened this issue Aug 8, 2024 · 0 comments
Labels
feature New feature or request

Comments

@megabitsenmzq
Copy link

megabitsenmzq commented Aug 8, 2024

Issue that this suggestion fixes

On a MacBook with the notch. the OS will hide a long status bar item. So sometimes the status bar item of this app is invisible. In this state, I can't access the app's preference to change the status bar item to a single icon.

Now the only way I can access MeetingBar is by reducing the icons I have on the bar. And it's not intuitive.

Solution description

Some apps open the preference window if the user tries to relaunch the app (maybe by clicking on Launchpad) while the app is already running.
(AltTab, Unclutter, etc.)

You might handle this by adding code in:

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows: Bool) {
    // Open preference window here
}

Alternatives considered

Or maybe you can also check if the status bar item is invisible.

By checking if the window of status bar button is on screen.

func isWindowOnScreen(_ windowNumber: Int) -> Bool {
    guard let allWindowsInfo = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) else {
        return false
    }
    guard let convertedInfo = allWindowsInfo as? [[String: Any]] else { return false }
    for item in convertedInfo {
        if item[kCGWindowIsOnscreen as String] as? Bool == true && item[kCGWindowNumber as String] as? Int == windowNumber {
            return true
        }
    }
    return false
}

Additional context

I'm confused the app disappeared after I connected my calendar. This small feature can make it a lot easier to let the app appear again.

@megabitsenmzq megabitsenmzq added the feature New feature or request label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant