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"
54 * icon_file for the dock is got from the preferences file by
55 * using the classname/instancename
58 /**** Global variables ****/
59 extern Cursor wCursor
[WCUR_LAST
];
60 extern WPreferences wPreferences
;
62 #define MOD_MASK wPreferences.modifier_mask
64 void appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
65 static void iconDblClick(WObjDescriptor
*desc
, XEvent
*event
);
66 static void iconExpose(WObjDescriptor
*desc
, XEvent
*event
);
71 wAppIconCreateForDock(WScreen
*scr
, char *command
, char *wm_instance
,
72 char *wm_class
, int tile
)
77 dicon
= wmalloc(sizeof(WAppIcon
));
79 memset(dicon
, 0, sizeof(WAppIcon
));
84 dicon
->next
= scr
->app_icon_list
;
85 if (scr
->app_icon_list
) {
86 scr
->app_icon_list
->prev
= dicon
;
88 scr
->app_icon_list
= dicon
;
91 dicon
->command
= wstrdup(command
);
94 dicon
->wm_class
= wstrdup(wm_class
);
96 dicon
->wm_instance
= wstrdup(wm_instance
);
98 path
= wDefaultGetIconFile(scr
, wm_instance
, wm_class
, True
);
99 if (!path
&& command
) {
100 wApplicationExtractDirPackIcon(scr
, command
, wm_instance
, wm_class
);
102 path
= wDefaultGetIconFile(scr
, wm_instance
, wm_class
, False
);
106 path
= FindImage(wPreferences
.icon_path
, path
);
108 dicon
->icon
= wIconCreateWithIconFile(scr
, path
, tile
);
112 wXDNDMakeAwareness(dicon
->icon
->core
->window
);
114 #ifdef REDUCE_APPICONS
117 #ifdef DEMATERIALIZE_ICON
119 XSetWindowAttributes attribs
;
120 attribs
.save_under
= True
;
121 XChangeWindowAttributes(dpy
, dicon
->icon
->core
->window
,
122 CWSaveUnder
, &attribs
);
126 /* will be overriden by dock */
127 dicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
128 dicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
129 dicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
130 dicon
->icon
->core
->descriptor
.parent
= dicon
;
131 AddToStackList(dicon
->icon
->core
);
139 wAppIconCreate(WWindow
*leader_win
)
142 #ifdef REDUCE_APPICONS
144 WAppIconAppList
*applist
;
145 char *tinstance
, *tclass
;
147 WScreen
*scr
= leader_win
->screen_ptr
;
149 aicon
= wmalloc(sizeof(WAppIcon
));
151 memset(aicon
, 0, sizeof(WAppIcon
));
152 #ifdef REDUCE_APPICONS
153 applist
= wmalloc(sizeof(WAppIconAppList
));
154 memset(applist
, 0, sizeof(WAppIconAppList
));
155 applist
->wapp
= wApplicationOf(leader_win
->main_window
);
156 aicon
->applist
= applist
;
157 if (applist
->wapp
== NULL
) {
158 /* Something's wrong. wApplicationOf() should always return a
159 * valid structure. Rather than violate assumptions, bail. -cls
171 aicon
->next
= scr
->app_icon_list
;
172 if (scr
->app_icon_list
) {
173 #ifndef REDUCE_APPICONS
174 scr
->app_icon_list
->prev
= aicon
;
176 /* If we aren't going to have a match, jump straight to new appicon */
177 if (leader_win
->wm_class
== NULL
|| leader_win
->wm_class
== NULL
)
180 atmp
= scr
->app_icon_list
;
182 while (atmp
!= NULL
) {
183 if ((tinstance
= atmp
->wm_instance
) == NULL
)
185 if ((tclass
= atmp
->wm_class
) == NULL
)
187 if ((strcmp(leader_win
->wm_class
, tclass
) == 0) &&
188 (strcmp(leader_win
->wm_instance
, tinstance
) == 0))
190 /* We have a winner */
193 applist
->next
= atmp
->applist
;
195 atmp
->applist
->prev
= applist
;
196 atmp
->applist
= applist
;
199 wDockSimulateLaunch(atmp
->dock
, atmp
);
207 scr
->app_icon_list
->prev
= aicon
;
209 #endif /* REDUCE_APPICONS */
211 scr
->app_icon_list
= aicon
;
213 if (leader_win
->wm_class
)
214 aicon
->wm_class
= wstrdup(leader_win
->wm_class
);
215 if (leader_win
->wm_instance
)
216 aicon
->wm_instance
= wstrdup(leader_win
->wm_instance
);
217 #ifdef REDUCE_APPICONS
221 aicon
->icon
= wIconCreate(leader_win
);
222 #ifdef DEMATERIALIZE_ICON
224 XSetWindowAttributes attribs
;
225 attribs
.save_under
= True
;
226 XChangeWindowAttributes(dpy
, aicon
->icon
->core
->window
,
227 CWSaveUnder
, &attribs
);
231 wXDNDMakeAwareness(aicon
->icon
->core
->window
);
234 /* will be overriden if docked */
235 aicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
236 aicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
237 aicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
238 aicon
->icon
->core
->descriptor
.parent
= aicon
;
239 AddToStackList(aicon
->icon
->core
);
240 aicon
->icon
->show_title
= 0;
241 wIconUpdate(aicon
->icon
);
248 wAppIconDestroy(WAppIcon
*aicon
)
250 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
251 #ifdef REDUCE_APPICONS
252 WAppIconAppList
*aptmp
;
255 RemoveFromStackList(aicon
->icon
->core
);
256 wIconDestroy(aicon
->icon
);
258 free(aicon
->command
);
260 if (aicon
->dnd_command
)
261 free(aicon
->dnd_command
);
263 if (aicon
->wm_instance
)
264 free(aicon
->wm_instance
);
266 free(aicon
->wm_class
);
267 #ifdef REDUCE_APPICONS
268 /* There should never be a list but just in case */
269 if (aicon
->applist
!= NULL
) {
270 aptmp
= aicon
->applist
;
271 while (aptmp
->next
) {
279 if (aicon
== scr
->app_icon_list
) {
281 aicon
->next
->prev
= NULL
;
282 scr
->app_icon_list
= aicon
->next
;
286 aicon
->next
->prev
= aicon
->prev
;
288 aicon
->prev
->next
= aicon
->next
;
291 aicon
->destroyed
= 1;
299 drawCorner(WIcon
*icon
, WWindow
*wwin
, int active
)
301 WScreen
*scr
= wwin
->screen_ptr
;
312 gc
=scr
->focused_texture
->any
.gc
;
314 gc
=scr
->unfocused_texture
->any
.gc
;
316 XFillPolygon(dpy
, icon
->core
->window
, gc
, points
, 3,
317 Convex
, CoordModeOrigin
);
319 #endif /* NEWAPPICON */
323 drawCorner(WIcon
*icon
)
325 WScreen
*scr
= icon
->core
->screen_ptr
;
334 XFillPolygon(dpy
, icon
->core
->window
, scr
->icon_title_texture
->normal_gc
,
335 points
, 3, Convex
, CoordModeOrigin
);
336 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
338 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
340 /* drawing the second line gives a weird concave look. -Dan */
342 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
344 XDrawLine(dpy
, icon
->core
->window
, scr
->icon_title_texture
->light_gc
,
351 wAppIconMove(WAppIcon
*aicon
, int x
, int y
)
353 XMoveWindow(dpy
, aicon
->icon
->core
->window
, x
, y
);
361 updateDockNumbers(WScreen
*scr
)
366 XGCValues my_gc_values
;
367 unsigned long my_v_mask
= (GCForeground
);
368 WAppIcon
*dicon
= scr
->dock
->icon_array
[0];
370 my_gc_values
.foreground
= scr
->white_pixel
;
371 numbers_gc
= XCreateGC(dpy
, dicon
->icon
->core
->window
,
372 my_v_mask
, &my_gc_values
);
374 ws_numbers
= malloc(20);
375 sprintf(ws_numbers
, "%i [ %i ]", scr
->current_workspace
+1,
376 ((scr
->current_workspace
/10)+1));
377 length
= strlen(ws_numbers
);
379 XClearArea(dpy
, dicon
->icon
->core
->window
, 2, 2, 50,
380 WMFontHeight(scr
->icon_title_font
)+1, False
);
382 XSetForeground(dpy
, numbers_gc
, scr
->black_pixel
);
383 WMDrawString(scr
->wmscreen
, dicon
->icon
->core
->window
, numbers_gc
,
384 scr
->icon_title_font
, 4, 3, ws_numbers
, length
);
386 XSetForeground(dpy
, numbers_gc
, scr
->white_pixel
);
387 WMDrawString(scr
->wmscreen
, dicon
->icon
->core
->window
, numbers_gc
,
388 scr
->icon_title_font
, 3, 2, ws_numbers
, length
);
390 XFreeGC(dpy
, numbers_gc
);
393 #endif /* WS_INDICATOR */
397 wAppIconPaint(WAppIcon
*aicon
)
399 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
401 wIconPaint(aicon
->icon
);
405 if (aicon
->docked
&& scr
->dock
&& aicon
->yindex
==0)
406 updateDockNumbers(scr
);
408 if (scr
->dock_dots
&& aicon
->docked
&& !aicon
->running
409 && aicon
->command
!=NULL
) {
410 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
411 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
412 XCopyArea(dpy
, scr
->dock_dots
->image
, aicon
->icon
->core
->window
,
413 scr
->copy_gc
, 0, 0, scr
->dock_dots
->width
,
414 scr
->dock_dots
->height
, 0, 0);
420 wapp
= wApplicationOf(aicon
->main_window
);
421 if (wapp
&& wapp
->flags
.hidden
) {
422 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
423 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
424 XCopyArea(dpy
, scr
->dock_dots
->image
,
425 aicon
->icon
->core
->window
,
426 scr
->copy_gc
, 0, 0, 7,
427 scr
->dock_dots
->height
, 0, 0);
430 #endif /* HIDDENDOT */
433 if (!wPreferences
.strict_ns
&& aicon
->icon
->owner
!=NULL
) {
435 if (aicon
->main_window
==None
) {
436 active
= (aicon
->icon
->owner
->flags
.focused
? 1 : 0);
440 wapp
= wApplicationOf(aicon
->main_window
);
442 active
= aicon
->icon
->owner
->flags
.focused
;
443 wwarning("error in wAppIconPaint(). Please report it");
445 active
= wapp
->main_window_desc
->flags
.focused
;
446 if (wapp
->main_window_desc
->flags
.hidden
447 || !wapp
->main_window_desc
->flags
.mapped
)
452 drawCorner(aicon
->icon
, aicon
->icon
->owner
, active
);
454 #endif /* NEWAPPICON */
456 if (aicon
->omnipresent
)
457 drawCorner(aicon
->icon
);
459 XSetClipMask(dpy
, scr
->copy_gc
, None
);
460 if (aicon
->launching
) {
461 XFillRectangle(dpy
, aicon
->icon
->core
->window
, scr
->stipple_gc
,
462 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
);
468 #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
470 #ifdef REDUCE_APPICONS
472 wAppIconReduceAppCount(WApplication
*wapp
)
474 WAppIconAppList
*applist
;
479 if (wapp
->app_icon
== NULL
)
482 /* If given a main window, check the applist
483 * and remove the if it exists
485 applist
= wapp
->app_icon
->applist
;
486 while (applist
!= NULL
) {
487 if (applist
->wapp
== wapp
) {
488 /* If this app owns the appicon, change the appicon's
489 * owner to the next app in the list or NULL
491 if (wapp
->app_icon
->icon
->owner
== applist
->wapp
->main_window_desc
)
494 wapp
->app_icon
->icon
->owner
= applist
->next
->wapp
->main_window_desc
;
495 } else if (applist
->prev
) {
496 wapp
->app_icon
->icon
->owner
= applist
->prev
->wapp
->main_window_desc
;
498 wapp
->app_icon
->icon
->owner
= NULL
;
502 applist
->prev
->next
= applist
->next
;
505 applist
->next
->prev
= applist
->prev
;
507 if (applist
== wapp
->app_icon
->applist
)
508 wapp
->app_icon
->applist
= applist
->next
;
512 if (wapp
->app_icon
->applist
!= NULL
)
513 wapp
->app_icon
->main_window
= wapp
->app_icon
->applist
->wapp
->main_window
;
515 return (--wapp
->app_icon
->num_apps
);
517 applist
= applist
->next
;
519 return (--wapp
->app_icon
->num_apps
);
525 hideCallback(WMenu
*menu
, WMenuEntry
*entry
)
527 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
529 if (wapp
->flags
.hidden
) {
530 wWorkspaceChange(menu
->menu
->screen_ptr
, wapp
->last_workspace
);
531 wUnhideApplication(wapp
, False
, False
);
533 wHideApplication(wapp
);
539 unhideHereCallback(WMenu
*menu
, WMenuEntry
*entry
)
541 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
543 wUnhideApplication(wapp
, False
, True
);
548 setIconCallback(WMenu
*menu
, WMenuEntry
*entry
)
550 WAppIcon
*icon
= ((WApplication
*)entry
->clientdata
)->app_icon
;
560 scr
= icon
->icon
->core
->screen_ptr
;
564 result
= wIconChooserDialog(scr
, &file
, icon
->wm_instance
, icon
->wm_class
);
566 if (result
&& !icon
->destroyed
) {
571 if (!wIconChangeImageFile(icon
->icon
, file
)) {
572 wMessageDialog(scr
, _("Error"),
573 _("Could not open specified icon file"),
574 _("OK"), NULL
, NULL
);
576 wDefaultChangeIcon(scr
, icon
->wm_instance
, icon
->wm_class
, file
);
588 killCallback(WMenu
*menu
, WMenuEntry
*entry
)
590 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
593 if (!WCHECK_STATE(WSTATE_NORMAL
))
596 WCHANGE_STATE(WSTATE_MODAL
);
598 assert(entry
->clientdata
!=NULL
);
600 buffer
= wstrappend(wapp
->app_icon
? wapp
->app_icon
->wm_class
: NULL
,
601 _(" will be forcibly closed.\n"
602 "Any unsaved changes will be lost.\n"
605 wretain(wapp
->main_window_desc
);
606 if (wPreferences
.dont_confirm_kill
607 || wMessageDialog(menu
->frame
->screen_ptr
, _("Kill Application"),
608 buffer
, _("Yes"), _("No"), NULL
)==WAPRDefault
) {
609 if (!wapp
->main_window_desc
->flags
.destroyed
)
610 wClientKill(wapp
->main_window_desc
);
612 wrelease(wapp
->main_window_desc
);
616 WCHANGE_STATE(WSTATE_NORMAL
);
621 createApplicationMenu(WScreen
*scr
)
625 menu
= wMenuCreate(scr
, NULL
, False
);
626 wMenuAddCallback(menu
, _("Unhide Here"), unhideHereCallback
, NULL
);
627 wMenuAddCallback(menu
, _("Hide"), hideCallback
, NULL
);
628 wMenuAddCallback(menu
, _("Set Icon..."), setIconCallback
, NULL
);
629 wMenuAddCallback(menu
, _("Kill"), killCallback
, NULL
);
636 openApplicationMenu(WApplication
*wapp
, int x
, int y
)
639 WScreen
*scr
= wapp
->main_window_desc
->screen_ptr
;
642 if (!scr
->icon_menu
) {
643 scr
->icon_menu
= createApplicationMenu(scr
);
644 free(scr
->icon_menu
->entries
[1]->text
);
647 menu
= scr
->icon_menu
;
649 if (wapp
->flags
.hidden
) {
650 menu
->entries
[1]->text
= _("Unhide");
652 menu
->entries
[1]->text
= _("Hide");
655 menu
->flags
.realized
= 0;
658 x
-= menu
->frame
->core
->width
/2;
659 if (x
+ menu
->frame
->core
->width
> scr
->scr_width
)
660 x
= scr
->scr_width
- menu
->frame
->core
->width
;
664 /* set client data */
665 for (i
= 0; i
< menu
->entry_no
; i
++) {
666 menu
->entries
[i
]->clientdata
= wapp
;
668 wMenuMapAt(menu
, x
, y
, False
);
672 /******************************************************************/
675 iconExpose(WObjDescriptor
*desc
, XEvent
*event
)
677 wAppIconPaint(desc
->parent
);
682 iconDblClick(WObjDescriptor
*desc
, XEvent
*event
)
684 WAppIcon
*aicon
= desc
->parent
;
686 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
689 #ifndef REDUCE_APPICONS
690 assert(aicon
->icon
->owner
!=NULL
);
692 if (aicon
->icon
->owner
== NULL
) {
693 fprintf(stderr
, "Double-click disabled: missing main window.\n");
698 wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
701 wwarning("could not find application descriptor for app icon!!");
705 #ifdef REDUCE_APPICONS
707 fprintf(stderr
, "Double-click disabled: missing wapp.\n");
710 #endif /* REDUCE_APPICONS */
712 unhideHere
= (event
->xbutton
.state
& ShiftMask
);
714 /* go to the last workspace that the user worked on the app */
715 if (!unhideHere
&& wapp
->last_workspace
!= scr
->current_workspace
)
716 wWorkspaceChange(scr
, wapp
->last_workspace
);
718 wUnhideApplication(wapp
, event
->xbutton
.button
==Button2
, unhideHere
);
720 if (event
->xbutton
.state
& MOD_MASK
) {
721 wHideOtherApplications(aicon
->icon
->owner
);
727 appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
729 WAppIcon
*aicon
= desc
->parent
;
730 WIcon
*icon
= aicon
->icon
;
732 int x
=aicon
->x_pos
, y
=aicon
->y_pos
;
733 int dx
=event
->xbutton
.x
, dy
=event
->xbutton
.y
;
736 int superfluous
= wPreferences
.superfluous
; /* we catch it to avoid problems */
737 WScreen
*scr
= icon
->core
->screen_ptr
;
738 WWorkspace
*workspace
= scr
->workspaces
[scr
->current_workspace
];
739 int shad_x
= 0, shad_y
= 0, docking
=0, dockable
, collapsed
= 0;
741 int clickButton
= event
->xbutton
.button
;
745 if (aicon
->editing
|| WCHECK_STATE(WSTATE_MODAL
))
748 if (IsDoubleClick(scr
, event
)) {
749 iconDblClick(desc
, event
);
753 if (event
->xbutton
.button
== Button3
) {
754 WObjDescriptor
*desc
;
755 WApplication
*wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
760 openApplicationMenu(wapp
, event
->xbutton
.x_root
,
761 event
->xbutton
.y_root
);
763 /* allow drag select of menu */
764 desc
= &scr
->icon_menu
->menu
->descriptor
;
765 event
->xbutton
.send_event
= True
;
766 (*desc
->handle_mousedown
)(desc
, event
);
773 if (event
->xbutton
.state
& MOD_MASK
)
774 wLowerFrame(icon
->core
);
776 wRaiseFrame(icon
->core
);
779 if (XGrabPointer(dpy
, icon
->core
->window
, True
, ButtonMotionMask
780 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
781 GrabModeAsync
, None
, None
, CurrentTime
) !=GrabSuccess
) {
782 wwarning("pointer grab failed for appicon move");
785 if (wPreferences
.flags
.nodock
&& wPreferences
.flags
.noclip
)
788 dockable
= canBeDocked(icon
->owner
);
790 wins
[0] = icon
->core
->window
;
791 wins
[1] = scr
->dock_shadow
;
792 XRestackWindows(dpy
, wins
, 2);
794 if (icon
->pixmap
!=None
)
795 ghost
= MakeGhostIcon(scr
, icon
->pixmap
);
797 ghost
= MakeGhostIcon(scr
, icon
->core
->window
);
798 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
800 XClearWindow(dpy
, scr
->dock_shadow
);
804 WMMaskEvent(dpy
, PointerMotionMask
|ButtonReleaseMask
|ButtonPressMask
805 |ButtonMotionMask
|ExposureMask
, &ev
);
813 if (abs(dx
-ev
.xmotion
.x
)>=MOVE_THRESHOLD
814 || abs(dy
-ev
.xmotion
.y
)>=MOVE_THRESHOLD
) {
815 XChangeActivePointerGrab(dpy
, ButtonMotionMask
816 |ButtonReleaseMask
|ButtonPressMask
,
817 wCursor
[WCUR_MOVE
], CurrentTime
);
823 x
= ev
.xmotion
.x_root
- dx
;
824 y
= ev
.xmotion
.y_root
- dy
;
825 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
828 if (scr
->dock
&& wDockSnapIcon(scr
->dock
, aicon
, x
, y
,
830 shad_x
= scr
->dock
->x_pos
+ ix
*wPreferences
.icon_size
;
831 shad_y
= scr
->dock
->y_pos
+ iy
*wPreferences
.icon_size
;
833 if (scr
->last_dock
!= scr
->dock
&& collapsed
) {
834 scr
->last_dock
->collapsed
= 1;
835 wDockHideIcons(scr
->last_dock
);
838 if (!collapsed
&& (collapsed
= scr
->dock
->collapsed
)) {
839 scr
->dock
->collapsed
= 0;
840 wDockShowIcons(scr
->dock
);
843 if (scr
->dock
->auto_raise_lower
)
844 wDockRaise(scr
->dock
);
846 scr
->last_dock
= scr
->dock
;
848 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
850 XMapWindow(dpy
, scr
->dock_shadow
);
853 } else if (workspace
->clip
&&
854 wDockSnapIcon(workspace
->clip
, aicon
, x
, y
,
856 shad_x
= workspace
->clip
->x_pos
+ ix
*wPreferences
.icon_size
;
857 shad_y
= workspace
->clip
->y_pos
+ iy
*wPreferences
.icon_size
;
859 if (scr
->last_dock
!= workspace
->clip
&& collapsed
) {
860 scr
->last_dock
->collapsed
= 1;
861 wDockHideIcons(scr
->last_dock
);
864 if (!collapsed
&& (collapsed
= workspace
->clip
->collapsed
)) {
865 workspace
->clip
->collapsed
= 0;
866 wDockShowIcons(workspace
->clip
);
869 if (workspace
->clip
->auto_raise_lower
)
870 wDockRaise(workspace
->clip
);
872 scr
->last_dock
= workspace
->clip
;
874 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
876 XMapWindow(dpy
, scr
->dock_shadow
);
879 } else if (docking
) {
880 XUnmapWindow(dpy
, scr
->dock_shadow
);
891 if (ev
.xbutton
.button
!= clickButton
)
893 XUngrabPointer(dpy
, CurrentTime
);
898 /* icon is trying to be docked */
899 SlideWindow(icon
->core
->window
, x
, y
, shad_x
, shad_y
);
900 XUnmapWindow(dpy
, scr
->dock_shadow
);
901 docked
= wDockAttachIcon(scr
->last_dock
, aicon
, ix
, iy
);
902 if (scr
->last_dock
->auto_collapse
) {
905 if (workspace
->clip
&&
906 workspace
->clip
!= scr
->last_dock
&&
907 workspace
->clip
->auto_raise_lower
)
908 wDockLower(workspace
->clip
);
911 /* If icon could not be docked, slide it back to the old
913 SlideWindow(icon
->core
->window
, x
, y
, aicon
->x_pos
,
917 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
920 if (workspace
->clip
&& workspace
->clip
->auto_raise_lower
)
921 wDockLower(workspace
->clip
);
924 scr
->last_dock
->collapsed
= 1;
925 wDockHideIcons(scr
->last_dock
);
930 XFreePixmap(dpy
, ghost
);
931 XSetWindowBackground(dpy
, scr
->dock_shadow
, scr
->white_pixel
);
934 if (wPreferences
.auto_arrange_icons
)
935 wArrangeIcons(scr
, True
);
942 puts("End icon move");