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

Frameless window cannot call out hidden menu #9990

Closed
stanleyxu2005 opened this issue Jul 12, 2017 · 2 comments
Closed

Frameless window cannot call out hidden menu #9990

stanleyxu2005 opened this issue Jul 12, 2017 · 2 comments

Comments

@stanleyxu2005
Copy link

stanleyxu2005 commented Jul 12, 2017

I'm using 1.7.4 beta on Windows 7 (x64). I set frame=false and autoHideMenuBar=true, the menu cannot be visible, when I press ALT. Is this a bug?

Further problems
I set transparent=true, I need to create a button to minimize/maximize the window like this

// Code in javascript of main HTML window
const w = require('electron').remote.getCurrentWindow()
w.minimize() // works
w.restore() // works
console.log(w.isMaximized()) // false
w.maximize() // works
console.log(w.isMaximized()) // false <-- wrong
w.unmaximize() // nothing happened

Problem 1:
The w.isMaximized() will always return false. Once the window is maximized, it will never unmaiximzed. (maybe a regression?)

Problem 2
I set the HTML window with -webkit-app-region:drag. Now right click on window, I can see the window context menu. But the menu item "Maximize" is by default bold. It is expected to be disabled.

Problem 3:
When I right click on the application button in task bar, the context menu (incl. Restore, Minimize, Maximize, etc.) is gone.

@andens
Copy link
Contributor

andens commented Aug 4, 2017

When setting the menu during browser window creation, a check explicitly aborts progress if the window is frameless. That's likely the reason why you can't show the menu; it was never created to begin with.

@zcbenz Is there any technical reason why this is done? I removed the check in NativeWindowViews::SetMenu when testing some stuff recently and everything seem to work out correctly.

I don't know the code enough to answer the questions regarding maximize, though.

Edit:
I took a look at it, and while I can't give a definitive answer to everything, here's what I found. On Windows, maximizing a window using the widget created by Chromium can't be done if the WS_THICKFRAME flag is not set. I tried doing it anyway to see what happens, and while the window is maximized (even w.isMaximized returns true) the caption is severely messed up with strange buttons I've never seen before.

So it's probably something within Chromium that is messed up in those cases. What Electron does to work around this is that it cheats a bit by manually setting the size and position of the window. It's not maximized per se, it just happens to fill the full screen. That's why it looks like it's maximized. This also explains why isMaximized returns false; that code calls the equivalent method on the Chromium widget, but we only set the size of the window and never called its maximize method so for all intents and purposes the widget is not actually maximized. Unmaximizing it worked for me though.

Now here's the real twist in the story. Setting transparency makes Chromium remove the WS_THICKFRAME on the window.

I guess Electron could keep track of maximized state when WS_THICKFRAME is not set so that isMaximized at least returns what we expect it to do, but I'm afraid the context menu stuff falls into the hands of Chromium.

@codebytere
Copy link
Member

We are no longer implementing bugfixes for versions of Electron <= 1.7.x, so i'm going to close this issue but if it is still persisting in more recent versions of Electron we can certainly reopen it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants