diff mbox series

[v2,1/1] ui/cocoa: show/hide menu in fullscreen on mouse ungrab/grab

Message ID 20220410193220.99168-2-carwynellis@gmail.com
State New
Headers show
Series ui/cocoa: show/hide menu in fullscreen on mouse | expand

Commit Message

Carwyn Ellis April 10, 2022, 7:32 p.m. UTC
The menu bar is only accessible when the Cocoa UI is windowed. In order
to allow the menu bar to be accessible in fullscreen mode, this change
makes the menu visible when the mouse is ungrabbed.

When the mouse is grabbed the menu is hidden again.

Incorporates changes in response to review feedback from Akihiko Odaki.

Signed-off-by: Carwyn Ellis <carwynellis@gmail.com>
---
 ui/cocoa.m | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index c4e5468f9e..ea2cd4ece0 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -656,13 +656,11 @@  - (void) toggleFullScreen:(id)sender
         [fullScreenWindow close];
         [normalWindow setContentView: self];
         [normalWindow makeKeyAndOrderFront: self];
-        [NSMenu setMenuBarVisible:YES];
     } else { // switch from desktop to fullscreen
         isFullscreen = TRUE;
         [normalWindow orderOut: nil]; /* Hide the window */
         [self grabMouse];
         [self setContentDimensions];
-        [NSMenu setMenuBarVisible:NO];
         fullScreenWindow = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame]
             styleMask:NSWindowStyleMaskBorderless
             backing:NSBackingStoreBuffered
@@ -1141,7 +1139,9 @@  - (void) grabMouse
 {
     COCOA_DEBUG("QemuCocoaView: grabMouse\n");
 
-    if (!isFullscreen) {
+    if (isFullscreen) {
+        [NSMenu setMenuBarVisible: FALSE];
+    } else {
         if (qemu_name)
             [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]];
         else
@@ -1156,7 +1156,9 @@  - (void) ungrabMouse
 {
     COCOA_DEBUG("QemuCocoaView: ungrabMouse\n");
 
-    if (!isFullscreen) {
+    if (isFullscreen) {
+        [NSMenu setMenuBarVisible: TRUE];
+    } else {
         if (qemu_name)
             [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
         else