Repository: electron/electron (language: cpp)

Issue:
[Bug]: Application menu visible while embedded video is in fullscreen
### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

24.3.1

### What operating system are you using?

Windows

### Operating System Version

Windows 11 22H2

### What arch are you using?

x64

### Last Known Working Electron version

_No response_

### Expected Behavior

When a video is in fullscreen mode, only the video itself is visible, i.e. there is no menu on the screen.

### Actual Behavior

When a video is in fullscreen mode, the application menu bar stays visible on top of the screen. See the screenshot below.

![Upper left corner of fullscreen video](https://github.com/electron/electron/assets/24460532/35595370-7bf4-446a-890d-81468e2b9fe6)


### Testcase Gist URL

_No response_

### Additional Information

I observed this problem on Windows. I didn't try Linux. On macOS, the behavior is as expected; but the application menu is outside the window there.

I made a minimal Electron application, to show this bug: https://github.com/c3er/electron-fullscreen-issue

The important part of this demo is the `index.html` file that contains a `<video>` tag referencing a local video file (downloaded from https://samplelib.com/).


Discussion / hints:
Hello, I am newbie.  Is this issue beginner friendly? what tech stack used in this project? what are the prerequisite for solving this issue. I am absolute beginner don't know how things works.
@Suvrajit69 I'm afraid, the Electron project is anything but beginner friendly.

First, you have to manage [to build the project](https://www.electronjs.org/docs/latest/development/build-instructions-gn), which is already not trivial.

Then one has to work through millions of lines of C++ code to isolate and fix this problem. I don't dare this myself without help by somebody with good knowledge of this codebase. Also a setup of local development environment with debugging facility would be *very* helpful.

Also, C++ is quite a complex language with a steep learning curve -- not only for beginners but also people who know already other languages.
what this code is witten in c++? I saw this issue in electron web which is written in javascript I belive. I think I took the wrong way. haha. sorry. 
@Suvrajit69 While Electron applications are written in JavaScript (and HTML, CSS of course), Electron itself is written in C++ (and additional languages). It is based on Chromium, the open source version of Google's Chrome browser.
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
Didn't disappear magically in version 26.1.0. I updated [my repro repo](https://github.com/c3er/electron-fullscreen-issue) accordingly.
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
Still no magic disappearance in version 27.1.3. [Repro repo](https://github.com/c3er/electron-fullscreen-issue) updated accordingly.

Please deactivate this so called triage bot. It hurts the contributor experience very badly and I think, I'm not the only one who is frustrated with this. A big count -- even a very big count -- of issues is only a problem if you're not able to prioritize them properly.
did you find any workaround? I found that if setting `autoHideMenuBar: true` in the BrowserWindow constructor, then the menu disappears completely in fullscreen (but also when not in fullscreen). see also discussion here: #543
I found in the source code that windows is handled differently from the others.

Windows:

https://github.com/electron/electron/blob/cee51785e1ed057fa5c78b2fc7bb1e8a5b91053d/shell/browser/native_window_views.cc#L720

Others:

https://github.com/electron/electron/blob/cee51785e1ed057fa5c78b2fc7bb1e8a5b91053d/shell/browser/native_window_views.cc#L756

specifically, the auto-hide menu bar code only gets called for non-windows:

https://github.com/electron/electron/blob/cee51785e1ed057fa5c78b2fc7bb1e8a5b91053d/shell/browser/native_window_views.cc#L763

not sure what's the reasoning for that, but someone on windows could try to enable that for Windows too and see if it helps
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
still a bug i bielieve
I can confirm this with version 30.0.3. The menu bar in the newest Electron got a little higher, both in the Electron window (I like this actually) and in fullscreen mode, described above (which makes the bug a little worse).

So, it seems like a bug is not like a bread, that gets stale with time.

This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
bump
Confirmed with version 31.3.1

> Well the stale bot has had the following effects on the repository:
>
> 1. Reduce the metric of Open Issues in github
> 1. Made duplicate issues far more likely
> 1. Increased friction of users reporting that the issue still exists
> 1. Ultimately decreased the quality of the software, as the issues don’t accurately reflect reality

https://blog.benwinding.com/github-stale-bots/

Fix patch:
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md
index ea6e7149de8df..5e14d39513d3c 100644
--- a/docs/breaking-changes.md
+++ b/docs/breaking-changes.md
@@ -14,6 +14,10 @@ This document uses the following convention to categorize breaking changes:
 
 ## Planned Breaking API Changes (33.0)
 
+### Behavior Changed: menu bar will be hidden during fullscreen on Windows
+
+This brings the behavior to parity with Linux. Prior behavior: Menu bar is still visible during fullscreen on Windows. New behavior: Menu bar is hidden during fullscreen on Windows.
+
 ### Behavior Changed: `webContents` property on `login` on `app`
 
 The `webContents` property in the `login` event from `app` will be `null`
diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc
index 91745ce91b819..29c0b14ccf656 100644
--- a/shell/browser/native_window_views.cc
+++ b/shell/browser/native_window_views.cc
@@ -746,6 +746,24 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
   // Note: the following must be after "widget()->SetFullscreen(fullscreen);"
   if (leaving_fullscreen && !IsVisible())
     FlipWindowStyle(GetAcceleratedWidget(), true, WS_VISIBLE);
+
+  // Auto-hide menubar when in fullscreen.
+  if (fullscreen) {
+    menu_bar_visible_before_fullscreen_ = IsMenuBarVisible();
+    SetMenuBarVisibility(false);
+  } else {
+    // No fullscreen -> fullscreen video -> un-fullscreen video results
+    // in `NativeWindowViews::SetFullScreen(false)` being called twice.
+    // `menu_bar_visible_before_fullscreen_` is always false on the
+    //  second call which results in `SetMenuBarVisibility(false)` no
+    // matter what. We check `leaving_fullscreen` to avoid this.
+    if (!leaving_fullscreen)
+      return;
+
+    SetMenuBarVisibility(!IsMenuBarAutoHide() &&
+                         menu_bar_visible_before_fullscreen_);
+    menu_bar_visible_before_fullscreen_ = false;
+  }
 #else
   if (IsVisible())
     widget()->SetFullscreen(fullscreen);
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts
index 91a55b9932e32..5ec083a0c3dde 100644
--- a/spec/api-browser-window-spec.ts
+++ b/spec/api-browser-window-spec.ts
@@ -5630,6 +5630,37 @@ describe('BrowserWindow module', () => {
       });
     });
 
+    ifdescribe(process.platform !== 'darwin')('fullscreen state', () => {
+      it('correctly remembers state prior to HTML fullscreen transition', async () => {
+        const w = new BrowserWindow();
+        await w.loadFile(path.join(fixtures, 'pages', 'a.html'));
+
+        expect(w.isMenuBarVisible()).to.be.true('isMenuBarVisible');
+        expect(w.isFullScreen()).to.be.false('is fullscreen');
+
+        const enterFullScreen = once(w, 'enter-full-screen');
+        const leaveFullScreen = once(w, 'leave-full-screen');
+
+        await w.webContents.executeJavaScript('document.getElementById("div").requestFullscreen()', true);
+        await enterFullScreen;
+        await w.webContents.executeJavaScript('document.exitFullscreen()', true);
+        await leaveFullScreen;
+
+        expect(w.isFullScreen()).to.be.false('is fullscreen');
+        expect(w.isMenuBarVisible()).to.be.true('isMenuBarVisible');
+
+        w.setMenuBarVisibility(false);
+        expect(w.isMenuBarVisible()).to.be.false('isMenuBarVisible');
+
+        await w.webContents.executeJavaScript('document.getElementById("div").requestFullscreen()', true);
+        await enterFullScreen;
+        await w.webContents.executeJavaScript('document.exitFullscreen()', true);
+        await leaveFullScreen;
+
+        expect(w.isMenuBarVisible()).to.be.false('isMenuBarVisible');
+      });
+    });
+
     ifdescribe(process.platform === 'darwin')('fullscreenable state', () => {
       it('with functions', () => {
         it('can be set with fullscreenable constructor option', () => {


Test patch: