[gtk+] Update Quartz DnD code to set device on DnD events
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Update Quartz DnD code to set device on DnD events
- Date: Wed, 30 Jun 2010 09:15:55 +0000 (UTC)
commit 53fbf2a30a9f2f2329c86ca3acf9345ec8ae23d5
Author: Kristian Rietveld <kris gtk org>
Date: Wed Jun 30 10:56:10 2010 +0200
Update Quartz DnD code to set device on DnD events
gdk/quartz/GdkQuartzWindow.c | 103 +++++++++++++++++++++++++-----------------
gdk/quartz/gdkdnd-quartz.c | 3 +
2 files changed, 65 insertions(+), 41 deletions(-)
---
diff --git a/gdk/quartz/GdkQuartzWindow.c b/gdk/quartz/GdkQuartzWindow.c
index dcd7250..f1ac22b 100644
--- a/gdk/quartz/GdkQuartzWindow.c
+++ b/gdk/quartz/GdkQuartzWindow.c
@@ -454,7 +454,8 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
- GdkEvent event;
+ GdkEvent *event;
+ GdkWindow *window;
if (current_context)
g_object_unref (current_context);
@@ -462,13 +463,22 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
current_context = gdk_drag_context_new ();
update_context_from_dragging_info (sender);
- event.dnd.type = GDK_DRAG_ENTER;
- event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
- event.dnd.send_event = FALSE;
- event.dnd.context = current_context;
- event.dnd.time = GDK_CURRENT_TIME;
+ window = [[self contentView] gdkWindow];
+
+ gdk_drag_context_set_device (current_context,
+ gdk_display_get_core_pointer (gdk_display_get_default ()));
- (*_gdk_event_func) (&event, _gdk_event_data);
+ event = gdk_event_new (GDK_DRAG_ENTER);
+ event->dnd.window = g_object_ref (window);
+ event->dnd.send_event = FALSE;
+ event->dnd.context = g_object_ref (current_context);
+ event->dnd.time = GDK_CURRENT_TIME;
+
+ gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
+
+ (*_gdk_event_func) (event, _gdk_event_data);
+
+ gdk_event_free (event);
return NSDragOperationNone;
}
@@ -486,15 +496,19 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
- GdkEvent event;
+ GdkEvent *event;
- event.dnd.type = GDK_DRAG_LEAVE;
- event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
- event.dnd.send_event = FALSE;
- event.dnd.context = current_context;
- event.dnd.time = GDK_CURRENT_TIME;
+ event = gdk_event_new (GDK_DRAG_LEAVE);
+ event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
+ event->dnd.send_event = FALSE;
+ event->dnd.context = g_object_ref (current_context);
+ event->dnd.time = GDK_CURRENT_TIME;
- (*_gdk_event_func) (&event, _gdk_event_data);
+ gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
+
+ (*_gdk_event_func) (event, _gdk_event_data);
+
+ gdk_event_free (event);
g_object_unref (current_context);
current_context = NULL;
@@ -504,23 +518,25 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
{
NSPoint point = [sender draggingLocation];
NSPoint screen_point = [self convertBaseToScreen:point];
- GdkEvent event;
+ GdkEvent *event;
int gx, gy;
update_context_from_dragging_info (sender);
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gx, &gy);
- event.dnd.type = GDK_DRAG_MOTION;
- event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
- event.dnd.send_event = FALSE;
- event.dnd.context = current_context;
- event.dnd.time = GDK_CURRENT_TIME;
- event.dnd.x_root = gx;
- event.dnd.y_root = gy;
+ event = gdk_event_new (GDK_DRAG_MOTION);
+ event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
+ event->dnd.send_event = FALSE;
+ event->dnd.context = g_object_ref (current_context);
+ event->dnd.time = GDK_CURRENT_TIME;
+ event->dnd.x_root = gx;
+ event->dnd.y_root = gy;
+
+ gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
- (*_gdk_event_func) (&event, _gdk_event_data);
+ (*_gdk_event_func) (event, _gdk_event_data);
- g_object_unref (event.dnd.window);
+ gdk_event_free (event);
return drag_action_to_drag_operation (current_context->action);
}
@@ -529,23 +545,25 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
{
NSPoint point = [sender draggingLocation];
NSPoint screen_point = [self convertBaseToScreen:point];
- GdkEvent event;
+ GdkEvent *event;
int gy, gx;
update_context_from_dragging_info (sender);
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gx, &gy);
- event.dnd.type = GDK_DROP_START;
- event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
- event.dnd.send_event = FALSE;
- event.dnd.context = current_context;
- event.dnd.time = GDK_CURRENT_TIME;
- event.dnd.x_root = gx;
- event.dnd.y_root = gy;
+ event = gdk_event_new (GDK_DROP_START);
+ event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
+ event->dnd.send_event = FALSE;
+ event->dnd.context = g_object_ref (current_context);
+ event->dnd.time = GDK_CURRENT_TIME;
+ event->dnd.x_root = gx;
+ event->dnd.y_root = gy;
+
+ gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
- (*_gdk_event_func) (&event, _gdk_event_data);
+ (*_gdk_event_func) (event, _gdk_event_data);
- g_object_unref (event.dnd.window);
+ gdk_event_free (event);
g_object_unref (current_context);
current_context = NULL;
@@ -560,18 +578,21 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
{
- GdkEvent event;
+ GdkEvent *event;
g_assert (_gdk_quartz_drag_source_context != NULL);
- event.dnd.type = GDK_DROP_FINISHED;
- event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
- event.dnd.send_event = FALSE;
- event.dnd.context = _gdk_quartz_drag_source_context;
+ event = gdk_event_new (GDK_DROP_FINISHED);
+ event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
+ event->dnd.send_event = FALSE;
+ event->dnd.context = g_object_ref (_gdk_quartz_drag_source_context);
+
+ gdk_event_set_device (event,
+ gdk_drag_context_get_device (_gdk_quartz_drag_source_context));
- (*_gdk_event_func) (&event, _gdk_event_data);
+ (*_gdk_event_func) (event, _gdk_event_data);
- g_object_unref (event.dnd.window);
+ gdk_event_free (event);
g_object_unref (_gdk_quartz_drag_source_context);
_gdk_quartz_drag_source_context = NULL;
diff --git a/gdk/quartz/gdkdnd-quartz.c b/gdk/quartz/gdkdnd-quartz.c
index a330300..442e821 100644
--- a/gdk/quartz/gdkdnd-quartz.c
+++ b/gdk/quartz/gdkdnd-quartz.c
@@ -154,6 +154,9 @@ gdk_drag_begin (GdkWindow *window,
/* Create fake context */
_gdk_quartz_drag_source_context = gdk_drag_context_new ();
_gdk_quartz_drag_source_context->is_source = TRUE;
+
+ gdk_drag_context_set_device (_gdk_quartz_drag_source_context,
+ gdk_display_get_core_pointer (gdk_display_get_default ()));
return _gdk_quartz_drag_source_context;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]