Add the GDK part of the DND implementation.

2006-03-21  Anders Carlsson  <andersca@imendio.com>

        * gdk/quartz/GdkQuartzWindow.c:
        (drag_operation_to_drag_action):
        (drag_action_to_drag_operation):
        (update_context_from_dragging_info):
        (-[GdkQuartzWindow draggingEntered:]):
        (-[GdkQuartzWindow draggingEnded:]):
        (-[GdkQuartzWindow draggingExited:]):
        (-[GdkQuartzWindow draggingUpdated:]):
        (-[GdkQuartzWindow performDragOperation:]):
        (-[GdkQuartzWindow wantsPeriodicDraggingUpdates]):
        (-[GdkQuartzWindow draggedImage:endedAt:operation:]):
        * gdk/quartz/gdkdnd-quartz.c:
        (gdk_drag_context_finalize):
        (gdk_drag_context_init):
        (gdk_drag_context_class_init):
        (gdk_drag_begin):
        (gdk_drag_status):
        Add the GDK part of the DND implementation.

        * gdk/quartz/Makefile.am:
        Add some missing headers.

        * gdk/quartz/gdkdrawable-quartz.h:
        * gdk/quartz/gdkprivate-quartz.h:
        * gdk/quartz/gdkquartz.h:
        * gdk/quartz/gdkwindow-quartz.c:
        (gdk_quartz_window_get_nsview):
        New function, for use by the GTK part of the DND implementation
This commit is contained in:
Anders Carlsson 2006-03-21 08:02:17 +00:00 committed by Anders Carlsson
parent ac3643d8f3
commit 6b1510bf23
9 changed files with 278 additions and 10 deletions

View File

@ -1,3 +1,34 @@
2006-03-21 Anders Carlsson <andersca@imendio.com>
* gdk/quartz/GdkQuartzWindow.c:
(drag_operation_to_drag_action):
(drag_action_to_drag_operation):
(update_context_from_dragging_info):
(-[GdkQuartzWindow draggingEntered:]):
(-[GdkQuartzWindow draggingEnded:]):
(-[GdkQuartzWindow draggingExited:]):
(-[GdkQuartzWindow draggingUpdated:]):
(-[GdkQuartzWindow performDragOperation:]):
(-[GdkQuartzWindow wantsPeriodicDraggingUpdates]):
(-[GdkQuartzWindow draggedImage:endedAt:operation:]):
* gdk/quartz/gdkdnd-quartz.c:
(gdk_drag_context_finalize):
(gdk_drag_context_init):
(gdk_drag_context_class_init):
(gdk_drag_begin):
(gdk_drag_status):
Add the GDK part of the DND implementation.
* gdk/quartz/Makefile.am:
Add some missing headers.
* gdk/quartz/gdkdrawable-quartz.h:
* gdk/quartz/gdkprivate-quartz.h:
* gdk/quartz/gdkquartz.h:
* gdk/quartz/gdkwindow-quartz.c:
(gdk_quartz_window_get_nsview):
New function, for use by the GTK part of the DND implementation
2006-03-21 Anders Carlsson <andersca@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c:

View File

@ -1,3 +1,34 @@
2006-03-21 Anders Carlsson <andersca@imendio.com>
* gdk/quartz/GdkQuartzWindow.c:
(drag_operation_to_drag_action):
(drag_action_to_drag_operation):
(update_context_from_dragging_info):
(-[GdkQuartzWindow draggingEntered:]):
(-[GdkQuartzWindow draggingEnded:]):
(-[GdkQuartzWindow draggingExited:]):
(-[GdkQuartzWindow draggingUpdated:]):
(-[GdkQuartzWindow performDragOperation:]):
(-[GdkQuartzWindow wantsPeriodicDraggingUpdates]):
(-[GdkQuartzWindow draggedImage:endedAt:operation:]):
* gdk/quartz/gdkdnd-quartz.c:
(gdk_drag_context_finalize):
(gdk_drag_context_init):
(gdk_drag_context_class_init):
(gdk_drag_begin):
(gdk_drag_status):
Add the GDK part of the DND implementation.
* gdk/quartz/Makefile.am:
Add some missing headers.
* gdk/quartz/gdkdrawable-quartz.h:
* gdk/quartz/gdkprivate-quartz.h:
* gdk/quartz/gdkquartz.h:
* gdk/quartz/gdkwindow-quartz.c:
(gdk_quartz_window_get_nsview):
New function, for use by the GTK part of the DND implementation
2006-03-21 Anders Carlsson <andersca@imendio.com>
* gdk/quartz/gdkdrawable-quartz.c:

