1 /* dock.c- built-in Dock module for WindowMaker
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1998, 1999 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,
28 #include <X11/Xutil.h>
36 #define PATH_MAX DEFAULT_PATH_MAX
39 #include "WindowMaker.h"
49 #include "properties.h"
53 #include "workspace.h"
55 #include "superfluous.h"
64 /**** Local variables ****/
67 #define CLIP_FORWARD 2
70 /**** Global variables ****/
73 extern void DestroyDockAppSettingsPanel();
75 extern void ShowDockAppSettingsPanel(WAppIcon
*aicon
);
78 extern XContext wWinContext
;
80 extern Cursor wCursor
[WCUR_LAST
];
82 extern WPreferences wPreferences
;
84 extern XContext wWinContext
;
87 extern Atom _XA_DND_PROTOCOL
;
91 #define MOD_MASK wPreferences.modifier_mask
93 extern void appIconMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
95 #define ICON_SIZE wPreferences.icon_size
98 /***** Local variables ****/
100 static proplist_t dCommand
=NULL
;
102 static proplist_t dDropCommand
=NULL
;
104 static proplist_t dAutoLaunch
, dName
, dForced
, dBuggyApplication
, dYes
, dNo
;
105 static proplist_t dHost
, dDock
, dClip
;
106 static proplist_t dAutoAttractIcons
, dKeepAttracted
;
108 static proplist_t dPosition
, dApplications
, dLowered
, dCollapsed
, dAutoCollapse
;
110 static proplist_t dAutoRaiseLower
, dOmnipresent
;
112 static void dockIconPaint(WAppIcon
*btn
);
114 static void iconMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
116 static pid_t
execCommand(WAppIcon
*btn
, char *command
, WSavedState
*state
);
118 static void trackDeadProcess(pid_t pid
, unsigned char status
, WDock
*dock
);
120 static int getClipButton(int px
, int py
);
122 static void toggleLowered(WDock
*dock
);
124 static void toggleCollapsed(WDock
*dock
);
126 static void clipIconExpose(WObjDescriptor
*desc
, XEvent
*event
);
128 static void clipLeave(WDock
*dock
);
130 static void handleClipChangeWorkspace(WScreen
*scr
, XEvent
*event
);
132 Bool
moveIconBetweenDocks(WDock
*src
, WDock
*dest
, WAppIcon
*icon
, int x
, int y
);
134 static void clipEnterNotify(WObjDescriptor
*desc
, XEvent
*event
);
135 static void clipLeaveNotify(WObjDescriptor
*desc
, XEvent
*event
);
136 static void clipAutoCollapse(void *cdata
);
137 static void clipAutoExpand(void *cdata
);
138 static void launchDockedApplication(WAppIcon
*btn
);
140 static void clipAutoLower(void *cdata
);
141 static void clipAutoRaise(void *cdata
);
143 static void showClipBalloon(WDock
*dock
, int workspace
);
159 #endif /* OFFIX_DND */
169 dCommand
= PLRetain(PLMakeString("Command"));
171 dDropCommand
= PLRetain(PLMakeString("DropCommand"));
173 dAutoLaunch
= PLRetain(PLMakeString("AutoLaunch"));
174 dName
= PLRetain(PLMakeString("Name"));
175 dForced
= PLRetain(PLMakeString("Forced"));
176 dBuggyApplication
= PLRetain(PLMakeString("BuggyApplication"));
177 dYes
= PLRetain(PLMakeString("Yes"));
178 dNo
= PLRetain(PLMakeString("No"));
179 dHost
= PLRetain(PLMakeString("Host"));
181 dPosition
= PLMakeString("Position");
182 dApplications
= PLMakeString("Applications");
183 dLowered
= PLMakeString("Lowered");
184 dCollapsed
= PLMakeString("Collapsed");
185 dAutoCollapse
= PLMakeString("AutoCollapse");
186 dAutoRaiseLower
= PLMakeString("AutoRaiseLower");
187 dAutoAttractIcons
= PLMakeString("AutoAttractIcons");
188 dKeepAttracted
= PLMakeString("KeepAttracted");
190 dOmnipresent
= PLMakeString("Omnipresent");
192 dDock
= PLMakeString("Dock");
193 dClip
= PLMakeString("Clip");
199 renameCallback(WMenu
*menu
, WMenuEntry
*entry
)
201 WDock
*dock
= entry
->clientdata
;
206 assert(entry
->clientdata
!=NULL
);
208 wspace
= dock
->screen_ptr
->current_workspace
;
210 name
= wstrdup(dock
->screen_ptr
->workspaces
[wspace
]->name
);
212 sprintf(buffer
, _("Type the name for workspace %i:"), wspace
+1);
213 if (wInputDialog(dock
->screen_ptr
, _("Rename Workspace"), buffer
,
215 wWorkspaceRename(dock
->screen_ptr
, wspace
, name
);
224 toggleLoweredCallback(WMenu
*menu
, WMenuEntry
*entry
)
226 assert(entry
->clientdata
!=NULL
);
228 toggleLowered(entry
->clientdata
);
230 entry
->flags
.indicator_on
= !((WDock
*)entry
->clientdata
)->lowered
;
238 killCallback(WMenu
*menu
, WMenuEntry
*entry
)
241 #ifdef REDUCE_APPICONS
242 WAppIconAppList
*tapplist
;
244 extern Atom _XA_WM_DELETE_WINDOW
;
249 if (!WCHECK_STATE(WSTATE_NORMAL
))
252 assert(entry
->clientdata
!=NULL
);
254 icon
= (WAppIcon
*)entry
->clientdata
;
258 WCHANGE_STATE(WSTATE_MODAL
);
260 #ifdef REDUCE_APPICONS
261 /* Send a delete message to the main window of each application
262 * bound to this docked appicon. - cls
264 tapplist
= icon
->applist
;
265 while (tapplist
!= NULL
) {
266 if (tapplist
->wapp
->main_window_desc
!= NULL
) {
267 if (tapplist
->wapp
->main_window_desc
->protocols
.DELETE_WINDOW
) {
268 wClientSendProtocol(tapplist
->wapp
->main_window_desc
,
269 _XA_WM_DELETE_WINDOW
, CurrentTime
);
271 wClientKill(tapplist
->wapp
->main_window_desc
);
274 tapplist
= tapplist
->next
;
277 buffer
= wstrappend(icon
->wm_class
,
278 _(" will be forcibly closed.\n"
279 "Any unsaved changes will be lost.\n"
282 if (wPreferences
.dont_confirm_kill
283 || wMessageDialog(menu
->frame
->screen_ptr
, _("Kill Application"),
284 buffer
, _("Yes"), _("No"), NULL
)==WAPRDefault
) {
285 if (icon
->icon
&& icon
->icon
->owner
) {
286 wClientKill(icon
->icon
->owner
);
289 #endif /* !REDUCE_APPICONS */
293 WCHANGE_STATE(WSTATE_NORMAL
);}
297 getSelected(WDock
*dock
)
299 LinkedList
*ret
=NULL
;
303 for (i
=1; i
<dock
->max_icons
; i
++) {
304 btn
= dock
->icon_array
[i
];
305 if (btn
&& btn
->icon
->selected
) {
306 ret
= list_cons(btn
, ret
);
315 paintClipButtons(WAppIcon
*clipIcon
, Bool lpushed
, Bool rpushed
)
317 Window win
= clipIcon
->icon
->core
->window
;
318 WScreen
*scr
= clipIcon
->icon
->core
->screen_ptr
;
320 int pt
= CLIP_BUTTON_SIZE
*ICON_SIZE
/64;
321 int tp
= ICON_SIZE
- pt
;
322 int as
= pt
- 15; /* 15 = 5+5+5 */
323 GC gc
= scr
->clip_title_gc
;
324 #ifdef GRADIENT_CLIP_ARROW
325 Bool collapsed
= clipIcon
->dock
->collapsed
;
331 p
[1].x
= ICON_SIZE
-2;
333 p
[2].x
= ICON_SIZE
-2;
335 } else if (lpushed
) {
339 p
[1].y
= ICON_SIZE
-2;
341 p
[2].y
= ICON_SIZE
-2;
343 if (lpushed
|| rpushed
) {
344 XSetForeground(dpy
, scr
->draw_gc
, scr
->white_pixel
);
345 XFillPolygon(dpy
, win
, scr
->draw_gc
, p
, 3, Convex
, CoordModeOrigin
);
346 XSetForeground(dpy
, scr
->draw_gc
, scr
->black_pixel
);
348 #ifdef GRADIENT_CLIP_ARROW
350 XSetFillStyle(dpy
, scr
->copy_gc
, FillTiled
);
351 XSetTile(dpy
, scr
->copy_gc
, scr
->clip_arrow_gradient
);
352 XSetClipMask(dpy
, scr
->copy_gc
, None
);
355 #endif /* GRADIENT_CLIP_ARROW */
357 /* top right arrow */
358 p
[0].x
= p
[3].x
= ICON_SIZE
-5-as
;
360 p
[1].x
= ICON_SIZE
-6;
362 p
[2].x
= ICON_SIZE
-6;
365 XFillPolygon(dpy
, win
, scr
->draw_gc
, p
, 3, Convex
, CoordModeOrigin
);
366 XDrawLines(dpy
, win
, scr
->draw_gc
, p
, 4, CoordModeOrigin
);
368 #ifdef GRADIENT_CLIP_ARROW
370 XSetTSOrigin(dpy
, gc
, ICON_SIZE
-6-as
, 5);
372 XFillPolygon(dpy
, win
, gc
, p
,3,Convex
,CoordModeOrigin
);
373 XDrawLines(dpy
, win
, gc
, p
,4,CoordModeOrigin
);
376 /* bottom left arrow */
378 p
[0].y
= p
[3].y
= ICON_SIZE
-5-as
;
380 p
[1].y
= ICON_SIZE
-6;
382 p
[2].y
= ICON_SIZE
-6;
384 XFillPolygon(dpy
, win
, scr
->draw_gc
, p
, 3, Convex
, CoordModeOrigin
);
385 XDrawLines(dpy
, win
, scr
->draw_gc
, p
, 4, CoordModeOrigin
);
387 #ifdef GRADIENT_CLIP_ARROW
389 XSetTSOrigin(dpy
, gc
, 5, ICON_SIZE
-6-as
);
391 XFillPolygon(dpy
, win
, gc
, p
,3,Convex
,CoordModeOrigin
);
392 XDrawLines(dpy
, win
, gc
, p
,4,CoordModeOrigin
);
394 #ifdef GRADIENT_CLIP_ARROW
396 XSetFillStyle(dpy
, scr
->copy_gc
, FillSolid
);
402 wClipMakeTile(WScreen
*scr
, RImage
*normalTile
)
404 RImage
*tile
= RCloneImage(normalTile
);
411 pt
= CLIP_BUTTON_SIZE
*wPreferences
.icon_size
/64;
412 tp
= wPreferences
.icon_size
-1 - pt
;
416 black
.red
= black
.green
= black
.blue
= 0;
419 dark
.red
= dark
.green
= dark
.blue
= 60;
422 light
.red
= light
.green
= light
.blue
= 80;
426 ROperateLine(tile
, RSubtractOperation
, tp
, 0, wPreferences
.icon_size
-2,
428 RDrawLine(tile
, tp
-1, 0, wPreferences
.icon_size
-1, pt
+1, &black
);
429 ROperateLine(tile
, RAddOperation
, tp
, 2, wPreferences
.icon_size
-3,
433 ROperateLine(tile
, RSubtractOperation
, ICON_SIZE
- 7 - as
, 4,
434 ICON_SIZE
- 5, 4, &dark
);
435 ROperateLine(tile
, RSubtractOperation
, ICON_SIZE
- 6 - as
, 5,
436 ICON_SIZE
- 5, 6 + as
, &dark
);
437 ROperateLine(tile
, RAddOperation
, ICON_SIZE
- 5, 4, ICON_SIZE
- 5, 6 + as
,
441 ROperateLine(tile
, RAddOperation
, 2, tp
+2, pt
-2,
442 wPreferences
.icon_size
-3, &dark
);
443 RDrawLine(tile
, 0, tp
-1, pt
+1, wPreferences
.icon_size
-1, &black
);
444 ROperateLine(tile
, RSubtractOperation
, 0, tp
-2, pt
+1,
445 wPreferences
.icon_size
-2, &light
);
448 ROperateLine(tile
, RSubtractOperation
, 4, ICON_SIZE
- 7 - as
, 4,
449 ICON_SIZE
- 5, &dark
);
450 ROperateLine(tile
, RSubtractOperation
, 5, ICON_SIZE
- 6 - as
,
451 6 + as
, ICON_SIZE
- 5, &dark
);
452 ROperateLine(tile
, RAddOperation
, 4, ICON_SIZE
- 5, 6 + as
, ICON_SIZE
- 5,
460 removeIconsCallback(WMenu
*menu
, WMenuEntry
*entry
)
462 WAppIcon
*clickedIcon
= (WAppIcon
*)entry
->clientdata
;
465 LinkedList
*selectedIcons
;
468 assert(clickedIcon
!=NULL
);
470 dock
= clickedIcon
->dock
;
472 selectedIcons
= getSelected(dock
);
475 if (wMessageDialog(dock
->screen_ptr
, _("Workspace Clip"),
476 _("All selected icons will be removed!"),
477 _("OK"), _("Cancel"), NULL
)!=WAPRDefault
) {
481 if (clickedIcon
->xindex
==0 && clickedIcon
->yindex
==0)
483 selectedIcons
= list_cons(clickedIcon
, NULL
);
486 while (selectedIcons
) {
487 aicon
= selectedIcons
->head
;
488 keepit
= aicon
->running
&& wApplicationOf(aicon
->main_window
);
489 wDockDetach(dock
, aicon
);
491 PlaceIcon(dock
->screen_ptr
, &aicon
->x_pos
, &aicon
->y_pos
);
492 XMoveWindow(dpy
, aicon
->icon
->core
->window
,
493 aicon
->x_pos
, aicon
->y_pos
);
494 if (!dock
->mapped
|| dock
->collapsed
)
495 XMapWindow(dpy
, aicon
->icon
->core
->window
);
497 list_remove_head(&selectedIcons
);
500 if (wPreferences
.auto_arrange_icons
)
501 wArrangeIcons(dock
->screen_ptr
, True
);
506 keepIconsCallback(WMenu
*menu
, WMenuEntry
*entry
)
508 WAppIcon
*clickedIcon
= (WAppIcon
*)entry
->clientdata
;
511 LinkedList
*selectedIcons
;
513 assert(clickedIcon
!=NULL
);
514 dock
= clickedIcon
->dock
;
516 selectedIcons
= getSelected(dock
);
518 if (!selectedIcons
&& clickedIcon
!=dock
->screen_ptr
->clip_icon
) {
519 char *command
= NULL
;
521 if (!clickedIcon
->command
&& !clickedIcon
->editing
) {
522 clickedIcon
->editing
= 1;
523 if (wInputDialog(dock
->screen_ptr
, _("Keep Icon"),
524 _("Type the command used to launch the application"),
526 if (command
&& (command
[0]==0 ||
527 (command
[0]=='-' && command
[1]==0))) {
531 clickedIcon
->command
= command
;
532 clickedIcon
->editing
= 0;
534 clickedIcon
->editing
= 0;
541 selectedIcons
= list_cons(clickedIcon
, NULL
);
544 while (selectedIcons
) {
545 aicon
= selectedIcons
->head
;
546 if (aicon
->icon
->selected
)
547 wIconSelect(aicon
->icon
);
548 if (aicon
&& aicon
->attracted
&& aicon
->command
) {
549 aicon
->attracted
= 0;
550 if (aicon
->icon
->shadowed
) {
551 aicon
->icon
->shadowed
= 0;
552 aicon
->icon
->force_paint
= 1;
553 wAppIconPaint(aicon
);
556 list_remove_head(&selectedIcons
);
564 toggleAutoAttractCallback(WMenu
*menu
, WMenuEntry
*entry
)
566 WDock
*dock
= (WDock
*)entry
->clientdata
;
568 assert(entry
->clientdata
!=NULL
);
570 dock
->attract_icons
= !dock
->attract_icons
;
571 /*if (!dock->attract_icons)
572 dock->keep_attracted = 0;*/
574 entry
->flags
.indicator_on
= dock
->attract_icons
;
581 toggleKeepCallback(WMenu
*menu
, WMenuEntry
*entry
)
583 WDock
*dock
= (WDock
*)entry
->clientdata
;
587 assert(entry
->clientdata
!=NULL
);
589 dock
->keep_attracted
= !dock
->keep_attracted
;
591 if (dock
->keep_attracted
) {
592 for (i
=0; i
< dock
->max_icons
; i
++) {
593 btn
= dock
->icon_array
[i
];
594 if (btn
&& btn
->attracted
&& btn
->command
) {
596 if (btn
->icon
->shadowed
) {
597 btn
->icon
->shadowed
= 0;
598 btn
->icon
->force_paint
= 1;
605 entry
->flags
.indicator_on
= dock
->keep_attracted
;
612 selectCallback(WMenu
*menu
, WMenuEntry
*entry
)
614 WAppIcon
*icon
= (WAppIcon
*)entry
->clientdata
;
618 wIconSelect(icon
->icon
);
625 colectIconsCallback(WMenu
*menu
, WMenuEntry
*entry
)
627 WAppIcon
*clickedIcon
= (WAppIcon
*)entry
->clientdata
;
630 int x
, y
, x_pos
, y_pos
;
632 assert(entry
->clientdata
!=NULL
);
633 clip
= clickedIcon
->dock
;
635 aicon
= clip
->screen_ptr
->app_icon_list
;
638 if (!aicon
->docked
&& wDockFindFreeSlot(clip
, &x
, &y
)) {
639 x_pos
= clip
->x_pos
+ x
*ICON_SIZE
;
640 y_pos
= clip
->y_pos
+ y
*ICON_SIZE
;
641 if (aicon
->x_pos
!= x_pos
|| aicon
->y_pos
!= y_pos
) {
643 if (wPreferences
.no_animations
) {
644 XMoveWindow(dpy
, aicon
->icon
->core
->window
, x_pos
, y_pos
);
646 SlideWindow(aicon
->icon
->core
->window
,
647 aicon
->x_pos
, aicon
->y_pos
, x_pos
, y_pos
);
650 XMoveWindow(dpy
, aicon
->icon
->core
->window
, x_pos
, y_pos
);
651 #endif /* ANIMATIONS */
653 aicon
->attracted
= 1;
654 if (!clip
->keep_attracted
&& !aicon
->icon
->shadowed
) {
655 aicon
->icon
->shadowed
= 1;
656 aicon
->icon
->force_paint
= 1;
657 /* We don't do an wAppIconPaint() here because it's in
658 * wDockAttachIcon(). -Dan
661 wDockAttachIcon(clip
, aicon
, x
, y
);
662 if (clip
->collapsed
|| !clip
->mapped
)
663 XUnmapWindow(dpy
, aicon
->icon
->core
->window
);
671 selectIconsCallback(WMenu
*menu
, WMenuEntry
*entry
)
673 WAppIcon
*clickedIcon
= (WAppIcon
*)entry
->clientdata
;
675 LinkedList
*selectedIcons
;
679 assert(clickedIcon
!=NULL
);
680 dock
= clickedIcon
->dock
;
682 selectedIcons
= getSelected(dock
);
684 if (!selectedIcons
) {
685 for (i
=1; i
<dock
->max_icons
; i
++) {
686 btn
= dock
->icon_array
[i
];
687 if (btn
&& !btn
->icon
->selected
) {
688 wIconSelect(btn
->icon
);
692 while(selectedIcons
) {
693 btn
= selectedIcons
->head
;
694 wIconSelect(btn
->icon
);
695 list_remove_head(&selectedIcons
);
704 toggleCollapsedCallback(WMenu
*menu
, WMenuEntry
*entry
)
706 assert(entry
->clientdata
!=NULL
);
708 toggleCollapsed(entry
->clientdata
);
710 entry
->flags
.indicator_on
= ((WDock
*)entry
->clientdata
)->collapsed
;
717 toggleAutoCollapseCallback(WMenu
*menu
, WMenuEntry
*entry
)
720 assert(entry
->clientdata
!=NULL
);
722 dock
= (WDock
*) entry
->clientdata
;
724 dock
->auto_collapse
= !dock
->auto_collapse
;
726 entry
->flags
.indicator_on
= ((WDock
*)entry
->clientdata
)->auto_collapse
;
733 toggleAutoRaiseLowerCallback(WMenu
*menu
, WMenuEntry
*entry
)
736 assert(entry
->clientdata
!=NULL
);
738 dock
= (WDock
*) entry
->clientdata
;
740 dock
->auto_raise_lower
= !dock
->auto_raise_lower
;
742 entry
->flags
.indicator_on
= ((WDock
*)entry
->clientdata
)->auto_raise_lower
;
749 launchCallback(WMenu
*menu
, WMenuEntry
*entry
)
751 WAppIcon
*btn
= (WAppIcon
*)entry
->clientdata
;
753 launchDockedApplication(btn
);
758 settingsCallback(WMenu
*menu
, WMenuEntry
*entry
)
760 WAppIcon
*btn
= (WAppIcon
*)entry
->clientdata
;
764 ShowDockAppSettingsPanel(btn
);
769 hideCallback(WMenu
*menu
, WMenuEntry
*entry
)
772 WAppIcon
*btn
= (WAppIcon
*)entry
->clientdata
;
774 wapp
= wApplicationOf(btn
->icon
->owner
->main_window
);
776 if (wapp
->flags
.hidden
) {
777 wWorkspaceChange(btn
->icon
->core
->screen_ptr
,wapp
->last_workspace
);
778 wUnhideApplication(wapp
, False
, False
);
780 wHideApplication(wapp
);
786 unhideHereCallback(WMenu
*menu
, WMenuEntry
*entry
)
789 WAppIcon
*btn
= (WAppIcon
*)entry
->clientdata
;
791 wapp
= wApplicationOf(btn
->icon
->owner
->main_window
);
793 wUnhideApplication(wapp
, False
, True
);
798 mainIconCreate(WScreen
*scr
, int type
)
803 if (type
== WM_CLIP
) {
805 return scr
->clip_icon
;
806 btn
= wAppIconCreateForDock(scr
, NULL
, "Logo", "WMClip", TILE_CLIP
);
807 btn
->icon
->core
->descriptor
.handle_expose
= clipIconExpose
;
808 btn
->icon
->core
->descriptor
.handle_enternotify
= clipEnterNotify
;
809 btn
->icon
->core
->descriptor
.handle_leavenotify
= clipLeaveNotify
;
810 /*x_pos = scr->scr_width - ICON_SIZE*2 - DOCK_EXTRA_SPACE;*/
813 btn
= wAppIconCreateForDock(scr
, NULL
, "Logo", "WMDock", TILE_NORMAL
);
814 x_pos
= scr
->scr_width
- ICON_SIZE
- DOCK_EXTRA_SPACE
;
820 btn
->icon
->core
->descriptor
.handle_mousedown
= iconMouseDown
;
821 btn
->icon
->core
->descriptor
.parent_type
= WCLASS_DOCK_ICON
;
822 btn
->icon
->core
->descriptor
.parent
= btn
;
823 /*ChangeStackingLevel(btn->icon->core, WMDockLevel);*/
824 XMapWindow(dpy
, btn
->icon
->core
->window
);
829 scr
->clip_icon
= btn
;
836 switchWSCommand(WMenu
*menu
, WMenuEntry
*entry
)
838 WAppIcon
*btn
, *icon
= (WAppIcon
*) entry
->clientdata
;
839 WScreen
*scr
= icon
->icon
->core
->screen_ptr
;
841 LinkedList
*selectedIcons
;
844 if (entry
->order
== scr
->current_workspace
)
847 dest
= scr
->workspaces
[entry
->order
]->clip
;
849 selectedIcons
= getSelected(src
);
852 while(selectedIcons
) {
853 btn
= selectedIcons
->head
;
854 if (wDockFindFreeSlot(dest
, &x
, &y
)) {
855 moveIconBetweenDocks(src
, dest
, btn
, x
, y
);
856 XUnmapWindow(dpy
, btn
->icon
->core
->window
);
858 list_remove_head(&selectedIcons
);
860 } else if (icon
!= scr
->clip_icon
) {
861 if (wDockFindFreeSlot(dest
, &x
, &y
)) {
862 moveIconBetweenDocks(src
, dest
, icon
, x
, y
);
863 XUnmapWindow(dpy
, icon
->icon
->core
->window
);
871 launchDockedApplication(WAppIcon
*btn
)
873 WScreen
*scr
= btn
->icon
->core
->screen_ptr
;
875 if (!btn
->launching
&& btn
->command
!=NULL
) {
876 if (!btn
->forced_dock
) {
877 btn
->relaunching
= btn
->running
;
880 if (btn
->wm_instance
|| btn
->wm_class
) {
881 WWindowAttributes attr
;
882 memset(&attr
, 0, sizeof(WWindowAttributes
));
883 wDefaultFillAttributes(scr
, btn
->wm_instance
, btn
->wm_class
,
886 if (!attr
.no_appicon
&& !btn
->buggy_app
)
891 btn
->drop_launch
= 0;
892 scr
->last_dock
= btn
->dock
;
893 btn
->pid
= execCommand(btn
, btn
->command
, NULL
);
895 if (btn
->buggy_app
) {
896 /* give feedback that the app was launched */
900 WMAddTimerHandler(200, (WMCallback
*)dockIconPaint
, btn
);
905 wwarning(_("could not launch application %s\n"), btn
->command
);
907 if (!btn
->relaunching
)
916 updateWorkspaceMenu(WMenu
*menu
, WAppIcon
*icon
)
918 WScreen
*scr
= menu
->frame
->screen_ptr
;
919 char title
[MAX_WORKSPACENAME_WIDTH
+1];
925 for (i
=0; i
<scr
->workspace_count
; i
++) {
926 if (i
< menu
->entry_no
) {
927 if (strcmp(menu
->entries
[i
]->text
,scr
->workspaces
[i
]->name
)!=0) {
928 free(menu
->entries
[i
]->text
);
929 strcpy(title
, scr
->workspaces
[i
]->name
);
930 menu
->entries
[i
]->text
= wstrdup(title
);
931 menu
->flags
.realized
= 0;
933 menu
->entries
[i
]->clientdata
= (void*)icon
;
935 strcpy(title
, scr
->workspaces
[i
]->name
);
937 wMenuAddCallback(menu
, title
, switchWSCommand
, (void*)icon
);
939 menu
->flags
.realized
= 0;
941 if (i
== scr
->current_workspace
) {
942 wMenuSetEnabled(menu
, i
, False
);
944 wMenuSetEnabled(menu
, i
, True
);
948 if (!menu
->flags
.realized
)
954 makeWorkspaceMenu(WScreen
*scr
)
958 menu
= wMenuCreate(scr
, NULL
, False
);
960 wwarning(_("could not create workspace submenu for Clip menu"));
962 wMenuAddCallback(menu
, "", switchWSCommand
, (void*)scr
->clip_icon
);
964 menu
->flags
.realized
= 0;
972 updateClipOptionsMenu(WMenu
*menu
, WDock
*dock
)
981 entry
= menu
->entries
[index
];
982 entry
->flags
.indicator_on
= !dock
->lowered
;
983 entry
->clientdata
= dock
;
986 entry
= menu
->entries
[++index
];
987 entry
->flags
.indicator_on
= dock
->collapsed
;
988 entry
->clientdata
= dock
;
991 entry
= menu
->entries
[++index
];
992 entry
->flags
.indicator_on
= dock
->auto_collapse
;
993 entry
->clientdata
= dock
;
995 /* auto-raise/lower */
996 entry
= menu
->entries
[++index
];
997 entry
->flags
.indicator_on
= dock
->auto_raise_lower
;
998 entry
->clientdata
= dock
;
1001 entry
= menu
->entries
[++index
];
1002 entry
->flags
.indicator_on
= dock
->attract_icons
;
1003 entry
->clientdata
= dock
;
1005 /* keep attracted icons */
1006 entry
= menu
->entries
[++index
];
1007 entry
->flags
.indicator_on
= dock
->keep_attracted
;
1008 entry
->clientdata
= dock
;
1010 menu
->flags
.realized
= 0;
1016 makeClipOptionsMenu(WScreen
*scr
)
1021 menu
= wMenuCreate(scr
, NULL
, False
);
1023 wwarning(_("could not create options submenu for Clip menu"));
1027 entry
= wMenuAddCallback(menu
, _("Keep on Top"),
1028 toggleLoweredCallback
, NULL
);
1029 entry
->flags
.indicator
= 1;
1030 entry
->flags
.indicator_on
= 1;
1031 entry
->flags
.indicator_type
= MI_CHECK
;
1033 entry
= wMenuAddCallback(menu
, _("Collapsed"),
1034 toggleCollapsedCallback
, NULL
);
1035 entry
->flags
.indicator
= 1;
1036 entry
->flags
.indicator_on
= 1;
1037 entry
->flags
.indicator_type
= MI_CHECK
;
1039 entry
= wMenuAddCallback(menu
, _("AutoCollapse"),
1040 toggleAutoCollapseCallback
, NULL
);
1041 entry
->flags
.indicator
= 1;
1042 entry
->flags
.indicator_on
= 1;
1043 entry
->flags
.indicator_type
= MI_CHECK
;
1045 entry
= wMenuAddCallback(menu
, _("AutoRaiseLower"),
1046 toggleAutoRaiseLowerCallback
, NULL
);
1047 entry
->flags
.indicator
= 1;
1048 entry
->flags
.indicator_on
= 1;
1049 entry
->flags
.indicator_type
= MI_CHECK
;
1051 entry
= wMenuAddCallback(menu
, _("AutoAttract Icons"),
1052 toggleAutoAttractCallback
, NULL
);
1053 entry
->flags
.indicator
= 1;
1054 entry
->flags
.indicator_on
= 1;
1055 entry
->flags
.indicator_type
= MI_CHECK
;
1057 entry
= wMenuAddCallback(menu
, _("Keep Attracted Icons"),
1058 toggleKeepCallback
, NULL
);
1059 entry
->flags
.indicator
= 1;
1060 entry
->flags
.indicator_on
= 1;
1061 entry
->flags
.indicator_type
= MI_CHECK
;
1063 menu
->flags
.realized
= 0;
1071 dockMenuCreate(WScreen
*scr
, int type
)
1076 if (type
== WM_CLIP
&& scr
->clip_menu
)
1077 return scr
->clip_menu
;
1079 menu
= wMenuCreate(scr
, NULL
, False
);
1080 if (type
!= WM_CLIP
) {
1081 entry
= wMenuAddCallback(menu
, _("Keep on top"),
1082 toggleLoweredCallback
, NULL
);
1083 entry
->flags
.indicator
= 1;
1084 entry
->flags
.indicator_on
= 1;
1085 entry
->flags
.indicator_type
= MI_CHECK
;
1087 entry
= wMenuAddCallback(menu
, _("Clip Options"), NULL
, NULL
);
1088 scr
->clip_options
= makeClipOptionsMenu(scr
);
1089 if (scr
->clip_options
)
1090 wMenuEntrySetCascade(menu
, entry
, scr
->clip_options
);
1092 wMenuAddCallback(menu
, _("Rename Workspace"), renameCallback
, NULL
);
1094 wMenuAddCallback(menu
, _("(Un)Select Icon"), selectCallback
, NULL
);
1096 wMenuAddCallback(menu
, _("(Un)Select All Icons"), selectIconsCallback
,
1099 wMenuAddCallback(menu
, _("Keep Icon(s)"), keepIconsCallback
, NULL
);
1101 entry
= wMenuAddCallback(menu
, _("Move Icon(s) To"), NULL
, NULL
);
1102 scr
->clip_submenu
= makeWorkspaceMenu(scr
);
1103 if (scr
->clip_submenu
)
1104 wMenuEntrySetCascade(menu
, entry
, scr
->clip_submenu
);
1106 wMenuAddCallback(menu
, _("Remove Icon(s)"), removeIconsCallback
, NULL
);
1108 wMenuAddCallback(menu
, _("Attract Icons"), colectIconsCallback
, NULL
);
1111 wMenuAddCallback(menu
, _("Launch"), launchCallback
, NULL
);
1113 wMenuAddCallback(menu
, _("Unhide Here"), unhideHereCallback
, NULL
);
1115 entry
= wMenuAddCallback(menu
, _("Hide"), hideCallback
, NULL
);
1117 entry
->text
= _("Hide");
1119 wMenuAddCallback(menu
, _("Settings..."), settingsCallback
, NULL
);
1121 wMenuAddCallback(menu
, _("Kill"), killCallback
, NULL
);
1123 if (type
== WM_CLIP
)
1124 scr
->clip_menu
= menu
;
1131 wDockCreate(WScreen
*scr
, int type
)
1139 dock
= wmalloc(sizeof(WDock
));
1140 memset(dock
, 0, sizeof(WDock
));
1142 if (type
== WM_CLIP
)
1143 icon_count
= CLIP_MAX_ICONS
;
1145 icon_count
= scr
->scr_height
/wPreferences
.icon_size
;
1147 dock
->icon_array
= wmalloc(sizeof(WAppIcon
*)*icon_count
);
1148 memset(dock
->icon_array
, 0, sizeof(WAppIcon
*)*icon_count
);
1150 dock
->max_icons
= icon_count
;
1152 btn
= mainIconCreate(scr
, type
);
1156 dock
->x_pos
= btn
->x_pos
;
1157 dock
->y_pos
= btn
->y_pos
;
1158 dock
->screen_ptr
= scr
;
1160 dock
->icon_count
= 1;
1161 dock
->on_right_side
= 1;
1162 dock
->collapsed
= 0;
1163 dock
->auto_collapse
= 0;
1164 dock
->auto_collapse_magic
= NULL
;
1165 dock
->auto_raise_lower
= 0;
1166 dock
->auto_lower_magic
= NULL
;
1167 dock
->auto_raise_magic
= NULL
;
1168 dock
->attract_icons
= 0;
1169 dock
->keep_attracted
= 0;
1171 dock
->icon_array
[0] = btn
;
1172 wRaiseFrame(btn
->icon
->core
);
1173 XMoveWindow(dpy
, btn
->icon
->core
->window
, btn
->x_pos
, btn
->y_pos
);
1175 /* create dock menu */
1176 dock
->menu
= dockMenuCreate(scr
, type
);
1183 wDockDestroy(WDock
*dock
)
1188 for (i
=(dock
->type
== WM_CLIP
) ? 1 : 0; i
<dock
->max_icons
; i
++) {
1189 aicon
= dock
->icon_array
[i
];
1191 int keepit
= aicon
->running
&& wApplicationOf(aicon
->main_window
);
1192 wDockDetach(dock
, aicon
);
1194 PlaceIcon(dock
->screen_ptr
, &aicon
->x_pos
, &aicon
->y_pos
);
1195 XMoveWindow(dpy
, aicon
->icon
->core
->window
,
1196 aicon
->x_pos
, aicon
->y_pos
);
1197 if (!dock
->mapped
|| dock
->collapsed
)
1198 XMapWindow(dpy
, aicon
->icon
->core
->window
);
1202 if (wPreferences
.auto_arrange_icons
)
1203 wArrangeIcons(dock
->screen_ptr
, True
);
1204 free(dock
->icon_array
);
1205 if (dock
->menu
&& dock
->type
!=WM_CLIP
)
1206 wMenuDestroy(dock
->menu
, True
);
1212 wClipIconPaint(WAppIcon
*aicon
)
1214 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
1215 WWorkspace
*workspace
= scr
->workspaces
[scr
->current_workspace
];
1217 Window win
= aicon
->icon
->core
->window
;
1218 int length
, nlength
;
1219 char *ws_name
, ws_number
[10];
1222 wIconPaint(aicon
->icon
);
1224 length
= strlen(workspace
->name
);
1225 ws_name
= malloc(length
+ 1);
1226 sprintf(ws_name
, "%s", workspace
->name
);
1227 sprintf(ws_number
, "%i", scr
->current_workspace
+ 1);
1228 nlength
= strlen(ws_number
);
1230 gc
= scr
->clip_title_gc
;
1232 if (!workspace
->clip
->collapsed
)
1233 XSetForeground(dpy
, gc
, scr
->clip_title_pixel
[CLIP_NORMAL
]);
1235 XSetForeground(dpy
, gc
, scr
->clip_title_pixel
[CLIP_COLLAPSED
]);
1237 ty
= ICON_SIZE
- scr
->clip_title_font
->height
- 3;
1239 tx
= CLIP_BUTTON_SIZE
*ICON_SIZE
/64;
1241 wDrawString(win
, scr
->clip_title_font
, gc
, tx
,
1242 ty
+ scr
->clip_title_font
->y
, ws_name
, length
);
1244 tx
= (ICON_SIZE
/2 - wTextWidth(scr
->clip_title_font
->font
, ws_number
, nlength
))/2;
1246 wDrawString(win
, scr
->clip_title_font
, gc
, tx
,
1247 scr
->clip_title_font
->y
+ 2, ws_number
, nlength
);
1251 if (aicon
->launching
) {
1252 XFillRectangle(dpy
, aicon
->icon
->core
->window
, scr
->stipple_gc
,
1253 0, 0, wPreferences
.icon_size
, wPreferences
.icon_size
);
1255 paintClipButtons(aicon
, aicon
->dock
->lclip_button_pushed
,
1256 aicon
->dock
->rclip_button_pushed
);
1261 clipIconExpose(WObjDescriptor
*desc
, XEvent
*event
)
1263 wClipIconPaint(desc
->parent
);
1268 dockIconPaint(WAppIcon
*btn
)
1270 if (btn
== btn
->icon
->core
->screen_ptr
->clip_icon
)
1271 wClipIconPaint(btn
);
1278 make_icon_state(WAppIcon
*btn
)
1280 proplist_t node
= NULL
;
1281 proplist_t command
, autolaunch
, name
, forced
, host
, position
, buggy
;
1282 proplist_t omnipresent
;
1288 command
= PLMakeString("-");
1290 command
= PLMakeString(btn
->command
);
1292 autolaunch
= btn
->auto_launch
? dYes
: dNo
;
1294 tmp
= EscapeWM_CLASS(btn
->wm_instance
, btn
->wm_class
);
1296 name
= PLMakeString(tmp
);
1300 forced
= btn
->forced_dock
? dYes
: dNo
;
1302 buggy
= btn
->buggy_app
? dYes
: dNo
;
1304 if (btn
== btn
->icon
->core
->screen_ptr
->clip_icon
)
1305 sprintf(buffer
, "%i,%i", btn
->x_pos
, btn
->y_pos
);
1307 sprintf(buffer
, "%hi,%hi", btn
->xindex
, btn
->yindex
);
1308 position
= PLMakeString(buffer
);
1310 node
= PLMakeDictionaryFromEntries(dCommand
, command
,
1312 dAutoLaunch
, autolaunch
,
1314 dBuggyApplication
, buggy
,
1315 dPosition
, position
,
1319 PLRelease(position
);
1321 omnipresent
= btn
->omnipresent
? dYes
: dNo
;
1322 if (btn
->dock
!= btn
->icon
->core
->screen_ptr
->dock
&&
1323 (btn
->xindex
!= 0 || btn
->yindex
!= 0))
1324 PLInsertDictionaryEntry(node
, dOmnipresent
, omnipresent
);
1327 if (btn
->dnd_command
) {
1328 command
= PLMakeString(btn
->dnd_command
);
1329 PLInsertDictionaryEntry(node
, dDropCommand
, command
);
1332 #endif /* OFFIX_DND */
1334 if (btn
->client_machine
&& btn
->remote_start
) {
1335 host
= PLMakeString(btn
->client_machine
);
1336 PLInsertDictionaryEntry(node
, dHost
, host
);
1346 dockSaveState(WDock
*dock
)
1349 proplist_t icon_info
;
1350 proplist_t list
=NULL
, dock_state
=NULL
;
1354 list
= PLMakeArrayFromElements(NULL
);
1356 for (i
=(dock
->type
==WM_DOCK
? 0 : 1); i
<dock
->max_icons
; i
++) {
1357 WAppIcon
*btn
= dock
->icon_array
[i
];
1359 if (!btn
|| (btn
->attracted
&& !dock
->keep_attracted
))
1362 if ((icon_info
= make_icon_state(dock
->icon_array
[i
]))) {
1363 list
= PLAppendArrayElement(list
, icon_info
);
1364 PLRelease(icon_info
);
1368 dock_state
= PLMakeDictionaryFromEntries(dApplications
, list
, NULL
);
1372 if (dock
->type
== WM_DOCK
) {
1373 sprintf(buffer
, "%i,%i", (dock
->on_right_side
? -ICON_SIZE
: 0),
1375 value
= PLMakeString(buffer
);
1376 PLInsertDictionaryEntry(dock_state
, dPosition
, value
);
1380 value
= (dock
->lowered
? dYes
: dNo
);
1381 PLInsertDictionaryEntry(dock_state
, dLowered
, value
);
1383 if (dock
->type
== WM_CLIP
) {
1384 value
= (dock
->collapsed
? dYes
: dNo
);
1385 PLInsertDictionaryEntry(dock_state
, dCollapsed
, value
);
1387 value
= (dock
->auto_collapse
? dYes
: dNo
);
1388 PLInsertDictionaryEntry(dock_state
, dAutoCollapse
, value
);
1390 value
= (dock
->auto_raise_lower
? dYes
: dNo
);
1391 PLInsertDictionaryEntry(dock_state
, dAutoRaiseLower
, value
);
1393 value
= (dock
->attract_icons
? dYes
: dNo
);
1394 PLInsertDictionaryEntry(dock_state
, dAutoAttractIcons
, value
);
1396 value
= (dock
->keep_attracted
? dYes
: dNo
);
1397 PLInsertDictionaryEntry(dock_state
, dKeepAttracted
, value
);
1405 wDockSaveState(WScreen
*scr
)
1407 proplist_t dock_state
;
1409 dock_state
= dockSaveState(scr
->dock
);
1411 PLInsertDictionaryEntry(scr
->session_state
, dDock
, dock_state
);
1413 PLRelease(dock_state
);
1418 wClipSaveState(WScreen
*scr
)
1420 proplist_t clip_state
;
1422 clip_state
= make_icon_state(scr
->clip_icon
);
1424 PLInsertDictionaryEntry(scr
->session_state
, dClip
, clip_state
);
1426 PLRelease(clip_state
);
1431 wClipSaveWorkspaceState(WScreen
*scr
, int workspace
)
1433 return dockSaveState(scr
->workspaces
[workspace
]->clip
);
1438 restore_icon_state(WScreen
*scr
, proplist_t info
, int type
, int index
)
1441 char *wclass
, *winstance
;
1442 proplist_t cmd
, value
;
1446 cmd
= PLGetDictionaryEntry(info
, dCommand
);
1447 if (!cmd
|| !PLIsString(cmd
)) {
1451 /* parse window name */
1452 value
= PLGetDictionaryEntry(info
, dName
);
1456 ParseWindowName(value
, &winstance
, &wclass
, "dock");
1458 if (!winstance
&& !wclass
) {
1465 command
= wstrdup(PLGetString(cmd
));
1469 if (!command
|| strcmp(command
, "-")==0) {
1480 aicon
= wAppIconCreateForDock(scr
, command
, winstance
, wclass
,
1487 aicon
->icon
->core
->descriptor
.handle_mousedown
= iconMouseDown
;
1488 if (type
== WM_CLIP
) {
1489 aicon
->icon
->core
->descriptor
.handle_enternotify
= clipEnterNotify
;
1490 aicon
->icon
->core
->descriptor
.handle_leavenotify
= clipLeaveNotify
;
1492 aicon
->icon
->core
->descriptor
.parent_type
= WCLASS_DOCK_ICON
;
1493 aicon
->icon
->core
->descriptor
.parent
= aicon
;
1497 cmd
= PLGetDictionaryEntry(info
, dDropCommand
);
1499 aicon
->dnd_command
= wstrdup(PLGetString(cmd
));
1502 /* check auto launch */
1503 value
= PLGetDictionaryEntry(info
, dAutoLaunch
);
1505 aicon
->auto_launch
= 0;
1507 if (PLIsString(value
)) {
1508 if (strcasecmp(PLGetString(value
), "YES")==0)
1509 aicon
->auto_launch
= 1;
1511 wwarning(_("bad value in docked icon state info %s"),
1512 PLGetString(dAutoLaunch
));
1516 /* check if it wasn't normally docked */
1517 value
= PLGetDictionaryEntry(info
, dForced
);
1519 aicon
->forced_dock
= 0;
1521 if (PLIsString(value
)) {
1522 if (strcasecmp(PLGetString(value
), "YES")==0)
1523 aicon
->forced_dock
= 1;
1525 wwarning(_("bad value in docked icon state info %s"),
1526 PLGetString(dForced
));
1530 /* check if we can rely on the stuff in the app */
1531 value
= PLGetDictionaryEntry(info
, dBuggyApplication
);
1533 aicon
->buggy_app
= 0;
1535 if (PLIsString(value
)) {
1536 if (strcasecmp(PLGetString(value
), "YES")==0)
1537 aicon
->buggy_app
= 1;
1539 wwarning(_("bad value in docked icon state info %s"),
1540 PLGetString(dBuggyApplication
));
1544 /* get position in the dock */
1545 value
= PLGetDictionaryEntry(info
, dPosition
);
1546 if (value
&& PLIsString(value
)) {
1547 if (sscanf(PLGetString(value
), "%hi,%hi", &aicon
->xindex
,
1549 wwarning(_("bad value in docked icon state info %s"),
1550 PLGetString(dPosition
));
1552 /* check position sanity */
1553 /* incomplete section! */
1554 if (type
== WM_DOCK
) {
1556 if (aicon
->yindex
< 0)
1557 wwarning(_("bad value in docked icon position %i,%i"),
1558 aicon
->xindex
, aicon
->yindex
);
1561 aicon
->yindex
= index
;
1565 /* check if icon is omnipresent */
1566 value
= PLGetDictionaryEntry(info
, dOmnipresent
);
1568 aicon
->omnipresent
= 0;
1570 if (PLIsString(value
)) {
1571 if (strcasecmp(PLGetString(value
), "YES")==0)
1572 aicon
->omnipresent
= 1;
1574 wwarning(_("bad value in docked icon state info %s"),
1575 PLGetString(dOmnipresent
));
1586 #define COMPLAIN(key) wwarning(_("bad value in dock state info:%s"), key)
1590 wClipRestoreState(WScreen
*scr
, proplist_t clip_state
)
1596 icon
= mainIconCreate(scr
, WM_CLIP
);
1601 PLRetain(clip_state
);
1603 /* restore position */
1605 value
= PLGetDictionaryEntry(clip_state
, dPosition
);
1608 if (!PLIsString(value
))
1609 COMPLAIN("Position");
1611 if (sscanf(PLGetString(value
), "%i,%i", &icon
->x_pos
,
1613 COMPLAIN("Position");
1615 /* check position sanity */
1616 if (icon
->y_pos
< 0)
1618 else if (icon
->y_pos
> scr
->scr_height
-ICON_SIZE
)
1619 icon
->y_pos
= scr
->scr_height
-ICON_SIZE
;
1621 if (icon
->x_pos
< 0)
1623 else if (icon
->x_pos
> scr
->scr_width
-ICON_SIZE
)
1624 icon
->x_pos
= scr
->scr_width
-ICON_SIZE
;
1629 value
= PLGetDictionaryEntry(clip_state
, dDropCommand
);
1630 if (value
&& PLIsString(value
))
1631 icon
->dnd_command
= wstrdup(PLGetString(value
));
1634 PLRelease(clip_state
);
1641 wDockRestoreState(WScreen
*scr
, proplist_t dock_state
, int type
)
1646 WAppIcon
*aicon
, *old_top
;
1650 dock
= wDockCreate(scr
, type
);
1656 PLRetain(dock_state
);
1659 /* restore position */
1661 value
= PLGetDictionaryEntry(dock_state
, dPosition
);
1664 if (!PLIsString(value
))
1665 COMPLAIN("Position");
1667 if (sscanf(PLGetString(value
), "%i,%i", &dock
->x_pos
,
1669 COMPLAIN("Position");
1671 /* check position sanity */
1672 if (dock
->y_pos
< 0)
1674 else if (dock
->y_pos
> scr
->scr_height
-ICON_SIZE
)
1675 dock
->y_pos
= scr
->scr_height
- ICON_SIZE
;
1677 /* This is no more needed. ??? */
1678 if (type
== WM_CLIP
) {
1679 if (dock
->x_pos
< 0)
1681 else if (dock
->x_pos
> scr
->scr_width
-ICON_SIZE
)
1682 dock
->x_pos
= scr
->scr_width
-ICON_SIZE
;
1684 if (dock
->x_pos
>= 0) {
1685 dock
->x_pos
= DOCK_EXTRA_SPACE
;
1686 dock
->on_right_side
= 0;
1688 dock
->x_pos
= scr
->scr_width
- DOCK_EXTRA_SPACE
- ICON_SIZE
;
1689 dock
->on_right_side
= 1;
1695 /* restore lowered/raised state */
1699 value
= PLGetDictionaryEntry(dock_state
, dLowered
);
1702 if (!PLIsString(value
))
1703 COMPLAIN("Lowered");
1705 if (strcasecmp(PLGetString(value
), "YES")==0)
1711 /* restore collapsed state */
1713 dock
->collapsed
= 0;
1715 value
= PLGetDictionaryEntry(dock_state
, dCollapsed
);
1718 if (!PLIsString(value
))
1719 COMPLAIN("Collapsed");
1721 if (strcasecmp(PLGetString(value
), "YES")==0)
1722 dock
->collapsed
= 1;
1727 /* restore auto-collapsed state */
1729 value
= PLGetDictionaryEntry(dock_state
, dAutoCollapse
);
1732 if (!PLIsString(value
))
1733 COMPLAIN("AutoCollapse");
1735 if (strcasecmp(PLGetString(value
), "YES")==0) {
1736 dock
->auto_collapse
= 1;
1737 dock
->collapsed
= 1;
1743 /* restore auto-raise/lower state */
1745 value
= PLGetDictionaryEntry(dock_state
, dAutoRaiseLower
);
1748 if (!PLIsString(value
))
1749 COMPLAIN("AutoRaiseLower");
1751 if (strcasecmp(PLGetString(value
), "YES")==0) {
1752 dock
->auto_raise_lower
= 1;
1757 /* restore attract icons state */
1759 dock
->attract_icons
= 0;
1761 value
= PLGetDictionaryEntry(dock_state
, dAutoAttractIcons
);
1764 if (!PLIsString(value
))
1765 COMPLAIN("AutoAttractIcons");
1767 if (strcasecmp(PLGetString(value
), "YES")==0)
1768 dock
->attract_icons
= 1;
1773 /* restore keep attracted icons state */
1775 dock
->keep_attracted
= 0;
1777 value
= PLGetDictionaryEntry(dock_state
, dKeepAttracted
);
1780 if (!PLIsString(value
))
1781 COMPLAIN("KeepAttracted");
1783 if (strcasecmp(PLGetString(value
), "YES")==0)
1784 dock
->keep_attracted
= 1;
1789 /* application list */
1791 apps
= PLGetDictionaryEntry(dock_state
, dApplications
);
1797 count
= PLGetNumberOfElements(apps
);
1802 old_top
= dock
->icon_array
[0];
1804 /* dock->icon_count is set to 1 when dock is created.
1805 * Since Clip is already restored, we want to keep it so for clip,
1806 * but for dock we may change the default top tile, so we set it to 0.
1808 if (type
== WM_DOCK
)
1809 dock
->icon_count
= 0;
1811 for (i
=0; i
<count
; i
++) {
1812 if (dock
->icon_count
>= dock
->max_icons
) {
1813 wwarning(_("there are too many icons stored in dock. Ignoring what doesn't fit"));
1817 value
= PLGetArrayElement(apps
, i
);
1818 aicon
= restore_icon_state(scr
, value
, type
, dock
->icon_count
);
1820 dock
->icon_array
[dock
->icon_count
] = aicon
;
1824 aicon
->x_pos
= dock
->x_pos
+ (aicon
->xindex
*ICON_SIZE
);
1825 aicon
->y_pos
= dock
->y_pos
+ (aicon
->yindex
*ICON_SIZE
);
1828 ChangeStackingLevel(aicon
->icon
->core
, WMNormalLevel
);
1830 ChangeStackingLevel(aicon
->icon
->core
, WMDockLevel
);
1832 wCoreConfigure(aicon
->icon
->core
, aicon
->x_pos
, aicon
->y_pos
,
1835 if (!dock
->collapsed
)
1836 XMapWindow(dpy
, aicon
->icon
->core
->window
);
1837 wRaiseFrame(aicon
->icon
->core
);
1840 } else if (dock
->icon_count
==0 && type
==WM_DOCK
)
1844 /* if the first icon is not defined, use the default */
1845 if (dock
->icon_array
[0]==NULL
) {
1846 /* update default icon */
1847 old_top
->x_pos
= dock
->x_pos
;
1848 old_top
->y_pos
= dock
->y_pos
;
1850 ChangeStackingLevel(old_top
->icon
->core
, WMNormalLevel
);
1852 ChangeStackingLevel(old_top
->icon
->core
, WMDockLevel
);
1853 dock
->icon_array
[0] = old_top
;
1854 XMoveWindow(dpy
, old_top
->icon
->core
->window
, dock
->x_pos
, dock
->y_pos
);
1855 /* we don't need to increment dock->icon_count here because it was
1856 * incremented in the loop above.
1858 } else if (old_top
!=dock
->icon_array
[0]) {
1859 if (old_top
== scr
->clip_icon
)
1860 scr
->clip_icon
= dock
->icon_array
[0];
1861 wAppIconDestroy(old_top
);
1866 PLRelease(dock_state
);
1874 wDockLaunchWithState(WDock
*dock
, WAppIcon
*btn
, WSavedState
*state
)
1876 if (btn
&& btn
->command
&& !btn
->running
&& !btn
->launching
) {
1878 btn
->drop_launch
= 0;
1880 btn
->pid
= execCommand(btn
, btn
->command
, state
);
1883 if (!btn
->forced_dock
&& !btn
->buggy_app
) {
1895 wDockDoAutoLaunch(WDock
*dock
, int workspace
)
1901 for (i
= 0; i
< dock
->max_icons
; i
++) {
1902 btn
= dock
->icon_array
[i
];
1903 if (!btn
|| !btn
->auto_launch
)
1906 state
= wmalloc(sizeof(WSavedState
));
1907 memset(state
, 0, sizeof(WSavedState
));
1908 state
->workspace
= workspace
;
1909 /* TODO: this is klugy and is very difficult to understand
1910 * what's going on. Try to clean up */
1911 wDockLaunchWithState(dock
, btn
, state
);
1915 #ifdef REDUCE_APPICONS
1917 wDockSimulateLaunch(WDock
*dock
, WAppIcon
*btn
)
1919 if ((btn
== NULL
) || (dock
== NULL
))
1922 if (!btn
->running
) {
1923 if ((btn
->icon
->owner
== NULL
) && (btn
->applist
))
1924 btn
->icon
->owner
= btn
->applist
->wapp
->main_window_desc
;
1925 if (!btn
->forced_dock
)
1935 findDock(WScreen
*scr
, XEvent
*event
, int *icon_pos
)
1941 if ((dock
= scr
->dock
)!=NULL
) {
1942 for (i
=0; i
<dock
->max_icons
; i
++) {
1943 if (dock
->icon_array
[i
]
1944 && dock
->icon_array
[i
]->icon
->core
->window
==event
->xclient
.window
) {
1950 if (*icon_pos
<0 && (dock
= scr
->workspaces
[scr
->current_workspace
]->clip
)!=NULL
) {
1951 for (i
=0; i
<dock
->max_icons
; i
++) {
1952 if (dock
->icon_array
[i
]
1953 && dock
->icon_array
[i
]->icon
->core
->window
==event
->xclient
.window
) {
1966 wDockReceiveDNDDrop(WScreen
*scr
, XEvent
*event
)
1972 dock
= findDock(scr
, event
, &icon_pos
);
1977 * Return True if the drop was on an application icon window.
1978 * In this case, let the ClientMessage handler redirect the
1979 * message to the app.
1981 if (dock
->icon_array
[icon_pos
]->icon
->icon_win
!=None
)
1984 if (dock
->icon_array
[icon_pos
]->dnd_command
!=NULL
) {
1985 scr
->flags
.dnd_data_convertion_status
= 0;
1987 btn
= dock
->icon_array
[icon_pos
];
1989 if (!btn
->forced_dock
) {
1990 btn
->relaunching
= btn
->running
;
1993 if (btn
->wm_instance
|| btn
->wm_class
) {
1994 WWindowAttributes attr
;
1995 memset(&attr
, 0, sizeof(WWindowAttributes
));
1996 wDefaultFillAttributes(btn
->icon
->core
->screen_ptr
,
1998 btn
->wm_class
, &attr
, NULL
, True
);
2000 if (!attr
.no_appicon
)
2006 btn
->drop_launch
= 1;
2007 scr
->last_dock
= dock
;
2008 btn
->pid
= execCommand(btn
, btn
->dnd_command
, NULL
);
2013 if (!btn
->relaunching
) {
2020 #endif /* OFFIX_DND */
2025 wDockAttachIcon(WDock
*dock
, WAppIcon
*icon
, int x
, int y
)
2032 wwin
= icon
->icon
->owner
;
2033 if (icon
->command
==NULL
) {
2035 if (XGetCommand(dpy
, wwin
->client_win
, &argv
, &argc
) && argc
>0) {
2037 icon
->command
= FlattenStringList(argv
, argc
);
2038 XFreeStringList(argv
);
2042 /* icon->forced_dock = 1;*/
2043 if (!icon
->attracted
|| dock
->type
!=WM_CLIP
|| dock
->keep_attracted
) {
2045 if (wInputDialog(dock
->screen_ptr
, _("Dock Icon"),
2046 _("Type the command used to launch the application"),
2048 if (command
&& (command
[0]==0 ||
2049 (command
[0]=='-' && command
[1]==0))) {
2053 icon
->command
= command
;
2059 /* If the target is the dock, reject the icon. If
2060 * the target is the clip, make it an attracted icon
2062 if (dock
->type
==WM_CLIP
) {
2063 icon
->attracted
= 1;
2064 if (!icon
->icon
->shadowed
) {
2065 icon
->icon
->shadowed
= 1;
2066 icon
->icon
->force_paint
= 1;
2078 for (index
=1; index
<dock
->max_icons
; index
++)
2079 if (dock
->icon_array
[index
] == NULL
)
2081 /* if (index == dock->max_icons)
2084 assert(index
< dock
->max_icons
);
2086 dock
->icon_array
[index
] = icon
;
2090 icon
->omnipresent
= 0;
2092 icon
->x_pos
= dock
->x_pos
+ x
*ICON_SIZE
;
2093 icon
->y_pos
= dock
->y_pos
+ y
*ICON_SIZE
;
2098 icon
->launching
= 0;
2101 icon
->icon
->core
->descriptor
.handle_mousedown
= iconMouseDown
;
2102 if (dock
->type
== WM_CLIP
) {
2103 icon
->icon
->core
->descriptor
.handle_enternotify
= clipEnterNotify
;
2104 icon
->icon
->core
->descriptor
.handle_leavenotify
= clipLeaveNotify
;
2106 icon
->icon
->core
->descriptor
.parent_type
= WCLASS_DOCK_ICON
;
2107 icon
->icon
->core
->descriptor
.parent
= icon
;
2109 MoveInStackListUnder(dock
->icon_array
[index
-1]->icon
->core
,
2111 wAppIconMove(icon
, icon
->x_pos
, icon
->y_pos
);
2112 wAppIconPaint(icon
);
2114 if (wPreferences
.auto_arrange_icons
)
2115 wArrangeIcons(dock
->screen_ptr
, True
);
2118 if (icon
->command
&& !icon
->dnd_command
) {
2119 icon
->dnd_command
= wmalloc(strlen(icon
->command
)+8);
2120 sprintf(icon
->dnd_command
, "%s %%d", icon
->command
);
2129 reattachIcon(WDock
*dock
, WAppIcon
*icon
, int x
, int y
)
2133 for(index
=1; index
<dock
->max_icons
; index
++) {
2134 if(dock
->icon_array
[index
] == icon
)
2137 assert(index
< dock
->max_icons
);
2142 icon
->x_pos
= dock
->x_pos
+ x
*ICON_SIZE
;
2143 icon
->y_pos
= dock
->y_pos
+ y
*ICON_SIZE
;
2148 moveIconBetweenDocks(WDock
*src
, WDock
*dest
, WAppIcon
*icon
, int x
, int y
)
2156 return True
; /* No move needed, we're already there */
2161 wwin
= icon
->icon
->owner
;
2164 * For the moment we can't do this if we move icons in Clip from one
2165 * workspace to other, because if we move two or more icons without
2166 * command, the dialog box will not be able to tell us to which of the
2167 * moved icons it applies. -Dan
2169 if ((dest
->type
==WM_DOCK
/*|| dest->keep_attracted*/) && icon
->command
==NULL
) {
2170 if (XGetCommand(dpy
, wwin
->client_win
, &argv
, &argc
) && argc
>0) {
2172 icon
->command
= FlattenStringList(argv
, argc
);
2173 XFreeStringList(argv
);
2178 /* icon->forced_dock = 1;*/
2179 if (wInputDialog(src
->screen_ptr
, _("Dock Icon"),
2180 _("Type the command used to launch the application"),
2182 if (command
&& (command
[0]==0 ||
2183 (command
[0]=='-' && command
[1]==0))) {
2187 icon
->command
= command
;
2198 if (dest
->type
== WM_DOCK
)
2199 wClipMakeIconOmnipresent(icon
, False
);
2201 for(index
=1; index
<src
->max_icons
; index
++) {
2202 if(src
->icon_array
[index
] == icon
)
2205 assert(index
< src
->max_icons
);
2207 src
->icon_array
[index
] = NULL
;
2210 for(index
=1; index
<dest
->max_icons
; index
++) {
2211 if(dest
->icon_array
[index
] == NULL
)
2214 /* if (index == dest->max_icons)
2217 assert(index
< dest
->max_icons
);
2219 dest
->icon_array
[index
] = icon
;
2222 /* deselect the icon */
2223 if (icon
->icon
->selected
)
2224 wIconSelect(icon
->icon
);
2226 if (dest
->type
== WM_DOCK
) {
2227 icon
->icon
->core
->descriptor
.handle_enternotify
= NULL
;
2228 icon
->icon
->core
->descriptor
.handle_leavenotify
= NULL
;
2230 icon
->icon
->core
->descriptor
.handle_enternotify
= clipEnterNotify
;
2231 icon
->icon
->core
->descriptor
.handle_leavenotify
= clipLeaveNotify
;
2234 /* set it to be kept when moving to dock, or to a clip that keep the
2236 * Unless the icon does not have a command set
2238 if (icon
->command
&& (dest
->type
==WM_DOCK
|| dest
->keep_attracted
)) {
2239 icon
->attracted
= 0;
2240 if (icon
->icon
->shadowed
) {
2241 icon
->icon
->shadowed
= 0;
2242 icon
->icon
->force_paint
= 1;
2246 if (src
->auto_collapse
|| src
->auto_raise_lower
)
2252 icon
->x_pos
= dest
->x_pos
+ x
*ICON_SIZE
;
2253 icon
->y_pos
= dest
->y_pos
+ y
*ICON_SIZE
;
2257 MoveInStackListUnder(dest
->icon_array
[index
-1]->icon
->core
,
2259 wAppIconPaint(icon
);
2266 wDockDetach(WDock
*dock
, WAppIcon
*icon
)
2270 /* make the settings panel be closed */
2272 DestroyDockAppSettingsPanel(icon
->panel
);
2277 icon
->attracted
= 0;
2278 if (icon
->icon
->shadowed
) {
2279 icon
->icon
->shadowed
= 0;
2280 icon
->icon
->force_paint
= 1;
2283 /* This must be called before dock->icon_array[index] is set to NULL.
2284 * Don't move it. -Dan
2286 wClipMakeIconOmnipresent(icon
, False
);
2288 /* deselect the icon */
2289 if (icon
->icon
->selected
)
2290 wIconSelect(icon
->icon
);
2292 if (icon
->command
) {
2293 free(icon
->command
);
2294 icon
->command
= NULL
;
2297 if (icon
->dnd_command
) {
2298 free(icon
->dnd_command
);
2299 icon
->dnd_command
= NULL
;
2303 for (index
=1; index
<dock
->max_icons
; index
++)
2304 if (dock
->icon_array
[index
] == icon
)
2306 assert(index
< dock
->max_icons
);
2307 dock
->icon_array
[index
] = NULL
;
2313 /* if the dock is not attached to an application or
2314 * the the application did not set the approriate hints yet,
2315 * destroy the icon */
2316 #ifdef REDUCE_APPICONS
2317 if ((icon
->num_apps
== 0) && (!icon
->running
|| !wApplicationOf(icon
->main_window
)) )
2319 if (!icon
->running
|| !wApplicationOf(icon
->main_window
))
2321 wAppIconDestroy(icon
);
2323 icon
->icon
->core
->descriptor
.handle_mousedown
= appIconMouseDown
;
2324 icon
->icon
->core
->descriptor
.handle_enternotify
= NULL
;
2325 icon
->icon
->core
->descriptor
.handle_leavenotify
= NULL
;
2326 icon
->icon
->core
->descriptor
.parent_type
= WCLASS_APPICON
;
2327 icon
->icon
->core
->descriptor
.parent
= icon
;
2329 ChangeStackingLevel(icon
->icon
->core
, NORMAL_ICON_LEVEL
);
2331 wAppIconPaint(icon
);
2332 if (wPreferences
.auto_arrange_icons
) {
2333 wArrangeIcons(dock
->screen_ptr
, True
);
2336 if (dock
->auto_collapse
|| dock
->auto_raise_lower
)
2342 * returns the closest Dock slot index for the passed
2345 * Returns False if icon can't be docked.
2347 * Note: this function should NEVER alter ret_x or ret_y, unless it will
2351 wDockSnapIcon(WDock
*dock
, WAppIcon
*icon
, int req_x
, int req_y
,
2352 int *ret_x
, int *ret_y
, int redocking
)
2354 WScreen
*scr
= dock
->screen_ptr
;
2357 int i
, offset
= ICON_SIZE
/2;
2358 WAppIcon
*aicon
= NULL
;
2359 WAppIcon
*nicon
= NULL
;
2360 int max_y_icons
, max_x_icons
;
2362 max_x_icons
= scr
->scr_width
/ICON_SIZE
;
2363 max_y_icons
= scr
->scr_height
/ICON_SIZE
-1;
2365 if (wPreferences
.flags
.noupdates
)
2371 /* if the dock is full */
2373 (dock
->icon_count
>= dock
->max_icons
)) {
2377 /* exact position */
2379 ex_y
= (req_y
- offset
- dy
)/ICON_SIZE
;
2381 ex_y
= (req_y
+ offset
- dy
)/ICON_SIZE
;
2384 ex_x
= (req_x
- offset
- dx
)/ICON_SIZE
;
2386 ex_x
= (req_x
+ offset
- dx
)/ICON_SIZE
;
2388 /* check if the icon is outside the screen boundaries */
2389 if (dx
+ ex_x
*ICON_SIZE
< -ICON_SIZE
+2 ||
2390 dx
+ ex_x
*ICON_SIZE
>= scr
->scr_width
-1 ||
2391 dy
+ ex_y
*ICON_SIZE
< -ICON_SIZE
+2 ||
2392 dy
+ ex_y
*ICON_SIZE
>= scr
->scr_height
-1)
2395 if (dock
->type
== WM_DOCK
) {
2396 if (icon
->dock
!= dock
&& ex_x
!= 0)
2400 for (i
=0; i
<dock
->max_icons
; i
++) {
2401 nicon
= dock
->icon_array
[i
];
2402 if (nicon
&& nicon
->yindex
== ex_y
) {
2409 int sig
, done
, closest
;
2411 /* Possible cases when redocking:
2413 * icon dragged out of range of any slot -> false
2414 * icon dragged to range of free slot
2415 * icon dragged to range of same slot
2416 * icon dragged to range of different icon
2418 if (abs(ex_x
) > DOCK_DETTACH_THRESHOLD
)
2421 if (ex_y
>=0 && ex_y
<=max_y_icons
&& (aicon
==icon
|| !aicon
)) {
2427 /* start looking at the upper slot or lower? */
2428 if (ex_y
*ICON_SIZE
< (req_y
+ offset
- dy
))
2435 /* look for closest free slot */
2436 for (i
=0; i
<(DOCK_DETTACH_THRESHOLD
+1)*2 && !done
; i
++) {
2440 closest
= sig
*(i
/2) + ex_y
;
2441 /* check if this slot is used */
2443 for (j
= 0; j
<dock
->max_icons
; j
++) {
2444 if (dock
->icon_array
[j
]
2445 && dock
->icon_array
[j
]->yindex
==closest
) {
2446 /* slot is used by someone else */
2447 if (dock
->icon_array
[j
]!=icon
)
2455 if (done
&& closest
>= 0 && closest
<= max_y_icons
&&
2456 ((ex_y
>= closest
&& ex_y
- closest
< DOCK_DETTACH_THRESHOLD
+1)
2458 (ex_y
< closest
&& closest
- ex_y
<= DOCK_DETTACH_THRESHOLD
+1))) {
2463 } else { /* !redocking */
2465 /* if slot is free and the icon is close enough, return it */
2466 if (!aicon
&& ex_x
== 0 && ex_y
>= 0 && ex_y
<= max_y_icons
) {
2476 start
= icon
->omnipresent
? 0 : scr
->current_workspace
;
2477 stop
= icon
->omnipresent
? scr
->workspace_count
: start
+1;
2480 for (k
=start
; k
<stop
; k
++) {
2481 WDock
*tmp
= scr
->workspaces
[k
]->clip
;
2484 for (i
=0; i
<tmp
->max_icons
; i
++) {
2485 nicon
= tmp
->icon_array
[i
];
2486 if (nicon
&& nicon
->xindex
== ex_x
&& nicon
->yindex
== ex_y
) {
2494 for (k
=start
; k
<stop
; k
++) {
2495 WDock
*tmp
= scr
->workspaces
[k
]->clip
;
2498 for (i
=0; i
<tmp
->max_icons
; i
++) {
2499 nicon
= tmp
->icon_array
[i
];
2500 if (nicon
&& nicon
!= icon
&& /* Icon can't be it's own neighbour */
2501 (abs(nicon
->xindex
- ex_x
) <= CLIP_ATTACH_VICINITY
&&
2502 abs(nicon
->yindex
- ex_y
) <= CLIP_ATTACH_VICINITY
)) {
2511 if (neighbours
&& (aicon
==NULL
|| (redocking
&& aicon
== icon
))) {
2520 #define MIN(x, y) ((x) > (y) ? (y) : (x))
2521 #define MAX(x, y) ((x) < (y) ? (y) : (x))
2523 #define ON_SCREEN(x, y, sx, ex, sy, ey) \
2524 ((((x)+ICON_SIZE/2) >= (sx)) && (((y)+ICON_SIZE/2) >= (sy)) && \
2525 (((x) + (ICON_SIZE/2)) <= (ex)) && (((y) + (ICON_SIZE/2)) <= ey))
2529 * returns true if it can find a free slot in the dock,
2530 * in which case it changes x_pos and y_pos accordingly.
2531 * Else returns false.
2534 wDockFindFreeSlot(WDock
*dock
, int *x_pos
, int *y_pos
)
2536 WScreen
*scr
= dock
->screen_ptr
;
2538 unsigned char *slot_map
;
2542 int i
, done
= False
;
2544 int sx
=0, sy
=0, ex
=scr
->scr_width
, ey
=scr
->scr_height
;
2547 /* if the dock is full */
2548 if (dock
->icon_count
>= dock
->max_icons
) {
2552 if (!wPreferences
.flags
.nodock
&& scr
->dock
) {
2553 if (scr
->dock
->on_right_side
)
2554 ex
-= ICON_SIZE
+ DOCK_EXTRA_SPACE
;
2556 sx
+= ICON_SIZE
+ DOCK_EXTRA_SPACE
;
2559 if (ex
< dock
->x_pos
)
2561 if (sx
> dock
->x_pos
+ICON_SIZE
)
2562 sx
= dock
->x_pos
+ICON_SIZE
;
2569 /* check if clip is in a corner */
2570 if (dock
->type
==WM_CLIP
) {
2571 if (dock
->x_pos
< 1 && dock
->y_pos
< 1)
2573 else if (dock
->x_pos
< 1 && dock
->y_pos
>= (ey
-ICON_SIZE
))
2575 else if (dock
->x_pos
>= (ex
-ICON_SIZE
)&& dock
->y_pos
>= (ey
-ICON_SIZE
))
2577 else if (dock
->x_pos
>= (ex
-ICON_SIZE
) && dock
->y_pos
< 1)
2584 /* If the clip is in the corner, use only slots that are in the border
2586 if (corner
!=C_NONE
) {
2590 hcount
= MIN(dock
->max_icons
, scr
->scr_width
/ICON_SIZE
);
2591 vcount
= MIN(dock
->max_icons
, scr
->scr_height
/ICON_SIZE
);
2592 hmap
= wmalloc(hcount
+1);
2593 memset(hmap
, 0, hcount
+1);
2594 vmap
= wmalloc(vcount
+1);
2595 memset(vmap
, 0, vcount
+1);
2597 /* mark used positions */
2600 for (i
=0; i
<dock
->max_icons
; i
++) {
2601 btn
= dock
->icon_array
[i
];
2605 if (btn
->xindex
==0 && btn
->yindex
> 0 && btn
->yindex
< vcount
)
2606 vmap
[btn
->yindex
] = 1;
2607 else if (btn
->yindex
==0 && btn
->xindex
>0 && btn
->xindex
<hcount
)
2608 hmap
[btn
->xindex
] = 1;
2611 for (i
=0; i
<dock
->max_icons
; i
++) {
2612 btn
= dock
->icon_array
[i
];
2616 if (btn
->xindex
==0 && btn
->yindex
> 0 && btn
->yindex
< vcount
)
2617 vmap
[btn
->yindex
] = 1;
2618 else if (btn
->yindex
==0 && btn
->xindex
<0 &&btn
->xindex
>-hcount
)
2619 hmap
[-btn
->xindex
] = 1;
2622 for (i
=0; i
<dock
->max_icons
; i
++) {
2623 btn
= dock
->icon_array
[i
];
2627 if (btn
->xindex
==0 && btn
->yindex
< 0 && btn
->yindex
> -vcount
)
2628 vmap
[-btn
->yindex
] = 1;
2629 else if (btn
->yindex
==0 && btn
->xindex
>0 && btn
->xindex
<hcount
)
2630 hmap
[btn
->xindex
] = 1;
2634 for (i
=0; i
<dock
->max_icons
; i
++) {
2635 btn
= dock
->icon_array
[i
];
2639 if (btn
->xindex
==0 && btn
->yindex
< 0 && btn
->yindex
> -vcount
)
2640 vmap
[-btn
->yindex
] = 1;
2641 else if (btn
->yindex
==0 && btn
->xindex
<0 &&btn
->xindex
>-hcount
)
2642 hmap
[-btn
->xindex
] = 1;
2647 /* search a vacant slot */
2648 for (i
=1; i
<MAX(vcount
, hcount
); i
++) {
2649 if (i
< vcount
&& vmap
[i
]==0) {
2655 } else if (i
< hcount
&& hmap
[i
]==0) {
2665 /* If found a slot, translate and return */
2667 if (corner
==C_NW
|| corner
==C_NE
) {
2672 if (corner
==C_NE
|| corner
==C_SE
) {
2679 /* else, try to find a slot somewhere else */
2682 /* a map of mwidth x mwidth would be enough if we allowed icons to be
2683 * placed outside of screen */
2684 mwidth
= (int)ceil(sqrt(dock
->max_icons
));
2686 /* In the worst case (the clip is in the corner of the screen),
2687 * the amount of icons that fit in the clip is smaller.
2688 * Double the map to get a safe value.
2694 slot_map
= wmalloc(mwidth
*mwidth
);
2695 memset(slot_map
, 0, mwidth
*mwidth
);
2697 #define XY2OFS(x,y) (MAX(abs(x),abs(y)) > r) ? 0 : (((y)+r)*(mwidth)+(x)+r)
2699 /* mark used slots in the map. If the slot falls outside the map
2700 * (for example, when all icons are placed in line), ignore them. */
2701 for (i
=0; i
<dock
->max_icons
; i
++) {
2702 btn
= dock
->icon_array
[i
];
2704 slot_map
[XY2OFS(btn
->xindex
, btn
->yindex
)] = 1;
2706 /* Find closest slot from the center that is free by scanning the
2707 * map from the center to outward in circular passes.
2708 * This will not result in a neat layout, but will be optimal
2709 * in the sense that there will not be holes left.
2712 for (i
= 1; i
<= r
&& !done
; i
++) {
2715 /* top and bottom parts of the ring */
2716 for (x
= -i
; x
<= i
&& !done
; x
++) {
2717 tx
= dock
->x_pos
+ x
*ICON_SIZE
;
2719 ty
= dock
->y_pos
+ y
*ICON_SIZE
;
2720 if (slot_map
[XY2OFS(x
,y
)]==0
2721 && ON_SCREEN(tx
, ty
, sx
, ex
, sy
, ey
)) {
2728 ty
= dock
->y_pos
+ y
*ICON_SIZE
;
2729 if (slot_map
[XY2OFS(x
,y
)]==0
2730 && ON_SCREEN(tx
, ty
, sx
, ex
, sy
, ey
)) {
2737 /* left and right parts of the ring */
2738 for (y
= -i
+1; y
<= i
-1; y
++) {
2739 ty
= dock
->y_pos
+ y
*ICON_SIZE
;
2741 tx
= dock
->x_pos
+ x
*ICON_SIZE
;
2742 if (slot_map
[XY2OFS(x
,y
)]==0
2743 && ON_SCREEN(tx
, ty
, sx
, ex
, sy
, ey
)) {
2750 tx
= dock
->x_pos
+ x
*ICON_SIZE
;
2751 if (slot_map
[XY2OFS(x
,y
)]==0
2752 && ON_SCREEN(tx
, ty
, sx
, ex
, sy
, ey
)) {
2767 moveDock(WDock
*dock
, int new_x
, int new_y
)
2772 dock
->x_pos
= new_x
;
2773 dock
->y_pos
= new_y
;
2774 for (i
=0; i
<dock
->max_icons
; i
++) {
2775 btn
= dock
->icon_array
[i
];
2777 btn
->x_pos
= new_x
+ btn
->xindex
*ICON_SIZE
;
2778 btn
->y_pos
= new_y
+ btn
->yindex
*ICON_SIZE
;
2779 XMoveWindow(dpy
, btn
->icon
->core
->window
, btn
->x_pos
, btn
->y_pos
);
2786 swapDock(WDock
*dock
)
2788 WScreen
*scr
= dock
->screen_ptr
;
2793 if (dock
->on_right_side
) {
2794 x
= dock
->x_pos
= scr
->scr_width
- ICON_SIZE
- DOCK_EXTRA_SPACE
;
2796 x
= dock
->x_pos
= DOCK_EXTRA_SPACE
;
2799 for (i
=0; i
<dock
->max_icons
; i
++) {
2800 btn
= dock
->icon_array
[i
];
2803 XMoveWindow(dpy
, btn
->icon
->core
->window
, btn
->x_pos
, btn
->y_pos
);
2807 wScreenUpdateUsableArea(scr
);
2812 execCommand(WAppIcon
*btn
, char *command
, WSavedState
*state
)
2814 WScreen
*scr
= btn
->icon
->core
->screen_ptr
;
2820 cmdline
= ExpandOptions(scr
, command
);
2822 if (scr
->flags
.dnd_data_convertion_status
|| !cmdline
) {
2830 ParseCommand(cmdline
, &argv
, &argc
);
2840 if ((pid
=fork())==0) {
2844 SetupEnvironment(scr
);
2850 args
= malloc(sizeof(char*)*(argc
+1));
2853 for (i
=0; i
<argc
; i
++) {
2857 execvp(argv
[0], args
);
2866 state
= wmalloc(sizeof(WSavedState
));
2867 memset(state
, 0, sizeof(WSavedState
));
2869 state
->miniaturized
= -1;
2871 if (btn
->dock
== scr
->dock
)
2872 state
->workspace
= -1;
2874 state
->workspace
= scr
->current_workspace
;
2876 wWindowAddSavedState(btn
->wm_instance
, btn
->wm_class
, cmdline
, pid
,
2878 wAddDeathHandler(pid
, (WDeathHandler
*)trackDeadProcess
,
2889 wDockHideIcons(WDock
*dock
)
2896 for (i
=1; i
<dock
->max_icons
; i
++) {
2897 if (dock
->icon_array
[i
])
2898 XUnmapWindow(dpy
, dock
->icon_array
[i
]->icon
->core
->window
);
2902 dockIconPaint(dock
->icon_array
[0]);
2907 wDockShowIcons(WDock
*dock
)
2915 btn
= dock
->icon_array
[0];
2916 moveDock(dock
, btn
->x_pos
, btn
->y_pos
);
2918 newlevel
= dock
->lowered
? WMNormalLevel
: WMDockLevel
;
2919 ChangeStackingLevel(btn
->icon
->core
, newlevel
);
2921 for (i
=1; i
<dock
->max_icons
; i
++) {
2922 if (dock
->icon_array
[i
]) {
2923 MoveInStackListAbove(dock
->icon_array
[i
]->icon
->core
,
2929 if (!dock
->collapsed
) {
2930 for (i
=1; i
<dock
->max_icons
; i
++) {
2931 if (dock
->icon_array
[i
]) {
2932 XMapWindow(dpy
, dock
->icon_array
[i
]->icon
->core
->window
);
2943 wDockLower(WDock
*dock
)
2947 for (i
=0; i
<dock
->max_icons
; i
++) {
2948 if (dock
->icon_array
[i
])
2949 wLowerFrame(dock
->icon_array
[i
]->icon
->core
);
2955 wDockRaise(WDock
*dock
)
2959 for (i
=dock
->max_icons
-1; i
>=0; i
--) {
2960 if (dock
->icon_array
[i
])
2961 wRaiseFrame(dock
->icon_array
[i
]->icon
->core
);
2967 wDockRaiseLower(WDock
*dock
)
2969 if (!dock
->icon_array
[0]->icon
->core
->stacking
->above
2970 ||(dock
->icon_array
[0]->icon
->core
->stacking
->window_level
2971 !=dock
->icon_array
[0]->icon
->core
->stacking
->above
->stacking
->window_level
))
2979 wDockFinishLaunch(WDock
*dock
, WAppIcon
*icon
)
2981 icon
->launching
= 0;
2982 icon
->relaunching
= 0;
2983 dockIconPaint(icon
);
2988 wDockFindIconFor(WDock
*dock
, Window window
)
2993 for (i
=0; i
<dock
->max_icons
; i
++) {
2994 icon
= dock
->icon_array
[i
];
2995 if (icon
&& icon
->main_window
== window
)
3003 wDockTrackWindowLaunch(WDock
*dock
, Window window
)
3006 #ifdef REDUCE_APPICONS
3007 WAppIconAppList
*tapplist
;
3009 char *wm_class
, *wm_instance
;
3011 Bool firstPass
= True
;
3013 char *command
= NULL
;
3019 if (XGetCommand(dpy
, window
, &argv
, &argc
)) {
3020 if (argc
> 0 && argv
!= NULL
)
3021 command
= FlattenStringList(argv
,argc
);
3023 XFreeStringList(argv
);
3028 if (!PropGetWMClass(window
, &wm_class
, &wm_instance
) ||
3029 (!wm_class
&& !wm_instance
))
3033 for (i
=0; i
<dock
->max_icons
; i
++) {
3034 icon
= dock
->icon_array
[i
];
3038 /* app is already attached to icon */
3039 if (icon
->main_window
== window
) {
3044 if ((icon
->wm_instance
|| icon
->wm_class
)
3046 || (dock
->screen_ptr
->flags
.startup
&& !icon
->running
))) {
3048 if (icon
->wm_instance
&& wm_instance
&&
3049 strcmp(icon
->wm_instance
, wm_instance
)!=0) {
3052 if (icon
->wm_class
&& wm_class
&&
3053 strcmp(icon
->wm_class
, wm_class
)!=0) {
3056 if (firstPass
&& command
&& strcmp(icon
->command
, command
)!=0) {
3060 if (!icon
->relaunching
) {
3063 /* Possibly an application that was docked with dockit,
3064 * but the user did not update WMState to indicate that
3065 * it was docked by force */
3066 wapp
= wApplicationOf(window
);
3068 icon
->forced_dock
= 1;
3071 if (!icon
->forced_dock
)
3072 icon
->main_window
= window
;
3074 #ifdef REDUCE_APPICONS
3075 tapplist
= wmalloc(sizeof(WAppIconAppList
));
3076 memset(tapplist
, 0, sizeof(WAppIconAppList
));
3077 tapplist
->next
= icon
->applist
;
3079 icon
->applist
->prev
= tapplist
;
3080 icon
->applist
= tapplist
;
3081 tapplist
->wapp
= wApplicationOf(window
);
3086 wDockFinishLaunch(dock
, icon
);
3091 if (firstPass
&& !found
) {
3108 wClipUpdateForWorkspaceChange(WScreen
*scr
, int workspace
)
3110 if (!wPreferences
.flags
.noclip
) {
3111 scr
->clip_icon
->dock
= scr
->workspaces
[workspace
]->clip
;
3112 if (scr
->current_workspace
!= workspace
) {
3113 WDock
*old_clip
= scr
->workspaces
[scr
->current_workspace
]->clip
;
3114 WAppIconChain
*chain
= scr
->global_icons
;
3117 moveIconBetweenDocks(chain
->aicon
->dock
,
3118 scr
->workspaces
[workspace
]->clip
,
3119 chain
->aicon
, chain
->aicon
->xindex
,
3120 chain
->aicon
->yindex
);
3121 if (scr
->workspaces
[workspace
]->clip
->collapsed
)
3122 XUnmapWindow(dpy
, chain
->aicon
->icon
->core
->window
);
3123 chain
= chain
->next
;
3126 wDockHideIcons(old_clip
);
3127 if (old_clip
->auto_raise_lower
) {
3128 if (old_clip
->auto_raise_magic
) {
3129 WMDeleteTimerHandler(old_clip
->auto_raise_magic
);
3130 old_clip
->auto_raise_magic
= NULL
;
3132 wDockLower(old_clip
);
3134 if (old_clip
->auto_collapse
) {
3135 if (old_clip
->auto_expand_magic
) {
3136 WMDeleteTimerHandler(old_clip
->auto_expand_magic
);
3137 old_clip
->auto_expand_magic
= NULL
;
3139 old_clip
->collapsed
= 1;
3141 wDockShowIcons(scr
->workspaces
[workspace
]->clip
);
3143 if (scr
->flags
.clip_balloon_mapped
)
3144 showClipBalloon(scr
->clip_icon
->dock
, workspace
);
3151 trackDeadProcess(pid_t pid
, unsigned char status
, WDock
*dock
)
3156 for (i
=0; i
<dock
->max_icons
; i
++) {
3157 icon
= dock
->icon_array
[i
];
3161 if (icon
->launching
&& icon
->pid
== pid
) {
3162 if (!icon
->relaunching
) {
3164 icon
->main_window
= None
;
3166 wDockFinishLaunch(dock
, icon
);
3171 sprintf(msg
, _("Could not execute command \"%s\""),
3172 icon
->drop_launch
&& icon
->dnd_command
3173 ? icon
->dnd_command
: icon
->command
);
3175 sprintf(msg
, _("Could not execute command \"%s\""),
3178 wMessageDialog(dock
->screen_ptr
, _("Error"), msg
,
3179 _("OK"), NULL
, NULL
);
3188 toggleLowered(WDock
*dock
)
3193 /* lower/raise Dock */
3194 if (!dock
->lowered
) {
3195 newlevel
= WMNormalLevel
;
3198 newlevel
= WMDockLevel
;
3202 for (i
=0; i
<dock
->max_icons
; i
++) {
3203 tmp
= dock
->icon_array
[i
];
3207 ChangeStackingLevel(tmp
->icon
->core
, newlevel
);
3209 wLowerFrame(tmp
->icon
->core
);
3212 if (dock
->type
== WM_DOCK
)
3213 wScreenUpdateUsableArea(dock
->screen_ptr
);
3218 toggleCollapsed(WDock
*dock
)
3220 if (dock
->collapsed
) {
3221 dock
->collapsed
= 0;
3222 wDockShowIcons(dock
);
3225 dock
->collapsed
= 1;
3226 wDockHideIcons(dock
);
3232 openDockMenu(WDock
*dock
, WAppIcon
*aicon
, XEvent
*event
)
3234 WScreen
*scr
= dock
->screen_ptr
;
3235 WObjDescriptor
*desc
;
3237 WApplication
*wapp
= NULL
;
3240 int appIsRunning
= aicon
->running
&& aicon
->icon
&& aicon
->icon
->owner
;
3242 if (dock
->type
== WM_DOCK
) {
3244 entry
= dock
->menu
->entries
[index
];
3245 entry
->flags
.indicator_on
= !dock
->lowered
;
3246 entry
->clientdata
= dock
;
3249 if (scr
->clip_options
)
3250 updateClipOptionsMenu(scr
->clip_options
, dock
);
3252 /* Rename Workspace */
3253 entry
= dock
->menu
->entries
[++index
];
3254 entry
->clientdata
= dock
;
3257 entry
= dock
->menu
->entries
[++index
];
3258 entry
->clientdata
= aicon
;
3259 wMenuSetEnabled(dock
->menu
, index
, aicon
!=scr
->clip_icon
);
3261 /* (un)select all icons */
3262 entry
= dock
->menu
->entries
[++index
];
3263 entry
->clientdata
= aicon
;
3264 wMenuSetEnabled(dock
->menu
, index
, dock
->icon_count
> 1);
3267 entry
= dock
->menu
->entries
[++index
];
3268 entry
->clientdata
= aicon
;
3269 wMenuSetEnabled(dock
->menu
, index
, dock
->icon_count
> 1);
3271 /* this is the workspace submenu part */
3272 if (scr
->clip_submenu
)
3273 updateWorkspaceMenu(scr
->clip_submenu
, aicon
);
3274 wMenuSetEnabled(dock
->menu
, ++index
, !aicon
->omnipresent
);
3276 /* remove icon(s) */
3277 entry
= dock
->menu
->entries
[++index
];
3278 entry
->clientdata
= aicon
;
3279 wMenuSetEnabled(dock
->menu
, index
, dock
->icon_count
> 1);
3281 /* attract icon(s) */
3282 entry
= dock
->menu
->entries
[++index
];
3283 entry
->clientdata
= aicon
;
3287 entry
= dock
->menu
->entries
[++index
];
3288 entry
->clientdata
= aicon
;
3289 wMenuSetEnabled(dock
->menu
, index
, aicon
->command
!=NULL
);
3292 entry
= dock
->menu
->entries
[++index
];
3293 entry
->clientdata
= aicon
;
3294 wMenuSetEnabled(dock
->menu
, index
, appIsRunning
);
3297 entry
= dock
->menu
->entries
[++index
];
3298 entry
->clientdata
= aicon
;
3299 if (aicon
->icon
->owner
) {
3300 wapp
= wApplicationOf(aicon
->icon
->owner
->main_window
);
3301 if (wapp
&& wapp
->flags
.hidden
)
3302 entry
->text
= _("Unhide");
3304 entry
->text
= _("Hide");
3306 entry
->text
= _("Hide");
3308 wMenuSetEnabled(dock
->menu
, index
, appIsRunning
);
3311 entry
= dock
->menu
->entries
[++index
];
3312 entry
->clientdata
= aicon
;
3313 wMenuSetEnabled(dock
->menu
, index
, !aicon
->editing
3314 && !wPreferences
.flags
.noupdates
);
3317 entry
= dock
->menu
->entries
[++index
];
3318 entry
->clientdata
= aicon
;
3319 wMenuSetEnabled(dock
->menu
, index
, appIsRunning
);
3321 if (!dock
->menu
->flags
.realized
)
3322 wMenuRealize(dock
->menu
);
3324 if (dock
->type
== WM_CLIP
) {
3325 x_pos
= event
->xbutton
.x_root
+2;
3327 x_pos
= dock
->on_right_side
?
3328 scr
->scr_width
- dock
->menu
->frame
->core
->width
- 2 : 0;
3331 wMenuMapAt(dock
->menu
, x_pos
, event
->xbutton
.y_root
+2, False
);
3333 /* allow drag select */
3334 event
->xany
.send_event
= True
;
3335 desc
= &dock
->menu
->menu
->descriptor
;
3336 (*desc
->handle_mousedown
)(desc
, event
);
3341 openClipWorkspaceMenu(WScreen
*scr
, int x
, int y
)
3343 if (!scr
->clip_ws_menu
) {
3344 scr
->clip_ws_menu
= wWorkspaceMenuMake(scr
, False
);
3346 wWorkspaceMenuUpdate(scr
, scr
->clip_ws_menu
);
3347 wMenuMapAt(scr
->clip_ws_menu
, x
, y
, False
);
3351 /******************************************************************/
3353 iconDblClick(WObjDescriptor
*desc
, XEvent
*event
)
3355 WAppIcon
*btn
= desc
->parent
;
3356 WDock
*dock
= btn
->dock
;
3357 WApplication
*wapp
= NULL
;
3360 #ifdef REDUCE_APPICONS
3361 if ((btn
->icon
->owner
&& !(event
->xbutton
.state
& ControlMask
)) ||
3362 ((btn
->icon
->owner
== NULL
) && (btn
->applist
!= NULL
))) {
3363 if (btn
->icon
->owner
== NULL
)
3364 btn
->icon
->owner
= btn
->applist
->wapp
->main_window_desc
;
3367 if (btn
->icon
->owner
&& !(event
->xbutton
.state
& ControlMask
)) {
3369 wapp
= wApplicationOf(btn
->icon
->owner
->main_window
);
3373 unhideHere
= (event
->xbutton
.state
& ShiftMask
);
3375 /* go to the last workspace that the user worked on the app */
3376 if (wapp
->last_workspace
!= dock
->screen_ptr
->current_workspace
3378 wWorkspaceChange(dock
->screen_ptr
, wapp
->last_workspace
);
3381 wUnhideApplication(wapp
, event
->xbutton
.button
==Button2
,
3384 if (event
->xbutton
.state
& MOD_MASK
) {
3385 wHideOtherApplications(btn
->icon
->owner
);
3388 if (event
->xbutton
.button
==Button1
) {
3390 if (event
->xbutton
.state
& MOD_MASK
) {
3391 /* raise/lower dock */
3392 toggleLowered(dock
);
3393 } else if (btn
== dock
->screen_ptr
->clip_icon
) {
3394 if (getClipButton(event
->xbutton
.x
, event
->xbutton
.y
)==CLIP_IDLE
)
3395 toggleCollapsed(dock
);
3397 handleClipChangeWorkspace(dock
->screen_ptr
, event
);
3398 } else if (btn
->command
) {
3399 if (!btn
->launching
&&
3400 (!btn
->running
|| (event
->xbutton
.state
& ControlMask
))) {
3401 launchDockedApplication(btn
);
3403 } else if (btn
->xindex
== 0 && btn
->yindex
== 0
3404 && btn
->dock
->type
== WM_DOCK
) {
3406 wShowGNUstepPanel(dock
->screen_ptr
);
3414 handleDockMove(WDock
*dock
, WAppIcon
*aicon
, XEvent
*event
)
3416 WScreen
*scr
= dock
->screen_ptr
;
3417 int ofs_x
=event
->xbutton
.x
, ofs_y
=event
->xbutton
.y
;
3420 int grabbed
= 0, swapped
= 0, done
;
3421 Pixmap ghost
= None
;
3422 int superfluous
= wPreferences
.superfluous
; /* we catch it to avoid problems */
3425 puts("moving dock");
3427 if (XGrabPointer(dpy
, aicon
->icon
->core
->window
, True
, ButtonMotionMask
3428 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
3429 GrabModeAsync
, None
, None
, CurrentTime
) !=GrabSuccess
) {
3430 wwarning("pointer grab failed for dock move");
3433 for (x
=0; x
<dock
->max_icons
; x
++) {
3434 if (dock
->icon_array
[x
]!=NULL
&&
3435 dock
->icon_array
[x
]->yindex
> y
)
3436 y
= dock
->icon_array
[x
]->yindex
;
3439 XResizeWindow(dpy
, scr
->dock_shadow
, ICON_SIZE
, ICON_SIZE
*y
);
3443 WMMaskEvent(dpy
, PointerMotionMask
|ButtonReleaseMask
|ButtonPressMask
3444 |ButtonMotionMask
|ExposureMask
, &ev
);
3452 if (abs(ofs_x
-ev
.xmotion
.x
)>=MOVE_THRESHOLD
3453 || abs(ofs_y
-ev
.xmotion
.y
)>=MOVE_THRESHOLD
) {
3454 XChangeActivePointerGrab(dpy
, ButtonMotionMask
3455 |ButtonReleaseMask
|ButtonPressMask
,
3456 wCursor
[WCUR_MOVE
], CurrentTime
);
3461 if (dock
->type
== WM_CLIP
) {
3462 if (ev
.xmotion
.x_root
- ofs_x
< 0) {
3464 } else if (ev
.xmotion
.x_root
- ofs_x
+ ICON_SIZE
>
3466 x
= scr
->scr_width
- ICON_SIZE
;
3468 x
= ev
.xmotion
.x_root
- ofs_x
;
3470 if (ev
.xmotion
.y_root
- ofs_y
< 0) {
3472 } else if (ev
.xmotion
.y_root
- ofs_y
+ ICON_SIZE
>
3474 y
= scr
->scr_height
- ICON_SIZE
;
3476 y
= ev
.xmotion
.y_root
- ofs_y
;
3478 moveDock(dock
, x
, y
);
3480 /* move vertically if pointer is inside the dock*/
3481 if ((dock
->on_right_side
&&
3482 ev
.xmotion
.x_root
>= dock
->x_pos
- ICON_SIZE
)
3483 || (!dock
->on_right_side
&&
3484 ev
.xmotion
.x_root
<= dock
->x_pos
+ ICON_SIZE
*2)) {
3486 if (ev
.xmotion
.y_root
- ofs_y
< 0) {
3488 } else if (ev
.xmotion
.y_root
- ofs_y
+ ICON_SIZE
>
3490 y
= scr
->scr_height
- ICON_SIZE
;
3492 y
= ev
.xmotion
.y_root
- ofs_y
;
3494 moveDock(dock
, dock
->x_pos
, y
);
3496 /* move horizontally to change sides */
3497 x
= ev
.xmotion
.x_root
- ofs_x
;
3498 if (!dock
->on_right_side
) {
3502 if (ev
.xmotion
.x_root
> dock
->x_pos
+ ICON_SIZE
*2) {
3503 XMoveWindow(dpy
, scr
->dock_shadow
, scr
->scr_width
-ICON_SIZE
3504 -DOCK_EXTRA_SPACE
-1, dock
->y_pos
);
3505 if (superfluous
&& ghost
==None
) {
3506 ghost
= MakeGhostDock(dock
, dock
->x_pos
,
3507 scr
->scr_width
-ICON_SIZE
3508 -DOCK_EXTRA_SPACE
-1,
3510 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
3512 XClearWindow(dpy
, scr
->dock_shadow
);
3514 XMapRaised(dpy
, scr
->dock_shadow
);
3517 if (superfluous
&& ghost
!=None
) {
3518 XFreePixmap(dpy
, ghost
);
3521 XUnmapWindow(dpy
, scr
->dock_shadow
);
3526 if (ev
.xmotion
.x_root
< dock
->x_pos
- ICON_SIZE
) {
3527 XMoveWindow(dpy
, scr
->dock_shadow
,
3528 DOCK_EXTRA_SPACE
, dock
->y_pos
);
3529 if (superfluous
&& ghost
==None
) {
3530 ghost
= MakeGhostDock(dock
, dock
->x_pos
,
3531 DOCK_EXTRA_SPACE
, dock
->y_pos
);
3532 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
,
3534 XClearWindow(dpy
, scr
->dock_shadow
);
3536 XMapRaised(dpy
, scr
->dock_shadow
);
3539 XUnmapWindow(dpy
, scr
->dock_shadow
);
3541 if (superfluous
&& ghost
!=None
) {
3542 XFreePixmap(dpy
, ghost
);
3554 if (ev
.xbutton
.button
!= event
->xbutton
.button
)
3556 XUngrabPointer(dpy
, CurrentTime
);
3557 XUnmapWindow(dpy
, scr
->dock_shadow
);
3558 XResizeWindow(dpy
, scr
->dock_shadow
, ICON_SIZE
, ICON_SIZE
);
3559 if (dock
->type
== WM_DOCK
) {
3562 dock
->on_right_side
= 1;
3564 dock
->on_right_side
= 0;
3566 wArrangeIcons(scr
, False
);
3575 XFreePixmap(dpy
, ghost
);
3576 XSetWindowBackground(dpy
, scr
->dock_shadow
, scr
->white_pixel
);
3579 puts("End dock move");
3586 handleIconMove(WDock
*dock
, WAppIcon
*aicon
, XEvent
*event
)
3588 WScreen
*scr
= dock
->screen_ptr
;
3590 WIcon
*icon
= aicon
->icon
;
3591 WDock
*dock2
= NULL
, *last_dock
= dock
, *clip
= NULL
;
3592 int ondock
, grabbed
= 0, change_dock
= 0, collapsed
= 0;
3594 int x
= aicon
->x_pos
, y
= aicon
->y_pos
;
3595 int ofs_x
= event
->xbutton
.x
, ofs_y
= event
->xbutton
.y
;
3596 int shad_x
= x
, shad_y
= y
;
3597 int ix
= aicon
->xindex
, iy
= aicon
->yindex
;
3599 Pixmap ghost
= None
;
3601 int superfluous
= wPreferences
.superfluous
; /* we catch it to avoid problems */
3602 int omnipresent
= aicon
->omnipresent
; /* this must be cached!!! */
3605 if (wPreferences
.flags
.noupdates
)
3608 if (XGrabPointer(dpy
, icon
->core
->window
, True
, ButtonMotionMask
3609 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
3610 GrabModeAsync
, None
, None
, CurrentTime
) !=GrabSuccess
) {
3612 wwarning("pointer grab failed for icon move");
3616 if (!(event
->xbutton
.state
& MOD_MASK
))
3617 wRaiseFrame(icon
->core
);
3619 if (!wPreferences
.flags
.noclip
)
3620 clip
= scr
->workspaces
[scr
->current_workspace
]->clip
;
3622 if (dock
== scr
->dock
&& !wPreferences
.flags
.noclip
)
3624 else if (dock
!= scr
->dock
&& !wPreferences
.flags
.nodock
)
3627 wins
[0] = icon
->core
->window
;
3628 wins
[1] = scr
->dock_shadow
;
3629 XRestackWindows(dpy
, wins
, 2);
3630 XMoveResizeWindow(dpy
, scr
->dock_shadow
, aicon
->x_pos
, aicon
->y_pos
,
3631 ICON_SIZE
, ICON_SIZE
);
3633 if (icon
->pixmap
!=None
)
3634 ghost
= MakeGhostIcon(scr
, icon
->pixmap
);
3636 ghost
= MakeGhostIcon(scr
, icon
->core
->window
);
3638 XSetWindowBackgroundPixmap(dpy
, scr
->dock_shadow
, ghost
);
3639 XClearWindow(dpy
, scr
->dock_shadow
);
3641 XMapWindow(dpy
, scr
->dock_shadow
);
3647 XMaskEvent(dpy
, PointerMotionMask
|ButtonReleaseMask
|ButtonPressMask
3648 |ButtonMotionMask
|ExposureMask
, &ev
);
3656 if (abs(ofs_x
-ev
.xmotion
.x
)>=MOVE_THRESHOLD
3657 || abs(ofs_y
-ev
.xmotion
.y
)>=MOVE_THRESHOLD
) {
3658 XChangeActivePointerGrab(dpy
, ButtonMotionMask
3659 |ButtonReleaseMask
|ButtonPressMask
,
3660 wCursor
[WCUR_MOVE
], CurrentTime
);
3669 for (i
=0; i
<scr
->workspace_count
; i
++) {
3670 if (i
== scr
->current_workspace
)
3672 wDockShowIcons(scr
->workspaces
[i
]->clip
);
3676 x
= ev
.xmotion
.x_root
- ofs_x
;
3677 y
= ev
.xmotion
.y_root
- ofs_y
;
3678 tmp
= wDockSnapIcon(dock
, aicon
, x
, y
, &ix
, &iy
, True
);
3681 if (last_dock
!= dock
&& collapsed
) {
3682 last_dock
->collapsed
= 1;
3683 wDockHideIcons(last_dock
);
3686 if (!collapsed
&& (collapsed
= dock
->collapsed
)) {
3687 dock
->collapsed
= 0;
3688 wDockShowIcons(dock
);
3690 if (dock
->auto_raise_lower
)
3694 tmp
= wDockSnapIcon(dock2
, aicon
, x
, y
, &ix
, &iy
, False
);
3697 if (last_dock
!= dock2
&& collapsed
) {
3698 last_dock
->collapsed
= 1;
3699 wDockHideIcons(last_dock
);
3702 if (!collapsed
&& (collapsed
= dock2
->collapsed
)) {
3703 dock2
->collapsed
= 0;
3704 wDockShowIcons(dock2
);
3706 if (dock2
->auto_raise_lower
)
3711 if (aicon
->launching
3712 || (aicon
->running
&& !(ev
.xmotion
.state
& MOD_MASK
))
3713 || (!aicon
->running
&& tmp
)) {
3714 shad_x
= last_dock
->x_pos
+ ix
*wPreferences
.icon_size
;
3715 shad_y
= last_dock
->y_pos
+ iy
*wPreferences
.icon_size
;
3717 XMoveWindow(dpy
, scr
->dock_shadow
, shad_x
, shad_y
);
3720 XMapWindow(dpy
, scr
->dock_shadow
);
3725 XUnmapWindow(dpy
, scr
->dock_shadow
);
3729 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
3736 if (ev
.xbutton
.button
!= event
->xbutton
.button
)
3738 XUngrabPointer(dpy
, CurrentTime
);
3740 SlideWindow(icon
->core
->window
, x
, y
, shad_x
, shad_y
);
3741 XUnmapWindow(dpy
, scr
->dock_shadow
);
3743 reattachIcon(dock
, aicon
, ix
, iy
);
3744 if (clip
&& dock
!=clip
&& clip
->auto_raise_lower
)
3747 docked
= moveIconBetweenDocks(dock
, dock2
, aicon
, ix
, iy
);
3749 /* Slide it back if dock rejected it */
3750 SlideWindow(icon
->core
->window
, x
, y
, aicon
->x_pos
,
3752 reattachIcon(dock
, aicon
, aicon
->xindex
,aicon
->yindex
);
3754 if (last_dock
->type
==WM_CLIP
&& last_dock
->auto_collapse
) {
3762 if (!aicon
->running
&& !wPreferences
.no_animations
) {
3763 /* We need to deselect it, even if is deselected in
3764 * wDockDetach(), because else DoKaboom() will fail.
3766 if (aicon
->icon
->selected
)
3767 wIconSelect(aicon
->icon
);
3768 DoKaboom(scr
,aicon
->icon
->core
->window
, x
, y
);
3771 if (clip
&& clip
->auto_raise_lower
)
3773 wDockDetach(dock
, aicon
);
3776 last_dock
->collapsed
= 1;
3777 wDockHideIcons(last_dock
);
3782 XFreePixmap(dpy
, ghost
);
3783 XSetWindowBackground(dpy
, scr
->dock_shadow
, scr
->white_pixel
);
3787 for (i
=0; i
<scr
->workspace_count
; i
++) {
3788 if (i
== scr
->current_workspace
)
3790 wDockHideIcons(scr
->workspaces
[i
]->clip
);
3795 puts("End icon move");
3804 getClipButton(int px
, int py
)
3806 int pt
= (CLIP_BUTTON_SIZE
+2)*ICON_SIZE
/64;
3808 if (px
< 0 || py
< 0 || px
>= ICON_SIZE
|| py
>= ICON_SIZE
)
3811 if (py
<= pt
-((int)ICON_SIZE
-1-px
))
3812 return CLIP_FORWARD
;
3813 else if (px
<= pt
-((int)ICON_SIZE
-1-py
))
3821 handleClipChangeWorkspace(WScreen
*scr
, XEvent
*event
)
3824 int done
, direction
, new_ws
;
3826 WDock
*clip
= scr
->clip_icon
->dock
;
3828 direction
= getClipButton(event
->xbutton
.x
, event
->xbutton
.y
);
3830 clip
->lclip_button_pushed
= direction
==CLIP_REWIND
;
3831 clip
->rclip_button_pushed
= direction
==CLIP_FORWARD
;
3833 wClipIconPaint(scr
->clip_icon
);
3836 WMMaskEvent(dpy
, ExposureMask
|ButtonMotionMask
|ButtonReleaseMask
3837 |ButtonPressMask
, &ev
);
3844 new_dir
= getClipButton(ev
.xmotion
.x
, ev
.xmotion
.y
);
3845 if (new_dir
!= direction
) {
3846 direction
= new_dir
;
3847 clip
->lclip_button_pushed
= direction
==CLIP_REWIND
;
3848 clip
->rclip_button_pushed
= direction
==CLIP_FORWARD
;
3849 wClipIconPaint(scr
->clip_icon
);
3857 if (ev
.xbutton
.button
== event
->xbutton
.button
)
3862 clip
->lclip_button_pushed
= 0;
3863 clip
->rclip_button_pushed
= 0;
3865 new_ws
= wPreferences
.ws_advance
|| (event
->xbutton
.state
& ControlMask
);
3867 if (direction
== CLIP_FORWARD
) {
3868 if (scr
->current_workspace
< scr
->workspace_count
-1)
3869 wWorkspaceChange(scr
, scr
->current_workspace
+1);
3870 else if (new_ws
&& scr
->current_workspace
< MAX_WORKSPACES
-1)
3871 wWorkspaceChange(scr
, scr
->current_workspace
+1);
3872 else if (wPreferences
.ws_cycle
)
3873 wWorkspaceChange(scr
, 0);
3875 else if (direction
== CLIP_REWIND
) {
3876 if (scr
->current_workspace
> 0)
3877 wWorkspaceChange(scr
, scr
->current_workspace
-1);
3878 else if (scr
->current_workspace
==0 && wPreferences
.ws_cycle
)
3879 wWorkspaceChange(scr
, scr
->workspace_count
-1);
3882 wClipIconPaint(scr
->clip_icon
);
3887 iconMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
3889 WAppIcon
*aicon
= desc
->parent
;
3890 WDock
*dock
= aicon
->dock
;
3891 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
3893 if (aicon
->editing
|| WCHECK_STATE(WSTATE_MODAL
))
3896 scr
->last_dock
= dock
;
3898 if (dock
->menu
->flags
.mapped
)
3899 wMenuUnmap(dock
->menu
);
3901 if (IsDoubleClick(scr
, event
)) {
3902 /* double-click was not in the main clip icon */
3903 if (dock
->type
!= WM_CLIP
|| aicon
->xindex
!=0 || aicon
->yindex
!=0
3904 || getClipButton(event
->xbutton
.x
, event
->xbutton
.y
)==CLIP_IDLE
) {
3905 iconDblClick(desc
, event
);
3910 if (dock
->type
== WM_CLIP
&& scr
->flags
.clip_balloon_mapped
) {
3911 XUnmapWindow(dpy
, scr
->clip_balloon
);
3912 scr
->flags
.clip_balloon_mapped
= 0;
3916 puts("handling dock");
3918 if (event
->xbutton
.button
== Button1
) {
3919 if (event
->xbutton
.state
& MOD_MASK
)
3924 if ((event
->xbutton
.state
& ShiftMask
) && aicon
!=scr
->clip_icon
&&
3925 dock
->type
!=WM_DOCK
) {
3926 wIconSelect(aicon
->icon
);
3930 if (aicon
->yindex
==0 && aicon
->xindex
==0) {
3931 if (getClipButton(event
->xbutton
.x
, event
->xbutton
.y
)!=CLIP_IDLE
3932 && dock
->type
==WM_CLIP
)
3933 handleClipChangeWorkspace(scr
, event
);
3935 handleDockMove(dock
, aicon
, event
);
3937 handleIconMove(dock
, aicon
, event
);
3939 } else if (event
->xbutton
.button
==Button2
&& dock
->type
==WM_CLIP
&&
3940 aicon
==scr
->clip_icon
) {
3941 openClipWorkspaceMenu(scr
, event
->xbutton
.x_root
+2,
3942 event
->xbutton
.y_root
+2);
3943 if (scr
->clip_ws_menu
) {
3945 menu
= scr
->clip_ws_menu
;
3946 desc
= &menu
->menu
->descriptor
;
3948 event
->xany
.send_event
= True
;
3949 (*desc
->handle_mousedown
)(desc
, event
);
3952 } else if (event
->xbutton
.button
==Button2
&& dock
->type
==WM_CLIP
&&
3953 (event
->xbutton
.state
& ShiftMask
) && aicon
!=scr
->clip_icon
) {
3954 wClipMakeIconOmnipresent(aicon
, !aicon
->omnipresent
);
3956 } else if (event
->xbutton
.button
== Button3
) {
3957 openDockMenu(dock
, aicon
, event
);
3963 showClipBalloon(WDock
*dock
, int workspace
)
3967 WScreen
*scr
= dock
->screen_ptr
;
3971 scr
->flags
.clip_balloon_mapped
= 1;
3972 XMapWindow(dpy
, scr
->clip_balloon
);
3974 text
= scr
->workspaces
[workspace
]->name
;
3976 w
= wTextWidth(scr
->clip_title_font
->font
, text
, strlen(text
));
3978 h
= scr
->clip_title_font
->height
;
3979 XResizeWindow(dpy
, scr
->clip_balloon
, w
, h
);
3981 x
= dock
->x_pos
+ CLIP_BUTTON_SIZE
*ICON_SIZE
/64;
3982 y
= dock
->y_pos
+ ICON_SIZE
-scr
->clip_title_font
->height
- 3;
3984 if (x
+w
> scr
->scr_width
) {
3985 x
= scr
->scr_width
- w
;
3986 if (dock
->y_pos
+ ICON_SIZE
+ h
> scr
->scr_height
)
3987 y
= dock
->y_pos
- h
- 1;
3989 y
= dock
->y_pos
+ ICON_SIZE
;
3990 XRaiseWindow(dpy
, scr
->clip_balloon
);
3992 stack
[0] = scr
->clip_icon
->icon
->core
->window
;
3993 stack
[1] = scr
->clip_balloon
;
3994 XRestackWindows(dpy
, stack
, 2);
3996 XMoveWindow(dpy
, scr
->clip_balloon
, x
, y
);
3997 XSetForeground(dpy
, scr
->clip_title_gc
,
3998 scr
->clip_title_pixel
[CLIP_NORMAL
]);
3999 XClearWindow(dpy
, scr
->clip_balloon
);
4000 wDrawString(scr
->clip_balloon
, scr
->clip_title_font
, scr
->clip_title_gc
,
4001 0, scr
->clip_title_font
->y
, text
, strlen(text
));
4006 clipEnterNotify(WObjDescriptor
*desc
, XEvent
*event
)
4008 WAppIcon
*btn
= (WAppIcon
*)desc
->parent
;
4012 assert(event
->type
==EnterNotify
);
4014 if(desc
->parent_type
!=WCLASS_DOCK_ICON
)
4017 scr
= btn
->icon
->core
->screen_ptr
;
4018 if (!btn
->omnipresent
)
4021 dock
= scr
->workspaces
[scr
->current_workspace
]->clip
;
4023 if (!dock
|| dock
->type
!=WM_CLIP
)
4026 /* The auto raise/lower code */
4027 if (dock
->auto_lower_magic
) {
4028 WMDeleteTimerHandler(dock
->auto_lower_magic
);
4029 dock
->auto_lower_magic
= NULL
;
4031 if (dock
->auto_raise_lower
&& !dock
->auto_raise_magic
) {
4032 dock
->auto_raise_magic
= WMAddTimerHandler(AUTO_RAISE_DELAY
,
4037 /* The auto expand/collapse code */
4038 if (dock
->auto_collapse_magic
) {
4039 WMDeleteTimerHandler(dock
->auto_collapse_magic
);
4040 dock
->auto_collapse_magic
= NULL
;
4042 if (dock
->auto_collapse
&& !dock
->auto_expand_magic
) {
4043 dock
->auto_expand_magic
= WMAddTimerHandler(AUTO_EXPAND_DELAY
,
4048 if (btn
->xindex
== 0 && btn
->yindex
== 0)
4049 showClipBalloon(dock
, dock
->screen_ptr
->current_workspace
);
4051 if (dock
->screen_ptr
->flags
.clip_balloon_mapped
) {
4052 XUnmapWindow(dpy
, dock
->screen_ptr
->clip_balloon
);
4053 dock
->screen_ptr
->flags
.clip_balloon_mapped
= 0;
4060 clipLeave(WDock
*dock
)
4063 WObjDescriptor
*desc
= NULL
;
4065 if (!dock
|| dock
->type
!=WM_CLIP
)
4068 if (XCheckTypedEvent(dpy
, EnterNotify
, &event
)!=False
) {
4069 if (XFindContext(dpy
, event
.xcrossing
.window
, wWinContext
,
4070 (XPointer
*)&desc
)!=XCNOENT
4071 && desc
&& desc
->parent_type
==WCLASS_DOCK_ICON
4072 && ((WAppIcon
*)desc
->parent
)->dock
4073 && ((WAppIcon
*)desc
->parent
)->dock
->type
==WM_CLIP
) {
4074 /* We didn't left the Clip yet */
4075 XPutBackEvent(dpy
, &event
);
4079 XPutBackEvent(dpy
, &event
);
4081 /* We entered a withdrawn window, so we're still in Clip */
4085 if (dock
->auto_raise_magic
) {
4086 WMDeleteTimerHandler(dock
->auto_raise_magic
);
4087 dock
->auto_raise_magic
= NULL
;
4089 if (dock
->auto_raise_lower
&& !dock
->auto_lower_magic
) {
4090 dock
->auto_lower_magic
= WMAddTimerHandler(AUTO_LOWER_DELAY
,
4095 if (dock
->auto_expand_magic
) {
4096 WMDeleteTimerHandler(dock
->auto_expand_magic
);
4097 dock
->auto_expand_magic
= NULL
;
4099 if (dock
->auto_collapse
&& !dock
->auto_collapse_magic
) {
4100 dock
->auto_collapse_magic
= WMAddTimerHandler(AUTO_COLLAPSE_DELAY
,
4108 clipLeaveNotify(WObjDescriptor
*desc
, XEvent
*event
)
4110 WAppIcon
*btn
= (WAppIcon
*)desc
->parent
;
4112 assert(event
->type
==LeaveNotify
);
4114 if(desc
->parent_type
!=WCLASS_DOCK_ICON
)
4117 clipLeave(btn
->dock
);
4122 clipAutoCollapse(void *cdata
)
4124 WDock
*dock
= (WDock
*)cdata
;
4126 if (dock
->type
!=WM_CLIP
)
4129 if (dock
->auto_collapse
) {
4130 dock
->collapsed
= 1;
4131 wDockHideIcons(dock
);
4133 dock
->auto_collapse_magic
= NULL
;
4138 clipAutoExpand(void *cdata
)
4140 WDock
*dock
= (WDock
*)cdata
;
4142 if (dock
->type
!=WM_CLIP
)
4145 if (dock
->auto_collapse
) {
4146 dock
->collapsed
= 0;
4147 wDockShowIcons(dock
);
4149 dock
->auto_expand_magic
= NULL
;
4154 clipAutoLower(void *cdata
)
4156 WDock
*dock
= (WDock
*)cdata
;
4158 if (dock
->type
!=WM_CLIP
)
4161 if (dock
->auto_raise_lower
)
4164 dock
->auto_lower_magic
= NULL
;
4169 clipAutoRaise(void *cdata
)
4171 WDock
*dock
= (WDock
*)cdata
;
4173 if (dock
->type
!=WM_CLIP
)
4176 if (dock
->auto_raise_lower
)
4179 if (dock
->screen_ptr
->flags
.clip_balloon_mapped
) {
4180 showClipBalloon(dock
, dock
->screen_ptr
->current_workspace
);
4183 dock
->auto_raise_magic
= NULL
;
4188 iconCanBeOmnipresent(WAppIcon
*aicon
)
4190 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
4194 Bool ocupied
= False
;
4196 for (i
=0; i
<scr
->workspace_count
; i
++) {
4197 clip
= scr
->workspaces
[i
]->clip
;
4199 if (clip
== aicon
->dock
)
4202 for (j
=0; j
<clip
->max_icons
; j
++) {
4203 btn
= clip
->icon_array
[j
];
4204 if(btn
&& btn
->xindex
==aicon
->xindex
&& btn
->yindex
==aicon
->yindex
) {
4216 wClipMakeIconOmnipresent(WAppIcon
*aicon
, int omnipresent
)
4218 WScreen
*scr
= aicon
->icon
->core
->screen_ptr
;
4219 WAppIconChain
*new_entry
, *tmp
, *tmp1
;
4220 int status
= WO_SUCCESS
;
4222 if (aicon
->dock
== scr
->dock
|| aicon
== scr
->clip_icon
)
4223 return WO_NOT_APPLICABLE
;
4225 if (aicon
->omnipresent
== omnipresent
)
4229 if (iconCanBeOmnipresent(aicon
)) {
4230 aicon
->omnipresent
= 1;
4231 new_entry
= wmalloc(sizeof(WAppIconChain
));
4232 new_entry
->aicon
= aicon
;
4233 new_entry
->next
= NULL
;
4234 if (!scr
->global_icons
) {
4235 scr
->global_icons
= new_entry
;
4237 tmp
= scr
->global_icons
;
4241 tmp
->next
= new_entry
;
4244 aicon
->omnipresent
= 0;
4248 aicon
->omnipresent
= 0;
4249 if (aicon
== scr
->global_icons
->aicon
) {
4250 tmp
= scr
->global_icons
->next
;
4251 free(scr
->global_icons
);
4252 scr
->global_icons
= tmp
;
4254 tmp
= scr
->global_icons
;
4256 if (tmp
->next
->aicon
== aicon
) {
4257 tmp1
= tmp
->next
->next
;