- Made dock/clip steal appicons of applications that were started from a
[wmaker-crm.git] / src / appicon.c
blobde61ab8bafe906caf6ff0f65d818ebaeb18dbbfd
1 /* appicon.c- icon for applications (not mini-window)
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1998 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 * USA.
24 #include "wconfig.h"
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <stdlib.h>
29 #include <string.h>
31 #include "WindowMaker.h"
32 #include "wcore.h"
33 #include "window.h"
34 #include "icon.h"
35 #include "appicon.h"
36 #include "actions.h"
37 #include "stacking.h"
38 #include "dock.h"
39 #include "funcs.h"
40 #include "defaults.h"
41 #include "workspace.h"
42 #include "superfluous.h"
43 #include "menu.h"
44 #include "framewin.h"
45 #include "dialog.h"
46 #include "client.h"
47 #ifdef XDND
48 #include "xdnd.h"
49 #endif
50 #include "wsound.h"
51 #include <WINGs/WINGsP.h>
55 * icon_file for the dock is got from the preferences file by
56 * using the classname/instancename
59 /**** Global variables ****/
60 extern Cursor wCursor[WCUR_LAST];
61 extern WPreferences wPreferences;
63 #define MOD_MASK wPreferences.modifier_mask
65 void appIconMouseDown(WObjDescriptor *desc, XEvent *event);
66 static void iconDblClick(WObjDescriptor *desc, XEvent *event);
67 static void iconExpose(WObjDescriptor *desc, XEvent *event);
71 WAppIcon*
72 wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
73 char *wm_class, int tile)
75 WAppIcon *dicon;
76 char *path;
78 dicon = wmalloc(sizeof(WAppIcon));
79 wretain(dicon);
80 memset(dicon, 0, sizeof(WAppIcon));
81 dicon->yindex = -1;
82 dicon->xindex = -1;
84 dicon->prev = NULL;
85 dicon->next = scr->app_icon_list;
86 if (scr->app_icon_list) {
87 scr->app_icon_list->prev = dicon;
89 scr->app_icon_list = dicon;
91 if (command) {
92 dicon->command = wstrdup(command);
94 if (wm_class)
95 dicon->wm_class = wstrdup(wm_class);
96 if (wm_instance)
97 dicon->wm_instance = wstrdup(wm_instance);
99 path = wDefaultGetIconFile(scr, wm_instance, wm_class, True);
100 if (!path && command) {
101 wApplicationExtractDirPackIcon(scr, command, wm_instance, wm_class);
103 path = wDefaultGetIconFile(scr, wm_instance, wm_class, False);
106 if (path)
107 path = FindImage(wPreferences.icon_path, path);
109 dicon->icon = wIconCreateWithIconFile(scr, path, tile);
110 if (path)
111 wfree(path);
112 #ifdef XDND
113 wXDNDMakeAwareness(dicon->icon->core->window);
114 #endif
116 #ifdef DEMATERIALIZE_ICON
118 XSetWindowAttributes attribs;
119 attribs.save_under = True;
120 XChangeWindowAttributes(dpy, dicon->icon->core->window,
121 CWSaveUnder, &attribs);
123 #endif
125 /* will be overriden by dock */
126 dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
127 dicon->icon->core->descriptor.handle_expose = iconExpose;
128 dicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
129 dicon->icon->core->descriptor.parent = dicon;
130 AddToStackList(dicon->icon->core);
132 return dicon;
137 WAppIcon*
138 wAppIconCreate(WWindow *leader_win)
140 WAppIcon *aicon;
141 WScreen *scr = leader_win->screen_ptr;
143 aicon = wmalloc(sizeof(WAppIcon));
144 wretain(aicon);
145 memset(aicon, 0, sizeof(WAppIcon));
147 aicon->yindex = -1;
148 aicon->xindex = -1;
150 aicon->prev = NULL;
151 aicon->next = scr->app_icon_list;
152 if (scr->app_icon_list) {
153 scr->app_icon_list->prev = aicon;
155 scr->app_icon_list = aicon;
157 if (leader_win->wm_class)
158 aicon->wm_class = wstrdup(leader_win->wm_class);
159 if (leader_win->wm_instance)
160 aicon->wm_instance = wstrdup(leader_win->wm_instance);
162 aicon->icon = wIconCreate(leader_win);
163 #ifdef DEMATERIALIZE_ICON
165 XSetWindowAttributes attribs;
166 attribs.save_under = True;
167 XChangeWindowAttributes(dpy, aicon->icon->core->window,
168 CWSaveUnder, &attribs);
170 #endif
171 #ifdef XDND
172 wXDNDMakeAwareness(aicon->icon->core->window);
173 #endif
175 /* will be overriden if docked */
176 aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
177 aicon->icon->core->descriptor.handle_expose = iconExpose;
178 aicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
179 aicon->icon->core->descriptor.parent = aicon;
180 AddToStackList(aicon->icon->core);
181 aicon->icon->show_title = 0;
182 wIconUpdate(aicon->icon);
184 return aicon;
188 void
189 wAppIconDestroy(WAppIcon *aicon)
191 WScreen *scr = aicon->icon->core->screen_ptr;
193 RemoveFromStackList(aicon->icon->core);
194 wIconDestroy(aicon->icon);
195 if (aicon->command)
196 wfree(aicon->command);
197 #ifdef OFFIX_DND
198 if (aicon->dnd_command)
199 wfree(aicon->dnd_command);
200 #endif
201 if (aicon->wm_instance)
202 wfree(aicon->wm_instance);
203 if (aicon->wm_class)
204 wfree(aicon->wm_class);
206 if (aicon == scr->app_icon_list) {
207 if (aicon->next)
208 aicon->next->prev = NULL;
209 scr->app_icon_list = aicon->next;
211 else {
212 if (aicon->next)
213 aicon->next->prev = aicon->prev;
214 if (aicon->prev)
215 aicon->prev->next = aicon->next;
218 aicon->destroyed = 1;
219 wrelease(aicon);
224 #ifdef NEWAPPICON
225 static void
226 drawCorner(WIcon *icon, WWindow *wwin, int active)
228 WScreen *scr = wwin->screen_ptr;
229 XPoint points[3];
230 GC gc;
232 points[0].x = 2;
233 points[0].y = 2;
234 points[1].x = 12;
235 points[1].y = 2;
236 points[2].x = 2;
237 points[2].y = 12;
238 if (active) {
239 gc=scr->focused_texture->any.gc;
240 } else {
241 gc=scr->unfocused_texture->any.gc;
243 XFillPolygon(dpy, icon->core->window, gc, points, 3,
244 Convex, CoordModeOrigin);
246 #endif /* NEWAPPICON */
249 static void
250 drawCorner(WIcon *icon)
252 WScreen *scr = icon->core->screen_ptr;
253 XPoint points[3];
255 points[0].x = 1;
256 points[0].y = 1;
257 points[1].x = 12;
258 points[1].y = 1;
259 points[2].x = 1;
260 points[2].y = 12;
261 XFillPolygon(dpy, icon->core->window, scr->icon_title_texture->normal_gc,
262 points, 3, Convex, CoordModeOrigin);
263 XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc,
264 0, 0, 0, 12);
265 XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc,
266 0, 0, 12, 0);
267 /* drawing the second line gives a weird concave look. -Dan */
268 #if 0
269 XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc,
270 1, 1, 1, 11);
271 XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc,
272 1, 1, 11, 1);
273 #endif
277 void
278 wAppIconMove(WAppIcon *aicon, int x, int y)
280 XMoveWindow(dpy, aicon->icon->core->window, x, y);
281 aicon->x_pos = x;
282 aicon->y_pos = y;
286 #ifdef WS_INDICATOR
287 static void
288 updateDockNumbers(WScreen *scr)
290 int length;
291 char *ws_numbers;
292 GC numbers_gc;
293 XGCValues my_gc_values;
294 unsigned long my_v_mask = (GCForeground);
295 WAppIcon *dicon = scr->dock->icon_array[0];
297 my_gc_values.foreground = scr->white_pixel;
298 numbers_gc = XCreateGC(dpy, dicon->icon->core->window,
299 my_v_mask, &my_gc_values);
301 ws_numbers = wmalloc(20);
302 snprintf(ws_numbers, 20, "%i [ %i ]", scr->current_workspace+1,
303 ((scr->current_workspace/10)+1));
304 length = strlen(ws_numbers);
306 XClearArea(dpy, dicon->icon->core->window, 2, 2, 50,
307 WMFontHeight(scr->icon_title_font)+1, False);
309 XSetForeground(dpy, numbers_gc, scr->black_pixel);
310 WMDrawString(scr->wmscreen, dicon->icon->core->window, numbers_gc,
311 scr->icon_title_font, 4, 3, ws_numbers, length);
313 XSetForeground(dpy, numbers_gc, scr->white_pixel);
314 WMDrawString(scr->wmscreen, dicon->icon->core->window, numbers_gc,
315 scr->icon_title_font, 3, 2, ws_numbers, length);
317 XFreeGC(dpy, numbers_gc);
318 wfree(ws_numbers);
320 #endif /* WS_INDICATOR */
323 void
324 wAppIconPaint(WAppIcon *aicon)
326 WApplication *wapp;
327 WScreen *scr = aicon->icon->core->screen_ptr;
329 if (aicon->icon->owner)
330 wapp = wApplicationOf(aicon->icon->owner->main_window);
331 else
332 wapp = NULL;
334 wIconPaint(aicon->icon);
337 # ifdef WS_INDICATOR
338 if (aicon->docked && scr->dock && scr->dock==aicon->dock &&
339 aicon->yindex==0)
340 updateDockNumbers(scr);
341 # endif
342 if (scr->dock_dots && aicon->docked && !aicon->running
343 && aicon->command!=NULL) {
344 XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
345 XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
346 XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window,
347 scr->copy_gc, 0, 0, scr->dock_dots->width,
348 scr->dock_dots->height, 0, 0);
351 #ifdef HIDDENDOT
352 if (wapp && wapp->flags.hidden) {
353 XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
354 XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
355 XCopyArea(dpy, scr->dock_dots->image,
356 aicon->icon->core->window,
357 scr->copy_gc, 0, 0, 7,
358 scr->dock_dots->height, 0, 0);
360 #endif /* HIDDENDOT */
362 if (aicon->omnipresent)
363 drawCorner(aicon->icon);
365 XSetClipMask(dpy, scr->copy_gc, None);
366 if (aicon->launching) {
367 XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc,
368 0, 0, wPreferences.icon_size, wPreferences.icon_size);
374 #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
378 static void
379 hideCallback(WMenu *menu, WMenuEntry *entry)
381 WApplication *wapp = (WApplication*)entry->clientdata;
383 if (wapp->flags.hidden) {
384 wWorkspaceChange(menu->menu->screen_ptr, wapp->last_workspace);
385 wUnhideApplication(wapp, False, False);
386 } else {
387 wHideApplication(wapp);
392 static void
393 unhideHereCallback(WMenu *menu, WMenuEntry *entry)
395 WApplication *wapp = (WApplication*)entry->clientdata;
397 wUnhideApplication(wapp, False, True);
401 static void
402 setIconCallback(WMenu *menu, WMenuEntry *entry)
404 WAppIcon *icon = ((WApplication*)entry->clientdata)->app_icon;
405 char *file=NULL;
406 WScreen *scr;
407 int result;
409 assert(icon!=NULL);
411 if (icon->editing)
412 return;
413 icon->editing = 1;
414 scr = icon->icon->core->screen_ptr;
416 wretain(icon);
418 result = wIconChooserDialog(scr, &file, icon->wm_instance, icon->wm_class);
420 if (result && !icon->destroyed) {
421 if (file[0]==0) {
422 wfree(file);
423 file = NULL;
425 if (!wIconChangeImageFile(icon->icon, file)) {
426 wMessageDialog(scr, _("Error"),
427 _("Could not open specified icon file"),
428 _("OK"), NULL, NULL);
429 } else {
430 wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file);
431 wAppIconPaint(icon);
433 if (file)
434 wfree(file);
436 icon->editing = 0;
437 wrelease(icon);
441 static void
442 killCallback(WMenu *menu, WMenuEntry *entry)
444 WApplication *wapp = (WApplication*)entry->clientdata;
445 WFakeGroupLeader *fPtr;
446 char *buffer;
448 if (!WCHECK_STATE(WSTATE_NORMAL))
449 return;
451 WCHANGE_STATE(WSTATE_MODAL);
453 assert(entry->clientdata!=NULL);
455 buffer = wstrconcat(wapp->app_icon ? wapp->app_icon->wm_class : NULL,
456 _(" will be forcibly closed.\n"
457 "Any unsaved changes will be lost.\n"
458 "Please confirm."));
460 fPtr = wapp->main_window_desc->fake_group;
462 wretain(wapp->main_window_desc);
463 if (wPreferences.dont_confirm_kill
464 || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"),
465 buffer, _("Yes"), _("No"), NULL)==WAPRDefault) {
466 if (fPtr!=NULL) {
467 WWindow *wwin, *twin;
469 wwin = wapp->main_window_desc->screen_ptr->focused_window;
470 while (wwin) {
471 twin = wwin->prev;
472 if (wwin->fake_group == fPtr) {
473 wClientKill(wwin);
475 wwin = twin;
477 } else if (!wapp->main_window_desc->flags.destroyed) {
478 wClientKill(wapp->main_window_desc);
481 wrelease(wapp->main_window_desc);
483 wfree(buffer);
485 WCHANGE_STATE(WSTATE_NORMAL);
489 static WMenu*
490 createApplicationMenu(WScreen *scr)
492 WMenu *menu;
494 menu = wMenuCreate(scr, NULL, False);
495 wMenuAddCallback(menu, _("Unhide Here"), unhideHereCallback, NULL);
496 wMenuAddCallback(menu, _("Hide"), hideCallback, NULL);
497 wMenuAddCallback(menu, _("Set Icon..."), setIconCallback, NULL);
498 wMenuAddCallback(menu, _("Kill"), killCallback, NULL);
500 return menu;
504 static void
505 openApplicationMenu(WApplication *wapp, int x, int y)
507 WMenu *menu;
508 WScreen *scr = wapp->main_window_desc->screen_ptr;
509 int i;
511 if (!scr->icon_menu) {
512 scr->icon_menu = createApplicationMenu(scr);
513 wfree(scr->icon_menu->entries[1]->text);
516 menu = scr->icon_menu;
518 if (wapp->flags.hidden) {
519 menu->entries[1]->text = _("Unhide");
520 } else {
521 menu->entries[1]->text = _("Hide");
524 menu->flags.realized = 0;
525 wMenuRealize(menu);
527 x -= menu->frame->core->width/2;
528 if (x + menu->frame->core->width > scr->scr_width)
529 x = scr->scr_width - menu->frame->core->width;
530 if (x < 0)
531 x = 0;
533 /* set client data */
534 for (i = 0; i < menu->entry_no; i++) {
535 menu->entries[i]->clientdata = wapp;
537 wMenuMapAt(menu, x, y, False);
541 /******************************************************************/
543 static void
544 iconExpose(WObjDescriptor *desc, XEvent *event)
546 wAppIconPaint(desc->parent);
550 static void
551 iconDblClick(WObjDescriptor *desc, XEvent *event)
553 WAppIcon *aicon = desc->parent;
554 WApplication *wapp;
555 WScreen *scr = aicon->icon->core->screen_ptr;
556 int unhideHere;
558 assert(aicon->icon->owner!=NULL);
560 wapp = wApplicationOf(aicon->icon->owner->main_window);
561 #ifdef DEBUG0
562 if (!wapp) {
563 wwarning("could not find application descriptor for app icon!!");
564 return;
566 #endif
568 unhideHere = (event->xbutton.state & ShiftMask);
570 /* go to the last workspace that the user worked on the app */
571 if (!unhideHere && wapp->last_workspace != scr->current_workspace)
572 wWorkspaceChange(scr, wapp->last_workspace);
574 wUnhideApplication(wapp, event->xbutton.button==Button2, unhideHere);
576 if (event->xbutton.state & MOD_MASK) {
577 wHideOtherApplications(aicon->icon->owner);
583 void
584 appIconMouseDown(WObjDescriptor *desc, XEvent *event)
586 WAppIcon *aicon = desc->parent;
587 WIcon *icon = aicon->icon;
588 XEvent ev;
589 int x=aicon->x_pos, y=aicon->y_pos;
590 int dx=event->xbutton.x, dy=event->xbutton.y;
591 int grabbed=0;
592 int done=0;
593 int superfluous = wPreferences.superfluous; /* we catch it to avoid problems */
594 WScreen *scr = icon->core->screen_ptr;
595 WWorkspace *workspace = scr->workspaces[scr->current_workspace];
596 int shad_x = 0, shad_y = 0, docking=0, dockable, collapsed = 0;
597 int ix, iy;
598 int clickButton = event->xbutton.button;
599 Pixmap ghost = None;
600 Window wins[2];
601 Bool movingSingle = False;
602 int oldX = x;
603 int oldY = y;
605 if (aicon->editing || WCHECK_STATE(WSTATE_MODAL))
606 return;
608 if (IsDoubleClick(scr, event)) {
609 iconDblClick(desc, event);
610 return;
613 if (event->xbutton.button == Button3) {
614 WObjDescriptor *desc;
615 WApplication *wapp = wApplicationOf(aicon->icon->owner->main_window);
617 if (!wapp)
618 return;
620 if (event->xbutton.send_event &&
621 XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask
622 |ButtonReleaseMask|ButtonPressMask, GrabModeAsync,
623 GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) {
624 wwarning("pointer grab failed for appicon menu");
625 return;
628 openApplicationMenu(wapp, event->xbutton.x_root,
629 event->xbutton.y_root);
631 /* allow drag select of menu */
632 desc = &scr->icon_menu->menu->descriptor;
633 event->xbutton.send_event = True;
634 (*desc->handle_mousedown)(desc, event);
635 return;
638 #ifdef DEBUG
639 puts("Moving icon");
640 #endif
641 if (event->xbutton.state & MOD_MASK)
642 wLowerFrame(icon->core);
643 else
644 wRaiseFrame(icon->core);
646 if (XGrabPointer(dpy, icon->core->window, True, ButtonMotionMask
647 |ButtonReleaseMask|ButtonPressMask, GrabModeAsync,
648 GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) {
649 wwarning("pointer grab failed for appicon move");
652 if (wPreferences.flags.nodock && wPreferences.flags.noclip)
653 dockable = 0;
654 else
655 dockable = canBeDocked(icon->owner);
657 wins[0] = icon->core->window;
658 wins[1] = scr->dock_shadow;
659 XRestackWindows(dpy, wins, 2);
660 if (superfluous) {
661 if (icon->pixmap!=None)
662 ghost = MakeGhostIcon(scr, icon->pixmap);
663 else
664 ghost = MakeGhostIcon(scr, icon->core->window);
665 XSetWindowBackgroundPixmap(dpy, scr->dock_shadow,
666 ghost);
667 XClearWindow(dpy, scr->dock_shadow);
670 while (!done) {
671 WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask
672 |ButtonMotionMask|ExposureMask, &ev);
673 switch (ev.type) {
674 case Expose:
675 WMHandleEvent(&ev);
676 break;
678 case MotionNotify:
679 if (!grabbed) {
680 if (abs(dx-ev.xmotion.x)>=MOVE_THRESHOLD
681 || abs(dy-ev.xmotion.y)>=MOVE_THRESHOLD) {
682 XChangeActivePointerGrab(dpy, ButtonMotionMask
683 |ButtonReleaseMask|ButtonPressMask,
684 wCursor[WCUR_MOVE], CurrentTime);
685 grabbed=1;
686 } else {
687 break;
690 x = ev.xmotion.x_root - dx;
691 y = ev.xmotion.y_root - dy;
693 if (movingSingle) {
694 XMoveWindow(dpy, icon->core->window, x, y);
695 } else {
696 wAppIconMove(aicon, x, y);
699 if (dockable) {
700 if (scr->dock && wDockSnapIcon(scr->dock, aicon, x, y,
701 &ix, &iy, False)) {
702 shad_x = scr->dock->x_pos + ix*wPreferences.icon_size;
703 shad_y = scr->dock->y_pos + iy*wPreferences.icon_size;
705 if (scr->last_dock != scr->dock && collapsed) {
706 scr->last_dock->collapsed = 1;
707 wDockHideIcons(scr->last_dock);
708 collapsed = 0;
710 if (!collapsed && (collapsed = scr->dock->collapsed)) {
711 scr->dock->collapsed = 0;
712 wDockShowIcons(scr->dock);
715 if (scr->dock->auto_raise_lower)
716 wDockRaise(scr->dock);
718 scr->last_dock = scr->dock;
720 XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y);
721 if (!docking) {
722 XMapWindow(dpy, scr->dock_shadow);
724 docking = 1;
725 } else if (workspace->clip &&
726 wDockSnapIcon(workspace->clip, aicon, x, y,
727 &ix, &iy, False)) {
728 shad_x = workspace->clip->x_pos + ix*wPreferences.icon_size;
729 shad_y = workspace->clip->y_pos + iy*wPreferences.icon_size;
731 if (scr->last_dock != workspace->clip && collapsed) {
732 scr->last_dock->collapsed = 1;
733 wDockHideIcons(scr->last_dock);
734 collapsed = 0;
736 if (!collapsed && (collapsed = workspace->clip->collapsed)) {
737 workspace->clip->collapsed = 0;
738 wDockShowIcons(workspace->clip);
741 if (workspace->clip->auto_raise_lower)
742 wDockRaise(workspace->clip);
744 scr->last_dock = workspace->clip;
746 XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y);
747 if (!docking) {
748 XMapWindow(dpy, scr->dock_shadow);
750 docking = 1;
751 } else if (docking) {
752 XUnmapWindow(dpy, scr->dock_shadow);
753 docking = 0;
757 break;
759 case ButtonPress:
760 break;
762 case ButtonRelease:
763 if (ev.xbutton.button != clickButton)
764 break;
765 XUngrabPointer(dpy, CurrentTime);
767 if (docking) {
768 Bool docked;
770 /* icon is trying to be docked */
771 SlideWindow(icon->core->window, x, y, shad_x, shad_y);
772 XUnmapWindow(dpy, scr->dock_shadow);
773 docked = wDockAttachIcon(scr->last_dock, aicon, ix, iy);
774 if (scr->last_dock->auto_collapse) {
775 collapsed = 0;
777 if (workspace->clip &&
778 workspace->clip != scr->last_dock &&
779 workspace->clip->auto_raise_lower)
780 wDockLower(workspace->clip);
782 if (!docked) {
783 /* If icon could not be docked, slide it back to the old
784 * position */
785 SlideWindow(icon->core->window, x, y, oldX, oldY);
788 wSoundPlay(WSOUND_DOCK);
789 } else {
790 if (movingSingle) {
791 /* move back to its place */
792 SlideWindow(icon->core->window, x, y, oldX, oldY);
793 wAppIconMove(aicon, oldX, oldY);
794 } else {
795 XMoveWindow(dpy, icon->core->window, x, y);
796 aicon->x_pos = x;
797 aicon->y_pos = y;
799 if (workspace->clip && workspace->clip->auto_raise_lower)
800 wDockLower(workspace->clip);
802 if (collapsed) {
803 scr->last_dock->collapsed = 1;
804 wDockHideIcons(scr->last_dock);
805 collapsed = 0;
807 if (superfluous) {
808 if (ghost!=None)
809 XFreePixmap(dpy, ghost);
810 XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel);
813 if (wPreferences.auto_arrange_icons)
814 wArrangeIcons(scr, True);
816 done = 1;
817 break;
820 #ifdef DEBUG
821 puts("End icon move");
822 #endif