Also relaunch from appicon with Ctrl + DblClick.
[wmaker-crm.git] / src / appicon.c
blob80f08f46ca292bfb87595603b05d3cf152a47631
1 /* appicon.c- icon for applications (not mini-window)
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 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 along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "wconfig.h"
25 #include <X11/Xlib.h>
26 #include <X11/Xutil.h>
27 #include <stdlib.h>
28 #include <string.h>
30 #include "WindowMaker.h"
31 #include "window.h"
32 #include "icon.h"
33 #include "application.h"
34 #include "appicon.h"
35 #include "actions.h"
36 #include "stacking.h"
37 #include "dock.h"
38 #include "funcs.h"
39 #include "defaults.h"
40 #include "workspace.h"
41 #include "superfluous.h"
42 #include "menu.h"
43 #include "framewin.h"
44 #include "dialog.h"
45 #include "client.h"
46 #ifdef XDND
47 #include "xdnd.h"
48 #endif
51 * icon_file for the dock is got from the preferences file by
52 * using the classname/instancename
55 /**** Global variables ****/
56 extern Cursor wCursor[WCUR_LAST];
57 extern WPreferences wPreferences;
59 #define MOD_MASK wPreferences.modifier_mask
61 void appIconMouseDown(WObjDescriptor * desc, XEvent * event);
62 static void iconDblClick(WObjDescriptor * desc, XEvent * event);
63 static void iconExpose(WObjDescriptor * desc, XEvent * event);
65 WAppIcon *wAppIconCreateForDock(WScreen * scr, char *command, char *wm_instance, char *wm_class, int tile)
67 WAppIcon *dicon;
68 char *path;
70 dicon = wmalloc(sizeof(WAppIcon));
71 wretain(dicon);
72 memset(dicon, 0, sizeof(WAppIcon));
73 dicon->yindex = -1;
74 dicon->xindex = -1;
76 dicon->prev = NULL;
77 dicon->next = scr->app_icon_list;
78 if (scr->app_icon_list)
79 scr->app_icon_list->prev = dicon;
81 scr->app_icon_list = dicon;
83 if (command)
84 dicon->command = wstrdup(command);
86 if (wm_class)
87 dicon->wm_class = wstrdup(wm_class);
89 if (wm_instance)
90 dicon->wm_instance = wstrdup(wm_instance);
92 path = wDefaultGetIconFile(scr, wm_instance, wm_class, True);
93 if (!path && command) {
94 wApplicationExtractDirPackIcon(scr, command, wm_instance, wm_class);
95 path = wDefaultGetIconFile(scr, wm_instance, wm_class, False);
98 if (path)
99 path = FindImage(wPreferences.icon_path, path);
101 dicon->icon = wIconCreateWithIconFile(scr, path, tile);
102 if (path)
103 wfree(path);
104 #ifdef XDND
105 wXDNDMakeAwareness(dicon->icon->core->window);
106 #endif
108 /* will be overriden by dock */
109 dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
110 dicon->icon->core->descriptor.handle_expose = iconExpose;
111 dicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
112 dicon->icon->core->descriptor.parent = dicon;
113 AddToStackList(dicon->icon->core);
115 return dicon;
118 WAppIcon *wAppIconCreate(WWindow * leader_win)
120 WAppIcon *aicon;
121 WScreen *scr = leader_win->screen_ptr;
123 aicon = wmalloc(sizeof(WAppIcon));
124 wretain(aicon);
125 memset(aicon, 0, sizeof(WAppIcon));
127 aicon->yindex = -1;
128 aicon->xindex = -1;
130 aicon->prev = NULL;
131 aicon->next = scr->app_icon_list;
132 if (scr->app_icon_list)
133 scr->app_icon_list->prev = aicon;
135 scr->app_icon_list = aicon;
137 if (leader_win->wm_class)
138 aicon->wm_class = wstrdup(leader_win->wm_class);
140 if (leader_win->wm_instance)
141 aicon->wm_instance = wstrdup(leader_win->wm_instance);
143 aicon->icon = wIconCreate(leader_win);
144 #ifdef XDND
145 wXDNDMakeAwareness(aicon->icon->core->window);
146 #endif
148 /* will be overriden if docked */
149 aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
150 aicon->icon->core->descriptor.handle_expose = iconExpose;
151 aicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
152 aicon->icon->core->descriptor.parent = aicon;
153 AddToStackList(aicon->icon->core);
154 aicon->icon->show_title = 0;
155 wIconUpdate(aicon->icon);
157 return aicon;
160 void wAppIconDestroy(WAppIcon * aicon)
162 WScreen *scr = aicon->icon->core->screen_ptr;
164 RemoveFromStackList(aicon->icon->core);
165 wIconDestroy(aicon->icon);
166 if (aicon->command)
167 wfree(aicon->command);
168 #ifdef XDND
169 if (aicon->dnd_command)
170 wfree(aicon->dnd_command);
171 #endif
172 if (aicon->wm_instance)
173 wfree(aicon->wm_instance);
175 if (aicon->wm_class)
176 wfree(aicon->wm_class);
178 if (aicon == scr->app_icon_list) {
179 if (aicon->next)
180 aicon->next->prev = NULL;
181 scr->app_icon_list = aicon->next;
182 } else {
183 if (aicon->next)
184 aicon->next->prev = aicon->prev;
185 if (aicon->prev)
186 aicon->prev->next = aicon->next;
189 aicon->destroyed = 1;
190 wrelease(aicon);
193 static void drawCorner(WIcon * icon)
195 WScreen *scr = icon->core->screen_ptr;
196 XPoint points[3];
198 points[0].x = 1;
199 points[0].y = 1;
200 points[1].x = 12;
201 points[1].y = 1;
202 points[2].x = 1;
203 points[2].y = 12;
204 XFillPolygon(dpy, icon->core->window, scr->icon_title_texture->normal_gc,
205 points, 3, Convex, CoordModeOrigin);
206 XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc, 0, 0, 0, 12);
207 XDrawLine(dpy, icon->core->window, scr->icon_title_texture->light_gc, 0, 0, 12, 0);
210 void wAppIconMove(WAppIcon * aicon, int x, int y)
212 XMoveWindow(dpy, aicon->icon->core->window, x, y);
213 aicon->x_pos = x;
214 aicon->y_pos = y;
217 #ifdef WS_INDICATOR
218 static void updateDockNumbers(WScreen * scr)
220 int length;
221 char *ws_numbers;
222 WAppIcon *dicon = scr->dock->icon_array[0];
224 ws_numbers = wmalloc(20);
225 snprintf(ws_numbers, 20, "%i [ %i ]", scr->current_workspace + 1, ((scr->current_workspace / 10) + 1));
226 length = strlen(ws_numbers);
228 XClearArea(dpy, dicon->icon->core->window, 2, 2, 50, WMFontHeight(scr->icon_title_font) + 1, False);
230 WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->black,
231 scr->icon_title_font, 4, 3, ws_numbers, length);
233 WMDrawString(scr->wmscreen, dicon->icon->core->window, scr->white,
234 scr->icon_title_font, 3, 2, ws_numbers, length);
236 wfree(ws_numbers);
238 #endif /* WS_INDICATOR */
240 void wAppIconPaint(WAppIcon * aicon)
242 WApplication *wapp;
243 WScreen *scr = aicon->icon->core->screen_ptr;
245 if (aicon->icon->owner)
246 wapp = wApplicationOf(aicon->icon->owner->main_window);
247 else
248 wapp = NULL;
250 wIconPaint(aicon->icon);
252 # ifdef WS_INDICATOR
253 if (aicon->docked && scr->dock && scr->dock == aicon->dock && aicon->yindex == 0)
254 updateDockNumbers(scr);
255 # endif
256 if (scr->dock_dots && aicon->docked && !aicon->running && aicon->command != NULL) {
257 XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
258 XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
259 XCopyArea(dpy, scr->dock_dots->image, aicon->icon->core->window,
260 scr->copy_gc, 0, 0, scr->dock_dots->width, scr->dock_dots->height, 0, 0);
262 #ifdef HIDDENDOT
263 if (wapp && wapp->flags.hidden) {
264 XSetClipMask(dpy, scr->copy_gc, scr->dock_dots->mask);
265 XSetClipOrigin(dpy, scr->copy_gc, 0, 0);
266 XCopyArea(dpy, scr->dock_dots->image,
267 aicon->icon->core->window, scr->copy_gc, 0, 0, 7, scr->dock_dots->height, 0, 0);
269 #endif /* HIDDENDOT */
271 if (aicon->omnipresent)
272 drawCorner(aicon->icon);
274 XSetClipMask(dpy, scr->copy_gc, None);
275 if (aicon->launching)
276 XFillRectangle(dpy, aicon->icon->core->window, scr->stipple_gc,
277 0, 0, wPreferences.icon_size, wPreferences.icon_size);
280 Bool wAppIconSave(WAppIcon *aicon)
282 char *path;
284 if (!aicon->docked || aicon->attracted) return True;
286 path = wIconStore(aicon->icon);
287 if (!path)
288 return False;
290 wApplicationSaveIconPathFor(path, aicon->wm_instance, aicon->wm_class);
292 wfree(path);
293 return True;
296 #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
298 /* main_window may not have the full command line; try to find one which does */
299 static void relaunchApplication(WApplication *wapp)
301 WScreen *scr;
302 WWindow *wlist, *next;
304 scr = wapp->main_window_desc->screen_ptr;
305 wlist = scr->focused_window;
306 if (! wlist)
307 return;
309 while (wlist->prev)
310 wlist = wlist->prev;
312 while (wlist) {
313 next = wlist->next;
315 if (wlist->main_window == wapp->main_window) {
316 if (RelaunchWindow(wlist))
317 return;
320 wlist = next;
324 static void relaunchCallback(WMenu * menu, WMenuEntry * entry)
326 WApplication *wapp = (WApplication *) entry->clientdata;
328 relaunchApplication(wapp);
331 static void hideCallback(WMenu * menu, WMenuEntry * entry)
333 WApplication *wapp = (WApplication *) entry->clientdata;
335 if (wapp->flags.hidden) {
336 wWorkspaceChange(menu->menu->screen_ptr, wapp->last_workspace);
337 wUnhideApplication(wapp, False, False);
338 } else {
339 wHideApplication(wapp);
343 static void unhideHereCallback(WMenu * menu, WMenuEntry * entry)
345 WApplication *wapp = (WApplication *) entry->clientdata;
347 wUnhideApplication(wapp, False, True);
350 static void setIconCallback(WMenu * menu, WMenuEntry * entry)
352 WAppIcon *icon = ((WApplication *) entry->clientdata)->app_icon;
353 char *file = NULL;
354 WScreen *scr;
355 int result;
357 assert(icon != NULL);
359 if (icon->editing)
360 return;
362 icon->editing = 1;
363 scr = icon->icon->core->screen_ptr;
365 wretain(icon);
367 result = wIconChooserDialog(scr, &file, icon->wm_instance, icon->wm_class);
369 if (result && !icon->destroyed) {
370 if (file && *file == 0) {
371 wfree(file);
372 file = NULL;
374 if (!wIconChangeImageFile(icon->icon, file)) {
375 wMessageDialog(scr, _("Error"),
376 _("Could not open specified icon file"), _("OK"), NULL, NULL);
377 } else {
378 wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file);
379 wAppIconPaint(icon);
381 if (file)
382 wfree(file);
384 icon->editing = 0;
385 wrelease(icon);
388 static void killCallback(WMenu * menu, WMenuEntry * entry)
390 WApplication *wapp = (WApplication *) entry->clientdata;
391 WFakeGroupLeader *fPtr;
392 char *buffer;
393 char *shortname;
394 char *basename(const char *shortname);
396 if (!WCHECK_STATE(WSTATE_NORMAL))
397 return;
399 WCHANGE_STATE(WSTATE_MODAL);
401 assert(entry->clientdata != NULL);
403 shortname = basename(wapp->app_icon->wm_instance);
405 buffer = wstrconcat(wapp->app_icon ? shortname : NULL,
406 _(" will be forcibly closed.\n"
407 "Any unsaved changes will be lost.\n" "Please confirm."));
409 fPtr = wapp->main_window_desc->fake_group;
411 wretain(wapp->main_window_desc);
412 if (wPreferences.dont_confirm_kill
413 || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"),
414 buffer, _("Yes"), _("No"), NULL) == WAPRDefault) {
415 if (fPtr != NULL) {
416 WWindow *wwin, *twin;
418 wwin = wapp->main_window_desc->screen_ptr->focused_window;
419 while (wwin) {
420 twin = wwin->prev;
421 if (wwin->fake_group == fPtr)
422 wClientKill(wwin);
423 wwin = twin;
425 } else if (!wapp->main_window_desc->flags.destroyed) {
426 wClientKill(wapp->main_window_desc);
429 wrelease(wapp->main_window_desc);
430 wfree(buffer);
431 WCHANGE_STATE(WSTATE_NORMAL);
434 static WMenu *createApplicationMenu(WScreen * scr)
436 WMenu *menu;
438 menu = wMenuCreate(scr, NULL, False);
439 wMenuAddCallback(menu, _("Launch"), relaunchCallback, NULL);
440 wMenuAddCallback(menu, _("Unhide Here"), unhideHereCallback, NULL);
441 wMenuAddCallback(menu, _("Hide"), hideCallback, NULL);
442 wMenuAddCallback(menu, _("Set Icon..."), setIconCallback, NULL);
443 wMenuAddCallback(menu, _("Kill"), killCallback, NULL);
445 return menu;
448 static void openApplicationMenu(WApplication * wapp, int x, int y)
450 WMenu *menu;
451 WScreen *scr = wapp->main_window_desc->screen_ptr;
452 int i;
454 if (!scr->icon_menu) {
455 scr->icon_menu = createApplicationMenu(scr);
456 wfree(scr->icon_menu->entries[1]->text);
459 menu = scr->icon_menu;
461 if (wapp->flags.hidden)
462 menu->entries[1]->text = _("Unhide");
463 else
464 menu->entries[1]->text = _("Hide");
466 menu->flags.realized = 0;
467 wMenuRealize(menu);
469 x -= menu->frame->core->width / 2;
470 if (x + menu->frame->core->width > scr->scr_width)
471 x = scr->scr_width - menu->frame->core->width;
473 if (x < 0)
474 x = 0;
476 /* set client data */
477 for (i = 0; i < menu->entry_no; i++)
478 menu->entries[i]->clientdata = wapp;
480 wMenuMapAt(menu, x, y, False);
483 /******************************************************************/
485 static void iconExpose(WObjDescriptor * desc, XEvent * event)
487 wAppIconPaint(desc->parent);
490 static void iconDblClick(WObjDescriptor * desc, XEvent * event)
492 WAppIcon *aicon = desc->parent;
493 WApplication *wapp;
494 WScreen *scr = aicon->icon->core->screen_ptr;
495 int unhideHere;
497 assert(aicon->icon->owner != NULL);
499 wapp = wApplicationOf(aicon->icon->owner->main_window);
501 if (event->xbutton.state & ControlMask) {
502 relaunchApplication(wapp);
503 return;
506 unhideHere = (event->xbutton.state & ShiftMask);
507 /* go to the last workspace that the user worked on the app */
508 if (!unhideHere && wapp->last_workspace != scr->current_workspace)
509 wWorkspaceChange(scr, wapp->last_workspace);
511 wUnhideApplication(wapp, event->xbutton.button == Button2, unhideHere);
513 if (event->xbutton.state & MOD_MASK)
514 wHideOtherApplications(aicon->icon->owner);
517 void appIconMouseDown(WObjDescriptor * desc, XEvent * event)
519 WAppIcon *aicon = desc->parent;
520 WIcon *icon = aicon->icon;
521 XEvent ev;
522 int x = aicon->x_pos, y = aicon->y_pos;
523 int dx = event->xbutton.x, dy = event->xbutton.y;
524 int grabbed = 0;
525 int done = 0;
526 int superfluous = wPreferences.superfluous; /* we catch it to avoid problems */
527 WScreen *scr = icon->core->screen_ptr;
528 WWorkspace *workspace = scr->workspaces[scr->current_workspace];
529 int shad_x = 0, shad_y = 0, docking = 0, dockable, collapsed = 0;
530 int ix, iy;
531 int clickButton = event->xbutton.button;
532 Pixmap ghost = None;
533 Window wins[2];
534 Bool movingSingle = False;
535 int oldX = x;
536 int oldY = y;
537 Bool hasMoved = False;
539 if (aicon->editing || WCHECK_STATE(WSTATE_MODAL))
540 return;
542 if (IsDoubleClick(scr, event)) {
543 /* Middle or right mouse actions were handled on first click */
544 if (event->xbutton.button == Button1)
545 iconDblClick(desc, event);
546 return;
549 if (event->xbutton.button == Button2) {
550 WApplication *wapp = wApplicationOf(aicon->icon->owner->main_window);
552 if (!wapp)
553 return;
555 relaunchApplication(wapp);
556 return;
559 if (event->xbutton.button == Button3) {
560 WObjDescriptor *desc;
561 WApplication *wapp = wApplicationOf(aicon->icon->owner->main_window);
563 if (!wapp)
564 return;
566 if (event->xbutton.send_event &&
567 XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask
568 | ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
569 GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
570 wwarning("pointer grab failed for appicon menu");
571 return;
574 openApplicationMenu(wapp, event->xbutton.x_root, event->xbutton.y_root);
576 /* allow drag select of menu */
577 desc = &scr->icon_menu->menu->descriptor;
578 event->xbutton.send_event = True;
579 (*desc->handle_mousedown) (desc, event);
580 return;
583 if (event->xbutton.state & MOD_MASK)
584 wLowerFrame(icon->core);
585 else
586 wRaiseFrame(icon->core);
588 if (XGrabPointer(dpy, icon->core->window, True, ButtonMotionMask
589 | ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
590 GrabModeAsync, None, None, CurrentTime) != GrabSuccess)
591 wwarning("pointer grab failed for appicon move");
593 if (wPreferences.flags.nodock && wPreferences.flags.noclip)
594 dockable = 0;
595 else
596 dockable = canBeDocked(icon->owner);
598 wins[0] = icon->core->window;
599 wins[1] = scr->dock_shadow;
600 XRestackWindows(dpy, wins, 2);
601 if (superfluous) {
602 if (icon->pixmap != None)
603 ghost = MakeGhostIcon(scr, icon->pixmap);
604 else
605 ghost = MakeGhostIcon(scr, icon->core->window);
606 XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, ghost);
607 XClearWindow(dpy, scr->dock_shadow);
610 while (!done) {
611 WMMaskEvent(dpy, PointerMotionMask | ButtonReleaseMask | ButtonPressMask
612 | ButtonMotionMask | ExposureMask | EnterWindowMask, &ev);
613 switch (ev.type) {
614 case Expose:
615 WMHandleEvent(&ev);
616 break;
618 case EnterNotify:
619 /* It means the cursor moved so fast that it entered
620 * something else (if moving slowly, it would have
621 * stayed in the appIcon that is being moved. Ignore
622 * such "spurious" EnterNotifiy's */
623 break;
625 case MotionNotify:
626 hasMoved = True;
627 if (!grabbed) {
628 if (abs(dx - ev.xmotion.x) >= MOVE_THRESHOLD
629 || abs(dy - ev.xmotion.y) >= MOVE_THRESHOLD) {
630 XChangeActivePointerGrab(dpy, ButtonMotionMask
631 | ButtonReleaseMask | ButtonPressMask,
632 wCursor[WCUR_MOVE], CurrentTime);
633 grabbed = 1;
634 } else {
635 break;
638 x = ev.xmotion.x_root - dx;
639 y = ev.xmotion.y_root - dy;
641 if (movingSingle)
642 XMoveWindow(dpy, icon->core->window, x, y);
643 else
644 wAppIconMove(aicon, x, y);
646 if (dockable) {
647 if (scr->dock && wDockSnapIcon(scr->dock, aicon, x, y, &ix, &iy, False)) {
648 shad_x = scr->dock->x_pos + ix * wPreferences.icon_size;
649 shad_y = scr->dock->y_pos + iy * wPreferences.icon_size;
651 if (scr->last_dock != scr->dock && collapsed) {
652 scr->last_dock->collapsed = 1;
653 wDockHideIcons(scr->last_dock);
654 collapsed = 0;
656 if (!collapsed && (collapsed = scr->dock->collapsed)) {
657 scr->dock->collapsed = 0;
658 wDockShowIcons(scr->dock);
661 if (scr->dock->auto_raise_lower)
662 wDockRaise(scr->dock);
664 scr->last_dock = scr->dock;
666 XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y);
667 if (!docking)
668 XMapWindow(dpy, scr->dock_shadow);
670 docking = 1;
671 } else if (workspace->clip &&
672 wDockSnapIcon(workspace->clip, aicon, x, y, &ix, &iy, False)) {
673 shad_x = workspace->clip->x_pos + ix * wPreferences.icon_size;
674 shad_y = workspace->clip->y_pos + iy * wPreferences.icon_size;
676 if (scr->last_dock != workspace->clip && collapsed) {
677 scr->last_dock->collapsed = 1;
678 wDockHideIcons(scr->last_dock);
679 collapsed = 0;
681 if (!collapsed && (collapsed = workspace->clip->collapsed)) {
682 workspace->clip->collapsed = 0;
683 wDockShowIcons(workspace->clip);
686 if (workspace->clip->auto_raise_lower)
687 wDockRaise(workspace->clip);
689 scr->last_dock = workspace->clip;
691 XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y);
692 if (!docking)
693 XMapWindow(dpy, scr->dock_shadow);
695 docking = 1;
696 } else if (docking) {
697 XUnmapWindow(dpy, scr->dock_shadow);
698 docking = 0;
701 break;
703 case ButtonPress:
704 break;
706 case ButtonRelease:
707 if (ev.xbutton.button != clickButton)
708 break;
709 XUngrabPointer(dpy, CurrentTime);
711 if (docking) {
712 Bool docked;
714 /* icon is trying to be docked */
715 SlideWindow(icon->core->window, x, y, shad_x, shad_y);
716 XUnmapWindow(dpy, scr->dock_shadow);
717 docked = wDockAttachIcon(scr->last_dock, aicon, ix, iy);
718 if (scr->last_dock->auto_collapse)
719 collapsed = 0;
721 if (workspace->clip &&
722 workspace->clip != scr->last_dock && workspace->clip->auto_raise_lower)
723 wDockLower(workspace->clip);
725 if (!docked) {
726 /* If icon could not be docked, slide it back to the old
727 * position */
728 SlideWindow(icon->core->window, x, y, oldX, oldY);
730 } else {
731 if (movingSingle) {
732 /* move back to its place */
733 SlideWindow(icon->core->window, x, y, oldX, oldY);
734 wAppIconMove(aicon, oldX, oldY);
735 } else {
736 XMoveWindow(dpy, icon->core->window, x, y);
737 aicon->x_pos = x;
738 aicon->y_pos = y;
740 if (workspace->clip && workspace->clip->auto_raise_lower)
741 wDockLower(workspace->clip);
743 if (collapsed) {
744 scr->last_dock->collapsed = 1;
745 wDockHideIcons(scr->last_dock);
746 collapsed = 0;
748 if (superfluous) {
749 if (ghost != None)
750 XFreePixmap(dpy, ghost);
751 XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel);
754 if (wPreferences.auto_arrange_icons)
755 wArrangeIcons(scr, True);
757 if (wPreferences.single_click && !hasMoved)
758 iconDblClick(desc, event);
760 done = 1;
761 break;