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

Window flickers instead of hiding when clicking tray [OS: Windows] #274

Closed
aabuhijleh opened this issue Mar 15, 2020 · 3 comments · Fixed by #276
Closed

Window flickers instead of hiding when clicking tray [OS: Windows] #274

aabuhijleh opened this issue Mar 15, 2020 · 3 comments · Fixed by #276

Comments

@aabuhijleh
Copy link

Description

I expect the app window to get hidden if I click the tray icon a second time (or when app window is already visible).

Looking at the function that gets fired on tray click, I can see the problem.

  private async clicked(
    event?: Electron.KeyboardEvent,
    bounds?: Electron.Rectangle
  ): Promise<void> {
    if (event && (event.shiftKey || event.ctrlKey || event.metaKey)) {
      return this.hideWindow();
    }
    
    // this will always return false
    if (this._browserWindow && this._browserWindow.isVisible()) {
      return this.hideWindow(); <--------------------------- // never fired on windows
    }

    this._cachedBounds = bounds || this._cachedBounds;
    await this.showWindow(this._cachedBounds);
  }

hideWindow() is never called on tray click because the browserWindow's blur event is fired first and it hides the window, so it becomes not visible => which causes the flickering

1) user clicks tray while window is already shown
2) focus is lost => "blur" event callback is triggered => hide window
3) clicked is called => window is not visible => show window again (flicker)

Steps to Reproduce the Problem

  1. Use Menubar on Windows
  2. Click tray to show Window
  3. Click tray again to hide it

Expected Behaviour

App window should get hidden on tray click if window is already visible

Actual Behaviour

App window flickers

Specifications

  • Menubar version: 8.0.0
  • Platform: Windows 10
  • Electron version: 8.1.1

Screen Recording

tGMArSQKda

Other information

I tried to mess around with setTimeout and isAlwaysOnTop but I never found a good consistent solution.

Thanks in advance!

@RobbieTheWagner
Copy link
Contributor

I'm noticing this as well.

@beoss
Copy link
Contributor

beoss commented Mar 28, 2020

hello, i added a PR to resolve this issue

@aabuhijleh
Copy link
Author

aabuhijleh commented Mar 29, 2020

Thanks @beoss. We should test this fix on both Windows and Mac. Because on Mac, menubar behaves correctly already.

amaury1093 added a commit that referenced this issue Apr 27, 2020
* update prevent flicker on Windows

* Update src/Menubar.ts

Co-authored-by: Amaury Martiny <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants