changeset 1045:238cd31c1512 trunk

[svn] - make playlist moveable again
author nenolod
date Sun, 14 May 2006 11:35:41 -0700
parents d4ecce9b5190
children 18ef6f3089d4
files audacious/ui_playlist.c
diffstat 1 files changed, 34 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/audacious/ui_playlist.c	Sun May 14 11:23:22 2006 -0700
+++ b/audacious/ui_playlist.c	Sun May 14 11:35:41 2006 -0700
@@ -573,6 +573,10 @@
         if (cfg.playlist_transparent)
             playlistwin_update_list();
 #endif
+    gtk_object_remove_data(GTK_OBJECT(playlistwin), "is_moving");
+    gtk_object_remove_data(GTK_OBJECT(playlistwin), "offset_x");
+    gtk_object_remove_data(GTK_OBJECT(playlistwin), "offset_y");
+
     handle_release_cb(playlistwin_wlist, widget, event);
     playlist_popup_destroy();
     draw_playlist_window(FALSE);
@@ -692,8 +696,25 @@
 {
     GdkEvent *gevent;
 
-    handle_motion_cb(playlistwin_wlist, widget, event);
-    draw_playlist_window(FALSE);
+    if (gtk_object_get_data(GTK_OBJECT(playlistwin), "is_moving"))
+    {
+        gint offset_x, offset_y, mx, my, x, y;
+
+        offset_x = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(playlistwin), "offset_x"));
+        offset_y = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(playlistwin), "offset_y"));
+
+        gdk_window_get_pointer(NULL, &mx, &my, NULL);
+
+        x = mx - offset_x;
+        y = my - offset_y;
+
+        gtk_window_move(GTK_WINDOW(playlistwin), x, y);
+    }
+    else
+    {
+        handle_motion_cb(playlistwin_wlist, widget, event);
+        draw_playlist_window(FALSE);
+    }
 
     gdk_flush();
 
@@ -1088,8 +1109,17 @@
                               GDK_TARGET_STRING, event->time);
     }
     else if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
-             !inside_sensitive_widgets(event->x, event->y) && event->y < 14) {
-        gdk_window_raise(playlistwin->window);
+             !inside_sensitive_widgets(event->x, event->y) && event->y < 14)
+    {
+        gint mx, my;
+
+        gdk_window_get_pointer(GDK_WINDOW(playlistwin->window), &mx, &my, NULL);
+
+        gtk_object_set_data(GTK_OBJECT(playlistwin), "offset_x", GINT_TO_POINTER(mx));
+        gtk_object_set_data(GTK_OBJECT(playlistwin), "offset_y", GINT_TO_POINTER(my));
+
+        gtk_object_set_data(GTK_OBJECT(playlistwin), "is_moving", GINT_TO_POINTER(1));
+        gtk_window_present(GTK_WINDOW(playlistwin));
     }
     else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS &&
              !inside_sensitive_widgets(event->x, event->y)