biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / virtualization / qemu / revert-ui-cocoa-add-clipboard-support.patch
blobd0e511c0403d7fa55e686d31e53b581e290d1746
1 Based on a reversion of upstream 7e3e20d89129614f4a7b2451fe321cc6ccca3b76,
2 adapted for 7.2.0
4 diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h
5 index ce76aa451f..c4e1dc4ff4 100644
6 --- a/include/ui/clipboard.h
7 +++ b/include/ui/clipboard.h
8 @@ -269,7 +269,7 @@ void qemu_clipboard_set_data(QemuClipboardPeer *peer,
9 QemuClipboardInfo *info,
10 QemuClipboardType type,
11 uint32_t size,
12 - const void *data,
13 + void *data,
14 bool update);
16 G_DEFINE_AUTOPTR_CLEANUP_FUNC(QemuClipboardInfo, qemu_clipboard_info_unref)
17 diff --git a/ui/clipboard.c b/ui/clipboard.c
18 index 3d14bffaf8..2c3f4c3ba0 100644
19 --- a/ui/clipboard.c
20 +++ b/ui/clipboard.c
21 @@ -154,7 +154,7 @@ void qemu_clipboard_set_data(QemuClipboardPeer *peer,
22 QemuClipboardInfo *info,
23 QemuClipboardType type,
24 uint32_t size,
25 - const void *data,
26 + void *data,
27 bool update)
29 if (!info ||
30 diff --git a/ui/cocoa.m b/ui/cocoa.m
31 index 660d3e0935..0e6760c360 100644
32 --- a/ui/cocoa.m
33 +++ b/ui/cocoa.m
34 @@ -29,7 +29,6 @@
36 #include "qemu/help-texts.h"
37 #include "qemu-main.h"
38 -#include "ui/clipboard.h"
39 #include "ui/console.h"
40 #include "ui/input.h"
41 #include "ui/kbd-state.h"
42 @@ -105,10 +104,6 @@ static void cocoa_switch(DisplayChangeListener *dcl,
44 static bool allow_events;
46 -static NSInteger cbchangecount = -1;
47 -static QemuClipboardInfo *cbinfo;
48 -static QemuEvent cbevent;
50 // Utility functions to run specified code block with iothread lock held
51 typedef void (^CodeBlock)(void);
52 typedef bool (^BoolCodeBlock)(void);
53 @@ -1799,107 +1794,6 @@ static void addRemovableDevicesMenuItems(void)
54 qapi_free_BlockInfoList(pointerToFree);
57 -@interface QemuCocoaPasteboardTypeOwner : NSObject<NSPasteboardTypeOwner>
58 -@end
60 -@implementation QemuCocoaPasteboardTypeOwner
62 -- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSPasteboardType)type
64 - if (type != NSPasteboardTypeString) {
65 - return;
66 - }
68 - with_iothread_lock(^{
69 - QemuClipboardInfo *info = qemu_clipboard_info_ref(cbinfo);
70 - qemu_event_reset(&cbevent);
71 - qemu_clipboard_request(info, QEMU_CLIPBOARD_TYPE_TEXT);
73 - while (info == cbinfo &&
74 - info->types[QEMU_CLIPBOARD_TYPE_TEXT].available &&
75 - info->types[QEMU_CLIPBOARD_TYPE_TEXT].data == NULL) {
76 - qemu_mutex_unlock_iothread();
77 - qemu_event_wait(&cbevent);
78 - qemu_mutex_lock_iothread();
79 - }
81 - if (info == cbinfo) {
82 - NSData *data = [[NSData alloc] initWithBytes:info->types[QEMU_CLIPBOARD_TYPE_TEXT].data
83 - length:info->types[QEMU_CLIPBOARD_TYPE_TEXT].size];
84 - [sender setData:data forType:NSPasteboardTypeString];
85 - [data release];
86 - }
88 - qemu_clipboard_info_unref(info);
89 - });
92 -@end
94 -static QemuCocoaPasteboardTypeOwner *cbowner;
96 -static void cocoa_clipboard_notify(Notifier *notifier, void *data);
97 -static void cocoa_clipboard_request(QemuClipboardInfo *info,
98 - QemuClipboardType type);
100 -static QemuClipboardPeer cbpeer = {
101 - .name = "cocoa",
102 - .notifier = { .notify = cocoa_clipboard_notify },
103 - .request = cocoa_clipboard_request
106 -static void cocoa_clipboard_update_info(QemuClipboardInfo *info)
108 - if (info->owner == &cbpeer || info->selection != QEMU_CLIPBOARD_SELECTION_CLIPBOARD) {
109 - return;
112 - if (info != cbinfo) {
113 - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
114 - qemu_clipboard_info_unref(cbinfo);
115 - cbinfo = qemu_clipboard_info_ref(info);
116 - cbchangecount = [[NSPasteboard generalPasteboard] declareTypes:@[NSPasteboardTypeString] owner:cbowner];
117 - [pool release];
120 - qemu_event_set(&cbevent);
123 -static void cocoa_clipboard_notify(Notifier *notifier, void *data)
125 - QemuClipboardNotify *notify = data;
127 - switch (notify->type) {
128 - case QEMU_CLIPBOARD_UPDATE_INFO:
129 - cocoa_clipboard_update_info(notify->info);
130 - return;
131 - case QEMU_CLIPBOARD_RESET_SERIAL:
132 - /* ignore */
133 - return;
137 -static void cocoa_clipboard_request(QemuClipboardInfo *info,
138 - QemuClipboardType type)
140 - NSAutoreleasePool *pool;
141 - NSData *text;
143 - switch (type) {
144 - case QEMU_CLIPBOARD_TYPE_TEXT:
145 - pool = [[NSAutoreleasePool alloc] init];
146 - text = [[NSPasteboard generalPasteboard] dataForType:NSPasteboardTypeString];
147 - if (text) {
148 - qemu_clipboard_set_data(&cbpeer, info, type,
149 - [text length], [text bytes], true);
151 - [pool release];
152 - break;
153 - default:
154 - break;
159 * The startup process for the OSX/Cocoa UI is complicated, because
160 * OSX insists that the UI runs on the initial main thread, and so we
161 @@ -1922,7 +1816,6 @@ static void cocoa_clipboard_request(QemuClipboardInfo *info,
162 status = qemu_default_main();
163 qemu_mutex_unlock_iothread();
164 COCOA_DEBUG("Second thread: qemu_default_main() returned, exiting\n");
165 - [cbowner release];
166 exit(status);
169 @@ -2003,18 +1896,6 @@ static void cocoa_refresh(DisplayChangeListener *dcl)
170 [cocoaView setAbsoluteEnabled:YES];
174 - if (cbchangecount != [[NSPasteboard generalPasteboard] changeCount]) {
175 - qemu_clipboard_info_unref(cbinfo);
176 - cbinfo = qemu_clipboard_info_new(&cbpeer, QEMU_CLIPBOARD_SELECTION_CLIPBOARD);
177 - if ([[NSPasteboard generalPasteboard] availableTypeFromArray:@[NSPasteboardTypeString]]) {
178 - cbinfo->types[QEMU_CLIPBOARD_TYPE_TEXT].available = true;
180 - qemu_clipboard_update(cbinfo);
181 - cbchangecount = [[NSPasteboard generalPasteboard] changeCount];
182 - qemu_event_set(&cbevent);
185 [pool release];
188 @@ -2071,12 +1952,6 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
190 // register vga output callbacks
191 register_displaychangelistener(&dcl);
193 - qemu_event_init(&cbevent, false);
194 - cbowner = [[QemuCocoaPasteboardTypeOwner alloc] init];
195 - qemu_clipboard_peer_register(&cbpeer);
197 - [pool release];
200 static QemuDisplay qemu_display_cocoa = {