From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Emanuele Giuseppe Esposito" <eesposit@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Akihiko Odaki" <akihiko.odaki@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [RFC PATCH-for-7.0 v3 1/2] ui/cocoa: Code movement
Date: Thu, 17 Mar 2022 12:56:43 +0100 [thread overview]
Message-ID: <20220317115644.37276-2-philippe.mathieu.daude@gmail.com> (raw)
In-Reply-To: <20220317115644.37276-1-philippe.mathieu.daude@gmail.com>
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
Pure code movement in preparation for the next commit.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
ui/cocoa.m | 86 +++++++++++++++++++++++++++---------------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index cb6e7c41dc..027c3053f7 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -75,6 +75,9 @@ typedef struct {
int height;
} QEMUScreen;
+@interface QemuCocoaPasteboardTypeOwner : NSObject<NSPasteboardTypeOwner>
+@end
+
static void cocoa_update(DisplayChangeListener *dcl,
int x, int y, int w, int h);
@@ -109,6 +112,8 @@ static bool allow_events;
static NSInteger cbchangecount = -1;
static QemuClipboardInfo *cbinfo;
+static QemuClipboardPeer cbpeer;
+static QemuCocoaPasteboardTypeOwner *cbowner;
static QemuEvent cbevent;
// Utility functions to run specified code block with iothread lock held
@@ -142,6 +147,44 @@ static bool bool_with_iothread_lock(BoolCodeBlock block)
return val;
}
+/*
+ * The startup process for the OSX/Cocoa UI is complicated, because
+ * OSX insists that the UI runs on the initial main thread, and so we
+ * need to start a second thread which runs the vl.c qemu_main():
+ *
+ * Initial thread: 2nd thread:
+ * in main():
+ * create qemu-main thread
+ * wait on display_init semaphore
+ * call qemu_main()
+ * ...
+ * in cocoa_display_init():
+ * post the display_init semaphore
+ * wait on app_started semaphore
+ * create application, menus, etc
+ * enter OSX run loop
+ * in applicationDidFinishLaunching:
+ * post app_started semaphore
+ * tell main thread to fullscreen if needed
+ * [...]
+ * run qemu main-loop
+ *
+ * We do this in two stages so that we don't do the creation of the
+ * GUI application menus and so on for command line options like --help
+ * where we want to just print text to stdout and exit immediately.
+ */
+
+static void *call_qemu_main(void *opaque)
+{
+ int status;
+
+ COCOA_DEBUG("Second thread: calling qemu_main()\n");
+ status = qemu_main(gArgc, gArgv, *_NSGetEnviron());
+ COCOA_DEBUG("Second thread: qemu_main() returned, exiting\n");
+ [cbowner release];
+ exit(status);
+}
+
// Mac to QKeyCode conversion
static const int mac_to_qkeycode_map[] = {
[kVK_ANSI_A] = Q_KEY_CODE_A,
@@ -1804,9 +1847,6 @@ static void addRemovableDevicesMenuItems(void)
qapi_free_BlockInfoList(pointerToFree);
}
-@interface QemuCocoaPasteboardTypeOwner : NSObject<NSPasteboardTypeOwner>
-@end
-
@implementation QemuCocoaPasteboardTypeOwner
- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSPasteboardType)type
@@ -1841,8 +1881,6 @@ static void addRemovableDevicesMenuItems(void)
@end
-static QemuCocoaPasteboardTypeOwner *cbowner;
-
static void cocoa_clipboard_notify(Notifier *notifier, void *data);
static void cocoa_clipboard_request(QemuClipboardInfo *info,
QemuClipboardType type);
@@ -1903,44 +1941,6 @@ static void cocoa_clipboard_request(QemuClipboardInfo *info,
}
}
-/*
- * The startup process for the OSX/Cocoa UI is complicated, because
- * OSX insists that the UI runs on the initial main thread, and so we
- * need to start a second thread which runs the vl.c qemu_main():
- *
- * Initial thread: 2nd thread:
- * in main():
- * create qemu-main thread
- * wait on display_init semaphore
- * call qemu_main()
- * ...
- * in cocoa_display_init():
- * post the display_init semaphore
- * wait on app_started semaphore
- * create application, menus, etc
- * enter OSX run loop
- * in applicationDidFinishLaunching:
- * post app_started semaphore
- * tell main thread to fullscreen if needed
- * [...]
- * run qemu main-loop
- *
- * We do this in two stages so that we don't do the creation of the
- * GUI application menus and so on for command line options like --help
- * where we want to just print text to stdout and exit immediately.
- */
-
-static void *call_qemu_main(void *opaque)
-{
- int status;
-
- COCOA_DEBUG("Second thread: calling qemu_main()\n");
- status = qemu_main(gArgc, gArgv, *_NSGetEnviron());
- COCOA_DEBUG("Second thread: qemu_main() returned, exiting\n");
- [cbowner release];
- exit(status);
-}
-
int main (int argc, char **argv) {
QemuThread thread;
--
2.34.1
next prev parent reply other threads:[~2022-03-17 12:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 11:56 [RFC PATCH-for-7.0 v3 0/2] cocoa: run qemu_init in the main thread Philippe Mathieu-Daudé
2022-03-17 11:56 ` Philippe Mathieu-Daudé [this message]
2022-03-17 11:58 ` [RFC PATCH-for-7.0 v3 1/2] ui/cocoa: Code movement Peter Maydell
2022-03-17 11:56 ` [RFC PATCH-for-7.0 v3 2/2] ui/cocoa: run qemu_init in the main thread Philippe Mathieu-Daudé
2022-03-17 12:02 ` Philippe Mathieu-Daudé
2022-03-17 12:04 ` Peter Maydell
2022-03-17 12:48 ` Akihiko Odaki
2022-03-17 12:51 ` Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220317115644.37276-2-philippe.mathieu.daude@gmail.com \
--to=philippe.mathieu.daude@gmail.com \
--cc=akihiko.odaki@gmail.com \
--cc=eesposit@redhat.com \
--cc=f4bug@amsat.org \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.