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"
49 * icon_file for the dock is got from the preferences file by
50 * using the classname/instancename
53 /**** Global variables ****/
54 extern Cursor wCursor
[WCUR_LAST
];
55 extern WPreferences wPreferences
;
57 #define MOD_MASK wPreferences.modifier_mask
59 void appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
60 static void iconDblClick(WObjDescriptor
*desc
, XEvent
*event
);
61 static void iconExpose(WObjDescriptor
*desc
, XEvent
*event
);
66 wAppIconCreateForDock(WScreen
*scr
, char *command
, char *wm_instance
,
67 char *wm_class
, int tile
)
72 dicon
= wmalloc(sizeof(WAppIcon
));
74 memset(dicon
, 0, sizeof(WAppIcon
));
79 dicon
->next
= scr
->app_icon_list
;
80 if (scr
->app_icon_list
) {
81 scr
->app_icon_list
->prev
= dicon
;
83 scr
->app_icon_list
= dicon
;
86 dicon
->command
= wstrdup(command
);
89 dicon
->wm_class
= wstrdup(wm_class
);
91 dicon
->wm_instance
= wstrdup(wm_instance
);
93 path
= wDefaultGetIconFile(scr
, wm_instance
, wm_class
, True
);
94 if (!path
&& command
) {
95 wApplicationExtractDirPackIcon(scr
, command
, wm_instance
, wm_class
);
97 path
= wDefaultGetIconFile(scr
, wm_instance
, wm_class
, False
);
101 path
= FindImage(wPreferences
.icon_path
, path
);
103 dicon
->icon
= wIconCreateWithIconFile(scr
, path
, tile
);
106 #ifdef REDUCE_APPICONS
110 /* will be overriden by dock */
111 dicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
112 dicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
113 dicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
114 dicon
->icon
->core
->descriptor
.parent
= dicon
;
115 AddToStackList(dicon
->icon
->core
);
123 wAppIconCreate(WWindow
*leader_win
)
126 #ifdef REDUCE_APPICONS
128 WAppIconAppList
*applist
;
129 char *tinstance
, *tclass
;
131 WScreen
*scr
= leader_win
->screen_ptr
;
133 aicon
= wmalloc(sizeof(WAppIcon
));
135 memset(aicon
, 0, sizeof(WAppIcon
));
136 #ifdef REDUCE_APPICONS
137 applist
= wmalloc(sizeof(WAppIconAppList
));
138 memset(applist
, 0, sizeof(WAppIconAppList
));
139 applist
->wapp
= wApplicationOf(leader_win
->main_window
);
140 aicon
->applist
= applist
;
141 if (applist
->wapp
== NULL
) {
142 /* Something's wrong. wApplicationOf() should always return a
143 * valid structure. Rather than violate assumptions, bail. -cls
155 aicon
->next
= scr
->app_icon_list
;
156 if (scr
->app_icon_list
) {
157 #ifndef REDUCE_APPICONS
158 scr
->app_icon_list
->prev
= aicon
;
160 /* If we aren't going to have a match, jump straight to new appicon */
161 if (leader_win
->wm_class
== NULL
|| leader_win
->wm_class
== NULL
)
164 atmp
= scr
->app_icon_list
;
166 while (atmp
!= NULL
) {
167 if ((tinstance
= atmp
->wm_instance
) == NULL
)
169 if ((tclass
= atmp
->wm_class
) == NULL
)
171 if ((strcmp(leader_win
->wm_class
, tclass
) == 0) &&
172 (strcmp(leader_win
->wm_instance
, tinstance
) == 0))
174 /* We have a winner */
177 applist
->next
= atmp
->applist
;
179 atmp
->applist
->prev
= applist
;
180 atmp
->applist
= applist
;
183 wDockSimulateLaunch(atmp
->dock
, atmp
);
191 scr
->app_icon_list
->prev
= aicon
;
193 #endif /* REDUCE_APPICONS */
195 scr
->app_icon_list
= aicon
;
197 if (leader_win
->wm_class
)
198 aicon
->wm_class
= wstrdup(leader_win
->wm_class
);
199 if (leader_win
->wm_instance
)
200 aicon
->wm_instance
= wstrdup(leader_win
->wm_instance
);
201 #ifdef REDUCE_APPICONS
205 aicon
->icon
= wIconCreate(leader_win
);
207 /* will be overriden if docked */
208 aicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
209 aicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
210 aicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
211 aicon
->icon
->core
->descriptor
.parent
= aicon
;
212 AddToStackList(aicon
->icon
->core
);
213 aicon
->icon
->show_title
= 0;
214 wIconUpdate(aicon
->icon
);
221 wAppIconDestroy(WAppIcon
*aicon
)
223 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
224 #ifdef REDUCE_APPICONS
225 WAppIconAppList
*aptmp
;
228 RemoveFromStackList(aicon
->icon
->core
);
229 wIconDestroy(aicon
->icon
);
231 free(aicon
->command
);
233 if (aicon
->dnd_command
)
234 free(aicon
->dnd_command
);
236 if (aicon
->wm_instance
)
237 free(aicon
->wm_instance
);
239 free(aicon
->wm_class
);
240 #ifdef REDUCE_APPICONS
241 /* There should never be a list but just in case */
242 if (aicon
->applist
!= NULL
) {
243 aptmp
= aicon
->applist
;
244 while (aptmp
->next
) {
252 if (aicon
== scr
->app_icon_list
) {
254 aicon
->next
->prev
= NULL
;
255 scr
->app_icon_list
= aicon
->next
;
259 aicon
->next
->prev
= aicon
->prev
;
261 aicon
->prev
->next
= aicon
->next
;
264 aicon
->destroyed
= 1;
272 drawCorner(WIcon
*icon
, WWindow
*wwin
, int active
)
274 WScreen
*scr
= wwin
->screen_ptr
;
285 gc
=scr
->focused_texture
->any
.gc
;
287 gc
=scr
->unfocused_texture
->any
.gc
;
289 XFillPolygon(dpy
, icon
->core
->window
, gc
, points
, 3,
290 Convex
, CoordModeOrigin
);
292 #endif /* NEWAPPICON */
296 wAppIconMove(WAppIcon
*aicon
, int x
, int y
)
298 XMoveWindow(dpy
, aicon
->icon
->core
->window
, x
, y
);
306 updateDockNumbers(WScreen
*scr
)
311 XGCValues my_gc_values
;
312 unsigned long my_v_mask
= (GCForeground
);
313 WAppIcon
*dicon
= scr
->dock
->icon_array
[0];
315 my_gc_values
.foreground
= scr
->white_pixel
;
316 numbers_gc
= XCreateGC(dpy
, dicon
->icon
->core
->window
,
317 my_v_mask
, &my_gc_values
);
319 ws_numbers
= malloc(20);
320 sprintf(ws_numbers
, "%i [ %i ]", scr
->current_workspace
+1,
321 ((scr
->current_workspace
/10)+1));
322 length
= strlen(ws_numbers
);
324 XClearArea(dpy
, dicon
->icon
->core
->window
, 2, 2, 50,
325 scr
->icon_title_font
->y
+1, False
);
328 XSetFont(dpy
, numbers_gc
, scr
->icon_title_font
->font
->fid
);
329 XSetForeground(dpy
, numbers_gc
, scr
->black_pixel
);
330 XDrawString(dpy
, dicon
->icon
->core
->window
,
331 numbers_gc
, 4, scr
->icon_title_font
->y
+3, ws_numbers
, length
);
332 XSetForeground(dpy
, numbers_gc
, scr
->white_pixel
);
333 XDrawString(dpy
, dicon
->icon
->core
->window
,
334 numbers_gc
, 3, scr
->icon_title_font
->y
+2, ws_numbers
, length
);
336 XSetForeground(dpy
, numbers_gc
, scr
->black_pixel
);
337 XmbDrawString(dpy
, dicon
->icon
->core
->window
,
338 scr
->icon_title_font
->font
, numbers_gc
, 4,
339 scr
->icon_title_font
->y
+3, ws_numbers
, length
);
340 XSetForeground(dpy
, numbers_gc
, scr
->white_pixel
);
341 XmbDrawString(dpy
, dicon
->icon
->core
->window
,
342 scr
->icon_title_font
->font
, numbers_gc
, 3,
343 scr
->icon_title_font
->y
+2, ws_numbers
, length
);
346 XFreeGC(dpy
, numbers_gc
);
349 #endif /* WS_INDICATOR */
353 wAppIconPaint(WAppIcon
*aicon
)
355 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
357 wIconPaint(aicon
->icon
);
361 if (aicon
->docked
&& scr
->dock
&& aicon
->yindex
==0)
362 updateDockNumbers(scr
);
364 if (scr
->dock_dots
&& aicon
->docked
&& !aicon
->running
365 && aicon
->command
!=NULL
) {
366 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
367 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
368 XCopyArea(dpy
, scr
->dock_dots
->image
, aicon
->icon
->core
->window
,
369 scr
->copy_gc
, 0, 0, scr
->dock_dots
->width
,
370 scr
->dock_dots
->height
, 0, 0);
376 wapp
= wApplicationOf(aicon
->main_window
);
378 if(wapp
->flags
.hidden
){
379 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
380 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
381 XCopyArea(dpy
, scr
->dock_dots
->image
, aicon
->icon
->core
->window
,
382 scr
->copy_gc
, 0, 0, 7,
383 scr
->dock_dots
->height
, 0, 0);
386 #endif /* HIDDENDOT */
389 if (!wPreferences
.strict_ns
&& aicon
->icon
->owner
!=NULL
) {
391 if (aicon
->main_window
==None
) {
392 active
= (aicon
->icon
->owner
->flags
.focused
? 1 : 0);
396 wapp
= wApplicationOf(aicon
->main_window
);
398 active
= aicon
->icon
->owner
->flags
.focused
;
399 wwarning("error in wAppIconPaint(). Please report it");
401 active
= wapp
->main_window_desc
->flags
.focused
;
402 if (wapp
->main_window_desc
->flags
.hidden
403 || !wapp
->main_window_desc
->flags
.mapped
)
408 drawCorner(aicon
->icon
, aicon
->icon
->owner
, active
);
410 #endif /* NEWAPPICON */
412 XSetClipMask(dpy
, scr
->copy_gc
, None
);
413 if (aicon
->launching
) {
414 XFillRectangle(dpy
, aicon
->icon
->core
->window
, scr
->stipple_gc
,
415 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
);
421 #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
423 #ifdef REDUCE_APPICONS
425 wAppIconReduceAppCount(WApplication
*wapp
)
427 WAppIconAppList
*applist
;
432 if (wapp
->app_icon
== NULL
)
435 /* If given a main window, check the applist
436 * and remove the if it exists
438 applist
= wapp
->app_icon
->applist
;
439 while (applist
!= NULL
) {
440 if (applist
->wapp
== wapp
) {
441 /* If this app owns the appicon, change the appicon's
442 * owner to the next app in the list or NULL
444 if (wapp
->app_icon
->icon
->owner
== applist
->wapp
->main_window_desc
)
447 wapp
->app_icon
->icon
->owner
= applist
->next
->wapp
->main_window_desc
;
448 } else if (applist
->prev
) {
449 wapp
->app_icon
->icon
->owner
= applist
->prev
->wapp
->main_window_desc
;
451 wapp
->app_icon
->icon
->owner
= NULL
;
455 applist
->prev
->next
= applist
->next
;
458 applist
->next
->prev
= applist
->prev
;
460 if (applist
== wapp
->app_icon
->applist
)
461 wapp
->app_icon
->applist
= applist
->next
;
465 if (wapp
->app_icon
->applist
!= NULL
)
466 wapp
->app_icon
->main_window
= wapp
->app_icon
->applist
->wapp
->main_window
;
468 return (--wapp
->app_icon
->num_apps
);
470 applist
= applist
->next
;
472 return (--wapp
->app_icon
->num_apps
);
478 hideCallback(WMenu
*menu
, WMenuEntry
*entry
)
480 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
482 if (wapp
->flags
.hidden
) {
483 wWorkspaceChange(menu
->menu
->screen_ptr
, wapp
->last_workspace
);
484 wUnhideApplication(wapp
, False
, False
);
486 wHideApplication(wapp
);
492 unhideHereCallback(WMenu
*menu
, WMenuEntry
*entry
)
494 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
496 wUnhideApplication(wapp
, False
, True
);
501 setIconCallback(WMenu
*menu
, WMenuEntry
*entry
)
503 WAppIcon
*icon
= ((WApplication
*)entry
->clientdata
)->app_icon
;
513 scr
= icon
->icon
->core
->screen_ptr
;
517 result
= wIconChooserDialog(scr
, &file
, icon
->wm_instance
, icon
->wm_class
);
519 if (result
&& !icon
->destroyed
) {
524 if (!wIconChangeImageFile(icon
->icon
, file
)) {
525 wMessageDialog(scr
, _("Error"),
526 _("Could not open specified icon file"),
527 _("OK"), NULL
, NULL
);
529 wDefaultChangeIcon(scr
, icon
->wm_instance
, icon
->wm_class
, file
);
541 killCallback(WMenu
*menu
, WMenuEntry
*entry
)
543 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
546 if (!WCHECK_STATE(WSTATE_NORMAL
))
549 WCHANGE_STATE(WSTATE_MODAL
);
551 assert(entry
->clientdata
!=NULL
);
553 buffer
= wstrappend(wapp
->app_icon
? wapp
->app_icon
->wm_class
: NULL
,
554 _(" will be forcibly closed.\n"
555 "Any unsaved changes will be lost.\n"
558 wretain(wapp
->main_window_desc
);
559 if (wPreferences
.dont_confirm_kill
560 || wMessageDialog(menu
->frame
->screen_ptr
, _("Kill Application"),
561 buffer
, _("Yes"), _("No"), NULL
)==WAPRDefault
) {
562 if (!wapp
->main_window_desc
->flags
.destroyed
)
563 wClientKill(wapp
->main_window_desc
);
565 wrelease(wapp
->main_window_desc
);
569 WCHANGE_STATE(WSTATE_NORMAL
);
574 createApplicationMenu(WScreen
*scr
)
578 menu
= wMenuCreate(scr
, NULL
, False
);
579 wMenuAddCallback(menu
, _("Unhide Here"), unhideHereCallback
, NULL
);
580 wMenuAddCallback(menu
, _("Hide"), hideCallback
, NULL
);
581 wMenuAddCallback(menu
, _("Set Icon..."), setIconCallback
, NULL
);
582 wMenuAddCallback(menu
, _("Kill"), killCallback
, NULL
);
589 openApplicationMenu(WApplication
*wapp
, int x
, int y
)
592 WScreen
*scr
= wapp
->main_window_desc
->screen_ptr
;
595 if (!scr
->icon_menu
) {
596 scr
->icon_menu
= createApplicationMenu(scr
);
597 free(scr
->icon_menu
->entries
[1]->text
);
600 menu
= scr
->icon_menu
;
602 if (wapp
->flags
.hidden
) {
603 menu
->entries
[1]->text
= _("Unhide");
605 menu
->entries
[1]->text
= _("Hide");
608 menu
->flags
.realized
= 0;
611 x
-= menu
->frame
->core
->width
/2;
612 if (x
+ menu
->frame
->core
->width
> scr
->scr_width
)
613 x
= scr
->scr_width
- menu
->frame
->core
->width
;
617 /* set client data */
618 for (i
= 0; i
< menu
->entry_no
; i
++) {
619 menu
->entries
[i
]->clientdata
= wapp
;
621 wMenuMapAt(menu
, x
, y
, False
);
625 /******************************************************************/
628 iconExpose(WObjDescriptor
*desc
, XEvent
*event
)
630 wAppIconPaint(desc
->parent
);
634 iconDblClick(WObjDescriptor
*desc
, XEvent
*event
)
636 WAppIcon
*aicon
= desc
->parent
;
638 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
641 #ifndef REDUCE_APPICONS
642 assert(aicon
->icon
->owner
!=NULL
);
644 if (aicon
->icon
->owner
== NULL
) {
645 fprintf(stderr
, "Double-click disabled: missing main window.\n");
650 wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
653 wwarning("could not find application descriptor for app icon!!");
657 #ifdef REDUCE_APPICONS
659 fprintf(stderr
, "Double-click disabled: missing wapp.\n");
662 #endif /* REDUCE_APPICONS */
664 /* aproveita que ta aqui pra atualizar */
665 wapp
->main_window
= aicon
->icon
->owner
->main_window
;
668 unhideHere
= (event
->xbutton
.state
& ShiftMask
);
670 /* go to the last workspace that the user worked on the app */
672 wWorkspaceChange(scr
, wapp
->last_workspace
);
674 wUnhideApplication(wapp
, event
->xbutton
.button
==Button2
, unhideHere
);
676 if (event
->xbutton
.state
& MOD_MASK
) {
677 wHideOtherApplications(aicon
->icon
->owner
);
683 appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
685 WAppIcon
*aicon
= desc
->parent
;
686 WIcon
*icon
= aicon
->icon
;
688 int x
=aicon
->x_pos
, y
=aicon
->y_pos
;
689 int dx
=event
->xbutton
.x
, dy
=event
->xbutton
.y
;
692 int superfluous
= wPreferences
.superfluous
; /* we catch it to avoid problems */
693 WScreen
*scr
= icon
->core
->screen_ptr
;
694 WWorkspace
*workspace
= scr
->workspaces
[scr
->current_workspace
];
695 int shad_x
= 0, shad_y
= 0, docking
=0, dockable
, collapsed
= 0;
697 int clickButton
= event
->xbutton
.button
;
700 if (aicon
->editing
|| WCHECK_STATE(WSTATE_MODAL
))
703 if (IsDoubleClick(scr
, event
)) {
704 iconDblClick(desc
, event
);
708 if (event
->xbutton
.button
== Button3
) {
709 WObjDescriptor
*desc
;
710 WApplication
*wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
715 openApplicationMenu(wapp
, event
->xbutton
.x_root
,
716 event
->xbutton
.y_root
);
718 /* allow drag select of menu */
719 desc
= &scr
->icon_menu
->menu
->descriptor
;
720 event
->xbutton
.send_event
= True
;
721 (*desc
->handle_mousedown
)(desc
, event
);
728 if (event
->xbutton
.state
& MOD_MASK
)
729 wLowerFrame(icon
->core
);
731 wRaiseFrame(icon
->core
);
734 if (XGrabPointer(dpy
, icon
->core
->window
, True
, ButtonMotionMask
735 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
736 GrabModeAsync
, None
, None
, CurrentTime
) !=GrabSuccess
) {
737 wwarning("pointer grab failed for appicon move");
740 if (wPreferences
.flags
.nodock
&& wPreferences
.flags
.noclip
)
743 dockable
= canBeDocked(icon
->owner
);
747 WMMaskEvent(dpy
, PointerMotionMask
|ButtonReleaseMask
|ButtonPressMask
748 |ButtonMotionMask
|ExposureMask
, &ev
);
756 if (abs(dx
-ev
.xmotion
.x
)>=MOVE_THRESHOLD
757 || abs(dy
-ev
.xmotion
.y
)>=MOVE_THRESHOLD
) {
758 XChangeActivePointerGrab(dpy
, ButtonMotionMask
759 |ButtonReleaseMask
|ButtonPressMask
,
760 wCursor
[WCUR_MOVE
], CurrentTime
);
766 x
= ev
.xmotion
.x_root
- dx
;
767 y
= ev
.xmotion
.y_root
- dy
;
768 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
771 if (scr
->dock
&& wDockSnapIcon(scr
->dock
, aicon
, x
, y
,
773 shad_x
= scr
->dock
->x_pos
+ ix
*wPreferences
.icon_size
;
774 shad_y
= scr
->dock
->y_pos
+ iy
*wPreferences
.icon_size
;
776 if (scr
->last_dock
!= scr
->dock
&& collapsed
) {
777 scr
->last_dock
->collapsed
= 1;
778 wDockHideIcons(scr
->last_dock
);
781 if (!collapsed
&& (collapsed
= scr
->dock
->collapsed
)) {
782 scr
->dock
->collapsed
= 0;
783 wDockShowIcons(scr
->dock
);
786 if (scr
->dock
->auto_raise_lower
)
787 wDockRaise(scr
->dock
);
789 scr
->last_dock
= scr
->dock
;
791 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
795 wins
[0] = icon
->core
->window
;
796 wins
[1] = scr
->dock_shadow
;
797 XRestackWindows(dpy
, wins
, 2);
799 if (icon
->pixmap
!=None
)
800 ghost
= MakeGhostIcon(scr
, icon
->pixmap
);
802 ghost
= MakeGhostIcon(scr
, icon
->core
->window
);
803 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
805 XClearWindow(dpy
, scr
->dock_shadow
);
807 XMapWindow(dpy
, scr
->dock_shadow
);
810 } else if (workspace
->clip
&&
811 wDockSnapIcon(workspace
->clip
, aicon
, x
, y
,
813 shad_x
= workspace
->clip
->x_pos
+ ix
*wPreferences
.icon_size
;
814 shad_y
= workspace
->clip
->y_pos
+ iy
*wPreferences
.icon_size
;
816 if (scr
->last_dock
!= workspace
->clip
&& collapsed
) {
817 scr
->last_dock
->collapsed
= 1;
818 wDockHideIcons(scr
->last_dock
);
821 if (!collapsed
&& (collapsed
= workspace
->clip
->collapsed
)) {
822 workspace
->clip
->collapsed
= 0;
823 wDockShowIcons(workspace
->clip
);
826 if (workspace
->clip
->auto_raise_lower
)
827 wDockRaise(workspace
->clip
);
829 scr
->last_dock
= workspace
->clip
;
831 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
835 wins
[0] = icon
->core
->window
;
836 wins
[1] = scr
->dock_shadow
;
837 XRestackWindows(dpy
, wins
, 2);
839 if (icon
->pixmap
!=None
)
840 ghost
= MakeGhostIcon(scr
, icon
->pixmap
);
842 ghost
= MakeGhostIcon(scr
, icon
->core
->window
);
843 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
845 XClearWindow(dpy
, scr
->dock_shadow
);
847 XMapWindow(dpy
, scr
->dock_shadow
);
850 } else if (docking
) {
851 XUnmapWindow(dpy
, scr
->dock_shadow
);
862 if (ev
.xbutton
.button
!= clickButton
)
864 XUngrabPointer(dpy
, CurrentTime
);
869 /* icon is trying to be docked */
870 SlideWindow(icon
->core
->window
, x
, y
, shad_x
, shad_y
);
871 XUnmapWindow(dpy
, scr
->dock_shadow
);
872 docked
= wDockAttachIcon(scr
->last_dock
, aicon
, ix
, iy
);
873 if (scr
->last_dock
->auto_collapse
) {
876 if (workspace
->clip
&&
877 workspace
->clip
!= scr
->last_dock
&&
878 workspace
->clip
->auto_raise_lower
)
879 wDockLower(workspace
->clip
);
882 /* If icon could not be docked, slide it back to the old
884 SlideWindow(icon
->core
->window
, x
, y
, aicon
->x_pos
,
888 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
891 if (workspace
->clip
&& workspace
->clip
->auto_raise_lower
)
892 wDockLower(workspace
->clip
);
895 scr
->last_dock
->collapsed
= 1;
896 wDockHideIcons(scr
->last_dock
);
901 XFreePixmap(dpy
, ghost
);
902 XSetWindowBackground(dpy
, scr
->dock_shadow
, scr
->white_pixel
);
909 puts("End icon move");