summaryrefslogtreecommitdiff
path: root/gtk/gtkwidget.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@gtk.org>1998-10-18 22:51:24 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-10-18 22:51:24 +0000
commitf7bcb456072dac59b1ce5bd5329282ba95a3b495 (patch)
treea9085af76de35b5c883776673b7a59521e52c043 /gtk/gtkwidget.c
parent7dbb5755a4cafc45108ec66ac89dfc1f11639494 (diff)
downloadgtk+-f7bcb456072dac59b1ce5bd5329282ba95a3b495.tar.gz
Added a modular client-message-filter mechanism, that is used for the DND
Sun Oct 18 18:16:39 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdk.c gdkprivate.h: Added a modular client-message-filter mechanism, that is used for the DND messages. Removed all the old DND code. * gdk/gdkcolormap.c gdk/gdkcolormap.h: Add a function to get the visual of a given colormap. * gtk/gtkcolorsel.c: Conversion to new DND, drag a color-swatch. * gdk/gdk.h gdk/gdkdnd.c: The low-level X oriented portions of drag and drop protocols. Sending and receiving client messages, and navigating window trees. * gdk/gdkimage.c: added a gdk_flush() when destroying SHM images to hopefully make it more likely that X will gracefully handle the segment being destroyed. * gdk/gdkprivate.h gtk/gtkdebug.h: Add new DND debugging flags. * gtk/gtkeditable.[ch]: Updates for the selection handling changes. * gtk/gtkselection.[ch]: Added GtkTargetList, a refcounted data structure for keeping track of lists of GdkAtom + information. Removed selection_handler_add in favor of a "drag_data_get" signal. * gtk/gtkdnd.[ch] gtk/gtk.h: New files - highlevel (event loop dependent) parts of the DND protocols, display of drag icons, drag-under highlighting, and the "default handlers". * gtk/gtkinvisible.[ch]: New widget - InputOnly offscreen windows that are used for reliable pointer grabs and selection handling in the DND code. * gtk/testdnd.c: New test program for new DND. (Old DND tests in testgtk still need to be converted.) * gtk/testselection.c: Use the new selection API. * docs/dnd_internals: Start at describing how all the new code works inside. * docs/Changes-1.2.txt: New file describing source-incompatible changes in GTK+-1.2. Sat Oct 17 22:50:34 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkwindow.c (gdk_window_remove_filter): Free the right list node. * gdk/gdkwindow.c (gdk_window_init): Add gdk_root_parent to the XID table so we can receive events on it. Wed Oct 14 12:57:40 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.c gdk/gdk.h (gdk_event_get_time): New function to get the timestamp from a generic event. Fri Oct 9 13:16:04 1998 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_add_events): Added function that safely adds additional events to a widget's event mask, even if the widget has previously been realized. (We can do this, but not remove events from the event mask). Fri Oct 2 17:35:35 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdkproperty.c (gdk_property_get): Allow type == 0, for AnyPropertyType. Fri Oct 2 10:32:21 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdkproperty.c (gdk_atom_intern): Add client-local hashing. Thu Sep 24 20:33:54 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.c (gdk_event_send_clientmessage_toall): serial isn't a timestamp. Thu Sep 17 14:23:03 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdk.c (gdk_event_translate): Removed printing of unknown window lookup warnings. (Made it a GDK_NOTE) - they happen in many circumstances.
Diffstat (limited to 'gtk/gtkwidget.c')
-rw-r--r--gtk/gtkwidget.c310
1 files changed, 141 insertions, 169 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 6871d48a4f..218428abe9 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -72,16 +72,18 @@ enum {
SELECTION_CLEAR_EVENT,
SELECTION_REQUEST_EVENT,
SELECTION_NOTIFY_EVENT,
+ SELECTION_GET,
SELECTION_RECEIVED,
PROXIMITY_IN_EVENT,
PROXIMITY_OUT_EVENT,
- DRAG_BEGIN_EVENT,
- DRAG_REQUEST_EVENT,
- DRAG_END_EVENT,
- DROP_ENTER_EVENT,
- DROP_LEAVE_EVENT,
- DROP_DATA_AVAILABLE_EVENT,
- OTHER_EVENT,
+ DRAG_BEGIN,
+ DRAG_END,
+ DRAG_DATA_DELETE,
+ DRAG_LEAVE,
+ DRAG_MOTION,
+ DRAG_DROP,
+ DRAG_DATA_GET,
+ DRAG_DATA_RECEIVED,
CLIENT_EVENT,
NO_EXPOSE_EVENT,
VISIBILITY_NOTIFY_EVENT,
@@ -548,9 +550,20 @@ gtk_widget_class_init (GtkWidgetClass *klass)
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_received),
- gtk_marshal_NONE__ENUM,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_SELECTION_DATA);
+ gtk_marshal_NONE__POINTER_UINT,
+ GTK_TYPE_NONE, 2,
+ GTK_TYPE_SELECTION_DATA,
+ GTK_TYPE_UINT);
+ widget_signals[SELECTION_GET] =
+ gtk_signal_new ("selection_get",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, selection_get),
+ gtk_marshal_NONE__POINTER_UINT_UINT,
+ GTK_TYPE_NONE, 2,
+ GTK_TYPE_SELECTION_DATA,
+ GTK_TYPE_UINT,
+ GTK_TYPE_UINT);
widget_signals[PROXIMITY_IN_EVENT] =
gtk_signal_new ("proximity_in_event",
GTK_RUN_LAST,
@@ -567,55 +580,83 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
GTK_TYPE_GDK_EVENT);
- widget_signals[DRAG_BEGIN_EVENT] =
- gtk_signal_new ("drag_begin_event",
+ widget_signals[DRAG_LEAVE] =
+ gtk_signal_new ("drag_leave",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_begin_event),
- gtk_marshal_BOOL__POINTER,
- GTK_TYPE_BOOL, 1,
- GTK_TYPE_GDK_EVENT);
- widget_signals[DRAG_REQUEST_EVENT] =
- gtk_signal_new ("drag_request_event",
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_leave),
+ gtk_marshal_NONE__POINTER_UINT,
+ GTK_TYPE_NONE, 2,
+ GTK_TYPE_GDK_DRAG_CONTEXT,
+ GTK_TYPE_UINT);
+ widget_signals[DRAG_BEGIN] =
+ gtk_signal_new ("drag_begin",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_request_event),
- gtk_marshal_BOOL__POINTER,
- GTK_TYPE_BOOL, 1,
- GTK_TYPE_GDK_EVENT);
- widget_signals[DRAG_END_EVENT] =
- gtk_signal_new ("drag_end_event",
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_begin),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_GDK_DRAG_CONTEXT);
+ widget_signals[DRAG_END] =
+ gtk_signal_new ("drag_end",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_end_event),
- gtk_marshal_BOOL__POINTER,
- GTK_TYPE_BOOL, 1,
- GTK_TYPE_GDK_EVENT);
- widget_signals[DROP_ENTER_EVENT] =
- gtk_signal_new ("drop_enter_event",
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_end),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_GDK_DRAG_CONTEXT);
+ widget_signals[DRAG_DATA_DELETE] =
+ gtk_signal_new ("drag_data_delete",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (GtkWidgetClass, drop_enter_event),
- gtk_marshal_BOOL__POINTER,
- GTK_TYPE_BOOL, 1,
- GTK_TYPE_GDK_EVENT);
- widget_signals[DROP_LEAVE_EVENT] =
- gtk_signal_new ("drop_leave_event",
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_delete),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_GDK_DRAG_CONTEXT);
+ widget_signals[DRAG_MOTION] =
+ gtk_signal_new ("drag_motion",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (GtkWidgetClass, drop_leave_event),
- gtk_marshal_BOOL__POINTER,
- GTK_TYPE_BOOL, 1,
- GTK_TYPE_GDK_EVENT);
- widget_signals[DROP_DATA_AVAILABLE_EVENT] =
- gtk_signal_new ("drop_data_available_event",
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_motion),
+ gtk_marshal_BOOL__POINTER_INT_INT_UINT,
+ GTK_TYPE_BOOL, 4,
+ GTK_TYPE_GDK_DRAG_CONTEXT,
+ GTK_TYPE_INT,
+ GTK_TYPE_INT,
+ GTK_TYPE_UINT);
+ widget_signals[DRAG_DROP] =
+ gtk_signal_new ("drag_drop",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (GtkWidgetClass,
- drop_data_available_event),
- gtk_marshal_BOOL__POINTER,
- GTK_TYPE_BOOL, 1,
- GTK_TYPE_GDK_EVENT);
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_drop),
+ gtk_marshal_BOOL__POINTER_INT_INT_UINT,
+ GTK_TYPE_BOOL, 4,
+ GTK_TYPE_GDK_DRAG_CONTEXT,
+ GTK_TYPE_INT,
+ GTK_TYPE_INT,
+ GTK_TYPE_UINT);
+ widget_signals[DRAG_DATA_GET] =
+ gtk_signal_new ("drag_data_get",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_get),
+ gtk_marshal_NONE__POINTER_POINTER_UINT_UINT,
+ GTK_TYPE_NONE, 4,
+ GTK_TYPE_GDK_DRAG_CONTEXT,
+ GTK_TYPE_SELECTION_DATA,
+ GTK_TYPE_UINT,
+ GTK_TYPE_UINT);
+ widget_signals[DRAG_DATA_RECEIVED] =
+ gtk_signal_new ("drag_data_received",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GtkWidgetClass, drag_data_received),
+ gtk_marshal_NONE__POINTER_POINTER_UINT_UINT,
+ GTK_TYPE_NONE, 4,
+ GTK_TYPE_GDK_DRAG_CONTEXT,
+ GTK_TYPE_SELECTION_DATA,
+ GTK_TYPE_UINT,
+ GTK_TYPE_UINT);
widget_signals[VISIBILITY_NOTIFY_EVENT] =
gtk_signal_new ("visibility_notify_event",
GTK_RUN_LAST,
@@ -640,14 +681,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_marshal_BOOL__POINTER,
GTK_TYPE_BOOL, 1,
GTK_TYPE_GDK_EVENT);
- widget_signals[OTHER_EVENT] =
- gtk_signal_new ("other_event",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (GtkWidgetClass, other_event),
- gtk_marshal_BOOL__POINTER,
- GTK_TYPE_BOOL, 1,
- GTK_TYPE_GDK_EVENT);
widget_signals[DEBUG_MSG] =
gtk_signal_new ("debug_msg",
GTK_RUN_LAST | GTK_RUN_ACTION,
@@ -706,13 +739,15 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->selection_received = NULL;
klass->proximity_in_event = NULL;
klass->proximity_out_event = NULL;
- klass->drag_begin_event = NULL;
- klass->drag_request_event = NULL;
- klass->drop_enter_event = NULL;
- klass->drop_leave_event = NULL;
- klass->drop_data_available_event = NULL;
+ klass->drag_begin = NULL;
+ klass->drag_end = NULL;
+ klass->drag_data_delete = NULL;
+ klass->drag_leave = NULL;
+ klass->drag_motion = NULL;
+ klass->drag_drop = NULL;
+ klass->drag_data_received = NULL;
+
klass->no_expose_event = NULL;
- klass->other_event = NULL;
klass->debug_msg = gtk_widget_debug_msg;
}
@@ -2071,24 +2106,6 @@ gtk_widget_event (GtkWidget *widget,
case GDK_PROXIMITY_OUT:
signal_num = PROXIMITY_OUT_EVENT;
break;
- case GDK_DRAG_BEGIN:
- signal_num = DRAG_BEGIN_EVENT;
- break;
- case GDK_DRAG_REQUEST:
- signal_num = DRAG_REQUEST_EVENT;
- break;
- case GDK_DROP_ENTER:
- signal_num = DROP_ENTER_EVENT;
- break;
- case GDK_DROP_LEAVE:
- signal_num = DROP_LEAVE_EVENT;
- break;
- case GDK_DROP_DATA_AVAIL:
- signal_num = DROP_DATA_AVAILABLE_EVENT;
- break;
- case GDK_OTHER_EVENT:
- signal_num = OTHER_EVENT;
- break;
case GDK_NO_EXPOSE:
signal_num = NO_EXPOSE_EVENT;
break;
@@ -3000,6 +3017,51 @@ gtk_widget_set_events (GtkWidget *widget,
}
/*****************************************
+ * gtk_widget_add_events:
+ *
+ * arguments:
+ *
+ * results:
+ *****************************************/
+
+void
+gtk_widget_add_events (GtkWidget *widget,
+ gint events)
+{
+ gint *eventp;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (!GTK_WIDGET_NO_WINDOW (widget));
+
+ eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), event_key_id);
+
+ if (events)
+ {
+ if (!eventp)
+ {
+ eventp = g_new (gint, 1);
+ *eventp = 0;
+ }
+
+ *eventp |= events;
+ if (!event_key_id)
+ event_key_id = g_quark_from_static_string (event_key);
+ gtk_object_set_data_by_id (GTK_OBJECT (widget), event_key_id, eventp);
+ }
+ else if (eventp)
+ {
+ g_free (eventp);
+ gtk_object_remove_data_by_id (GTK_OBJECT (widget), event_key_id);
+ }
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ gdk_window_set_events (widget->window,
+ gdk_window_get_events (widget->window) | events);
+ }
+}
+
+/*****************************************
* gtk_widget_set_extension_events:
*
* arguments:
@@ -3949,96 +4011,6 @@ gtk_widget_shape_combine_mask (GtkWidget *widget,
}
}
-/*****************************************
- * gtk_widget_dnd_drag_add:
- * when you get a DRAG_ENTER event, you can use this
- * to tell Gtk ofother widgets that are to be dragged as well
- *
- * arguments:
- *
- * results:
- *****************************************/
-void
-gtk_widget_dnd_drag_add (GtkWidget *widget)
-{
-}
-
-/*****************************************
- * gtk_widget_dnd_drag_set:
- * these two functions enable drag and/or drop on a
- * widget and also let Gtk know what data types will be accepted
- * use MIME type naming,plus tacking "URL:" on the front for link
- * dragging
- *
- *
- * arguments:
- *
- * results:
- *****************************************/
-void
-gtk_widget_dnd_drag_set (GtkWidget *widget,
- guint8 drag_enable,
- gchar **type_accept_list,
- guint numtypes)
-{
- g_return_if_fail(widget != NULL);
-
- if (!widget->window)
- gtk_widget_realize (widget);
-
- g_return_if_fail (widget->window != NULL);
- gdk_window_dnd_drag_set (widget->window,
- drag_enable,
- type_accept_list,
- numtypes);
-}
-
-/*****************************************
- * gtk_widget_dnd_drop_set:
- *
- * arguments:
- *
- * results:
- *****************************************/
-void
-gtk_widget_dnd_drop_set (GtkWidget *widget,
- guint8 drop_enable,
- gchar **type_accept_list,
- guint numtypes,
- guint8 is_destructive_operation)
-{
- g_return_if_fail(widget != NULL);
-
- if (!widget->window)
- gtk_widget_realize (widget);
-
- g_return_if_fail (widget->window != NULL);
- gdk_window_dnd_drop_set (widget->window,
- drop_enable,
- type_accept_list,
- numtypes,
- is_destructive_operation);
-}
-
-/*****************************************
- * gtk_widget_dnd_data_set:
- *
- * arguments:
- *
- * results:
- *****************************************/
-void
-gtk_widget_dnd_data_set (GtkWidget *widget,
- GdkEvent *event,
- gpointer data,
- gulong data_numbytes)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (widget->window != NULL);
-
- gdk_window_dnd_data_set (widget->window, event, data, data_numbytes);
-}
-
void
gtk_widget_ref (GtkWidget *widget)
{