changeset 3137:19908efce4e5 trunk

one mutex is enough for resizing
author Tomasz Mon <desowin@gmail.com>
date Sat, 21 Jul 2007 20:25:56 +0200
parents cfd7f8d144fa
children c7fca96bfc78 670c41ca0147
files src/audacious/ui_playlist.c src/audacious/ui_skinned_button.c src/audacious/ui_skinned_playlist_slider.c src/audacious/ui_skinned_textbox.c
diffstat 4 files changed, 18 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/ui_playlist.c	Sat Jul 21 20:13:01 2007 +0200
+++ b/src/audacious/ui_playlist.c	Sat Jul 21 20:25:56 2007 +0200
@@ -65,6 +65,8 @@
 
 GtkWidget *playlistwin;
 
+static GMutex *resize_mutex = NULL;
+
 PlayList_List *playlistwin_list = NULL;
 GtkWidget *playlistwin_shade, *playlistwin_close;
 
@@ -669,7 +671,7 @@
     cfg.playlist_width = width = tx;
     cfg.playlist_height = height = ty;
 
-
+    g_mutex_lock(resize_mutex);
     widget_resize_relative(WIDGET(playlistwin_list), dx, dy);
 
     ui_skinned_playlist_slider_move_relative(playlistwin_slider, dx);
@@ -708,6 +710,7 @@
     widget_list_draw(playlistwin_wlist, &redraw, TRUE);
     widget_list_clear_redraw(playlistwin_wlist);
 
+    g_mutex_unlock(resize_mutex);
     widget_list_unlock(playlistwin_wlist);
 
     gdk_window_set_back_pixmap(playlistwin->window, playlistwin_bg, 0);
@@ -1771,6 +1774,7 @@
 void
 playlistwin_create(void)
 {
+    resize_mutex = g_mutex_new();
     playlistwin_create_window();
 
     /* create GC and back pixmap for custom widget to draw on */
--- a/src/audacious/ui_skinned_button.c	Sat Jul 21 20:13:01 2007 +0200
+++ b/src/audacious/ui_skinned_button.c	Sat Jul 21 20:25:56 2007 +0200
@@ -25,8 +25,6 @@
 #define UI_SKINNED_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_button_get_type(), UiSkinnedButtonPrivate))
 typedef struct _UiSkinnedButtonPrivate UiSkinnedButtonPrivate;
 
-static GMutex *mutex = NULL;
-
 enum {
     PRESSED,
     RELEASED,
@@ -170,7 +168,6 @@
 
 static void ui_skinned_button_init (UiSkinnedButton *button) {
     UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
-    mutex = g_mutex_new();
     button->inside = FALSE;
     button->type = TYPE_NOT_SET;
     priv->move_x = 0;
@@ -272,7 +269,6 @@
 }
 
 static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
-    g_mutex_lock(mutex);
     UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
     UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
     widget->allocation = *allocation;
@@ -287,12 +283,13 @@
             gdk_window_move_resize(widget->window, allocation->x*(1+priv->double_size), allocation->y*(1+priv->double_size), allocation->width, allocation->height);
     }
 
+    if (button->x + priv->move_x == widget->allocation.x/(priv->double_size ? 2 : 1))
+        priv->move_x = 0;
+    if (button->y + priv->move_y == widget->allocation.y/(priv->double_size ? 2 : 1))
+        priv->move_y = 0;
+
     button->x = widget->allocation.x/(priv->double_size ? 2 : 1);
     button->y = widget->allocation.y/(priv->double_size ? 2 : 1);
-    priv->move_x = 0;
-    priv->move_y = 0;
-
-    g_mutex_unlock(mutex);
 }
 
 static gboolean ui_skinned_button_expose(GtkWidget *widget, GdkEventExpose *event) {
@@ -523,13 +520,11 @@
 }
 
 static void ui_skinned_button_redraw(UiSkinnedButton *button) {
-    g_mutex_lock(mutex);
     UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
     if (priv->move_x || priv->move_y)
         gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(button), button->x+priv->move_x, button->y+priv->move_y);
 
     gtk_widget_queue_draw(GTK_WIDGET(button));
-    g_mutex_unlock(mutex);
 }
 
 
@@ -557,9 +552,7 @@
 }
 
 void ui_skinned_button_move_relative(GtkWidget *button, gint x, gint y) {
-    g_mutex_lock(mutex);
     UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
     priv->move_x += x;
     priv->move_y += y;
-    g_mutex_unlock(mutex);
 }
--- a/src/audacious/ui_skinned_playlist_slider.c	Sat Jul 21 20:13:01 2007 +0200
+++ b/src/audacious/ui_skinned_playlist_slider.c	Sat Jul 21 20:25:56 2007 +0200
@@ -30,8 +30,6 @@
 #include "util.h"
 #include "ui_playlist.h"
 
-static GMutex *mutex = NULL;
-
 #define UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_playlist_slider_get_type(), UiSkinnedPlaylistSliderPrivate))
 typedef struct _UiSkinnedPlaylistSliderPrivate UiSkinnedPlaylistSliderPrivate;
 
@@ -117,7 +115,6 @@
 
 static void ui_skinned_playlist_slider_init(UiSkinnedPlaylistSlider *playlist_slider) {
     UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(playlist_slider);
-    mutex = g_mutex_new();
     playlist_slider->pressed = FALSE;
     priv->resize_height = 0;
     priv->move_x = 0;
@@ -190,7 +187,6 @@
 }
 
 static void ui_skinned_playlist_slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
-    g_mutex_lock(mutex);
     UiSkinnedPlaylistSlider *playlist_slider = UI_SKINNED_PLAYLIST_SLIDER (widget);
     UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(playlist_slider);
 
