]> Pileus Git - ~andy/gtk/commitdiff
Update the RGBA cursor if an icon is set after the cursor has been
authorMatthias Clasen <matthiasc@src.gnome.org>
Thu, 16 Jun 2005 16:06:54 +0000 (16:06 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 16 Jun 2005 16:06:54 +0000 (16:06 +0000)
* gtk/gtkdnd.c: Update the RGBA cursor if an
icon is set after the cursor has been constructed.
Also handle repeated setting of icons correctly.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkdnd.c

index 3a5fb3b35b79fb76fcbb9d3284bb2dd7220fb146..9fb5aca76b717c4ada2fb9afce0e74d525c9b6bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-06-16  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkdnd.c: Update the RGBA cursor if an
+       icon is set after the cursor has been constructed.
+       Also handle repeated setting of icons correctly.
+
 2005-06-16  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkbutton.c (gtk_button_set_image): Add some more
index 3a5fb3b35b79fb76fcbb9d3284bb2dd7220fb146..9fb5aca76b717c4ada2fb9afce0e74d525c9b6bc 100644 (file)
@@ -1,3 +1,9 @@
+2005-06-16  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkdnd.c: Update the RGBA cursor if an
+       icon is set after the cursor has been constructed.
+       Also handle repeated setting of icons correctly.
+
 2005-06-16  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkbutton.c (gtk_button_set_image): Add some more
index 3a5fb3b35b79fb76fcbb9d3284bb2dd7220fb146..9fb5aca76b717c4ada2fb9afce0e74d525c9b6bc 100644 (file)
@@ -1,3 +1,9 @@
+2005-06-16  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkdnd.c: Update the RGBA cursor if an
+       icon is set after the cursor has been constructed.
+       Also handle repeated setting of icons correctly.
+
 2005-06-16  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkbutton.c (gtk_button_set_image): Add some more
index 8e9448a8e4a908e46f490a6b6b9c9757306b03ea..5c35b1e4655e0df74981d56c68f5fe53cf506a47 100644 (file)
  */
 
 #include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+
 #include "gdkconfig.h"
 
 #include "gdk/gdkkeysyms.h"
@@ -196,6 +200,7 @@ static void          gtk_drag_get_event_actions (GdkEvent        *event,
 static GdkCursor *   gtk_drag_get_cursor         (GdkDisplay     *display,
                                                  GdkDragAction   action,
                                                  GtkDragSourceInfo *info);
+static void          gtk_drag_update_cursor      (GtkDragSourceInfo *info);
 static GtkWidget    *gtk_drag_get_ipc_widget     (GdkScreen     *screen);
 static void          gtk_drag_release_ipc_widget (GtkWidget      *widget);
 
@@ -620,7 +625,7 @@ gtk_drag_get_cursor (GdkDisplay        *display,
          for (j = 0; j < 10; j++)
            {
              const gchar *opt;
-             const gchar key[32];
+             gchar key[32];
              gchar **toks;
 
              g_snprintf (key, 32, "comment%d", j);
@@ -726,6 +731,37 @@ gtk_drag_get_cursor (GdkDisplay        *display,
   return drag_cursors[i].cursor;
 }
 
+static void
+gtk_drag_update_cursor (GtkDragSourceInfo *info)
+{
+  GdkCursor *cursor;
+  gint i;
+
+  if (!info->have_grab)
+    return;
+
+  for (i = 0 ; i < n_drag_cursors - 1; i++)
+    if (info->cursor == drag_cursors[i].cursor ||
+       info->cursor == info->drag_cursors[i])
+      break;
+  
+  if (i == n_drag_cursors)
+    return;
+
+  cursor = gtk_drag_get_cursor (gdk_cursor_get_display (info->cursor), 
+                               i, info);
+  
+  if (cursor != info->cursor)
+    {
+      gdk_pointer_grab (info->ipc_widget->window, FALSE,
+                       GDK_POINTER_MOTION_MASK |
+                       GDK_BUTTON_RELEASE_MASK,
+                       NULL,
+                       cursor, info->grab_time);
+      info->cursor = cursor;
+    }
+}
+
 /********************
  * Destination side *
  ********************/
@@ -2125,8 +2161,7 @@ gtk_drag_begin_internal (GtkWidget         *widget,
                               &info->cur_screen, &info->cur_x, &info->cur_y, NULL);
     }
 
-  g_signal_emit_by_name (widget, "drag_begin",
-                        info->context);
+  g_signal_emit_by_name (widget, "drag_begin", info->context);
 
   /* Ensure that we have an icon before we start the drag; the
    * application may have set one in ::drag_begin, or it may
@@ -2724,13 +2759,20 @@ gtk_drag_set_icon_window (GdkDragContext *context,
   gtk_drag_remove_icon (info);
 
   if (widget)
-    gtk_widget_ref (widget);
+    gtk_widget_ref (widget);  
   
   info->icon_window = widget;
   info->hot_x = hot_x;
   info->hot_y = hot_y;
   info->destroy_icon = destroy_on_release;
+
+  if (widget && info->icon_pixbuf)
+    {
+      g_object_unref (info->icon_pixbuf);
+      info->icon_pixbuf = NULL;
+    }
+
+  gtk_drag_update_cursor (info);
   gtk_drag_update_icon (info);
 }
 
@@ -2836,8 +2878,14 @@ set_icon_stock_pixbuf (GdkDragContext    *context,
       GtkDragSourceInfo *info;
 
       gtk_widget_destroy (window);
+
       info = gtk_drag_get_source_info (context, FALSE);
+
+      if (info->icon_pixbuf)
+       g_object_unref (info->icon_pixbuf);
       info->icon_pixbuf = pixbuf;
+
+      gtk_drag_set_icon_window (context, NULL, hot_x, hot_y, TRUE);
     }
   else
     {