View File

@ -143,4 +143,153 @@
return YES;
}
static GdkDragContext *current_context = NULL;
static GdkDragAction
drag_operation_to_drag_action (NSDragOperation operation)
{
GdkDragAction result = 0;
if (operation & NSDragOperationGeneric)
result |= GDK_ACTION_COPY;
return result;
}
static NSDragOperation
drag_action_to_drag_operation (GdkDragAction action)
{
NSDragOperation result = 0;
if (action & GDK_ACTION_COPY)
result |= NSDragOperationCopy;
return result;
}
static void
update_context_from_dragging_info (id <NSDraggingInfo> sender)
{
g_assert (current_context != NULL);
GDK_DRAG_CONTEXT_PRIVATE (current_context)->dragging_info = sender;
current_context->suggested_action = drag_operation_to_drag_action ([sender draggingSourceOperationMask]);
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
GdkEvent event;
if (current_context)
g_object_unref (current_context);
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;
(*_gdk_event_func) (&event, _gdk_event_data);
return NSDragOperationNone;
}
- (void)draggingEnded:(id <NSDraggingInfo>)sender
{
g_object_unref (current_context);
current_context = NULL;
}
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
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;
(*_gdk_event_func) (&event, _gdk_event_data);
g_object_unref (current_context);
current_context = NULL;
}
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
NSPoint point = [sender draggingLocation];
NSPoint screen_point = [self convertBaseToScreen:point];
GdkEvent event;
update_context_from_dragging_info (sender);
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 = screen_point.x;
event.dnd.y_root = _gdk_quartz_get_inverted_screen_y (screen_point.y);
(*_gdk_event_func) (&event, _gdk_event_data);
g_object_unref (event.dnd.window);
return drag_action_to_drag_operation (current_context->action);
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPoint point = [sender draggingLocation];
NSPoint screen_point = [self convertBaseToScreen:point];
GdkEvent event;
update_context_from_dragging_info (sender);
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 = screen_point.x;
event.dnd.y_root = _gdk_quartz_get_inverted_screen_y (screen_point.y);
(*_gdk_event_func) (&event, _gdk_event_data);
g_object_unref (event.dnd.window);
g_object_unref (current_context);
current_context = NULL;
return YES;
}
- (BOOL)wantsPeriodicDraggingUpdates
{
return NO;
}
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
{
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;
(*_gdk_event_func) (&event, _gdk_event_data);
g_object_unref (event.dnd.window);
g_object_unref (_gdk_quartz_drag_source_context);
_gdk_quartz_drag_source_context = NULL;
}
@end

View File

@ -26,19 +26,23 @@ libgdk_quartz_la_SOURCES = \
gdkdisplay-quartz.c \
gdkdnd-quartz.c \
gdkdrawable-quartz.c \
gdkdrawable-quartz.h \
gdkevents-quartz.c \
gdkfont-quartz.c \
gdkfont-quartz.c \
gdkgc-quartz.c \
gdkgeometry-quartz.c \
gdkglobals-quartz.c \
gdkim-quartz.c \
gdkimage-quartz.c \
gdkinput.c \
gdkkeys-quartz.c \
gdkmain-quartz.c \
gdkkeys-quartz.c \
gdkmain-quartz.c \
gdkpixmap-quartz.c \
gdkpixmap-quartz.h \
gdkproperty-quartz.c \
gdkquartz.h \
gdkscreen-quartz.c \
gdkselection-quartz.c \
gdkvisual-quartz.c \
gdkwindow-quartz.c
gdkwindow-quartz.c \
gdkwindow-quartz.h \