@@ -198,17 +194,16 @@
     if (GTK_WIDGET_REALIZED (widget))
         gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
 
+    if (playlist_slider->x + priv->move_x == widget->allocation.x)
+        priv->move_x = 0;
     playlist_slider->x = widget->allocation.x;
     playlist_slider->y = widget->allocation.y;
 
-    priv->move_x = 0;
-
     if (priv->height != widget->allocation.height) {
         priv->height = priv->height + priv->resize_height;
         priv->resize_height = 0;
         gtk_widget_queue_draw(widget);
     }
-    g_mutex_unlock(mutex);
 }
 
 static gboolean ui_skinned_playlist_slider_expose(GtkWidget *widget, GdkEventExpose *event) {
@@ -307,7 +302,6 @@
 }
 
 static void ui_skinned_playlist_slider_redraw(UiSkinnedPlaylistSlider *playlist_slider) {
-    g_mutex_lock(mutex);
     UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(playlist_slider);
 
     if (priv->resize_height)
@@ -316,19 +310,14 @@
         gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(playlist_slider), playlist_slider->x+priv->move_x, playlist_slider->y);
 
     gtk_widget_queue_draw(GTK_WIDGET(playlist_slider));
-    g_mutex_unlock(mutex);
 }
 
 void ui_skinned_playlist_slider_move_relative(GtkWidget *widget, gint x) {
-    g_mutex_lock(mutex);
     UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(widget);
     priv->move_x += x;
-    g_mutex_unlock(mutex);
 }
 
 void ui_skinned_playlist_slider_resize_relative(GtkWidget *widget, gint h) {
-    g_mutex_lock(mutex);
     UiSkinnedPlaylistSliderPrivate *priv = UI_SKINNED_PLAYLIST_SLIDER_GET_PRIVATE(widget);
     priv->resize_height += h;
-    g_mutex_unlock(mutex);
 }
--- a/src/audacious/ui_skinned_textbox.c	Sat Jul 21 20:13:01 2007 +0200
+++ b/src/audacious/ui_skinned_textbox.c	Sat Jul 21 20:25:56 2007 +0200
@@ -34,8 +34,6 @@
 #define UI_SKINNED_TEXTBOX_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_textbox_get_type(), UiSkinnedTextboxPrivate))
 typedef struct _UiSkinnedTextboxPrivate UiSkinnedTextboxPrivate;
 
-static GMutex *mutex = NULL;
-
 #define TEXTBOX_SCROLL_SMOOTH_TIMEOUT  30
 #define TEXTBOX_SCROLL_WAIT            80
 
@@ -167,7 +165,6 @@
 
 static void ui_skinned_textbox_init(UiSkinnedTextbox *textbox) {
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
-    mutex = g_mutex_new();
     priv->resize_width = 0;
     priv->resize_height = 0;
     priv->move_x = 0;
@@ -252,7 +249,6 @@
 }
 
 static void ui_skinned_textbox_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
-    g_mutex_lock(mutex);
     UiSkinnedTextbox *textbox = UI_SKINNED_TEXTBOX (widget);
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
 
@@ -262,21 +258,23 @@
     if (GTK_WIDGET_REALIZED (widget))
         gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
 
+    if (textbox->x + priv->move_x == widget->allocation.x/(priv->double_size ? 2 : 1))
+        priv->move_x = 0;
+    if (textbox->y + priv->move_y == widget->allocation.y/(priv->double_size ? 2 : 1))
+        priv->move_y = 0;
     textbox->x = widget->allocation.x/(priv->double_size ? 2 : 1);
     textbox->y = widget->allocation.y/(priv->double_size ? 2 : 1);
-    priv->move_x = 0;
-    priv->move_y = 0;
 
     if (textbox->width != widget->allocation.width/(priv->double_size ? 2 : 1)) {
+        if (textbox->width + priv->resize_width == widget->allocation.width/(priv->double_size ? 2 : 1))
+            priv->resize_width = 0;
         textbox->width = widget->allocation.width/(priv->double_size ? 2 : 1);
-        priv->resize_width = 0;
         priv->resize_height = 0;
         if (priv->pixmap_text) g_free(priv->pixmap_text);
         priv->pixmap_text = NULL;
         priv->offset = 0;
         gtk_widget_queue_draw(GTK_WIDGET(textbox));
     }
-    g_mutex_unlock(mutex);
 }
 
 static gboolean ui_skinned_textbox_expose(GtkWidget *widget, GdkEventExpose *event) {
@@ -431,7 +429,6 @@
 }
 
 static void ui_skinned_textbox_redraw(UiSkinnedTextbox *textbox) {
-    g_mutex_lock(mutex);
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(textbox);
 
     if (priv->resize_width || priv->resize_height)
@@ -442,7 +439,6 @@
         gtk_fixed_move(GTK_FIXED(priv->fixed), GTK_WIDGET(textbox), textbox->x+priv->move_x, textbox->y+priv->move_y);
 
     gtk_widget_queue_draw(GTK_WIDGET(textbox));
-    g_mutex_unlock(mutex);
 }
 
 static gboolean ui_skinned_textbox_should_scroll(UiSkinnedTextbox *textbox) {
@@ -886,17 +882,13 @@
 }
 
 void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y) {
-    g_mutex_lock(mutex);
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget);
     priv->move_x += x;
     priv->move_y += y;
-    g_mutex_unlock(mutex);
 }
 
 void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h) {
-    g_mutex_lock(mutex);
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE(widget);
     priv->resize_width += w;
     priv->resize_height += h;
-    g_mutex_unlock(mutex);
 }