- API change in WINGs for WMDraw*String().
[wmaker-crm.git] / src / appicon.c
blob5060238f6769466d8d9eb955a28b681e0654efc0
1 /* appicon.c- icon for applications (not mini-window)
3 * Window Maker window manager
5 * Copyright (c) 1997-2002 Alfredo K. Kojima
6 * Copyright (c) 1998-2002 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 WAppIcon *dicon = scr->dock->icon_array[0];
293 WMColor *black, *white;
295 black = WMBlackColor(scr->wmscreen);
296 white = WMWhiteColor(scr->wmscreen);
298 ws_numbers = wmalloc(20);
299 snprintf(ws_numbers, 20, "%i [ %i ]", scr->current_workspace+1,
300 ((scr->current_workspace/10)+1));
301 length = strlen(ws_numbers);
303 XClearArea(dpy, dicon->icon->core->window, 2, 2, 50,
304 WMFontHeight(scr->icon_title_font)+1, False);
306 WMDrawString(scr->wmscreen, dicon->icon->core->window, black,
307 scr->icon_title_font, 4, 3, ws_numbers, length);
309 WMDrawString(scr->wmscreen, dicon->icon->core->window, white,
310 scr->icon_title_font, 3, 2, ws_numbers, length);
312 WMReleaseColor(black);
313 WMReleaseColor(white);
314 wfree(ws_numbers);
316 #endif /* WS_INDICATOR */
319 void
320 wAppIconPaint(WAppIcon *aicon)
322 WApplication *wapp;
323 WScreen *scr = aicon->icon->core->screen_ptr;
325 if (aicon->icon->owner)
326 wapp = wApplicationOf(aicon->icon->owner->main_window);
327 else
328 wapp = NULL;
330 wIconPaint(aicon->icon);
333 # ifdef WS_INDICATOR
334 if (aicon->docked && scr->dock && scr->dock==aicon->dock &&
335 aicon->yindex==0)
336 updateDockNumbers(scr);
337 # endif
338 if (scr->dock_dots && aicon->docked && !aicon->running
339 && aicon->command!=NULL) {
340 XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
341 XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
342 XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window,
343 scr->copy_gc, 0, 0, scr->dock_dots->width,
344 scr->dock_dots->height, 0, 0);
347 #ifdef HIDDENDOT
348 if (wapp && wapp->flags.hidden) {
349 XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
350 XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
351 XCopyArea(dpy, scr->dock_dots->image,
352 aicon->icon->core->window,
353 scr->copy_gc, 0, 0, 7,
354 scr->dock_dots->height, 0, 0);
356 #endif /* HIDDENDOT */
358 if (aicon->omnipresent)
359 drawCorner(aicon->icon);
361 XSetClipMask(dpy, scr->copy_gc, None);
362 if (aicon->launching) {
363 XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc,
364 0, 0, wPreferences.icon_size, wPreferences.icon_size);
370 #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
374 static void
375 hideCallback(WMenu *menu, WMenuEntry *entry)
377 WApplication *wapp = (WApplication*)entry->clientdata;
379 if (wapp->flags.hidden) {
380 wWorkspaceChange(menu->menu->screen_ptr, wapp->last_workspace);
381 wUnhideApplication(wapp, False, False);
382 } else {
383 wHideApplication(wapp);
388 static void
389 unhideHereCallback(WMenu *menu, WMenuEntry *entry)
391 WApplication *wapp = (WApplication*)entry->clientdata;
393 wUnhideApplication(wapp, False, True);
397 static void
398 setIconCallback(WMenu *menu, WMenuEntry *entry)
400 WAppIcon *icon = ((WApplication*)entry->clientdata)->app_icon;
401 char *file=NULL;
402 WScreen *scr;
403 int result;
405 assert(icon!=NULL);
407 if (icon->editing)
408 return;
409 icon->editing = 1;
410 scr = icon->icon->core->screen_ptr;
412 wretain(icon);
414 result = wIconChooserDialog(scr, &file, icon->wm_instance, icon->wm_class);
416 if (result && !icon->destroyed) {
417 if (file[0]==0) {
418 wfree(file);
419 file = NULL;
421 if (!wIconChangeImageFile(icon->icon, file)) {
422 wMessageDialog(scr, _("Error"),
423 _("Could not open specified icon file"),
424 _("OK"), NULL, NULL);
425 } else {
426 wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file);
427 wAppIconPaint(icon);
429 if (file)
430 wfree(file);
432 icon->editing = 0;
433 wrelease(icon);
437 static void
438 killCallback(WMenu *menu, WMenuEntry *entry)
440 WApplication *wapp = (WApplication*)entry->clientdata;
441 WFakeGroupLeader *fPtr;
442 char *buffer;
444 if (!WCHECK_STATE(WSTATE_NORMAL))
445 return;
447 WCHANGE_STATE(WSTATE_MODAL);
449 assert(entry->clientdata!=NULL);
451 buffer = wstrconcat(wapp->app_icon ? wapp->app_icon->wm_class : NULL,
452 _(" will be forcibly closed.\n"
453 "Any unsaved changes will be lost.\n"
454 "Please confirm."));
456 fPtr = wapp->main_window_desc->fake_group;
458 wretain(wapp->main_window_desc);
459 if (wPreferences.dont_confirm_kill
460 || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"),
461 buffer, _("Yes"), _("No"), NULL)==WAPRDefault) {
462 if (fPtr!=NULL) {
463 WWindow *wwin, *twin;
465 wwin = wapp->main_window_desc->screen_ptr->focused_window;
466 while (wwin) {
467 twin = wwin->prev;
468 if (wwin->fake_group == fPtr) {
469 wClientKill(wwin);
471 wwin = twin;
473 } else if (!wapp->main_window_desc->flags.destroyed) {
474 wClientKill(wapp->main_window_desc);
477 wrelease(wapp->main_window_desc);
479 wfree(buffer);
481 WCHANGE_STATE(WSTATE_NORMAL);
485 static WMenu*
486 createApplicationMenu(WScreen *scr)
488 WMenu *menu;
490 menu = wMenuCreate(scr, NULL, False);
491 wMenuAddCallback(menu, _("Unhide Here"), unhideHereCallback, NULL);
492 wMenuAddCallback(menu, _("Hide"), hideCallback, NULL);
493 wMenuAddCallback(menu, _("Set Icon..."), setIconCallback, NULL);
494 wMenuAddCallback(menu, _("Kill"), killCallback, NULL);
496 return menu;
500 static void
501 openApplicationMenu(WApplication *wapp, int x, int y)
503 WMenu *menu;
504 WScreen *scr = wapp->main_window_desc->screen_ptr;
505 int i;
507 if (!scr->icon_menu) {
508 scr->icon_menu = createApplicationMenu(scr);
509 wfree(scr->icon_menu->entries[1]->text);
512 menu = scr->icon_menu;
514 if (wapp->flags.hidden) {
515 menu->entries[1]->text = _("Unhide");
516 } else {
517 menu->entries[1]->text = _("Hide");
520 menu->flags.realized = 0;
521 wMenuRealize(menu);
523 x -= menu->frame->core->width/2;
524 if (x + menu->frame->core->width > scr->scr_width)
525 x = scr->scr_width - menu->frame->core->width;
526 if (x < 0)
527 x = 0;
529 /* set client data */
530 for (i = 0; i < menu->entry_no; i++) {
531 menu->entries[i]->clientdata = wapp;
533 wMenuMapAt(menu, x, y, False);
537 /******************************************************************/
539 static void
540 iconExpose(WObjDescriptor *desc, XEvent *event)
542 wAppIconPaint(desc->parent);
546 static void
547 iconDblClick(WObjDescriptor *desc, XEvent *event)
549 WAppIcon *aicon = desc->parent;
550 WApplication *wapp;
551 WScreen *scr = aicon->icon->core->screen_ptr;
552 int unhideHere;
554 assert(aicon->icon->owner!=NULL);
556 wapp = wApplicationOf(aicon->icon->owner->main_window);
557 #ifdef DEBUG0
558 if (!wapp) {
559 wwarning("could not find application descriptor for app icon!!");
560 return;
562 #endif
564 unhideHere = (event->xbutton.state & ShiftMask);
566 /* go to the last workspace that the user worked on the app */
567 if (!unhideHere && wapp->last_workspace != scr->current_workspace)
568 wWorkspaceChange(scr, wapp->last_workspace);
570 wUnhideApplication(wapp, event->xbutton.button==Button2, unhideHere);
572 if (event->xbutton.state & MOD_MASK) {
573 wHideOtherApplications(aicon->icon->owner);
579 void
580 appIconMouseDown(WObjDescriptor *desc, XEvent *event)
582 WAppIcon *aicon = desc->parent;
583 WIcon *icon = aicon->icon;
584 XEvent ev;
585 int x=aicon->x_pos, y=aicon->y_pos;
586 int dx=event->xbutton.x, dy=event->xbutton.y;
587 int grabbed=0;
588 int done=0;
589 int superfluous = wPreferences.superfluous; /* we catch it to avoid problems */
590 WScreen *scr = icon->core->screen_ptr;
591 WWorkspace *workspace = scr->workspaces[scr->current_workspace];
592 int shad_x = 0, shad_y = 0, docking=0, dockable, collapsed = 0;
593 int ix, iy;
594 int clickButton = event->xbutton.button;
595 Pixmap ghost = None;
596 Window wins[2];
597 Bool movingSingle = False;
598 int oldX = x;
599 int oldY = y;
601 if (aicon->editing || WCHECK_STATE(WSTATE_MODAL))
602 return;
604 if (IsDoubleClick(scr, event)) {
605 iconDblClick(desc, event);
606 return;
609 if (event->xbutton.button == Button3) {
610 WObjDescriptor *desc;
611 WApplication *wapp = wApplicationOf(aicon->icon->owner->main_window);
613 if (!wapp)
614 return;
616 if (event->xbutton.send_event &&
617 XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask
618 |ButtonReleaseMask|ButtonPressMask, GrabModeAsync,
619 GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) {
620 wwarning("pointer grab failed for appicon menu");
621 return;
624 openApplicationMenu(wapp, event->xbutton.x_root,
625 event->xbutton.y_root);
627 /* allow drag select of menu */
628 desc = &scr->icon_menu->menu->descriptor;
629 event->xbutton.send_event = True;
630 (*desc->handle_mousedown)(desc, event);
631 return;
634 #ifdef DEBUG
635 puts("Moving icon");
636 #endif
637 if (event->xbutton.state & MOD_MASK)
638 wLowerFrame(icon->core);
639 else
640 wRaiseFrame(icon->core);
642 if (XGrabPointer(dpy, icon->core->window, True, ButtonMotionMask
643 |ButtonReleaseMask|ButtonPressMask, GrabModeAsync,
644 GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) {
645 wwarning("pointer grab failed for appicon move");
648 if (wPreferences.flags.nodock && wPreferences.flags.noclip)
649 dockable = 0;
650 else
651 dockable = canBeDocked(icon->owner);
653 wins[0] = icon->core->window;
654 wins[1] = scr->dock_shadow;
655 XRestackWindows(dpy, wins, 2);
656 if (superfluous) {
657 if (icon->pixmap!=None)
658 ghost = MakeGhostIcon(scr, icon->pixmap);
659 else
660 ghost = MakeGhostIcon(scr, icon->core->window);
661 XSetWindowBackgroundPixmap(dpy, scr->dock_shadow,
662 ghost);
663 XClearWindow(dpy, scr->dock_shadow);
666 while (!done) {
667 WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask
668 |ButtonMotionMask|ExposureMask, &ev);
669 switch (ev.type) {
670 case Expose:
671 WMHandleEvent(&ev);
672 break;
674 case MotionNotify:
675 if (!grabbed) {
676 if (abs(dx-ev.xmotion.x)>=MOVE_THRESHOLD
677 || abs(dy-ev.xmotion.y)>=MOVE_THRESHOLD) {
678 XChangeActivePointerGrab(dpy, ButtonMotionMask
679 |ButtonReleaseMask|ButtonPressMask,
680 wCursor[WCUR_MOVE], CurrentTime);
681 grabbed=1;
682 } else {
683 break;
686 x = ev.xmotion.x_root - dx;
687 y = ev.xmotion.y_root - dy;
689 if (movingSingle) {
690 XMoveWindow(dpy, icon->core->window, x, y);
691 } else {
692 wAppIconMove(aicon, x, y);
695 if (dockable) {
696 if (scr->dock && wDockSnapIcon(scr->dock, aicon, x, y,
697 &ix, &iy, False)) {
698 shad_x = scr->dock->x_pos + ix*wPreferences.icon_size;
699 shad_y = scr->dock->y_pos + iy*wPreferences.icon_size;
701 if (scr->last_dock != scr->dock && collapsed) {
702 scr->last_dock->collapsed = 1;
703 wDockHideIcons(scr->last_dock);
704 collapsed = 0;
706 if (!collapsed && (collapsed = scr->dock->collapsed)) {
707 scr->dock->collapsed = 0;
708 wDockShowIcons(scr->dock);
711 if (scr->dock->auto_raise_lower)
712 wDockRaise(scr->dock);
714 scr->last_dock = scr->dock;
716 XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y);
717 if (!docking) {
718 XMapWindow(dpy, scr->dock_shadow);
720 docking = 1;
721 } else if (workspace->clip &&
722 wDockSnapIcon(workspace->clip, aicon, x, y,
723 &ix, &iy, False)) {
724 shad_x = workspace->clip->x_pos + ix*wPreferences.icon_size;
725 shad_y = workspace->clip->y_pos + iy*wPreferences.icon_size;
727 if (scr->last_dock != workspace->clip && collapsed) {
728 scr->last_dock->collapsed = 1;
729 wDockHideIcons(scr->last_dock);
730 collapsed = 0;
732 if (!collapsed && (collapsed = workspace->clip->collapsed)) {
733 workspace->clip->collapsed = 0;
734 wDockShowIcons(workspace->clip);
737 if (workspace->clip->auto_raise_lower)
738 wDockRaise(workspace->clip);
740 scr->last_dock = workspace->clip;
742 XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y);
743 if (!docking) {
744 XMapWindow(dpy, scr->dock_shadow);
746 docking = 1;
747 } else if (docking) {
748 XUnmapWindow(dpy, scr->dock_shadow);
749 docking = 0;
753 break;
755 case ButtonPress:
756 break;
758 case ButtonRelease:
759 if (ev.xbutton.button != clickButton)
760 break;
761 XUngrabPointer(dpy, CurrentTime);
763 if (docking) {
764 Bool docked;
766 /* icon is trying to be docked */
767 SlideWindow(icon->core->window, x, y, shad_x, shad_y);
768 XUnmapWindow(dpy, scr->dock_shadow);
769 docked = wDockAttachIcon(scr->last_dock, aicon, ix, iy);
770 if (scr->last_dock->auto_collapse) {
771 collapsed = 0;
773 if (workspace->clip &&
774 workspace->clip != scr->last_dock &&
775 workspace->clip->auto_raise_lower)
776 wDockLower(workspace->clip);
778 if (!docked) {
779 /* If icon could not be docked, slide it back to the old
780 * position */
781 SlideWindow(icon->core->window, x, y, oldX, oldY);
784 wSoundPlay(WSOUND_DOCK);
785 } else {
786 if (movingSingle) {
787 /* move back to its place */
788 SlideWindow(icon->core->window, x, y, oldX, oldY);
789 wAppIconMove(aicon, oldX, oldY);
790 } else {
791 XMoveWindow(dpy, icon->core->window, x, y);
792 aicon->x_pos = x;
793 aicon->y_pos = y;
795 if (workspace->clip && workspace->clip->auto_raise_lower)
796 wDockLower(workspace->clip);
798 if (collapsed) {
799 scr->last_dock->collapsed = 1;
800 wDockHideIcons(scr->last_dock);
801 collapsed = 0;
803 if (superfluous) {
804 if (ghost!=None)
805 XFreePixmap(dpy, ghost);
806 XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel);
809 if (wPreferences.auto_arrange_icons)
810 wArrangeIcons(scr, True);
812 done = 1;
813 break;
816 #ifdef DEBUG
817 puts("End icon move");
818 #endif