annotate audacious/dock.c @ 666:778737af1e80 trunk

[svn] directory creation
author nenolod
date Thu, 23 Feb 2006 16:09:56 -0800
parents fc968772e096
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #include "dock.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #include <gdk/gdk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include "main.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <gdk/gdkx.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <X11/Xlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 struct _DockedWindow {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 GtkWindow *w;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 gint offset_x, offset_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 typedef struct _DockedWindow DockedWindow;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 static gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 docked_list_compare(DockedWindow * a, DockedWindow * b)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 if (a->w == b->w)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 return 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 return 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 snap_edge(gint * x, gint * y, gint w, gint h, gint bx, gint by,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 gint bw, gint bh)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 gint sd = cfg.snap_distance;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 if ((*x + w > bx - sd) && (*x + w < bx + sd) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 (*y > by - h - sd) && (*y < by + bh + sd)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 *x = bx - w;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 if ((*y > by - sd) && (*y < by + sd))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 *y = by;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 if ((*y + h > by + bh - sd) && (*y + h < by + bh + sd))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 *y = by + bh - h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 if ((*x > bx + bw - sd) && (*x < bx + bw + sd) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 (*y > by - h - sd) && (*y < by + bh + sd)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 *x = bx + bw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 if ((*y > by - sd) && (*y < by + sd))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 *y = by;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 if ((*y + h > by + bh - sd) && (*y + h < by + bh + sd))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 *y = by + bh - h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 snap(gint * x, gint * y, gint w, gint h, gint bx, gint by, gint bw, gint bh)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 snap_edge(x, y, w, h, bx, by, bw, bh);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 snap_edge(y, x, h, w, by, bx, bh, bw);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 calc_snap_offset(GList * dlist, GList * wlist, gint x, gint y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 gint * off_x, gint * off_y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 gint nx, ny, nw, nh, sx, sy, sw, sh;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 GtkWindow *w;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 GList *dnode, *wnode;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 DockedWindow temp, *dw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 *off_x = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 *off_y = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 if (!cfg.snap_windows)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 * FIXME: Why not break out of the loop when we find someting
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 * to snap to?
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 for (dnode = dlist; dnode; dnode = g_list_next(dnode)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 dw = dnode->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 gtk_window_get_size(dw->w, &nw, &nh);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 nx = dw->offset_x + *off_x + x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 ny = dw->offset_y + *off_y + y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 /* Snap to screen edges */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 if (abs(nx) < cfg.snap_distance)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 *off_x -= nx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 if (abs(ny) < cfg.snap_distance)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 *off_y -= ny;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 if (abs(nx + nw - gdk_screen_width()) < cfg.snap_distance)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 *off_x -= nx + nw - gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 if (abs(ny + nh - gdk_screen_height()) < cfg.snap_distance)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 *off_y -= ny + nh - gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 /* Snap to other windows */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 for (wnode = wlist; wnode; wnode = g_list_next(wnode)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 temp.w = wnode->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 if (g_list_find_custom
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 (dlist, &temp, (GCompareFunc) docked_list_compare))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 /* These windows are already docked */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 w = GTK_WINDOW(wnode->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 gtk_window_get_position(w, &sx, &sy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 gtk_window_get_size(w, &sw, &sh);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 nx = dw->offset_x + *off_x + x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 ny = dw->offset_y + *off_y + y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 snap(&nx, &ny, nw, nh, sx, sy, sw, sh);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 *off_x += nx - (dw->offset_x + *off_x + x);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 *off_y += ny - (dw->offset_y + *off_y + y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 is_docked(gint a_x, gint a_y, gint a_w, gint a_h,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 gint b_x, gint b_y, gint b_w, gint b_h)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 if (((a_x == b_x + b_w) || (a_x + a_w == b_x)) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 (b_y + b_h >= a_y) && (b_y <= a_y + a_h))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 if (((a_y == b_y + b_h) || (a_y + a_h == b_y)) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 (b_x >= a_x - b_w) && (b_x <= a_x + a_w))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 * Builds a list of all windows that are docked to the window "w".
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 * Recursively adds all windows that are docked to the windows that are
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 * docked to "w" and so on...
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 * FIXME: init_off_? ?
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 static GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 get_docked_list(GList * dlist, GList * wlist, GtkWindow * w,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 gint init_off_x, gint init_off_y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 DockedWindow *dwin, temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 gint w_x, w_y, w_width, w_height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 gint t_x, t_y, t_width, t_height;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 gtk_window_get_position(w, &w_x, &w_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 gtk_window_get_size(w, &w_width, &w_height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 if (!dlist) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 dwin = g_new0(DockedWindow, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 dwin->w = w;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 dlist = g_list_append(dlist, dwin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 for (node = wlist; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 temp.w = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 if (g_list_find_custom
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 (dlist, &temp, (GCompareFunc) docked_list_compare))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 gtk_window_get_position(GTK_WINDOW(node->data), &t_x, &t_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 gtk_window_get_size(GTK_WINDOW(node->data), &t_width, &t_height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 if (is_docked
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 (w_x, w_y, w_width, w_height, t_x, t_y, t_width, t_height)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 dwin = g_new0(DockedWindow, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 dwin->w = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 dwin->offset_x = t_x - w_x + init_off_x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 dwin->offset_y = t_y - w_y + init_off_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 dlist = g_list_append(dlist, dwin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 dlist =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 get_docked_list(dlist, wlist, dwin->w, dwin->offset_x,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 dwin->offset_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 return dlist;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 free_docked_list(GList * dlist)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 for (node = dlist; node; node = g_list_next(node))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 g_free(node->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 g_list_free(dlist);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 docked_list_move(GList * list, gint x, gint y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 DockedWindow *dw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 for (node = list; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 gtk_window_move(dw->w, x + dw->offset_x, y + dw->offset_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 gdk_flush();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 static GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 shade_move_list(GList * list, GtkWindow * widget, gint offset)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 gint x, y, w, h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 DockedWindow *dw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 gtk_window_get_position(widget, &x, &y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 gtk_window_get_size(widget, &w, &h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 for (node = list; node;) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 gint dx, dy, dwidth, dheight;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 if (is_docked(x, y, w, h, dx, dy, dwidth, dheight) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 ((dx + dwidth) > x && dx < (x + w))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 list = g_list_remove_link(list, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 g_list_free_1(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 node = list = shade_move_list(list, dw->w, offset);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 node = g_list_next(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 gtk_window_move(widget, x, y + offset);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 return list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 * Builds a list of the windows in the list of DockedWindows "winlist"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 * that are docked to the top or bottom of the window, and recursively
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 * adds all windows that are docked to the top or bottom of that window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 * and so on...
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 * Note: The data in "winlist" is not copied.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 static GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 find_shade_list(GtkWindow * widget, GList * winlist, GList * shade_list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 gint x, y, w, h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 gint dx, dy, dwidth, dheight;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 gtk_window_get_position(widget, &x, &y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 gtk_window_get_size(widget, &w, &h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 for (node = winlist; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 DockedWindow *dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 if (g_list_find_custom
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 (shade_list, dw, (GCompareFunc) docked_list_compare))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 /* FIXME. Is the is_docked() necessary? */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 if (is_docked(x, y, w, h, dx, dy, dwidth, dheight) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 ((dx + dwidth) > x && dx < (x + w))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 shade_list = g_list_append(shade_list, dw);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 shade_list = find_shade_list(dw->w, winlist, shade_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 return shade_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294 dock_window_resize(GtkWindow * widget, gint new_w, gint new_h, gint w, gint h)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 gdk_window_set_hints(GTK_WIDGET(widget)->window, 0, 0, MIN(w, new_w),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297 MIN(h, new_h), MAX(w, new_w), MAX(h, new_h),
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 gdk_window_resize(GTK_WIDGET(widget)->window, new_w, new_h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300 gdk_window_set_hints(GTK_WIDGET(widget)->window, 0, 0, new_w, new_h,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301 new_w, new_h, GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305 dock_shade(GList * window_list, GtkWindow * widget, gint new_h)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307 gint x, y, w, h, off_y, orig_off_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 GList *node, *docked_list, *slist;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 DockedWindow *dw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311 gtk_window_get_position(widget, &x, &y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 gtk_window_get_size(widget, &w, &h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314 if (cfg.show_wm_decorations) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 dock_window_resize(widget, w, new_h, w, h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 docked_list = get_docked_list(NULL, window_list, widget, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320 slist = find_shade_list(widget, docked_list, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 off_y = new_h - h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324 orig_off_y = off_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 for (node = slist; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326 gint dx, dy, dwidth, dheight;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 if (dw->w == widget)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330 continue;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333 if ((dy >= y) && ((dy + off_y + dheight) > gdk_screen_height()))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 off_y -= (dy + off_y + dheight) - gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 else if ((dy >= y) && ((dy + dheight) == gdk_screen_height()))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 off_y = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338 if (((dy >= y) && ((dy + off_y) < 0)))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 off_y -= dy + off_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 if ((dy < y) && ((dy + (off_y - (new_h - h))) < 0))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341 off_y -= dy + (off_y - (new_h - h));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 } while (orig_off_y != off_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 if (slist) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 GList *mlist = g_list_copy(slist);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 /* Remove this widget from the list */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 for (node = mlist; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 if (dw->w == widget) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 mlist = g_list_remove_link(mlist, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 g_list_free_1(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 for (node = mlist; node;) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 GList *temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 gint dx, dy, dwidth, dheight;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 /*
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 * Find windows that are directly docked to this window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 * move it, and any windows docked to that window again
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 if (is_docked(x, y, w, h, dx, dy, dwidth, dheight) &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 ((dx + dwidth) > x && dx < (x + w))) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 mlist = g_list_remove_link(mlist, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 g_list_free_1(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 if (dy > y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 temp = shade_move_list(mlist, dw->w, off_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 else if (off_y - (new_h - h) != 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375 temp = shade_move_list(mlist, dw->w, off_y - (new_h - h));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 temp = mlist;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 node = mlist = temp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381 node = g_list_next(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 g_list_free(mlist);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385 g_list_free(slist);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386 free_docked_list(docked_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
387 gtk_window_move(widget, x, y + off_y - (new_h - h));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
388 dock_window_resize(widget, w, new_h, w, h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
389 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
390
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
391 static GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
392 resize_move_list(GList * list, GtkWindow * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
393 gint offset_x, gint offset_y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
394 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
395 gint x, y, w, h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
396 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
397 DockedWindow *dw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
398
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
399 gtk_window_get_position(widget, &x, &y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
400 gtk_window_get_size(widget, &w, &h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
401
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
402
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
403 for (node = list; node;) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
404 gint dx, dy, dwidth, dheight;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
405 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
406 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
407 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
408 if (is_docked(x, y, w, h, dx, dy, dwidth, dheight)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
409
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
410 list = g_list_remove_link(list, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
411 g_list_free_1(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
412 node = list = resize_move_list(list, dw->w, offset_x, offset_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
413 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
414 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
415 node = g_list_next(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
416 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 gtk_window_move(widget, x + offset_x, y + offset_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418 return list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
420
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
421 static GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
422 resize_calc_offset(GList * list, GtkWindow * widget,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
423 gint offset_x, gint offset_y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
424 gint * goffset_x, gint * goffset_y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
425 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
426 gint x, y, w, h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
427 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
428 DockedWindow *dw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
429
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
430 gtk_window_get_position(widget, &x, &y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
431 gtk_window_get_size(widget, &w, &h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
432
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
433
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
434 for (node = list; node;) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
435 gint dx, dy, dwidth, dheight;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
436 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
437 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
438 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
439 if (is_docked(x, y, w, h, dx, dy, dwidth, dheight)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
440 if (dx + offset_x + dwidth > gdk_screen_width()) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
441 offset_x -= dx + offset_x + dwidth - gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
442 (*goffset_x) -= dx + offset_x + dwidth - gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
443 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
444 if (dy + offset_y + dheight > gdk_screen_height()) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
445 offset_y -= dy + offset_y + dheight - gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
446 (*goffset_y) -= dy + offset_y + dheight - gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
447 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
448 list = g_list_remove_link(list, node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
449 g_list_free_1(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
450 node = list =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
451 resize_calc_offset(list, dw->w, offset_x, offset_y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
452 goffset_x, goffset_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
453 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
454 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
455 node = g_list_next(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
456 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
457 return list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
458 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
459
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
460 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
461 dock_resize(GList * window_list, GtkWindow * widget, gint new_w, gint new_h)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
462 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
463 gint x, y, w, h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
464 gint dx, dy, dwidth, dheight;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
465 gint off_x, off_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
466 GList *list, *dlist = NULL, *tlist = NULL, *mlist = NULL, *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
467 DockedWindow *dw;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
468
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
469 gtk_window_get_position(widget, &x, &y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
470 gtk_window_get_size(widget, &w, &h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
471 if (cfg.show_wm_decorations) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
472 dock_window_resize(widget, new_w, new_h, w, h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
473 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
474 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
475
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
476 list = get_docked_list(NULL, window_list, widget, 0, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
477
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
478 off_x = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
479 off_y = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
480
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
481 for (node = list; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
482 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
483 if (dw->w != widget) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
484 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
485 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
486 if (is_docked(x, y, w, h, dx, dy, dwidth, dheight))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
487 dlist = g_list_append(dlist, dw);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
488 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
489 mlist = g_list_append(mlist, dw);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
490 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
491 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
492 tlist = g_list_copy(mlist);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
493 for (node = dlist; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
494 gint doff_x, doff_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
495 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
496 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
497 gtk_window_get_size(dw->w, &dwidth, &dheight);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
498 if (dx - x - w == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
499 doff_x = (x + off_x + new_w) - dx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
500 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
501 doff_x = (x + off_x + (dx - x)) - dx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
502
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
503 if (dy - y - h == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
504 doff_y = (y + off_y + new_h) - dy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
505 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
506 doff_y = (y + off_y + (dy - y)) - dy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
507
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
508 if (dx + doff_x + dwidth > gdk_screen_width()) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
509 off_x -= dx + doff_x + dwidth - gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
510 doff_x -= dx + doff_x + dwidth - gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
511 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
512 if (dy + doff_y + dheight > gdk_screen_height()) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
513 off_y -= dy + doff_y + dheight - gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
514 doff_y -= dy + doff_y + dheight - gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
515 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
516 tlist =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
517 resize_calc_offset(tlist, dw->w, doff_x, doff_y, &off_x, &off_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
518 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
519 if ((x + off_x + new_w) > gdk_screen_width())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
520 off_x -= x + off_x + new_w - gdk_screen_width();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
521 if ((y + off_y + new_h) > gdk_screen_height())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
522 off_y -= y + off_y + new_h - gdk_screen_height();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
523
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
524 g_list_free(tlist);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
525 for (node = dlist; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
526 gint doff_x, doff_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
527 dw = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
528 gtk_window_get_position(dw->w, &dx, &dy);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
529 if (dx - x - w == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
530 doff_x = (x + off_x + new_w) - dx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
531 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
532 doff_x = (x + off_x + (dx - x)) - dx;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
533
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
534 if (dy - y - h == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
535 doff_y = (y + off_y + new_h) - dy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
536 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
537 doff_y = (y + off_y + (dy - y)) - dy;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
538 mlist = resize_move_list(mlist, dw->w, doff_x, doff_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
539 gtk_window_move(GTK_WINDOW(dw->w), dx + doff_x, dy + doff_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
540 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
541
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
542
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
543 gtk_window_move(widget, x + off_x, y + off_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
544 dock_window_resize(widget, new_w, new_h, w, h);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
545 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
546
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
547 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
548 dock_move_press(GList * window_list, GtkWindow * w,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
549 GdkEventButton * event, gboolean move_list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
550 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
551 gint mx, my;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
552 DockedWindow *dwin;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
553
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
554 if (cfg.show_wm_decorations)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
555 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
556
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
557 gtk_window_present(w);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
558 gdk_window_get_pointer(GTK_WIDGET(w)->window, &mx, &my, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
559 gtk_object_set_data(GTK_OBJECT(w), "move_offset_x", GINT_TO_POINTER(mx));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
560 gtk_object_set_data(GTK_OBJECT(w), "move_offset_y", GINT_TO_POINTER(my));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
561 if (move_list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
562 gtk_object_set_data(GTK_OBJECT(w), "docked_list",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
563 get_docked_list(NULL, window_list, w, 0, 0));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
564 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
565 dwin = g_new0(DockedWindow, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
566 dwin->w = w;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
567 gtk_object_set_data(GTK_OBJECT(w), "docked_list",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
568 g_list_append(NULL, dwin));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
569 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
570 gtk_object_set_data(GTK_OBJECT(w), "window_list", window_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
571 gtk_object_set_data(GTK_OBJECT(w), "is_moving", GINT_TO_POINTER(1));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
572 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
573
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
574 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
575 dock_move_motion(GtkWindow * w, GdkEventMotion * event)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
576 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
577 gint offset_x, offset_y, win_x, win_y, x, y, mx, my;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
578 GList *dlist;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
579 GList *window_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
580
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
581 gdk_flush();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
582
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
583 if (!gtk_object_get_data(GTK_OBJECT(w), "is_moving"))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
584 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
585
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
586 offset_x =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
587 GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(w), "move_offset_x"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
588 offset_y =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
589 GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(w), "move_offset_y"));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
590 dlist = gtk_object_get_data(GTK_OBJECT(w), "docked_list");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
591 window_list = gtk_object_get_data(GTK_OBJECT(w), "window_list");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
592
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
593 gtk_window_get_position(w, &win_x, &win_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
594
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
595 gdk_window_get_pointer(NULL, &mx, &my, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
596
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
597 x = mx - offset_x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
598 y = my - offset_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
599
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
600 calc_snap_offset(dlist, window_list, x, y, &offset_x, &offset_y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
601 x += offset_x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
602 y += offset_y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
603
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
604 docked_list_move(dlist, x, y);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
605 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
606
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
607 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
608 dock_move_release(GtkWindow * w)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
609 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
610 GList *dlist;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
611 gtk_object_remove_data(GTK_OBJECT(w), "is_moving");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
612 gtk_object_remove_data(GTK_OBJECT(w), "move_offset_x");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
613 gtk_object_remove_data(GTK_OBJECT(w), "move_offset_y");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
614 if ((dlist = gtk_object_get_data(GTK_OBJECT(w), "docked_list")) != NULL)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
615 free_docked_list(dlist);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
616 gtk_object_remove_data(GTK_OBJECT(w), "docked_list");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
617 gtk_object_remove_data(GTK_OBJECT(w), "window_list");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
618 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
619
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
620 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
621 dock_is_moving(GtkWindow * w)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
622 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
623 if (gtk_object_get_data(GTK_OBJECT(w), "is_moving"))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
624 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
625 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
626 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
627
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
628 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
629 dock_add_window(GList * list, GtkWindow * window)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
630 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
631 return g_list_append(list, window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
632 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
633
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
634 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
635 dock_remove_window(GList * list, GtkWindow * window)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
636 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
637 return g_list_remove(list, window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
638 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
639
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
640 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
641 dock_window_set_decorated(GList * list, GtkWindow * window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
642 gboolean decorated)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
643 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
644 if (gtk_window_get_decorated(window) == decorated)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
645 return list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
646
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
647 if (decorated)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
648 list = dock_remove_window(list, window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
649 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
650 list = dock_add_window(list, window);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
651
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
652 gtk_window_set_decorated(window, decorated);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
653
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
654 return list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
655 }