# HG changeset patch # User John Lindgren # Date 1241211594 14400 # Node ID 8b97f9560dc301c8c83cb7bd886161886bb92b15 # Parent d73418aa0db3c99036f84045f4c66c85b53eaea3 More clean-up of roll-up code (should fix bug #37; if not, it's a WM problem). diff -r d73418aa0db3 -r 8b97f9560dc3 src/skins/ui_dock.c --- a/src/skins/ui_dock.c Fri May 22 19:11:38 2009 +0900 +++ b/src/skins/ui_dock.c Fri May 01 16:59:54 2009 -0400 @@ -252,168 +252,58 @@ } } -static GList * -shade_move_list(GList * list, GtkWindow * widget, gint offset) -{ - gint x, y, w, h; - GList *node; - DockedWindow *dw; - - gtk_window_get_position(widget, &x, &y); - gtk_window_get_size(widget, &w, &h); - - - for (node = list; node;) { - gint dx, dy, dwidth, dheight; - - dw = node->data; - gtk_window_get_position(dw->w, &dx, &dy); - gtk_window_get_size(dw->w, &dwidth, &dheight); - if (is_docked(x, y, w, h, dx, dy, dwidth, dheight) && - ((dx + dwidth) > x && dx < (x + w))) { - list = g_list_remove_link(list, node); - g_list_free_1(node); - - node = list = shade_move_list(list, dw->w, offset); - } - else - node = g_list_next(node); - } - gtk_window_move(widget, x, y + offset); - return list; -} - -/* - * Builds a list of the windows in the list of DockedWindows "winlist" - * that are docked to the top or bottom of the window, and recursively - * adds all windows that are docked to the top or bottom of that window, - * and so on... - * Note: The data in "winlist" is not copied. - */ -static GList * -find_shade_list(GtkWindow * widget, GList * winlist, GList * shade_list) -{ - gint x, y, w, h; - gint dx, dy, dwidth, dheight; - GList *node; - - gtk_window_get_position(widget, &x, &y); - gtk_window_get_size(widget, &w, &h); - for (node = winlist; node; node = g_list_next(node)) { - DockedWindow *dw = node->data; - if (g_list_find_custom - (shade_list, dw, (GCompareFunc) docked_list_compare)) - continue; - gtk_window_get_position(dw->w, &dx, &dy); - gtk_window_get_size(dw->w, &dwidth, &dheight); - - /* FIXME. Is the is_docked() necessary? */ - if (is_docked(x, y, w, h, dx, dy, dwidth, dheight) && - ((dx + dwidth) > x && dx < (x + w))) { - shade_list = g_list_append(shade_list, dw); - shade_list = find_shade_list(dw->w, winlist, shade_list); - } - } - return shade_list; -} - -void -dock_window_resize(GtkWindow * widget, gint new_w, gint new_h, gint w, gint h) -{ - GdkGeometry hints; - hints.min_width = new_w; - hints.min_height = new_h; - hints.max_width = new_w; - hints.max_height = new_h; - gtk_window_resize (widget, new_w, new_h); - gtk_window_set_geometry_hints (widget, 0, & hints, - GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); +void dock_window_resize (GtkWindow * widget, int width, int height) { + GdkGeometry hints; + hints.min_width = width; + hints.min_height = height; + hints.max_width = width; + hints.max_height = height; + gtk_window_resize (widget, width, height); + gtk_window_set_geometry_hints (widget, 0, & hints, + GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); } -void -dock_shade(GList * window_list, GtkWindow * widget, gint new_h) -{ - gint x, y, w, h, off_y, orig_off_y; - GList *node, *docked_list, *slist; - DockedWindow *dw; - - gtk_window_get_position(widget, &x, &y); - gtk_window_get_size(widget, &w, &h); - - if (config.show_wm_decorations) { - dock_window_resize(widget, w, new_h, w, h); - return; - } - - docked_list = get_docked_list(NULL, window_list, widget, 0, 0); - slist = find_shade_list(widget, docked_list, NULL); - - off_y = new_h - h; - do { - orig_off_y = off_y; - for (node = slist; node; node = g_list_next(node)) { - gint dx, dy, dwidth, dheight; - - dw = node->data; - if (dw->w == widget) - continue; - gtk_window_get_position(dw->w, &dx, &dy); - gtk_window_get_size(dw->w, &dwidth, &dheight); - if ((dy >= y) && ((dy + off_y + dheight) > gdk_screen_height())) - off_y -= (dy + off_y + dheight) - gdk_screen_height(); - else if ((dy >= y) && ((dy + dheight) == gdk_screen_height())) - off_y = 0; +static void move_attached (GtkWindow * window, GList * * others, int offset) { + int x, y, width, height, x2, y2; + GList * move, * scan, * next; + gtk_window_get_position (window, & x, & y); + gtk_window_get_size (window, & width, & height); + move = 0; + for (scan = * others; scan; scan = next) { + next = g_list_next (scan); + gtk_window_get_position (scan->data, & x2, & y2); + if (y2 == y + height) { + * others = g_list_remove_link (* others, scan); + move = g_list_concat (move, scan); + } + } + for (; move; move = g_list_delete_link (move, move)) + move_attached (move->data, others, offset); + gtk_window_move (window, x, y + offset); +} - if (((dy >= y) && ((dy + off_y) < 0))) - off_y -= dy + off_y; - if ((dy < y) && ((dy + (off_y - (new_h - h))) < 0)) - off_y -= dy + (off_y - (new_h - h)); - } - } while (orig_off_y != off_y); - if (slist) { - GList *mlist = g_list_copy(slist); - - /* Remove this widget from the list */ - for (node = mlist; node; node = g_list_next(node)) { - dw = node->data; - if (dw->w == widget) { - mlist = g_list_remove_link(mlist, node); - g_list_free_1(node); - break; - } - } - for (node = mlist; node;) { - GList *temp; - gint dx, dy, dwidth, dheight; - - dw = node->data; - - gtk_window_get_position(dw->w, &dx, &dy); - gtk_window_get_size(dw->w, &dwidth, &dheight); - /* - * Find windows that are directly docked to this window, - * move it, and any windows docked to that window again - */ - if (is_docked(x, y, w, h, dx, dy, dwidth, dheight) && - ((dx + dwidth) > x && dx < (x + w))) { - mlist = g_list_remove_link(mlist, node); - g_list_free_1(node); - if (dy > y) - temp = shade_move_list(mlist, dw->w, off_y); - else if (off_y - (new_h - h) != 0) - temp = shade_move_list(mlist, dw->w, off_y - (new_h - h)); - else - temp = mlist; - node = mlist = temp; - } - else - node = g_list_next(node); - } - g_list_free(mlist); - } - g_list_free(slist); - free_docked_list(docked_list); - dock_window_resize(widget, w, new_h, w, h); +void dock_shade (GList * window_list, GtkWindow * window, int new_height) { + int x, y, width, height, x2, y2; + GList * move, * others, * scan, * next; + if (! config.show_wm_decorations) { + gtk_window_get_position (window, & x, & y); + gtk_window_get_size (window, & width, & height); + others = g_list_copy (window_list); + others = g_list_remove (others, window); + move = 0; + for (scan = others; scan; scan = next) { + next = g_list_next (scan); + gtk_window_get_position (scan->data, & x2, & y2); + if (y2 == y + height) { + others = g_list_remove_link (others, scan); + move = g_list_concat (move, scan); + } + } + for (; move; move = g_list_delete_link (move, move)) + move_attached (move->data, & others, new_height - height); + g_list_free (others); + } + dock_window_resize (window, width, new_height); } void diff -r d73418aa0db3 -r 8b97f9560dc3 src/skins/ui_dock.h --- a/src/skins/ui_dock.h Fri May 22 19:11:38 2009 +0900 +++ b/src/skins/ui_dock.h Fri May 01 16:59:54 2009 -0400 @@ -38,11 +38,11 @@ void dock_move_release(GtkWindow * w); void dock_get_widget_pos(GtkWindow * w, gint * x, gint * y); gboolean dock_is_moving(GtkWindow * w); -void dock_shade(GList * window_list, GtkWindow * widget, gint new_h); +void dock_shade (GList * window_list, GtkWindow * widget, int new_height); GList *dock_window_set_decorated(GList * list, GtkWindow * window, gboolean decorated); -void dock_window_resize(GtkWindow * widget, gint new_w, gint new_h, gint w, gint h); +void dock_window_resize (GtkWindow * widget, int width, int height); GList *get_dock_window_list(); void set_dock_window_list(GList * list); diff -r d73418aa0db3 -r 8b97f9560dc3 src/skins/ui_equalizer.c --- a/src/skins/ui_equalizer.c Fri May 22 19:11:38 2009 +0900 +++ b/src/skins/ui_equalizer.c Fri May 01 16:59:54 2009 -0400 @@ -115,9 +115,9 @@ if (config.scaled) { dock_window_resize(GTK_WINDOW(equalizerwin), 275 * config.scale_factor, - height * config.scale_factor, 275 * config.scale_factor, height * config.scale_factor); + height * config.scale_factor); } else { - dock_window_resize(GTK_WINDOW(equalizerwin), 275, height, 275, height); + dock_window_resize(GTK_WINDOW(equalizerwin), 275, height); } GList *iter; diff -r d73418aa0db3 -r 8b97f9560dc3 src/skins/ui_main.c --- a/src/skins/ui_main.c Fri May 22 19:11:38 2009 +0900 +++ b/src/skins/ui_main.c Fri May 01 16:59:54 2009 -0400 @@ -585,9 +585,7 @@ if (aud_active_skin->properties.mainwin_height && aud_active_skin->properties.mainwin_width) { dock_window_resize(GTK_WINDOW(mainwin), config.player_shaded ? MAINWIN_SHADED_WIDTH * MAINWIN_SCALE_FACTOR : aud_active_skin->properties.mainwin_width * MAINWIN_SCALE_FACTOR, - config.player_shaded ? MAINWIN_SHADED_HEIGHT * MAINWIN_SCALE_FACTOR : aud_active_skin->properties.mainwin_height * MAINWIN_SCALE_FACTOR, - aud_active_skin->properties.mainwin_width * MAINWIN_SCALE_FACTOR, - aud_active_skin->properties.mainwin_height * MAINWIN_SCALE_FACTOR); + config.player_shaded ? MAINWIN_SHADED_HEIGHT * MAINWIN_SCALE_FACTOR : aud_active_skin->properties.mainwin_height * MAINWIN_SCALE_FACTOR); gdk_flush(); } @@ -1644,8 +1642,7 @@ height = aud_active_skin->properties.mainwin_height; dock_window_resize(GTK_WINDOW(mainwin), config.player_shaded ? MAINWIN_SHADED_WIDTH : aud_active_skin->properties.mainwin_width, - config.player_shaded ? MAINWIN_SHADED_HEIGHT : aud_active_skin->properties.mainwin_height, - aud_active_skin->properties.mainwin_width * config.scale_factor , aud_active_skin->properties.mainwin_height * config.scale_factor); + config.player_shaded ? MAINWIN_SHADED_HEIGHT : aud_active_skin->properties.mainwin_height); GList *iter; for (iter = GTK_FIXED (SKINNED_WINDOW(mainwin)->normal)->children; iter; iter = g_list_next (iter)) {