View File

@ -19,17 +19,37 @@
*/
#include "gdkdnd.h"
#include "gdkprivate-quartz.h"
static gpointer parent_class = NULL;
static void
gdk_drag_context_finalize (GObject *object)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
GdkDragContextPrivate *private = GDK_DRAG_CONTEXT_PRIVATE (context);
g_free (private);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gdk_drag_context_init (GdkDragContext *dragcontext)
{
/* FIXME: Implement */
GdkDragContextPrivate *priv = g_new0 (GdkDragContextPrivate, 1);
dragcontext->windowing_data = priv;
}
static void
gdk_drag_context_class_init (GdkDragContextClass *klass)
{
/* FIXME: Implement */
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_drag_context_finalize;
}
GType
@ -79,12 +99,19 @@ gdk_drag_context_unref (GdkDragContext *context)
g_object_unref (context);
}
GdkDragContext *_gdk_quartz_drag_source_context = NULL;
GdkDragContext *
gdk_drag_begin (GdkWindow *window,
GList *targets)
{
/* FIXME: Implement */
return NULL;
g_assert (_gdk_quartz_drag_source_context == NULL);
/* Create fake context */
_gdk_quartz_drag_source_context = gdk_drag_context_new ();
_gdk_quartz_drag_source_context->is_source = TRUE;
return _gdk_quartz_drag_source_context;
}
gboolean
@ -143,7 +170,7 @@ gdk_drag_status (GdkDragContext *context,
GdkDragAction action,
guint32 time)
{
/* FIXME: Implement */
context->action = action;
}
void

View File

@ -22,7 +22,6 @@
#define __GDK_DRAWABLE_QUARTZ_H__
#include <gdk/gdkdrawable.h>
#include <gdk/quartz/gdkquartz.h>
G_BEGIN_DECLS

View File

@ -41,9 +41,12 @@
#define GDK_IS_GC_QUARTZ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_QUARTZ))
#define GDK_GC_QUARTZ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_QUARTZ, GdkGCQuartzClass))
#define GDK_DRAG_CONTEXT_PRIVATE(context) ((GdkDragContextPrivate *) GDK_DRAG_CONTEXT (context)->windowing_data)
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkGCQuartz GdkGCQuartz;
typedef struct _GdkGCQuartzClass GdkGCQuartzClass;
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
struct _GdkGCQuartz
{
@ -72,10 +75,17 @@ struct _GdkCursorPrivate
NSCursor *nscursor;
};
struct _GdkDragContextPrivate
{
id <NSDraggingInfo> dragging_info;
};
extern GdkDisplay *_gdk_display;
extern GdkScreen *_gdk_screen;
extern GdkWindow *_gdk_root;
extern GdkDragContext *_gdk_quartz_drag_source_context;
GType _gdk_gc_quartz_get_type (void);
GdkGC *_gdk_quartz_gc_new (GdkDrawable *drawable,

View File

@ -3,5 +3,14 @@
#include <Quartz/Quartz.h>
#include "gdk/gdkprivate.h"
#include "gdkprivate-quartz.h"
#include "gdkdrawable-quartz.h"
#include "gdkwindow-quartz.h"
G_BEGIN_DECLS
NSView *gdk_quartz_window_get_nsview (GdkWindow *window);
G_END_DECLS
#endif /* __GDK_QUARTZ_H__ */

View File

@ -26,6 +26,14 @@
static gpointer parent_class;
NSView *
gdk_quartz_window_get_nsview (GdkWindow *window)
{
GdkWindowObject *private = (GdkWindowObject *)window;
return ((GdkWindowImplQuartz *)private->impl)->view;
}
static void
gdk_window_impl_quartz_get_size (GdkDrawable *drawable,
gint *width,