ui/cocoa: Remove normalWindow

QemuCocoaView used to have fullScreenWindow but now it's gone, so we
do no longer have to call the window specifically "normalWindow".
Instead, refer to it with [-QemuCocoaView window].

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Rene Engel <ReneEngel80@emailn.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20240224-cocoa-v12-7-e89f70bdda71@daynix.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Akihiko Odaki 2024-02-24 21:43:38 +09:00 committed by Philippe Mathieu-Daudé
parent 91aa508d02
commit 0c35886e80
1 changed files with 17 additions and 16 deletions

View File

@ -93,7 +93,6 @@ static void cocoa_switch(DisplayChangeListener *dcl,
static void cocoa_refresh(DisplayChangeListener *dcl); static void cocoa_refresh(DisplayChangeListener *dcl);
static NSWindow *normalWindow;
static const DisplayChangeListenerOps dcl_ops = { static const DisplayChangeListenerOps dcl_ops = {
.dpy_name = "cocoa", .dpy_name = "cocoa",
.dpy_gfx_update = cocoa_update, .dpy_gfx_update = cocoa_update,
@ -1071,9 +1070,9 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
COCOA_DEBUG("QemuCocoaView: grabMouse\n"); COCOA_DEBUG("QemuCocoaView: grabMouse\n");
if (qemu_name) if (qemu_name)
[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)", qemu_name]]; [[self window] setTitle:[NSString stringWithFormat:@"QEMU %s - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)", qemu_name]];
else else
[normalWindow setTitle:@"QEMU - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)"]; [[self window] setTitle:@"QEMU - (Press " UC_CTRL_KEY " " UC_ALT_KEY " G to release Mouse)"];
[self hideCursor]; [self hideCursor];
CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled); CGAssociateMouseAndMouseCursorPosition(isAbsoluteEnabled);
isMouseGrabbed = TRUE; // while isMouseGrabbed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:] isMouseGrabbed = TRUE; // while isMouseGrabbed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:]
@ -1084,9 +1083,9 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
COCOA_DEBUG("QemuCocoaView: ungrabMouse\n"); COCOA_DEBUG("QemuCocoaView: ungrabMouse\n");
if (qemu_name) if (qemu_name)
[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; [[self window] setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
else else
[normalWindow setTitle:@"QEMU"]; [[self window] setTitle:@"QEMU"];
[self unhideCursor]; [self unhideCursor];
CGAssociateMouseAndMouseCursorPosition(TRUE); CGAssociateMouseAndMouseCursorPosition(TRUE);
isMouseGrabbed = FALSE; isMouseGrabbed = FALSE;
@ -1157,6 +1156,8 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
@implementation QemuCocoaAppController @implementation QemuCocoaAppController
- (id) init - (id) init
{ {
NSWindow *window;
COCOA_DEBUG("QemuCocoaAppController: init\n"); COCOA_DEBUG("QemuCocoaAppController: init\n");
self = [super init]; self = [super init];
@ -1170,20 +1171,20 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
} }
// create a window // create a window
normalWindow = [[NSWindow alloc] initWithContentRect:[cocoaView frame] window = [[NSWindow alloc] initWithContentRect:[cocoaView frame]
styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskClosable styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskClosable
backing:NSBackingStoreBuffered defer:NO]; backing:NSBackingStoreBuffered defer:NO];
if(!normalWindow) { if(!window) {
error_report("(cocoa) can't create window"); error_report("(cocoa) can't create window");
exit(1); exit(1);
} }
[normalWindow setAcceptsMouseMovedEvents:YES]; [window setAcceptsMouseMovedEvents:YES];
[normalWindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[normalWindow setTitle:qemu_name ? [NSString stringWithFormat:@"QEMU %s", qemu_name] : @"QEMU"]; [window setTitle:qemu_name ? [NSString stringWithFormat:@"QEMU %s", qemu_name] : @"QEMU"];
[normalWindow setContentView:cocoaView]; [window setContentView:cocoaView];
[normalWindow makeKeyAndOrderFront:self]; [window makeKeyAndOrderFront:self];
[normalWindow center]; [window center];
[normalWindow setDelegate: self]; [window setDelegate: self];
/* Used for displaying pause on the screen */ /* Used for displaying pause on the screen */
pauseLabel = [NSTextField new]; pauseLabel = [NSTextField new];
@ -1306,7 +1307,7 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
*/ */
- (void) doToggleFullScreen:(id)sender - (void) doToggleFullScreen:(id)sender
{ {
[normalWindow toggleFullScreen:sender]; [[cocoaView window] toggleFullScreen:sender];
} }
- (void) setFullGrab:(id)sender - (void) setFullGrab:(id)sender
@ -2004,7 +2005,7 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
/* if fullscreen mode is to be used */ /* if fullscreen mode is to be used */
if (opts->has_full_screen && opts->full_screen) { if (opts->has_full_screen && opts->full_screen) {
[normalWindow toggleFullScreen: nil]; [[cocoaView window] toggleFullScreen: nil];
} }
if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) { if (opts->u.cocoa.has_full_grab && opts->u.cocoa.full_grab) {
[controller setFullGrab: nil]; [controller setFullGrab: nil];