1 /* appicon.c- icon for applications (not mini-window)
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 #include <X11/Xutil.h>
30 #include "WindowMaker.h"
40 #include "workspace.h"
41 #include "superfluous.h"
48 * icon_file for the dock is got from the preferences file by
49 * using the classname/instancename
52 /**** Global variables ****/
53 extern Cursor wCursor
[WCUR_LAST
];
54 extern WPreferences wPreferences
;
56 #define MOD_MASK wPreferences.modifier_mask
58 void appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
59 static void iconDblClick(WObjDescriptor
*desc
, XEvent
*event
);
60 static void iconExpose(WObjDescriptor
*desc
, XEvent
*event
);
65 wAppIconCreateForDock(WScreen
*scr
, char *command
, char *wm_instance
,
66 char *wm_class
, int tile
)
71 dicon
= wmalloc(sizeof(WAppIcon
));
73 memset(dicon
, 0, sizeof(WAppIcon
));
78 dicon
->next
= scr
->app_icon_list
;
79 if (scr
->app_icon_list
) {
80 scr
->app_icon_list
->prev
= dicon
;
82 scr
->app_icon_list
= dicon
;
85 dicon
->command
= wstrdup(command
);
88 dicon
->wm_class
= wstrdup(wm_class
);
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
);
96 path
= wDefaultGetIconFile(scr
, wm_instance
, wm_class
, False
);
100 path
= FindImage(wPreferences
.icon_path
, path
);
102 dicon
->icon
= wIconCreateWithIconFile(scr
, path
, tile
);
105 #ifdef REDUCE_APPICONS
109 /* will be overriden by dock */
110 dicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
111 dicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
112 dicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
113 dicon
->icon
->core
->descriptor
.parent
= dicon
;
114 AddToStackList(dicon
->icon
->core
);
122 wAppIconCreate(WWindow
*leader_win
)
125 #ifdef REDUCE_APPICONS
127 WAppIconAppList
*applist
;
128 char *tinstance
, *tclass
;
130 WScreen
*scr
= leader_win
->screen_ptr
;
132 aicon
= wmalloc(sizeof(WAppIcon
));
134 memset(aicon
, 0, sizeof(WAppIcon
));
135 #ifdef REDUCE_APPICONS
136 applist
= wmalloc(sizeof(WAppIconAppList
));
137 memset(applist
, 0, sizeof(WAppIconAppList
));
138 applist
->wapp
= wApplicationOf(leader_win
->main_window
);
139 aicon
->applist
= applist
;
140 if (applist
->wapp
== NULL
) {
141 /* Something's wrong. wApplicationOf() should always return a
142 * valid structure. Rather than violate assumptions, bail. -cls
154 aicon
->next
= scr
->app_icon_list
;
155 if (scr
->app_icon_list
) {
156 #ifndef REDUCE_APPICONS
157 scr
->app_icon_list
->prev
= aicon
;
159 /* If we aren't going to have a match, jump straight to new appicon */
160 if (leader_win
->wm_class
== NULL
|| leader_win
->wm_class
== NULL
)
163 atmp
= scr
->app_icon_list
;
165 while (atmp
!= NULL
) {
166 if ((tinstance
= atmp
->wm_instance
) == NULL
)
168 if ((tclass
= atmp
->wm_class
) == NULL
)
170 if ((strcmp(leader_win
->wm_class
, tclass
) == 0) &&
171 (strcmp(leader_win
->wm_instance
, tinstance
) == 0))
173 /* We have a winner */
176 applist
->next
= atmp
->applist
;
178 atmp
->applist
->prev
= applist
;
179 atmp
->applist
= applist
;
182 wDockSimulateLaunch(atmp
->dock
, atmp
);
190 scr
->app_icon_list
->prev
= aicon
;
192 #endif /* REDUCE_APPICONS */
194 scr
->app_icon_list
= aicon
;
196 if (leader_win
->wm_class
)
197 aicon
->wm_class
= wstrdup(leader_win
->wm_class
);
198 if (leader_win
->wm_instance
)
199 aicon
->wm_instance
= wstrdup(leader_win
->wm_instance
);
200 #ifdef REDUCE_APPICONS
204 aicon
->icon
= wIconCreate(leader_win
);
206 /* will be overriden if docked */
207 aicon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
208 aicon
->icon
->core
->descriptor
.handle_expose
= iconExpose
;
209 aicon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
210 aicon
->icon
->core
->descriptor
.parent
= aicon
;
211 AddToStackList(aicon
->icon
->core
);
212 aicon
->icon
->show_title
= 0;
213 wIconUpdate(aicon
->icon
);
220 wAppIconDestroy(WAppIcon
*aicon
)
222 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
223 #ifdef REDUCE_APPICONS
224 WAppIconAppList
*aptmp
;
227 RemoveFromStackList(aicon
->icon
->core
);
228 wIconDestroy(aicon
->icon
);
230 free(aicon
->command
);
232 if (aicon
->dnd_command
)
233 free(aicon
->dnd_command
);
235 if (aicon
->wm_instance
)
236 free(aicon
->wm_instance
);
238 free(aicon
->wm_class
);
239 #ifdef REDUCE_APPICONS
240 /* There should never be a list but just in case */
241 if (aicon
->applist
!= NULL
) {
242 aptmp
= aicon
->applist
;
243 while (aptmp
->next
) {
251 if (aicon
== scr
->app_icon_list
) {
253 aicon
->next
->prev
= NULL
;
254 scr
->app_icon_list
= aicon
->next
;
258 aicon
->next
->prev
= aicon
->prev
;
260 aicon
->prev
->next
= aicon
->next
;
263 aicon
->destroyed
= 1;
271 drawCorner(WIcon
*icon
, WWindow
*wwin
, int active
)
273 WScreen
*scr
= wwin
->screen_ptr
;
284 gc
=scr
->focused_texture
->any
.gc
;
286 gc
=scr
->unfocused_texture
->any
.gc
;
288 XFillPolygon(dpy
, icon
->core
->window
, gc
, points
, 3,
289 Convex
, CoordModeOrigin
);
291 #endif /* NEWAPPICON */
295 wAppIconMove(WAppIcon
*aicon
, int x
, int y
)
297 XMoveWindow(dpy
, aicon
->icon
->core
->window
, x
, y
);
305 updateDockNumbers(WScreen
*scr
)
310 XGCValues my_gc_values
;
311 unsigned long my_v_mask
= (GCForeground
);
312 WAppIcon
*dicon
= scr
->dock
->icon_array
[0];
314 my_gc_values
.foreground
= scr
->white_pixel
;
315 numbers_gc
= XCreateGC(dpy
, dicon
->icon
->core
->window
,
316 my_v_mask
, &my_gc_values
);
318 ws_numbers
= malloc(20);
319 sprintf(ws_numbers
, "%i [ %i ]", scr
->current_workspace
+1,
320 ((scr
->current_workspace
/10)+1));
321 length
= strlen(ws_numbers
);
323 XClearArea(dpy
, dicon
->icon
->core
->window
, 2, 2, 50,
324 scr
->icon_title_font
->y
+1, False
);
327 XSetFont(dpy
, numbers_gc
, scr
->icon_title_font
->font
->fid
);
328 XSetForeground(dpy
, numbers_gc
, scr
->black_pixel
);
329 XDrawString(dpy
, dicon
->icon
->core
->window
,
330 numbers_gc
, 4, scr
->icon_title_font
->y
+3, ws_numbers
, length
);
331 XSetForeground(dpy
, numbers_gc
, scr
->white_pixel
);
332 XDrawString(dpy
, dicon
->icon
->core
->window
,
333 numbers_gc
, 3, scr
->icon_title_font
->y
+2, ws_numbers
, length
);
335 XSetForeground(dpy
, numbers_gc
, scr
->black_pixel
);
336 XmbDrawString(dpy
, dicon
->icon
->core
->window
,
337 scr
->icon_title_font
->font
, numbers_gc
, 4,
338 scr
->icon_title_font
->y
+3, ws_numbers
, length
);
339 XSetForeground(dpy
, numbers_gc
, scr
->white_pixel
);
340 XmbDrawString(dpy
, dicon
->icon
->core
->window
,
341 scr
->icon_title_font
->font
, numbers_gc
, 3,
342 scr
->icon_title_font
->y
+2, ws_numbers
, length
);
345 XFreeGC(dpy
, numbers_gc
);
348 #endif /* WS_INDICATOR */
352 draw_dot(WScreen
*scr
, Drawable d
)
357 y
= wPreferences
.icon_size
-6;
358 XSetForeground(dpy
, gc
, scr
->black_pixel
);
359 XDrawLine(dpy
, d
, gc
, 4, y
, 5, y
);
360 XDrawPoint(dpy
, d
, gc
, 4, y
+1);
361 XSetForeground(dpy
, gc
, scr
->white_pixel
);
362 XDrawLine(dpy
, d
, gc
, 6, y
, 6, y
+1);
363 XDrawPoint(dpy
, d
, gc
, 5, y
+1);
365 #endif /* HIDDENDOT */
368 wAppIconPaint(WAppIcon
*aicon
)
370 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
372 wIconPaint(aicon
->icon
);
376 if (aicon
->docked
&& scr
->dock
&& aicon
->yindex
==0)
377 updateDockNumbers(scr
);
379 if (scr
->dock_dots
&& aicon
->docked
&& !aicon
->running
380 && aicon
->command
!=NULL
) {
381 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
382 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
383 XCopyArea(dpy
, scr
->dock_dots
->image
, aicon
->icon
->core
->window
,
384 scr
->copy_gc
, 0, 0, scr
->dock_dots
->width
,
385 scr
->dock_dots
->height
, 0, 0);
391 wapp
= wApplicationOf(aicon
->main_window
);
393 if(wapp
->flags
.hidden
){
394 XSetClipMask(dpy
, scr
->copy_gc
, scr
->dock_dots
->mask
);
395 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
396 XCopyArea(dpy
, scr
->dock_dots
->image
, aicon
->icon
->core
->window
,
397 scr
->copy_gc
, 0, 0, 7,
398 scr
->dock_dots
->height
, 0, 0);
401 #endif /* HIDDENDOT */
404 if (!wPreferences
.strict_ns
&& aicon
->icon
->owner
!=NULL
) {
406 if (aicon
->main_window
==None
) {
407 active
= (aicon
->icon
->owner
->flags
.focused
? 1 : 0);
411 wapp
= wApplicationOf(aicon
->main_window
);
413 active
= aicon
->icon
->owner
->flags
.focused
;
414 wwarning("error in wAppIconPaint(). Please report it");
416 active
= wapp
->main_window_desc
->flags
.focused
;
417 if (wapp
->main_window_desc
->flags
.hidden
418 || !wapp
->main_window_desc
->flags
.mapped
)
423 drawCorner(aicon
->icon
, aicon
->icon
->owner
, active
);
425 #endif /* NEWAPPICON */
427 XSetClipMask(dpy
, scr
->copy_gc
, None
);
428 if (aicon
->launching
) {
429 XFillRectangle(dpy
, aicon
->icon
->core
->window
, scr
->stipple_gc
,
430 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
);
436 #define canBeDocked(wwin) ((wwin) && ((wwin)->wm_class||(wwin)->wm_instance))
438 #ifdef REDUCE_APPICONS
440 wAppIconReduceAppCount(WApplication
*wapp
)
442 WAppIconAppList
*applist
;
447 if (wapp
->app_icon
== NULL
)
450 /* If given a main window, check the applist
451 * and remove the if it exists
453 applist
= wapp
->app_icon
->applist
;
454 while (applist
!= NULL
) {
455 if (applist
->wapp
== wapp
) {
456 /* If this app owns the appicon, change the appicon's
457 * owner to the next app in the list or NULL
459 if (wapp
->app_icon
->icon
->owner
== applist
->wapp
->main_window_desc
)
462 wapp
->app_icon
->icon
->owner
= applist
->next
->wapp
->main_window_desc
;
463 } else if (applist
->prev
) {
464 wapp
->app_icon
->icon
->owner
= applist
->prev
->wapp
->main_window_desc
;
466 wapp
->app_icon
->icon
->owner
= NULL
;
470 applist
->prev
->next
= applist
->next
;
473 applist
->next
->prev
= applist
->prev
;
475 if (applist
== wapp
->app_icon
->applist
)
476 wapp
->app_icon
->applist
= applist
->next
;
480 if (wapp
->app_icon
->applist
!= NULL
)
481 wapp
->app_icon
->main_window
= wapp
->app_icon
->applist
->wapp
->main_window
;
483 return (--wapp
->app_icon
->num_apps
);
485 applist
= applist
->next
;
487 return (--wapp
->app_icon
->num_apps
);
493 hideCallback(WMenu
*menu
, WMenuEntry
*entry
)
495 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
497 if (wapp
->flags
.hidden
) {
498 wWorkspaceChange(menu
->menu
->screen_ptr
, wapp
->last_workspace
);
499 wUnhideApplication(wapp
, False
, False
);
501 wHideApplication(wapp
);
507 unhideHereCallback(WMenu
*menu
, WMenuEntry
*entry
)
509 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
511 wUnhideApplication(wapp
, False
, True
);
516 setIconCallback(WMenu
*menu
, WMenuEntry
*entry
)
518 WAppIcon
*icon
= ((WApplication
*)entry
->clientdata
)->app_icon
;
528 scr
= icon
->icon
->core
->screen_ptr
;
532 result
= wIconChooserDialog(scr
, &file
, icon
->wm_instance
, icon
->wm_class
);
534 if (result
&& !icon
->destroyed
) {
539 if (!wIconChangeImageFile(icon
->icon
, file
)) {
540 wMessageDialog(scr
, _("Error"),
541 _("Could not open specified icon file"),
542 _("OK"), NULL
, NULL
);
544 wDefaultChangeIcon(scr
, icon
->wm_instance
, icon
->wm_class
, file
);
556 killCallback(WMenu
*menu
, WMenuEntry
*entry
)
558 WApplication
*wapp
= (WApplication
*)entry
->clientdata
;
561 if (!WCHECK_STATE(WSTATE_NORMAL
))
564 WCHANGE_STATE(WSTATE_MODAL
);
566 assert(entry
->clientdata
!=NULL
);
568 buffer
= wstrappend(wapp
->app_icon
? wapp
->app_icon
->wm_class
: NULL
,
569 _(" will be forcibly closed.\n"
570 "Any unsaved changes will be lost.\n"
573 wretain(wapp
->main_window_desc
);
574 if (wPreferences
.dont_confirm_kill
575 || wMessageDialog(menu
->frame
->screen_ptr
, _("Kill Application"),
576 buffer
, _("Yes"), _("No"), NULL
)==WAPRDefault
) {
577 if (!wapp
->main_window_desc
->flags
.destroyed
)
578 wClientKill(wapp
->main_window_desc
);
580 wrelease(wapp
->main_window_desc
);
584 WCHANGE_STATE(WSTATE_NORMAL
);
589 createApplicationMenu(WScreen
*scr
)
593 menu
= wMenuCreate(scr
, NULL
, False
);
594 wMenuAddCallback(menu
, _("Unhide Here"), unhideHereCallback
, NULL
);
595 wMenuAddCallback(menu
, _("Hide"), hideCallback
, NULL
);
596 wMenuAddCallback(menu
, _("Set Icon..."), setIconCallback
, NULL
);
597 wMenuAddCallback(menu
, _("Kill"), killCallback
, NULL
);
604 openApplicationMenu(WApplication
*wapp
, int x
, int y
)
607 WScreen
*scr
= wapp
->main_window_desc
->screen_ptr
;
610 if (!scr
->icon_menu
) {
611 scr
->icon_menu
= createApplicationMenu(scr
);
612 free(scr
->icon_menu
->entries
[1]->text
);
615 menu
= scr
->icon_menu
;
617 if (wapp
->flags
.hidden
) {
618 menu
->entries
[1]->text
= _("Unhide");
620 menu
->entries
[1]->text
= _("Hide");
623 menu
->flags
.realized
= 0;
626 x
-= menu
->frame
->core
->width
/2;
627 if (x
+ menu
->frame
->core
->width
> scr
->scr_width
)
628 x
= scr
->scr_width
- menu
->frame
->core
->width
;
632 /* set client data */
633 for (i
= 0; i
< menu
->entry_no
; i
++) {
634 menu
->entries
[i
]->clientdata
= wapp
;
636 wMenuMapAt(menu
, x
, y
, False
);
640 /******************************************************************/
643 iconExpose(WObjDescriptor
*desc
, XEvent
*event
)
645 wAppIconPaint(desc
->parent
);
649 iconDblClick(WObjDescriptor
*desc
, XEvent
*event
)
651 WAppIcon
*aicon
= desc
->parent
;
653 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
656 #ifndef REDUCE_APPICONS
657 assert(aicon
->icon
->owner
!=NULL
);
659 if (aicon
->icon
->owner
== NULL
) {
660 fprintf(stderr
, "Double-click disabled: missing main window.\n");
665 wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
668 wwarning("could not find application descriptor for app icon!!");
672 #ifdef REDUCE_APPICONS
674 fprintf(stderr
, "Double-click disabled: missing wapp.\n");
677 #endif /* REDUCE_APPICONS */
679 /* aproveita que ta aqui pra atualizar */
680 wapp
->main_window
= aicon
->icon
->owner
->main_window
;
683 unhideHere
= (event
->xbutton
.state
& ShiftMask
);
685 /* go to the last workspace that the user worked on the app */
687 wWorkspaceChange(scr
, wapp
->last_workspace
);
689 wUnhideApplication(wapp
, event
->xbutton
.button
==Button2
, unhideHere
);
691 if (event
->xbutton
.state
& MOD_MASK
) {
692 wHideOtherApplications(aicon
->icon
->owner
);
698 appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
700 WAppIcon
*aicon
= desc
->parent
;
701 WIcon
*icon
= aicon
->icon
;
703 int x
=aicon
->x_pos
, y
=aicon
->y_pos
;
704 int dx
=event
->xbutton
.x
, dy
=event
->xbutton
.y
;
707 int superfluous
= wPreferences
.superfluous
; /* we catch it to avoid problems */
708 WScreen
*scr
= icon
->core
->screen_ptr
;
709 WWorkspace
*workspace
= scr
->workspaces
[scr
->current_workspace
];
710 int shad_x
= 0, shad_y
= 0, docking
=0, dockable
, collapsed
= 0;
712 int clickButton
= event
->xbutton
.button
;
715 if (aicon
->editing
|| WCHECK_STATE(WSTATE_MODAL
))
718 if (IsDoubleClick(scr
, event
)) {
719 iconDblClick(desc
, event
);
723 if (event
->xbutton
.button
== Button3
) {
724 WObjDescriptor
*desc
;
725 WApplication
*wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
730 openApplicationMenu(wapp
, event
->xbutton
.x_root
,
731 event
->xbutton
.y_root
);
733 /* allow drag select of menu */
734 desc
= &scr
->icon_menu
->menu
->descriptor
;
735 event
->xbutton
.send_event
= True
;
736 (*desc
->handle_mousedown
)(desc
, event
);
743 if (event
->xbutton
.state
& MOD_MASK
)
744 wLowerFrame(icon
->core
);
746 wRaiseFrame(icon
->core
);
749 if (XGrabPointer(dpy
, icon
->core
->window
, True
, ButtonMotionMask
750 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
751 GrabModeAsync
, None
, None
, CurrentTime
) !=GrabSuccess
) {
752 wwarning("pointer grab failed for appicon move");
755 if (wPreferences
.flags
.nodock
&& wPreferences
.flags
.noclip
)
758 dockable
= canBeDocked(icon
->owner
);
762 WMMaskEvent(dpy
, PointerMotionMask
|ButtonReleaseMask
|ButtonPressMask
763 |ButtonMotionMask
|ExposureMask
, &ev
);
771 if (abs(dx
-ev
.xmotion
.x
)>=MOVE_THRESHOLD
772 || abs(dy
-ev
.xmotion
.y
)>=MOVE_THRESHOLD
) {
773 XChangeActivePointerGrab(dpy
, ButtonMotionMask
774 |ButtonReleaseMask
|ButtonPressMask
,
775 wCursor
[WCUR_MOVE
], CurrentTime
);
781 x
= ev
.xmotion
.x_root
- dx
;
782 y
= ev
.xmotion
.y_root
- dy
;
783 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
786 if (scr
->dock
&& wDockSnapIcon(scr
->dock
, aicon
, x
, y
,
788 shad_x
= scr
->dock
->x_pos
+ ix
*wPreferences
.icon_size
;
789 shad_y
= scr
->dock
->y_pos
+ iy
*wPreferences
.icon_size
;
791 if (scr
->last_dock
!= scr
->dock
&& collapsed
) {
792 scr
->last_dock
->collapsed
= 1;
793 wDockHideIcons(scr
->last_dock
);
796 if (!collapsed
&& (collapsed
= scr
->dock
->collapsed
)) {
797 scr
->dock
->collapsed
= 0;
798 wDockShowIcons(scr
->dock
);
801 if (scr
->dock
->auto_raise_lower
)
802 wDockRaise(scr
->dock
);
804 scr
->last_dock
= scr
->dock
;
806 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
810 wins
[0] = icon
->core
->window
;
811 wins
[1] = scr
->dock_shadow
;
812 XRestackWindows(dpy
, wins
, 2);
814 if (icon
->pixmap
!=None
)
815 ghost
= MakeGhostIcon(scr
, icon
->pixmap
);
817 ghost
= MakeGhostIcon(scr
, icon
->core
->window
);
818 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
820 XClearWindow(dpy
, scr
->dock_shadow
);
822 XMapWindow(dpy
, scr
->dock_shadow
);
825 } else if (workspace
->clip
&&
826 wDockSnapIcon(workspace
->clip
, aicon
, x
, y
,
828 shad_x
= workspace
->clip
->x_pos
+ ix
*wPreferences
.icon_size
;
829 shad_y
= workspace
->clip
->y_pos
+ iy
*wPreferences
.icon_size
;
831 if (scr
->last_dock
!= workspace
->clip
&& collapsed
) {
832 scr
->last_dock
->collapsed
= 1;
833 wDockHideIcons(scr
->last_dock
);
836 if (!collapsed
&& (collapsed
= workspace
->clip
->collapsed
)) {
837 workspace
->clip
->collapsed
= 0;
838 wDockShowIcons(workspace
->clip
);
841 if (workspace
->clip
->auto_raise_lower
)
842 wDockRaise(workspace
->clip
);
844 scr
->last_dock
= workspace
->clip
;
846 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
850 wins
[0] = icon
->core
->window
;
851 wins
[1] = scr
->dock_shadow
;
852 XRestackWindows(dpy
, wins
, 2);
854 if (icon
->pixmap
!=None
)
855 ghost
= MakeGhostIcon(scr
, icon
->pixmap
);
857 ghost
= MakeGhostIcon(scr
, icon
->core
->window
);
858 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
860 XClearWindow(dpy
, scr
->dock_shadow
);
862 XMapWindow(dpy
, scr
->dock_shadow
);
865 } else if (docking
) {
866 XUnmapWindow(dpy
, scr
->dock_shadow
);
877 if (ev
.xbutton
.button
!= clickButton
)
879 XUngrabPointer(dpy
, CurrentTime
);
884 /* icon is trying to be docked */
885 SlideWindow(icon
->core
->window
, x
, y
, shad_x
, shad_y
);
886 XUnmapWindow(dpy
, scr
->dock_shadow
);
887 docked
= wDockAttachIcon(scr
->last_dock
, aicon
, ix
, iy
);
888 if (scr
->last_dock
->auto_collapse
) {
891 if (workspace
->clip
&&
892 workspace
->clip
!= scr
->last_dock
&&
893 workspace
->clip
->auto_raise_lower
)
894 wDockLower(workspace
->clip
);
897 /* If icon could not be docked, slide it back to the old
899 SlideWindow(icon
->core
->window
, x
, y
, aicon
->x_pos
,
903 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
906 if (workspace
->clip
&& workspace
->clip
->auto_raise_lower
)
907 wDockLower(workspace
->clip
);
910 scr
->last_dock
->collapsed
= 1;
911 wDockHideIcons(scr
->last_dock
);
916 XFreePixmap(dpy
, ghost
);
917 XSetWindowBackground(dpy
, scr
->dock_shadow
, scr
->white_pixel
);
924 puts("End icon move");