1 Index: gtk/gtktreeview.c
2 ===================================================================
3 --- gtk/gtktreeview.c (revision 21770)
4 +++ gtk/gtktreeview.c (working copy)
11 + GtkTreeModel* model;
15 @@ -6967,6 +6970,17 @@
19 +#ifdef GDK_WINDOWING_QUARTZ
21 +gtk_tree_view_catch_drag_begin (GtkWidget* widget,
22 + GdkDragContext* context,
25 + TreeViewDragInfo* drag_info = (TreeViewDragInfo*) user_data;
26 + set_source_row (context, drag_info->model, drag_info->path);
31 gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view,
32 GdkEventMotion *event)
36 gboolean retval = FALSE;
39 di = get_info (tree_view);
41 @@ -7025,13 +7040,25 @@
45 +#ifdef GDK_WINDOWING_QUARTZ
46 + /* catch drag-being signal */
49 + drag_begin_id = g_signal_connect (tree_view, "drag-begin", G_CALLBACK (gtk_tree_view_catch_drag_begin), (gpointer) di);
52 context = gtk_drag_begin (widget,
53 gtk_drag_source_get_target_list (widget),
58 +#ifndef GDK_WINDOWING_QUARTZ
59 set_source_row (context, model, path);
61 + /* disconnect drag-begin and catch drag-end */
62 + g_signal_handler_disconnect (tree_view, drag_begin_id);
67 Index: gtk/gtkquartz.c
68 ===================================================================
69 --- gtk/gtkquartz.c (revision 21770)
70 +++ gtk/gtkquartz.c (working copy)
75 +_gtk_quartz_create_image_from_drawable (GdkDrawable* drawable)
78 + NSImage* image = NULL;
80 + pixbuf = gdk_pixbuf_get_from_drawable (NULL, drawable, NULL,
85 + image = _gtk_quartz_create_image_from_pixbuf (pixbuf);
92 _gtk_quartz_create_image_from_pixbuf (GdkPixbuf *pixbuf)
94 CGColorSpaceRef colorspace;
95 Index: gtk/gtkquartz.h
96 ===================================================================
97 --- gtk/gtkquartz.h (revision 21770)
98 +++ gtk/gtkquartz.h (working copy)
100 GtkSelectionData *selection_data);
102 NSImage *_gtk_quartz_create_image_from_pixbuf (GdkPixbuf *pixbuf);
103 +NSImage *_gtk_quartz_create_image_from_drawable (GdkDrawable *drawable);
107 Index: gtk/gtktooltip.c
108 ===================================================================
109 --- gtk/gtktooltip.c (revision 21770)
110 +++ gtk/gtktooltip.c (working copy)
112 gtk_tooltip_trigger_tooltip_query (GdkDisplay *display)
119 @@ -434,10 +435,14 @@
123 + gdk_window_get_origin (window, &rx, &ry);
125 event.type = GDK_MOTION_NOTIFY;
126 event.motion.window = window;
128 + event.motion.x_root = rx + x;
130 + event.motion.y_root = ry + y;
131 event.motion.is_hint = FALSE;
133 _gtk_tooltip_handle_event (&event);
134 Index: gtk/gtkdnd-quartz.c
135 ===================================================================
136 --- gtk/gtkdnd-quartz.c (revision 21770)
137 +++ gtk/gtkdnd-quartz.c (working copy)
140 static void gtk_drag_source_site_destroy (gpointer data);
142 +static GtkDragSourceInfo *gtk_drag_get_source_info (GdkDragContext *context,
145 +extern GdkDragContext *gdk_quartz_drag_source_context(); /* gdk/quartz/gdkdnd-quartz.c */
147 struct _GtkDragSourceSite
149 GdkModifierType start_button_mask;
152 struct _GtkDragSourceInfo
154 + GtkWidget *source_widget;
156 GtkTargetList *target_list; /* Targets for drag data */
157 GdkDragAction possible_actions; /* Actions allowed by source */
160 gint hot_x, hot_y; /* Hot spot for drag */
161 GdkPixbuf *icon_pixbuf;
166 struct _GtkDragDestSite
174 if (site && site->flags & GTK_DEST_DEFAULT_DROP)
176 gtk_drag_finish (context,
177 @@ -233,19 +243,23 @@
183 -gtk_drag_get_source_widget (GdkDragContext *context)
189 gtk_drag_finish (GdkDragContext *context,
194 + GtkDragSourceInfo *info;
195 + GdkDragContext* source_context = gdk_quartz_drag_source_context ();
197 + g_assert (source_context);
199 + info = gtk_drag_get_source_info (source_context, FALSE);
202 + info->success = success;
203 + info->delete = del;
209 g_object_set_qdata (G_OBJECT (context), dest_info_quark, NULL);
213 +gtk_drag_get_source_widget (GdkDragContext *context)
215 + GtkDragSourceInfo *info;
216 + GdkDragContext* real_source_context = gdk_quartz_drag_source_context();
218 + if (!real_source_context)
221 + info = gtk_drag_get_source_info (real_source_context, FALSE);
225 + return info->source_widget;
228 /*************************************************************
229 * gtk_drag_highlight_expose:
230 * Callback for expose_event for highlighted widgets.
232 gtk_drag_get_data (widget, context, target, time);
235 + /* leave a note for the source-side context about the action chosen */
237 g_signal_emit_by_name (widget, "drag-drop",
238 context, x, y, time, &retval);
240 @@ -1052,6 +1084,7 @@
242 info = gtk_drag_get_source_info (context, TRUE);
244 + info->source_widget = g_object_ref (widget);
245 info->widget = g_object_ref (widget);
246 info->target_list = target_list;
247 gtk_target_list_ref (target_list);
248 @@ -1086,13 +1119,13 @@
251 pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 1, 1);
252 - gdk_pixbuf_fill (pixbuf, 0xffffff);
254 - gtk_drag_set_icon_pixbuf (context,
256 + gdk_pixbuf_fill (pixbuf, 0xffffff);
258 + gtk_drag_set_icon_pixbuf (context,
262 - g_object_unref (pixbuf);
263 + g_object_unref (pixbuf);
266 case GTK_IMAGE_PIXBUF:
267 @@ -1668,7 +1701,20 @@
271 - g_warning ("gtk_drag_set_icon_pixmap is not supported on Mac OS X");
274 + g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
275 + g_return_if_fail (context->is_source);
276 + g_return_if_fail (GDK_IS_COLORMAP (colormap));
277 + g_return_if_fail (GDK_IS_PIXMAP (pixmap));
279 + pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, colormap,
284 + gtk_drag_set_icon_pixbuf (context, pixbuf, hot_x, hot_y);
285 + g_object_unref (pixbuf);
289 @@ -1760,6 +1806,9 @@
290 g_signal_emit_by_name (info->widget, "drag-end",
293 + if (info->source_widget)
294 + g_object_unref (info->source_widget);
297 g_object_unref (info->widget);
299 @@ -1781,6 +1830,10 @@
301 gtk_drag_drop_finished (GtkDragSourceInfo *info)
303 + if (info->success && info->delete)
304 + g_signal_emit_by_name (info->source_widget, "drag-data-delete",
307 /* Workaround for the fact that the NS API blocks until the drag is
308 * over. This way the context is still valid when returning from
309 * drag_begin, even if it will still be quite useless. See bug #501588.
310 Index: gdk/quartz/gdkevents-quartz.c
311 ===================================================================
312 --- gdk/quartz/gdkevents-quartz.c (revision 21770)
313 +++ gdk/quartz/gdkevents-quartz.c (working copy)
315 return ((GdkEventPrivate *) event)->windowing_data;
318 +/* A category that exposes the protected carbon event for an NSEvent. */
319 +@interface NSEvent (GdkQuartzNSEvent)
320 +- (void *)gdk_quartz_event_ref;
323 +@implementation NSEvent (GdkQuartzNSEvent)
324 +- (void *)gdk_quartz_event_ref
331 _gdk_events_init (void)
333 @@ -1668,6 +1680,65 @@
337 +_gdk_quartz_possibly_forward_accelerator (NSEvent* nsevent)
339 + /* Special-case menu shortcut events. We create command events for
340 + * those and forward to the corresponding menu.
342 + if ((!_gdk_quartz_keyboard_grab_window ||
343 + (_gdk_quartz_keyboard_grab_window && keyboard_grab_owner_events)) &&
344 + [nsevent type] == NSKeyDown)
346 + EventRef event_ref;
348 + MenuItemIndex index;
350 + event_ref = [nsevent gdk_quartz_event_ref];
351 + if (IsMenuKeyEvent (NULL, event_ref,
352 + kMenuEventQueryOnly,
353 + &menu_ref, &index))
355 + MenuCommand menu_command;
356 + HICommand hi_command;
358 + if (GetMenuItemCommandID (menu_ref, index, &menu_command) != noErr)
361 + hi_command.commandID = menu_command;
362 + hi_command.menu.menuRef = menu_ref;
363 + hi_command.menu.menuItemIndex = index;
365 + CreateEvent (NULL, kEventClassCommand, kEventCommandProcess,
366 + 0, kEventAttributeUserEvent, &event_ref);
367 + SetEventParameter (event_ref, kEventParamDirectObject,
369 + sizeof (HICommand), &hi_command);
371 + SendEventToEventTarget (event_ref, GetMenuEventTarget (menu_ref));
373 + ReleaseEvent (event_ref);
382 +gdk_quartz_possibly_forward (GdkEvent* event)
385 + g_return_val_if_fail (event != NULL, FALSE);
387 + nsevent = ((GdkEventPrivate*)event)->windowing_data;
390 + return _gdk_quartz_possibly_forward_accelerator (nsevent);
396 gdk_event_translate (NSEvent *nsevent)
399 Index: gdk/quartz/gdkdnd-quartz.c
400 ===================================================================
401 --- gdk/quartz/gdkdnd-quartz.c (revision 21770)
402 +++ gdk/quartz/gdkdnd-quartz.c (working copy)
405 GdkDragContext *_gdk_quartz_drag_source_context = NULL;
408 +gdk_quartz_drag_source_context()
410 + return _gdk_quartz_drag_source_context;
414 gdk_drag_begin (GdkWindow *window,
416 Index: gdk/quartz/GdkQuartzWindow.c
417 ===================================================================
418 --- gdk/quartz/GdkQuartzWindow.c (revision 21770)
419 +++ gdk/quartz/GdkQuartzWindow.c (working copy)
422 GdkDragAction result = 0;
424 + /* GDK and Quartz drag operations do not map 1:1.
425 + This mapping represents about the best that we
428 + Note that NSDragOperationPrivate and GDK_ACTION_PRIVATE
429 + have almost opposite meanings: the GDK one means that the
430 + destination is solely responsible for the action; the Quartz
431 + one means that the source and destination will agree
432 + privately on the action. NSOperationGeneric is close in meaning
433 + to GDK_ACTION_PRIVATE but there is a problem: it will be
434 + sent for any ordinary drag, and likely not understood
435 + by any intra-widget drag (since the source & dest are the
439 if (operation & NSDragOperationGeneric)
440 + result |= GDK_ACTION_MOVE;
441 + if (operation & NSDragOperationCopy)
442 result |= GDK_ACTION_COPY;
443 + if (operation & NSDragOperationMove)
444 + result |= GDK_ACTION_MOVE;
445 + if (operation & NSDragOperationLink)
446 + result |= GDK_ACTION_LINK;
452 if (action & GDK_ACTION_COPY)
453 result |= NSDragOperationCopy;
454 + if (action & GDK_ACTION_LINK)
455 + result |= NSDragOperationLink;
456 + if (action & GDK_ACTION_MOVE)
457 + result |= NSDragOperationMove;
463 GDK_DRAG_CONTEXT_PRIVATE (current_context)->dragging_info = sender;
464 current_context->suggested_action = drag_operation_to_drag_action ([sender draggingSourceOperationMask]);
465 + current_context->actions = current_context->suggested_action;
468 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
471 - (void)draggingEnded:(id <NSDraggingInfo>)sender
473 + /* leave a note for the source about what action was taken */
474 + if (_gdk_quartz_drag_source_context && current_context)
475 + _gdk_quartz_drag_source_context->action = current_context->action;
478 g_object_unref (current_context);
479 current_context = NULL;