mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
Update Quartz DnD code to set device on DnD events
This commit is contained in:
parent
03a313d2a9
commit
53fbf2a30a
@ -454,7 +454,8 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
|
|||||||
|
|
||||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
GdkEvent event;
|
GdkEvent *event;
|
||||||
|
GdkWindow *window;
|
||||||
|
|
||||||
if (current_context)
|
if (current_context)
|
||||||
g_object_unref (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 ();
|
current_context = gdk_drag_context_new ();
|
||||||
update_context_from_dragging_info (sender);
|
update_context_from_dragging_info (sender);
|
||||||
|
|
||||||
event.dnd.type = GDK_DRAG_ENTER;
|
window = [[self contentView] gdkWindow];
|
||||||
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;
|
|
||||||
|
|
||||||
(*_gdk_event_func) (&event, _gdk_event_data);
|
gdk_drag_context_set_device (current_context,
|
||||||
|
gdk_display_get_core_pointer (gdk_display_get_default ()));
|
||||||
|
|
||||||
|
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;
|
return NSDragOperationNone;
|
||||||
}
|
}
|
||||||
@ -486,15 +496,19 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
|
|||||||
|
|
||||||
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
GdkEvent event;
|
GdkEvent *event;
|
||||||
|
|
||||||
event.dnd.type = GDK_DRAG_LEAVE;
|
event = gdk_event_new (GDK_DRAG_LEAVE);
|
||||||
event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
||||||
event.dnd.send_event = FALSE;
|
event->dnd.send_event = FALSE;
|
||||||
event.dnd.context = current_context;
|
event->dnd.context = g_object_ref (current_context);
|
||||||
event.dnd.time = GDK_CURRENT_TIME;
|
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);
|
g_object_unref (current_context);
|
||||||
current_context = NULL;
|
current_context = NULL;
|
||||||
@ -504,23 +518,25 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
|
|||||||
{
|
{
|
||||||
NSPoint point = [sender draggingLocation];
|
NSPoint point = [sender draggingLocation];
|
||||||
NSPoint screen_point = [self convertBaseToScreen:point];
|
NSPoint screen_point = [self convertBaseToScreen:point];
|
||||||
GdkEvent event;
|
GdkEvent *event;
|
||||||
int gx, gy;
|
int gx, gy;
|
||||||
|
|
||||||
update_context_from_dragging_info (sender);
|
update_context_from_dragging_info (sender);
|
||||||
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gx, &gy);
|
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gx, &gy);
|
||||||
|
|
||||||
event.dnd.type = GDK_DRAG_MOTION;
|
event = gdk_event_new (GDK_DRAG_MOTION);
|
||||||
event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
||||||
event.dnd.send_event = FALSE;
|
event->dnd.send_event = FALSE;
|
||||||
event.dnd.context = current_context;
|
event->dnd.context = g_object_ref (current_context);
|
||||||
event.dnd.time = GDK_CURRENT_TIME;
|
event->dnd.time = GDK_CURRENT_TIME;
|
||||||
event.dnd.x_root = gx;
|
event->dnd.x_root = gx;
|
||||||
event.dnd.y_root = gy;
|
event->dnd.y_root = gy;
|
||||||
|
|
||||||
(*_gdk_event_func) (&event, _gdk_event_data);
|
gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
|
||||||
|
|
||||||
g_object_unref (event.dnd.window);
|
(*_gdk_event_func) (event, _gdk_event_data);
|
||||||
|
|
||||||
|
gdk_event_free (event);
|
||||||
|
|
||||||
return drag_action_to_drag_operation (current_context->action);
|
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 point = [sender draggingLocation];
|
||||||
NSPoint screen_point = [self convertBaseToScreen:point];
|
NSPoint screen_point = [self convertBaseToScreen:point];
|
||||||
GdkEvent event;
|
GdkEvent *event;
|
||||||
int gy, gx;
|
int gy, gx;
|
||||||
|
|
||||||
update_context_from_dragging_info (sender);
|
update_context_from_dragging_info (sender);
|
||||||
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gx, &gy);
|
_gdk_quartz_window_nspoint_to_gdk_xy (screen_point, &gx, &gy);
|
||||||
|
|
||||||
event.dnd.type = GDK_DROP_START;
|
event = gdk_event_new (GDK_DROP_START);
|
||||||
event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
||||||
event.dnd.send_event = FALSE;
|
event->dnd.send_event = FALSE;
|
||||||
event.dnd.context = current_context;
|
event->dnd.context = g_object_ref (current_context);
|
||||||
event.dnd.time = GDK_CURRENT_TIME;
|
event->dnd.time = GDK_CURRENT_TIME;
|
||||||
event.dnd.x_root = gx;
|
event->dnd.x_root = gx;
|
||||||
event.dnd.y_root = gy;
|
event->dnd.y_root = gy;
|
||||||
|
|
||||||
(*_gdk_event_func) (&event, _gdk_event_data);
|
gdk_event_set_device (event, gdk_drag_context_get_device (current_context));
|
||||||
|
|
||||||
g_object_unref (event.dnd.window);
|
(*_gdk_event_func) (event, _gdk_event_data);
|
||||||
|
|
||||||
|
gdk_event_free (event);
|
||||||
|
|
||||||
g_object_unref (current_context);
|
g_object_unref (current_context);
|
||||||
current_context = NULL;
|
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
|
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
|
||||||
{
|
{
|
||||||
GdkEvent event;
|
GdkEvent *event;
|
||||||
|
|
||||||
g_assert (_gdk_quartz_drag_source_context != NULL);
|
g_assert (_gdk_quartz_drag_source_context != NULL);
|
||||||
|
|
||||||
event.dnd.type = GDK_DROP_FINISHED;
|
event = gdk_event_new (GDK_DROP_FINISHED);
|
||||||
event.dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
event->dnd.window = g_object_ref ([[self contentView] gdkWindow]);
|
||||||
event.dnd.send_event = FALSE;
|
event->dnd.send_event = FALSE;
|
||||||
event.dnd.context = _gdk_quartz_drag_source_context;
|
event->dnd.context = g_object_ref (_gdk_quartz_drag_source_context);
|
||||||
|
|
||||||
(*_gdk_event_func) (&event, _gdk_event_data);
|
gdk_event_set_device (event,
|
||||||
|
gdk_drag_context_get_device (_gdk_quartz_drag_source_context));
|
||||||
|
|
||||||
g_object_unref (event.dnd.window);
|
(*_gdk_event_func) (event, _gdk_event_data);
|
||||||
|
|
||||||
|
gdk_event_free (event);
|
||||||
|
|
||||||
g_object_unref (_gdk_quartz_drag_source_context);
|
g_object_unref (_gdk_quartz_drag_source_context);
|
||||||
_gdk_quartz_drag_source_context = NULL;
|
_gdk_quartz_drag_source_context = NULL;
|
||||||
|
@ -155,6 +155,9 @@ gdk_drag_begin (GdkWindow *window,
|
|||||||
_gdk_quartz_drag_source_context = gdk_drag_context_new ();
|
_gdk_quartz_drag_source_context = gdk_drag_context_new ();
|
||||||
_gdk_quartz_drag_source_context->is_source = TRUE;
|
_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;
|
return _gdk_quartz_drag_source_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user