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