forked from jralls/gtk-osx-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgtk3-quartz-3-24-7-fixes.patch
250 lines (236 loc) · 9.51 KB
/
gtk3-quartz-3-24-7-fixes.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
diff --git a/gtk/gtkclipboard-quartz.c b/gtk/gtkclipboard-quartz.c
index 75699cc..c01a9cd 100644
--- a/gtk/gtkclipboard-quartz.c
+++ b/gtk/gtkclipboard-quartz.c
@@ -370,7 +370,6 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
gpointer user_data,
gboolean have_owner)
{
- GtkClipboardOwner *owner;
NSSet *types;
NSAutoreleasePool *pool;
@@ -406,26 +405,35 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
*/
if (user_data && user_data == clipboard->user_data)
{
- owner = [clipboard->owner retain];
-
- owner->setting_same_owner = TRUE;
+ clipboard->owner->setting_same_owner = TRUE;
clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
- owner: owner];
- owner->setting_same_owner = FALSE;
+ owner: clipboard->owner];
+ clipboard->owner->setting_same_owner = FALSE;
}
else
{
- owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
+ GtkClipboardOwner *new_owner;
+ /* We do not set the new owner on clipboard->owner immediately,
+ * because declareTypes could (but not always does -- see also the
+ * comment at pasteboardChangedOwner above) cause clipboard_unset
+ * to be called, which releases clipboard->owner.
+ */
+ new_owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
- owner: owner];
+ owner: new_owner];
+
+ /* In case pasteboardChangedOwner was not triggered, check to see
+ * whether the previous owner still needs to be released.
+ */
+ if (clipboard->owner)
+ [clipboard->owner release];
+ clipboard->owner = new_owner;
}
- [owner release];
[types release];
[pool release];
- clipboard->owner = owner;
clipboard->user_data = user_data;
clipboard->have_owner = have_owner;
if (have_owner)
@@ -538,6 +546,8 @@ clipboard_unset (GtkClipboard *clipboard)
g_free (clipboard->storable_targets);
clipboard->storable_targets = NULL;
+ if (clipboard->owner)
+ [clipboard->owner release];
clipboard->owner = NULL;
clipboard->get_func = NULL;
clipboard->clear_func = NULL;
@@ -564,8 +574,16 @@ void
gtk_clipboard_clear (GtkClipboard *clipboard)
{
clipboard_unset (clipboard);
-
- [clipboard->pasteboard declareTypes:nil owner:nil];
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+ if (gdk_quartz_osx_version() >= GDK_OSX_SNOW_LEOPARD)
+ [clipboard->pasteboard clearContents];
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ else
+#endif
+#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ [clipboard->pasteboard declareTypes:nil owner:nil];
+#endif
}
static void
@@ -851,7 +869,6 @@ gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
/**
* gtk_clipboard_wait_for_text:
* @clipboard:
- * @target:
*
* Returns: (nullable):
*/
@@ -899,7 +916,7 @@ gtk_clipboard_wait_for_image (GtkClipboard *clipboard)
* gtk_clipboard_wait_for_uris:
* @clipboard:
*
- * Returns: (nullable) (array zero-terminated=1):
+ * Returns: (nullable) (array zero-terminated=1) (transfer full) (element-type utf8):
*/
gchar **
gtk_clipboard_wait_for_uris (GtkClipboard *clipboard)
@@ -1276,6 +1293,8 @@ _gtk_clipboard_store_all (void)
* gtk_clipboard_get_selection:
* @clipboard:
*
+ * Returns: the selection
+ *
* Since: 3.22
*/
GdkAtom
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index f12deb5..01b31ef 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -5271,12 +5271,12 @@ gtk_menu_position (GtkMenu *menu,
/* Realize so we have the proper width and height to figure out
* the right place to popup the menu.
*/
- gtk_widget_realize (priv->toplevel);
- gtk_window_move_resize (GTK_WINDOW (priv->toplevel));
-
if (!gtk_widget_get_visible (priv->toplevel))
gtk_window_set_type_hint (GTK_WINDOW (priv->toplevel), priv->menu_type_hint);
+ gtk_widget_realize (priv->toplevel);
+ gtk_window_move_resize (GTK_WINDOW (priv->toplevel));
+
if (text_direction == GTK_TEXT_DIR_NONE)
text_direction = gtk_widget_get_direction (GTK_WIDGET (menu));
diff --git a/gdk/quartz/GdkQuartzView.c b/gdk/quartz/GdkQuartzView.c
index 72e305c..193fcc1 100644
--- a/gdk/quartz/GdkQuartzView.c
+++ b/gdk/quartz/GdkQuartzView.c
@@ -33,6 +33,7 @@
markedRange = NSMakeRange (NSNotFound, 0);
selectedRange = NSMakeRange (0, 0);
}
+ [self setValue: @(YES) forKey: @"postsFrameChangedNotifications"];
return self;
}
diff --git a/gdk/quartz/gdkdisplay-quartz.c b/gdk/quartz/gdkdisplay-quartz.c
index 30ba921..ed81f9c 100644
--- a/gdk/quartz/gdkdisplay-quartz.c
+++ b/gdk/quartz/gdkdisplay-quartz.c
@@ -469,7 +469,7 @@ gdk_quartz_display_get_monitor_at_window (GdkDisplay *display,
}
if (!monitor)
{
- GdkRectangle rect = cgrect_to_gdkrect ([nswindow frame]);
+ GdkRectangle rect = cgrect_to_gdkrect (NSRectToCGRect ([nswindow frame]));
monitor = gdk_display_get_monitor_at_point (display,
rect.x + rect.width/2,
rect.y + rect.height /2);
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 83c1232..efb6961 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -608,11 +608,16 @@ find_toplevel_under_pointer (GdkDisplay *display,
info = _gdk_display_get_pointer_info (display, gdk_seat_get_pointer (seat));
toplevel = info->toplevel_under_pointer;
- if (toplevel && WINDOW_IS_TOPLEVEL (toplevel))
- get_window_point_from_screen_point (toplevel, screen_point, x, y);
-
+ if (!(toplevel && WINDOW_IS_TOPLEVEL (toplevel)))
+ {
+ gint gdk_x = 0, gdk_y = 0;
+ _gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gdk_x, &gdk_y);
+ toplevel = _gdk_quartz_window_find_child (_gdk_root, gdk_x, gdk_y, TRUE);
+ info->toplevel_under_pointer = g_object_ref (toplevel);
+ }
if (toplevel)
{
+ get_window_point_from_screen_point (toplevel, screen_point, x, y);
/* If the coordinates are out of window bounds, this toplevel is not
* under the pointer and we thus return NULL. This can occur when
* toplevel under pointer has not yet been updated due to a very recent
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 66c4a14..3b0b565 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -208,6 +208,11 @@ gdk_window_impl_quartz_finalize (GObject *object)
if (impl->transient_for)
g_object_unref (impl->transient_for);
+ if (impl->view)
+ [[NSNotificationCenter defaultCenter] removeObserver: impl->toplevel
+ name: @"NSViewFrameDidChangeNotification"
+ object: impl->view];
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -909,6 +914,10 @@ _gdk_quartz_display_create_window_impl (GdkDisplay *display,
impl->view = [[GdkQuartzView alloc] initWithFrame:content_rect];
[impl->view setGdkWindow:window];
[impl->toplevel setContentView:impl->view];
+ [[NSNotificationCenter defaultCenter] addObserver: impl->toplevel
+ selector: @selector (windowDidResize:)
+ name: @"NSViewFrameDidChangeNotification"
+ object: impl->view];
[impl->view release];
}
break;
@@ -2174,7 +2183,14 @@ _gdk_quartz_window_set_collection_behavior (NSWindow *nswindow,
GdkWindowTypeHint hint)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (gdk_quartz_osx_version() >= GDK_OSX_LION)
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 10110
+#define GDK_QUARTZ_ALLOWS_TILING NSWindowCollectionBehaviorFullScreenAllowsTiling
+#define GDK_QUARTZ_DISALLOWS_TILING NSWindowCollectionBehaviorFullScreenDisallowsTiling
+#else
+#define GDK_QUARTZ_ALLOWS_TILING 1 << 11
+#define GDK_QUARTZ_DISALLOWS_TILING 1 << 12
+#endif
+ if (gdk_quartz_osx_version() >= GDK_OSX_LION)
{
/* Fullscreen Collection Behavior */
NSWindowCollectionBehavior behavior = [nswindow collectionBehavior];
@@ -2183,20 +2199,22 @@ _gdk_quartz_window_set_collection_behavior (NSWindow *nswindow,
case GDK_WINDOW_TYPE_HINT_NORMAL:
case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
behavior &= ~(NSWindowCollectionBehaviorFullScreenAuxiliary &
- NSWindowCollectionBehaviorFullScreenDisallowsTiling);
+ GDK_QUARTZ_DISALLOWS_TILING);
behavior |= (NSWindowCollectionBehaviorFullScreenPrimary |
- NSWindowCollectionBehaviorFullScreenAllowsTiling);
+ GDK_QUARTZ_ALLOWS_TILING);
break;
default:
behavior &= ~(NSWindowCollectionBehaviorFullScreenPrimary &
- NSWindowCollectionBehaviorFullScreenAllowsTiling);
+ GDK_QUARTZ_ALLOWS_TILING);
behavior |= (NSWindowCollectionBehaviorFullScreenAuxiliary |
- NSWindowCollectionBehaviorFullScreenDisallowsTiling);
+ GDK_QUARTZ_DISALLOWS_TILING);
break;
}
[nswindow setCollectionBehavior:behavior];
}
+#undef GDK_QUARTZ_ALLOWS_TILING
+#undef GDK_QUARTZ_DISALLOWS_TILING
#endif
}