Skip to content

Commit

Permalink
ui/cocoa.m: conditionally compile on > 10.13
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed May 4, 2022
1 parent 8b1388f commit f041931
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ui/cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,13 @@ static void cocoa_switch(DisplayChangeListener *dcl,
static QemuSemaphore app_started_sem;
static bool allow_events;

// xPack
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_13
static NSInteger cbchangecount = -1;
static QemuClipboardInfo *cbinfo;
static QemuEvent cbevent;
#endif
// xPack

// Utility functions to run specified code block with iothread lock held
typedef void (^CodeBlock)(void);
Expand Down Expand Up @@ -1805,6 +1809,8 @@ static void addRemovableDevicesMenuItems(void)
qapi_free_BlockInfoList(pointerToFree);
}

// xPack
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_13
@interface QemuCocoaPasteboardTypeOwner : NSObject<NSPasteboardTypeOwner>
@end

Expand Down Expand Up @@ -1903,6 +1909,8 @@ static void cocoa_clipboard_request(QemuClipboardInfo *info,
break;
}
}
#endif
// xPack

/*
* The startup process for the OSX/Cocoa UI is complicated, because
Expand Down Expand Up @@ -1938,7 +1946,11 @@ static void cocoa_clipboard_request(QemuClipboardInfo *info,
COCOA_DEBUG("Second thread: calling qemu_main()\n");
status = qemu_main(gArgc, gArgv, *_NSGetEnviron());
COCOA_DEBUG("Second thread: qemu_main() returned, exiting\n");
// xPack
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_13
[cbowner release];
#endif
// xPack
exit(status);
}

Expand Down Expand Up @@ -2055,6 +2067,8 @@ static void cocoa_refresh(DisplayChangeListener *dcl)
});
}

// xPack
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_13
if (cbchangecount != [[NSPasteboard generalPasteboard] changeCount]) {
qemu_clipboard_info_unref(cbinfo);
cbinfo = qemu_clipboard_info_new(&cbpeer, QEMU_CLIPBOARD_SELECTION_CLIPBOARD);
Expand All @@ -2065,6 +2079,8 @@ static void cocoa_refresh(DisplayChangeListener *dcl)
cbchangecount = [[NSPasteboard generalPasteboard] changeCount];
qemu_event_set(&cbevent);
}
#endif
// xPack

[pool release];
}
Expand Down Expand Up @@ -2105,10 +2121,13 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)

// register vga output callbacks
register_displaychangelistener(&dcl);

// xPack
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_13
qemu_event_init(&cbevent, false);
cbowner = [[QemuCocoaPasteboardTypeOwner alloc] init];
qemu_clipboard_peer_register(&cbpeer);
#endif
// xPack
}

static QemuDisplay qemu_display_cocoa = {
Expand Down

0 comments on commit f041931

Please sign in to comment.