Skip to contentSkip to conversation

ui/cocoa: show/hide menu in fullscreen on mouse

PATCH New Carwyn Ellis 1 participant 2 messages Apr 10, 2022

lore
Share & tools
lore
#0 lore raw

v2 cover ui/cocoa: show/hide menu in fullscreen on mouse

Minor change to make fullscreen mode in the Cocoa UI a little more convenient.

The menu bar is now made visible when the mouse is released (ungrabbed) making it accessible without having to leave fullscreen mode. Grabbing the mouse hides the menu.

Incorporates changes in response to feedback from Akihiko Odaki.

Carwyn Ellis (1):
ui/cocoa: show/hide menu in fullscreen on mouse ungrab/grab

 ui/cocoa.m | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH v2 1/1 ui/cocoa: show/hide menu in fullscreen on mouse ungrab/grab

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.

---
 ui/cocoa.m | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
ui/cocoa.m +6 -4
index c4e5468f9e..ea2cd4ece0 100644
@@ -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
Signature · 1 line
2.35.1