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,
27 #include <X11/Xutil.h>
31 #include "WindowMaker.h"
41 #include "workspace.h"
42 #include "superfluous.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
);
72 wAppIconCreateForDock(WScreen
*scr
, char *command
, char *wm_instance
,
73 char *wm_class
, int tile
)
78 dicon
= wmalloc(sizeof(WAppIcon
));
80 memset(dicon
, 0, sizeof(WAppIcon
));
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
;
92 dicon
->command
= wstrdup(command
);
95 dicon
->wm_class
= wstrdup(wm_class
);
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
);
107 path
= FindImage(wPreferences
.icon_path
, path
);
109 dicon
->icon
= wIconCreateWithIconFile(scr
, path
, tile
);
113 wXDNDMakeAwareness(dicon
->icon
->core
->window
);
115 #ifdef REDUCE_APPICONS
118 #ifdef DEMATERIALIZE_ICON
120 XSetWindowAttributes attribs
;
121 attribs
.save_under
= True
;
122 XChangeWindowAttributes(dpy
, dicon
->icon
->core
->window
,
123 CWSaveUnder
, &attribs
);
127 /* will be overriden by dock */
128 dicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
129 dicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
130 dicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
131 dicon
->icon
->core
->descriptor
.parent
= dicon
;
132 AddToStackList(dicon
->icon
->core
);
140 wAppIconCreate(WWindow
*leader_win
)
143 #ifdef REDUCE_APPICONS
145 WAppIconAppList
*applist
;
146 char *tinstance
, *tclass
;
148 WScreen
*scr
= leader_win
->screen_ptr
;
150 aicon
= wmalloc(sizeof(WAppIcon
));
152 memset(aicon
, 0, sizeof(WAppIcon
));
153 #ifdef REDUCE_APPICONS
154 applist
= wmalloc(sizeof(WAppIconAppList
));
155 memset(applist
, 0, sizeof(WAppIconAppList
));
156 applist
->wapp
= wApplicationOf(leader_win
->main_window
);
157 aicon
->applist
= applist
;
158 if (applist
->wapp
== NULL
) {
159 /* Something's wrong. wApplicationOf() should always return a
160 * valid structure. Rather than violate assumptions, bail. -cls
172 aicon
->next
= scr
->app_icon_list
;
173 if (scr
->app_icon_list
) {
174 #ifndef REDUCE_APPICONS
175 scr
->app_icon_list
->prev
= aicon
;
177 /* If we aren't going to have a match, jump straight to new appicon */
178 if (leader_win
->wm_class
== NULL
|| leader_win
->wm_class
== NULL
)
181 atmp
= scr
->app_icon_list
;
183 while (atmp
!= NULL
) {
184 if ((tinstance
= atmp
->wm_instance
) == NULL
)
186 if ((tclass
= atmp
->wm_class
) == NULL
)
188 if ((strcmp(leader_win
->wm_class
, tclass
) == 0) &&
189 (strcmp(leader_win
->wm_instance
, tinstance
) == 0))
191 /* We have a winner */
194 applist
->next
= atmp
->applist
;
196 atmp
->applist
->prev
= applist
;
197 atmp
->applist
= applist
;
200 wDockSimulateLaunch(atmp
->dock
, atmp
);
208 scr
->app_icon_list
->prev
= aicon
;
210 #endif /* REDUCE_APPICONS */
212 scr
->app_icon_list
= aicon
;
214 if (leader_win
->wm_class
)
215 aicon
->wm_class
= wstrdup(leader_win
->wm_class
);
216 if (leader_win
->wm_instance
)
217 aicon
->wm_instance
= wstrdup(leader_win
->wm_instance
);
218 #ifdef REDUCE_APPICONS
222 aicon
->icon
= wIconCreate(leader_win
);
223 #ifdef DEMATERIALIZE_ICON
225 XSetWindowAttributes attribs
;
226 attribs
.save_under
= True
;
227 XChangeWindowAttributes(dpy
, aicon
->icon
->core
->window
,
228 CWSaveUnder
, &attribs
);
232 wXDNDMakeAwareness(aicon
->icon
->core
->window
);
235 /* will be overriden if docked */
236 aicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
237 aicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
238 aicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
239 aicon
->icon
->core
->descriptor
.parent
= aicon
;
240 AddToStackList(aicon
->icon
->core
);
241 aicon
->icon
->show_title
= 0;
242 wIconUpdate(aicon
->icon
);
249 wAppIconDestroy(WAppIcon
*aicon
)
251 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
252 #ifdef REDUCE_APPICONS
253 WAppIconAppList
*aptmp
;
256 RemoveFromStackList(aicon
->icon
->core
);
257 wIconDestroy(aicon
->icon
);
259 free(aicon
->command
);
261 if (aicon
->dnd_command
)
262 free(aicon
->dnd_command
);
264 if (aicon
->wm_instance
)
265 free(aicon
->wm_instance
);
267 free(aicon
->wm_class
);
268 #ifdef REDUCE_APPICONS
269 /* There should never be a list but just in case */
270 if (aicon
->applist
!= NULL
) {
271 aptmp
= aicon
->applist
;
272 while (aptmp
->next
) {
280 if (aicon
== scr
->app_icon_list
) {
282 aicon
->next
->prev
= NULL
;
283 scr
->app_icon_list
= aicon
->next
;
287 aicon
->next
->prev
= aicon
->prev
;
289 aicon
->prev
->next
= aicon
->next
;
292 aicon
->destroyed
= 1;
300 drawCorner(WIcon
*icon
, WWindow
*wwin
, int active
)
302 WScreen
*scr
= wwin
->screen_ptr
;
313 gc
=scr
->focused_texture
->any
.gc
;
315 gc
=scr
->unfocused_texture
->any
.gc
;
317 XFillPolygon(dpy
, icon
->core
->window
, gc
, points
, 3,
318 Convex
, CoordModeOrigin
);
320 #endif /* NEWAPPICON */
324 drawCorner(WIcon
*icon
)
326 WScreen
*scr
= icon
->core
->screen_ptr
;
335 XFillPolygon(dpy
, icon
->core
->window
, scr
->icon_title_texture
->normal_gc
,
336 points
, 3, Convex
, CoordModeOrigin
);
337 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
339 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
341 /* drawing the second line gives a weird concave look. -Dan */
343 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
345 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
352 wAppIconMove(WAppIcon
*aicon
, int x
, int y
)
354 XMoveWindow(dpy
, aicon
->icon
->core
->window
, x
, y
);
362 updateDockNumbers(WScreen
*scr
)
367 XGCValues my_gc_values
;
368 unsigned long my_v_mask
= (GCForeground
);
369 WAppIcon
*dicon
= scr
->dock
->icon_array
[0];
371 my_gc_values
.foreground
= scr
->white_pixel
;
372 numbers_gc
= XCreateGC(dpy
, dicon
->icon
->core
->window
,
373 my_v_mask
, &my_gc_values
);
375 ws_numbers
= malloc(20);
376 sprintf(ws_numbers
, "%i [ %i ]", scr
->current_workspace
+1,
377 ((scr
->current_workspace
/10)+1));
378 length
= strlen(ws_numbers
);
380 XClearArea(dpy
, dicon
->icon
->core
->window
, 2, 2, 50,
381 WMFontHeight(scr
->icon_title_font
)+1, False
);
383 XSetForeground(dpy
, numbers_gc
, scr
->black_pixel
);
384 WMDrawString(scr
->wmscreen
, dicon
->icon
->core
->window
, numbers_gc
,
385 scr
->icon_title_font
, 4, 3, ws_numbers
, length
);
387 XSetForeground(dpy
, numbers_gc
, scr
->white_pixel
);
388 WMDrawString(scr
->wmscreen
, dicon
->icon
->core
->window
, numbers_gc
,
389 scr
->icon_title_font
, 3, 2, ws_numbers
, length
);
391 XFreeGC(dpy
, numbers_gc
);
394 #endif /* WS_INDICATOR */
398 wAppIconPaint(WAppIcon
*aicon
)
400 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
402 wIconPaint(aicon
->icon
);
406 if (aicon
->docked
&& scr
->dock
&& scr
->dock
==aicon
->dock
&&
408 updateDockNumbers(scr
);
410 if (scr
->dock_dots
&& aicon
->docked
&& !aicon
->running
411 && aicon
->command
!=NULL
) {
412 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
413 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
414 XCopyArea(dpy
, scr
->dock_dots
->image
, aicon
->icon
->core
->window
,
415 scr
->copy_gc
, 0, 0, scr
->dock_dots
->width
,
416 scr
->dock_dots
->height
, 0, 0);
422 wapp
= wApplicationOf(aicon
->main_window
);
423 if (wapp
&& wapp
->flags
.hidden
) {
424 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
425 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
426 XCopyArea(dpy
, scr
->dock_dots
->image
,
427 aicon
->icon
->core
->window
,
428 scr
->copy_gc
, 0, 0, 7,
429 scr
->dock_dots
->height
, 0, 0);
432 #endif /* HIDDENDOT */
435 if (!wPreferences
.strict_ns
&& aicon
->icon
->owner
!=NULL
) {
437 if (aicon
->main_window
==None
) {
438 active
= (aicon
->icon
->owner
->flags
.focused
? 1 : 0);
442 wapp
= wApplicationOf(aicon
->main_window
);
444 active
= aicon
->icon
->owner
->flags
.focused
;
445 wwarning("error in wAppIconPaint(). Please report it");
447 active
= wapp
->main_window_desc
->flags
.focused
;
448 if (wapp
->main_window_desc
->flags
.hidden
449 || !wapp
->main_window_desc
->flags
.mapped
)
454 drawCorner(aicon
->icon
, aicon
->icon
->owner
, active
);
456 #endif /* NEWAPPICON */
458 if (aicon
->omnipresent
)
459 drawCorner(aicon
->icon
);
461 XSetClipMask(dpy
, scr
->copy_gc
, None
);
462 if (aicon
->launching
) {
463 XFillRectangle(dpy
, aicon
->icon
->core
->window
, scr
->stipple_gc
,
464 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
);
470 #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
472 #ifdef REDUCE_APPICONS
474 wAppIconReduceAppCount(WApplication
*wapp
)
476 WAppIconAppList
*applist
;
481 if (wapp
->app_icon
== NULL
)
484 /* If given a main window, check the applist
485 * and remove the if it exists
487 applist
= wapp
->app_icon
->applist
;
488 while (applist
!= NULL
) {
489 if (applist
->wapp
== wapp
) {
490 /* If this app owns the appicon, change the appicon's
491 * owner to the next app in the list or NULL
493 if (wapp
->app_icon
->icon
->owner
== applist
->wapp
->main_window_desc
)
496 wapp
->app_icon
->icon
->owner
= applist
->next
->wapp
->main_window_desc
;
497 } else if (applist
->prev
) {
498 wapp
->app_icon
->icon
->owner
= applist
->prev
->wapp
->main_window_desc
;
500 wapp
->app_icon
->icon
->owner
= NULL
;
504 applist
->prev
->next
= applist
->next
;
507 applist
->next
->prev
= applist
->prev
;
509 if (applist
== wapp
->app_icon
->applist
)
510 wapp
->app_icon
->applist
= applist
->next
;
514 if (wapp
->app_icon
->applist
!= NULL
)
515 wapp
->app_icon
->main_window
= wapp
->app_icon
->applist
->wapp
->main_window
;
517 return (--wapp
->app_icon
->num_apps
);
519 applist
= applist
->next
;
521 return (--wapp
->app_icon
->num_apps
);
527 hideCallback(WMenu
*menu
, WMenuEntry
*entry
)
529 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
531 if (wapp
->flags
.hidden
) {
532 wWorkspaceChange(menu
->menu
->screen_ptr
, wapp
->last_workspace
);
533 wUnhideApplication(wapp
, False
, False
);
535 wHideApplication(wapp
);
541 unhideHereCallback(WMenu
*menu
, WMenuEntry
*entry
)
543 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
545 wUnhideApplication(wapp
, False
, True
);
550 setIconCallback(WMenu
*menu
, WMenuEntry
*entry
)
552 WAppIcon
*icon
= ((WApplication
*)entry
->clientdata
)->app_icon
;
562 scr
= icon
->icon
->core
->screen_ptr
;
566 result
= wIconChooserDialog(scr
, &file
, icon
->wm_instance
, icon
->wm_class
);
568 if (result
&& !icon
->destroyed
) {
573 if (!wIconChangeImageFile(icon
->icon
, file
)) {
574 wMessageDialog(scr
, _("Error"),
575 _("Could not open specified icon file"),
576 _("OK"), NULL
, NULL
);
578 wDefaultChangeIcon(scr
, icon
->wm_instance
, icon
->wm_class
, file
);
590 killCallback(WMenu
*menu
, WMenuEntry
*entry
)
592 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
595 if (!WCHECK_STATE(WSTATE_NORMAL
))
598 WCHANGE_STATE(WSTATE_MODAL
);
600 assert(entry
->clientdata
!=NULL
);
602 buffer
= wstrappend(wapp
->app_icon
? wapp
->app_icon
->wm_class
: NULL
,
603 _(" will be forcibly closed.\n"
604 "Any unsaved changes will be lost.\n"
607 wretain(wapp
->main_window_desc
);
608 if (wPreferences
.dont_confirm_kill
609 || wMessageDialog(menu
->frame
->screen_ptr
, _("Kill Application"),
610 buffer
, _("Yes"), _("No"), NULL
)==WAPRDefault
) {
611 if (!wapp
->main_window_desc
->flags
.destroyed
)
612 wClientKill(wapp
->main_window_desc
);
614 wrelease(wapp
->main_window_desc
);
618 WCHANGE_STATE(WSTATE_NORMAL
);
623 createApplicationMenu(WScreen
*scr
)
627 menu
= wMenuCreate(scr
, NULL
, False
);
628 wMenuAddCallback(menu
, _("Unhide Here"), unhideHereCallback
, NULL
);
629 wMenuAddCallback(menu
, _("Hide"), hideCallback
, NULL
);
630 wMenuAddCallback(menu
, _("Set Icon..."), setIconCallback
, NULL
);
631 wMenuAddCallback(menu
, _("Kill"), killCallback
, NULL
);
638 openApplicationMenu(WApplication
*wapp
, int x
, int y
)
641 WScreen
*scr
= wapp
->main_window_desc
->screen_ptr
;
644 if (!scr
->icon_menu
) {
645 scr
->icon_menu
= createApplicationMenu(scr
);
646 free(scr
->icon_menu
->entries
[1]->text
);
649 menu
= scr
->icon_menu
;
651 if (wapp
->flags
.hidden
) {
652 menu
->entries
[1]->text
= _("Unhide");
654 menu
->entries
[1]->text
= _("Hide");
657 menu
->flags
.realized
= 0;
660 x
-= menu
->frame
->core
->width
/2;
661 if (x
+ menu
->frame
->core
->width
> scr
->scr_width
)
662 x
= scr
->scr_width
- menu
->frame
->core
->width
;
666 /* set client data */
667 for (i
= 0; i
< menu
->entry_no
; i
++) {
668 menu
->entries
[i
]->clientdata
= wapp
;
670 wMenuMapAt(menu
, x
, y
, False
);
674 /******************************************************************/
677 iconExpose(WObjDescriptor
*desc
, XEvent
*event
)
679 wAppIconPaint(desc
->parent
);
684 iconDblClick(WObjDescriptor
*desc
, XEvent
*event
)
686 WAppIcon
*aicon
= desc
->parent
;
688 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
691 #ifndef REDUCE_APPICONS
692 assert(aicon
->icon
->owner
!=NULL
);
694 if (aicon
->icon
->owner
== NULL
) {
695 fprintf(stderr
, "Double-click disabled: missing main window.\n");
700 wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
703 wwarning("could not find application descriptor for app icon!!");
707 #ifdef REDUCE_APPICONS
709 fprintf(stderr
, "Double-click disabled: missing wapp.\n");
712 #endif /* REDUCE_APPICONS */
714 unhideHere
= (event
->xbutton
.state
& ShiftMask
);
716 /* go to the last workspace that the user worked on the app */
717 if (!unhideHere
&& wapp
->last_workspace
!= scr
->current_workspace
)
718 wWorkspaceChange(scr
, wapp
->last_workspace
);
720 wUnhideApplication(wapp
, event
->xbutton
.button
==Button2
, unhideHere
);
722 if (event
->xbutton
.state
& MOD_MASK
) {
723 wHideOtherApplications(aicon
->icon
->owner
);
729 appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
731 WAppIcon
*aicon
= desc
->parent
;
732 WIcon
*icon
= aicon
->icon
;
734 int x
=aicon
->x_pos
, y
=aicon
->y_pos
;
735 int dx
=event
->xbutton
.x
, dy
=event
->xbutton
.y
;
738 int superfluous
= wPreferences
.superfluous
; /* we catch it to avoid problems */
739 WScreen
*scr
= icon
->core
->screen_ptr
;
740 WWorkspace
*workspace
= scr
->workspaces
[scr
->current_workspace
];
741 int shad_x
= 0, shad_y
= 0, docking
=0, dockable
, collapsed
= 0;
743 int clickButton
= event
->xbutton
.button
;
747 if (aicon
->editing
|| WCHECK_STATE(WSTATE_MODAL
))
750 if (IsDoubleClick(scr
, event
)) {
751 iconDblClick(desc
, event
);
755 if (event
->xbutton
.button
== Button3
) {
756 WObjDescriptor
*desc
;
757 WApplication
*wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
762 openApplicationMenu(wapp
, event
->xbutton
.x_root
,
763 event
->xbutton
.y_root
);
765 /* allow drag select of menu */
766 desc
= &scr
->icon_menu
->menu
->descriptor
;
767 event
->xbutton
.send_event
= True
;
768 (*desc
->handle_mousedown
)(desc
, event
);
775 if (event
->xbutton
.state
& MOD_MASK
)
776 wLowerFrame(icon
->core
);
778 wRaiseFrame(icon
->core
);
781 if (XGrabPointer(dpy
, icon
->core
->window
, True
, ButtonMotionMask
782 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
783 GrabModeAsync
, None
, None
, CurrentTime
) !=GrabSuccess
) {
784 wwarning("pointer grab failed for appicon move");
787 if (wPreferences
.flags
.nodock
&& wPreferences
.flags
.noclip
)
790 dockable
= canBeDocked(icon
->owner
);
792 wins
[0] = icon
->core
->window
;
793 wins
[1] = scr
->dock_shadow
;
794 XRestackWindows(dpy
, wins
, 2);
796 if (icon
->pixmap
!=None
)
797 ghost
= MakeGhostIcon(scr
, icon
->pixmap
);
799 ghost
= MakeGhostIcon(scr
, icon
->core
->window
);
800 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
802 XClearWindow(dpy
, scr
->dock_shadow
);
806 WMMaskEvent(dpy
, PointerMotionMask
|ButtonReleaseMask
|ButtonPressMask
807 |ButtonMotionMask
|ExposureMask
, &ev
);
815 if (abs(dx
-ev
.xmotion
.x
)>=MOVE_THRESHOLD
816 || abs(dy
-ev
.xmotion
.y
)>=MOVE_THRESHOLD
) {
817 XChangeActivePointerGrab(dpy
, ButtonMotionMask
818 |ButtonReleaseMask
|ButtonPressMask
,
819 wCursor
[WCUR_MOVE
], CurrentTime
);
825 x
= ev
.xmotion
.x_root
- dx
;
826 y
= ev
.xmotion
.y_root
- dy
;
827 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
830 if (scr
->dock
&& wDockSnapIcon(scr
->dock
, aicon
, x
, y
,
832 shad_x
= scr
->dock
->x_pos
+ ix
*wPreferences
.icon_size
;
833 shad_y
= scr
->dock
->y_pos
+ iy
*wPreferences
.icon_size
;
835 if (scr
->last_dock
!= scr
->dock
&& collapsed
) {
836 scr
->last_dock
->collapsed
= 1;
837 wDockHideIcons(scr
->last_dock
);
840 if (!collapsed
&& (collapsed
= scr
->dock
->collapsed
)) {
841 scr
->dock
->collapsed
= 0;
842 wDockShowIcons(scr
->dock
);
845 if (scr
->dock
->auto_raise_lower
)
846 wDockRaise(scr
->dock
);
848 scr
->last_dock
= scr
->dock
;
850 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
852 XMapWindow(dpy
, scr
->dock_shadow
);
855 } else if (workspace
->clip
&&
856 wDockSnapIcon(workspace
->clip
, aicon
, x
, y
,
858 shad_x
= workspace
->clip
->x_pos
+ ix
*wPreferences
.icon_size
;
859 shad_y
= workspace
->clip
->y_pos
+ iy
*wPreferences
.icon_size
;
861 if (scr
->last_dock
!= workspace
->clip
&& collapsed
) {
862 scr
->last_dock
->collapsed
= 1;
863 wDockHideIcons(scr
->last_dock
);
866 if (!collapsed
&& (collapsed
= workspace
->clip
->collapsed
)) {
867 workspace
->clip
->collapsed
= 0;
868 wDockShowIcons(workspace
->clip
);
871 if (workspace
->clip
->auto_raise_lower
)
872 wDockRaise(workspace
->clip
);
874 scr
->last_dock
= workspace
->clip
;
876 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
878 XMapWindow(dpy
, scr
->dock_shadow
);
881 } else if (docking
) {
882 XUnmapWindow(dpy
, scr
->dock_shadow
);
893 if (ev
.xbutton
.button
!= clickButton
)
895 XUngrabPointer(dpy
, CurrentTime
);
900 /* icon is trying to be docked */
901 SlideWindow(icon
->core
->window
, x
, y
, shad_x
, shad_y
);
902 XUnmapWindow(dpy
, scr
->dock_shadow
);
903 docked
= wDockAttachIcon(scr
->last_dock
, aicon
, ix
, iy
);
904 if (scr
->last_dock
->auto_collapse
) {
907 if (workspace
->clip
&&
908 workspace
->clip
!= scr
->last_dock
&&
909 workspace
->clip
->auto_raise_lower
)
910 wDockLower(workspace
->clip
);
913 /* If icon could not be docked, slide it back to the old
915 SlideWindow(icon
->core
->window
, x
, y
, aicon
->x_pos
,
920 wSoundPlay(WMSOUND_DOCK
);
923 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
926 if (workspace
->clip
&& workspace
->clip
->auto_raise_lower
)
927 wDockLower(workspace
->clip
);
930 scr
->last_dock
->collapsed
= 1;
931 wDockHideIcons(scr
->last_dock
);
936 XFreePixmap(dpy
, ghost
);
937 XSetWindowBackground(dpy
, scr
->dock_shadow
, scr
->white_pixel
);
940 if (wPreferences
.auto_arrange_icons
)
941 wArrangeIcons(scr
, True
);
948 puts("End icon move");