forked from acornejo/homebrew-quartz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverse-gtkclipboard-quartz.patch
131 lines (121 loc) · 3.64 KB
/
reverse-gtkclipboard-quartz.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--- gtk/gtkclipboard-quartz.c.orig 2014-05-01 21:30:25.000000000 +0800
+++ gtk/gtkclipboard-quartz.c 2014-05-01 21:34:18.000000000 +0800
@@ -39,14 +39,6 @@ enum {
LAST_SIGNAL
};
-@interface GtkClipboardOwner : NSObject {
- GtkClipboard *clipboard;
- @public
- gboolean setting_same_owner;
-}
-
-@end
-
typedef struct _GtkClipboardClass GtkClipboardClass;
struct _GtkClipboard
@@ -54,7 +46,6 @@ struct _GtkClipboard
GObject parent_instance;
NSPasteboard *pasteboard;
- GtkClipboardOwner *owner;
NSInteger change_count;
GdkAtom selection;
@@ -97,6 +88,12 @@ static GtkClipboard *clipboard_peek
GdkAtom selection,
gboolean only_if_exists);
+@interface GtkClipboardOwner : NSObject {
+ GtkClipboard *clipboard;
+}
+
+@end
+
@implementation GtkClipboardOwner
-(void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
{
@@ -135,8 +132,9 @@ static GtkClipboard *clipboard_peek
*/
- (void)pasteboardChangedOwner:(NSPasteboard *)sender
{
- if (! setting_same_owner)
- clipboard_unset (clipboard);
+ clipboard_unset (clipboard);
+
+ [self release];
}
- (id)initWithClipboard:(GtkClipboard *)aClipboard
@@ -146,7 +144,7 @@ static GtkClipboard *clipboard_peek
if (self)
{
clipboard = aClipboard;
- setting_same_owner = FALSE;
+
}
return self;
@@ -337,6 +335,10 @@ gtk_clipboard_set_contents (GtkClipboard
NSSet *types;
NSAutoreleasePool *pool;
+ pool = [[NSAutoreleasePool alloc] init];
+
+ owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
+
if (!(clipboard->have_owner && have_owner) ||
clipboard->user_data != user_data)
{
@@ -351,44 +353,26 @@ gtk_clipboard_set_contents (GtkClipboard
clipboard->user_data != user_data)
{
(*clear_func) (clipboard, user_data);
+ [pool release];
return FALSE;
}
else
{
+ [pool release];
return TRUE;
}
}
}
- pool = [[NSAutoreleasePool alloc] init];
-
- types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
-
/* call declareTypes before setting the clipboard members because
* declareTypes might clear the clipboard
*/
- if (user_data && user_data == clipboard->user_data)
- {
- owner = [clipboard->owner retain];
-
- owner->setting_same_owner = TRUE;
- clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
- owner: owner];
- owner->setting_same_owner = FALSE;
- }
- else
- {
- owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
-
- clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
- owner: owner];
- }
-
- [owner release];
- [types release];
+ types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
+ clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
+ owner: owner];
+ [types release];
[pool release];
- clipboard->owner = owner;
clipboard->user_data = user_data;
clipboard->have_owner = have_owner;
if (have_owner)
@@ -477,8 +461,7 @@ clipboard_unset (GtkClipboard *clipboard
clipboard->n_storable_targets = -1;
g_free (clipboard->storable_targets);
clipboard->storable_targets = NULL;
-
- clipboard->owner = NULL;
+
clipboard->get_func = NULL;
clipboard->clear_func = NULL;
clipboard->user_data = NULL;