summaryrefslogtreecommitdiff
path: root/gtk/gtkdnd.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>1999-02-05 18:40:14 +0000
committerOwen Taylor <otaylor@src.gnome.org>1999-02-05 18:40:14 +0000
commiteb437560d35e11836eea5bac750e6f64e98d8632 (patch)
tree1e88a46cbc949580ba4068b7c6d19ffc1e0b7075 /gtk/gtkdnd.c
parent915f2c5e5991888d8237c1ecee09bda825c20d39 (diff)
downloadgdk-pixbuf-eb437560d35e11836eea5bac750e6f64e98d8632.tar.gz
Adjust saved positions of children when resizing a guffaw_gravity = TRUE
Fri Feb 5 13:23:50 1999 Owen Taylor <otaylor@redhat.com> * gdk/gdkwindow.c (gdk_window_move_resize): Adjust saved positions of children when resizing a guffaw_gravity = TRUE window. * gtk/gtkdnd.c (gtk_drag_highlight): Rework the highlighting so that it is done in callbacks for draw and expose. This should solve problems with multiple highlights for the same GdkWindow. * gtk/gtkdnd.c (gtk_drag_highlight): Fix bug where the highlight was being drawn with an incorrect width/height for !NO_WINDOW widgets.
Diffstat (limited to 'gtk/gtkdnd.c')
-rw-r--r--gtk/gtkdnd.c133
1 files changed, 89 insertions, 44 deletions
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 612f1fc26..6e4adfff6 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -155,6 +155,12 @@ static GdkCursor * gtk_drag_get_cursor (GdkDragAction action);
static GtkWidget *gtk_drag_get_ipc_widget (void);
static void gtk_drag_release_ipc_widget (GtkWidget *widget);
+static void gtk_drag_highlight_paint (GtkWidget *widget);
+static gboolean gtk_drag_highlight_expose (GtkWidget *widget,
+ GdkEventExpose *event,
+ gpointer data);
+
+
static GdkAtom gtk_drag_dest_find_target (GtkWidget *widget,
GtkDragDestSite *site,
GdkDragContext *context);
@@ -650,43 +656,85 @@ gtk_drag_finish (GdkDragContext *context,
}
/*************************************************************
- * gtk_drag_highlight:
- * Highlight the given widget in the default manner.
+ * gtk_drag_highlight_paint:
+ * Paint a highlight indicating drag status onto the widget.
* arguments:
* widget:
* results:
*************************************************************/
-void
-gtk_drag_highlight (GtkWidget *widget)
+static void
+gtk_drag_highlight_paint (GtkWidget *widget)
{
- gint x, y;
+ gint x, y, width, height;
g_return_if_fail (widget != NULL);
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- x = widget->allocation.x;
- y = widget->allocation.y;
- }
- else
+ if (GTK_WIDGET_DRAWABLE (widget))
{
- x = 0;
- y = 0;
+ if (GTK_WIDGET_NO_WINDOW (widget))
+ {
+ x = widget->allocation.x;
+ y = widget->allocation.y;
+ width = widget->allocation.width;
+ height = widget->allocation.height;
+ }
+ else
+ {
+ x = 0;
+ y = 0;
+ gdk_window_get_size (widget->window, &width, &height);
+ }
+
+ gtk_draw_shadow (widget->style, widget->window,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ x, y, width, height);
+
+ gdk_draw_rectangle (widget->window,
+ widget->style->black_gc,
+ FALSE,
+ x, y, width - 1, height - 1);
}
-
- gtk_draw_shadow (widget->style, widget->window,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- x, y,
- widget->allocation.width,
- widget->allocation.height);
-
- gdk_draw_rectangle (widget->window,
- widget->style->black_gc,
- FALSE,
- x, y,
- widget->allocation.width - 1,
- widget->allocation.height - 1);
+}
+
+/*************************************************************
+ * gtk_drag_highlight_expose:
+ * Callback for expose_event for highlighted widgets.
+ * arguments:
+ * widget:
+ * event:
+ * data:
+ * results:
+ *************************************************************/
+
+static gboolean
+gtk_drag_highlight_expose (GtkWidget *widget,
+ GdkEventExpose *event,
+ gpointer data)
+{
+ gtk_drag_highlight_paint (widget);
+ return TRUE;
+}
+
+/*************************************************************
+ * gtk_drag_highlight:
+ * Highlight the given widget in the default manner.
+ * arguments:
+ * widget:
+ * results:
+ *************************************************************/
+
+void
+gtk_drag_highlight (GtkWidget *widget)
+{
+ gtk_signal_connect_after (GTK_OBJECT (widget), "draw",
+ GTK_SIGNAL_FUNC (gtk_drag_highlight_expose),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (widget), "expose_event",
+ GTK_SIGNAL_FUNC (gtk_drag_highlight_paint),
+ NULL);
+
+ gtk_widget_queue_draw (widget);
}
/*************************************************************
@@ -700,25 +748,16 @@ gtk_drag_highlight (GtkWidget *widget)
void
gtk_drag_unhighlight (GtkWidget *widget)
{
- gint x, y;
-
g_return_if_fail (widget != NULL);
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- x = widget->allocation.x;
- y = widget->allocation.y;
- }
- else
- {
- x = 0;
- y = 0;
- }
-
- gdk_window_clear_area_e (widget->window,
- x, y,
- widget->allocation.width,
- widget->allocation.height);
+ gtk_signal_disconnect_by_func (GTK_OBJECT (widget),
+ GTK_SIGNAL_FUNC (gtk_drag_highlight_paint),
+ NULL);
+ gtk_signal_disconnect_by_func (GTK_OBJECT (widget),
+ GTK_SIGNAL_FUNC (gtk_drag_highlight_expose),
+ NULL);
+
+ gtk_widget_queue_clear (widget);
}
/*************************************************************
@@ -1097,6 +1136,12 @@ gtk_drag_find_widget (GtkWidget *widget,
if (data->found || !GTK_WIDGET_MAPPED (widget))
return;
+ /* Note that in the following code, we only count the
+ * position as being inside a WINDOW widget if it is inside
+ * widget->window; points that are outside of widget->window
+ * but within the allocation are not counted. This is consistent
+ * with the way we highlight drag targets.
+ */
if (!GTK_WIDGET_NO_WINDOW (widget))
{
new_allocation.x = 0;
@@ -1412,7 +1457,7 @@ gtk_drag_dest_drop (GtkWidget *widget,
else
{
/* We need to synthesize a motion event, wait for a status,
- * and, if we get one a good one, do a drop.
+ * and, if we get a good one, do a drop.
*/
GdkEvent *current_event;