1 /* icon.c - window icon and dock and appicon parent
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>
35 #include "WindowMaker.h"
43 #include "application.h"
47 /**** Global variables ****/
48 extern WPreferences wPreferences
;
50 #define MOD_MASK wPreferences.modifier_mask
52 extern Cursor wCursor
[WCUR_LAST
];
55 static void miniwindowExpose(WObjDescriptor
*desc
, XEvent
*event
);
56 static void miniwindowMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
57 static void miniwindowDblClick(WObjDescriptor
*desc
, XEvent
*event
);
61 getSize(Drawable d
, unsigned int *w
, unsigned int *h
, unsigned int *dep
)
67 XGetGeometry(dpy
, d
, &rjunk
, &xjunk
, &yjunk
, w
, h
, &bjunk
, dep
);
72 wIconCreate(WWindow
*wwin
)
74 WScreen
*scr
=wwin
->screen_ptr
;
77 unsigned long vmask
= 0;
78 XSetWindowAttributes attribs
;
80 icon
= wmalloc(sizeof(WIcon
));
81 memset(icon
, 0, sizeof(WIcon
));
82 icon
->core
= wCoreCreateTopLevel(scr
, wwin
->icon_x
, wwin
->icon_y
,
83 wPreferences
.icon_size
,
84 wPreferences
.icon_size
, 0);
86 if (wPreferences
.use_saveunders
) {
88 attribs
.save_under
= True
;
90 /* a white border for selecting it */
91 vmask
|= CWBorderPixel
;
92 attribs
.border_pixel
= scr
->white_pixel
;
94 XChangeWindowAttributes(dpy
, icon
->core
->window
, vmask
, &attribs
);
97 /* will be overriden if this is an application icon */
98 icon
->core
->descriptor
.handle_mousedown
= miniwindowMouseDown
;
99 icon
->core
->descriptor
.handle_expose
= miniwindowExpose
;
100 icon
->core
->descriptor
.parent_type
= WCLASS_MINIWINDOW
;
101 icon
->core
->descriptor
.parent
= icon
;
103 icon
->core
->stacking
= wmalloc(sizeof(WStacking
));
104 icon
->core
->stacking
->above
= NULL
;
105 icon
->core
->stacking
->under
= NULL
;
106 icon
->core
->stacking
->window_level
= NORMAL_ICON_LEVEL
;
107 icon
->core
->stacking
->child_of
= NULL
;
110 if (wwin
->wm_hints
&& (wwin
->wm_hints
->flags
& IconWindowHint
)) {
111 if (wwin
->client_win
== wwin
->main_window
) {
113 /* do not let miniwindow steal app-icon's icon window */
114 wapp
= wApplicationOf(wwin
->client_win
);
115 if (!wapp
|| wapp
->app_icon
==NULL
)
116 icon
->icon_win
= wwin
->wm_hints
->icon_window
;
118 icon
->icon_win
= wwin
->wm_hints
->icon_window
;
121 #ifdef NO_MINIWINDOW_TITLES
122 icon
->show_title
= 0;
124 icon
->show_title
= 1;
126 icon
->image
= wDefaultGetImage(scr
, wwin
->wm_instance
, wwin
->wm_class
);
128 file
= wDefaultGetIconFile(scr
, wwin
->wm_instance
, wwin
->wm_class
,
131 icon
->file
= wstrdup(file
);
134 wGetIconName(dpy
, wwin
->client_win
, &icon
->icon_name
);
136 icon
->tile_type
= TILE_NORMAL
;
147 wIconCreateWithIconFile(WScreen
*scr
, char *iconfile
, int tile
)
150 unsigned long vmask
= 0;
151 XSetWindowAttributes attribs
;
153 icon
= wmalloc(sizeof(WIcon
));
154 memset(icon
, 0, sizeof(WIcon
));
155 icon
->core
= wCoreCreateTopLevel(scr
, 0, 0, wPreferences
.icon_size
,
156 wPreferences
.icon_size
, 0);
157 if (wPreferences
.use_saveunders
) {
159 attribs
.save_under
= True
;
161 /* a white border for selecting it */
162 vmask
|= CWBorderPixel
;
163 attribs
.border_pixel
= scr
->white_pixel
;
165 XChangeWindowAttributes(dpy
, icon
->core
->window
, vmask
, &attribs
);
167 /* will be overriden if this is a application icon */
168 icon
->core
->descriptor
.handle_mousedown
= miniwindowMouseDown
;
169 icon
->core
->descriptor
.handle_expose
= miniwindowExpose
;
170 icon
->core
->descriptor
.parent_type
= WCLASS_MINIWINDOW
;
171 icon
->core
->descriptor
.parent
= icon
;
173 icon
->core
->stacking
= wmalloc(sizeof(WStacking
));
174 icon
->core
->stacking
->above
= NULL
;
175 icon
->core
->stacking
->under
= NULL
;
176 icon
->core
->stacking
->window_level
= NORMAL_ICON_LEVEL
;
177 icon
->core
->stacking
->child_of
= NULL
;
180 icon
->image
= RLoadImage(scr
->rcontext
, iconfile
, 0);
182 wwarning(_("error loading image file \"%s\""), iconfile
, RMessageForError(RErrorCode
));
185 icon
->image
= wIconValidateIconSize(scr
, icon
->image
);
187 icon
->file
= wstrdup(iconfile
);
190 icon
->tile_type
= tile
;
200 wIconDestroy(WIcon
*icon
)
202 WCoreWindow
*core
= icon
->core
;
203 WScreen
*scr
= core
->screen_ptr
;
206 WMDeleteTimerHandler(icon
->handlerID
);
208 if (icon
->icon_win
) {
212 x
= icon
->owner
->icon_x
;
213 y
= icon
->owner
->icon_y
;
215 XUnmapWindow(dpy
, icon
->icon_win
);
216 XReparentWindow(dpy
, icon
->icon_win
, scr
->root_win
, x
, y
);
219 XFree(icon
->icon_name
);
222 XFreePixmap(dpy
, icon
->pixmap
);
227 if (icon
->image
!=NULL
)
228 RDestroyImage(icon
->image
);
230 wCoreDestroy(icon
->core
);
237 drawIconTitle(WScreen
*scr
, Pixmap pixmap
, int height
)
239 XFillRectangle(dpy
, pixmap
, scr
->icon_title_texture
->normal_gc
,
240 0, 0, wPreferences
.icon_size
, height
+1);
241 XDrawLine(dpy
, pixmap
, scr
->icon_title_texture
->light_gc
, 0, 0,
242 wPreferences
.icon_size
, 0);
243 XDrawLine(dpy
, pixmap
, scr
->icon_title_texture
->light_gc
, 0, 0,
245 XDrawLine(dpy
, pixmap
, scr
->icon_title_texture
->dim_gc
,
246 wPreferences
.icon_size
-1, 0, wPreferences
.icon_size
-1, height
+1);
251 makeIcon(WScreen
*scr
, RImage
*icon
, int titled
, int shadowed
, int tileType
)
257 int theight
= scr
->icon_title_font
->height
;
259 if (tileType
== TILE_NORMAL
)
260 tile
= RCloneImage(scr
->icon_tile
);
262 assert(scr
->clip_tile
);
263 tile
= RCloneImage(scr
->clip_tile
);
266 w
= (icon
->width
> wPreferences
.icon_size
)
267 ? wPreferences
.icon_size
: icon
->width
;
268 x
= (wPreferences
.icon_size
- w
) / 2;
269 sx
= (icon
->width
- w
)/2;
272 h
= (icon
->height
> wPreferences
.icon_size
)
273 ? wPreferences
.icon_size
: icon
->height
;
274 y
= (wPreferences
.icon_size
- h
) / 2;
275 sy
= (icon
->height
- h
)/2;
277 h
= (icon
->height
+theight
> wPreferences
.icon_size
278 ? wPreferences
.icon_size
-theight
: icon
->height
);
279 y
= theight
+((int)wPreferences
.icon_size
-theight
-h
)/2;
280 sy
= (icon
->height
- h
)/2;
282 RCombineArea(tile
, icon
, sx
, sy
, w
, h
, x
, y
);
288 color
.red
= scr
->icon_back_texture
->light
.red
>> 8;
289 color
.green
= scr
->icon_back_texture
->light
.green
>> 8;
290 color
.blue
= scr
->icon_back_texture
->light
.blue
>> 8;
291 color
.alpha
= 150; /* about 60% */
292 RClearImage(tile
, &color
);
295 if (!RConvertImage(scr
->rcontext
, tile
, &pixmap
)) {
296 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
301 drawIconTitle(scr
, pixmap
, theight
);
308 wIconChangeTitle(WIcon
*icon
, char *new_title
)
312 changed
= (new_title
==NULL
&& icon
->icon_name
!=NULL
)
313 || (new_title
!=NULL
&& icon
->icon_name
==NULL
);
315 if (icon
->icon_name
!=NULL
)
316 XFree(icon
->icon_name
);
318 icon
->icon_name
= new_title
;
321 icon
->force_paint
= 1;
327 wIconChangeImage(WIcon
*icon
, RImage
*new_image
)
329 assert(icon
!= NULL
);
332 RDestroyImage(icon
->image
);
334 icon
->image
= wIconValidateIconSize(icon
->core
->screen_ptr
, new_image
);
341 wIconValidateIconSize(WScreen
*scr
, RImage
*icon
)
349 if (icon
->width
> wPreferences
.icon_size
350 || icon
->height
> wPreferences
.icon_size
) {
351 if (icon
->width
> icon
->height
) {
352 w
= wPreferences
.icon_size
- 4;
353 h
= w
*icon
->height
/icon
->width
;
355 h
= wPreferences
.icon_size
- 4;
356 w
= h
*icon
->width
/icon
->height
;
358 tmp
= RScaleImage(icon
, w
, h
);
368 wIconChangeImageFile(WIcon
*icon
, char *file
)
370 WScreen
*scr
= icon
->core
->screen_ptr
;
376 wIconChangeImage(icon
, NULL
);
380 path
= FindImage(wPreferences
.icon_path
, file
);
382 if (path
&& (image
= RLoadImage(scr
->rcontext
, path
, 0))) {
383 wIconChangeImage(icon
, image
);
397 getnameforicon(WWindow
*wwin
)
399 char *prefix
, *suffix
;
403 if (wwin
->wm_class
&& wwin
->wm_instance
) {
404 suffix
= wmalloc(strlen(wwin
->wm_class
)+strlen(wwin
->wm_instance
)+2);
405 sprintf(suffix
, "%s.%s", wwin
->wm_instance
, wwin
->wm_class
);
406 } else if (wwin
->wm_class
) {
407 suffix
= wmalloc(strlen(wwin
->wm_class
)+1);
408 strcpy(suffix
, wwin
->wm_class
);
409 } else if (wwin
->wm_instance
) {
410 suffix
= wmalloc(strlen(wwin
->wm_instance
)+1);
411 strcpy(suffix
, wwin
->wm_instance
);
416 prefix
= getenv("GNUSTEP_USER_PATH");
418 len
= strlen(wgethomedir())+64+strlen(suffix
);
419 path
= wmalloc(len
+1);
420 sprintf(path
, "%s/GNUstep/.AppInfo", wgethomedir());
422 prefix
= wexpandpath(prefix
);
423 len
= strlen(prefix
)+64+strlen(suffix
);
424 path
= wmalloc(len
+1);
425 sprintf(path
, "%s/.AppInfo", prefix
);
428 if (access(path
, F_OK
)!=0) {
429 if (mkdir(path
, S_IRUSR
|S_IWUSR
|S_IXUSR
)) {
430 wsyserror(_("could not create directory %s"), path
);
436 strcat(path
, "/WindowMaker");
437 if (access(path
, F_OK
)!=0) {
438 if (mkdir(path
, S_IRUSR
|S_IWUSR
|S_IXUSR
)!=0) {
439 wsyserror(_("could not create directory %s"), path
);
447 strcat(path
, suffix
);
448 strcat(path
, ".xpm");
457 * Stores the client supplied icon at ~/GNUstep/.AppInfo/WindowMaker
458 * and returns the path for that icon. Returns NULL if there is no
459 * client supplied icon or on failure.
462 * New directories might be created.
465 wIconStore(WIcon
*icon
)
469 WWindow
*wwin
= icon
->owner
;
471 if (!wwin
|| !wwin
->wm_hints
|| !(wwin
->wm_hints
->flags
& IconPixmapHint
)
472 || wwin
->wm_hints
->icon_pixmap
== None
)
475 path
= getnameforicon(wwin
);
479 image
= RCreateImageFromDrawable(icon
->core
->screen_ptr
->rcontext
,
480 wwin
->wm_hints
->icon_pixmap
,
481 (wwin
->wm_hints
->flags
& IconMaskHint
)
482 ? wwin
->wm_hints
->icon_mask
: None
);
488 if (!RSaveImage(image
, path
, "XPM")) {
492 RDestroyImage(image
);
500 wIconChangeIconWindow(WIcon *icon, Window new_window);
504 cycleColor(void *data
)
506 WIcon
*icon
= (WIcon
*)data
;
507 WScreen
*scr
= icon
->core
->screen_ptr
;
511 gcv
.dash_offset
= icon
->step
;
512 XChangeGC(dpy
, scr
->icon_select_gc
, GCDashOffset
, &gcv
);
514 XDrawRectangle(dpy
, icon
->core
->window
, scr
->icon_select_gc
, 0, 0,
515 icon
->core
->width
-1, icon
->core
->height
-1);
516 icon
->handlerID
= WMAddTimerHandler(COLOR_CYCLE_DELAY
, cycleColor
, icon
);
521 wIconSetHighlited(WIcon
*icon
, Bool flag
)
523 if (icon
->highlighted
== flag
) {
527 icon
->highlighted
= flag
;
534 wIconSelect(WIcon
*icon
)
536 WScreen
*scr
= icon
->core
->screen_ptr
;
537 icon
->selected
= !icon
->selected
;
539 if (icon
->selected
) {
541 if (!wPreferences
.dont_blink
)
542 icon
->handlerID
= WMAddTimerHandler(10, cycleColor
, icon
);
544 XDrawRectangle(dpy
, icon
->core
->window
, scr
->icon_select_gc
, 0, 0,
545 icon
->core
->width
-1, icon
->core
->height
-1);
547 if (icon
->handlerID
) {
548 WMDeleteTimerHandler(icon
->handlerID
);
549 icon
->handlerID
= NULL
;
551 XClearArea(dpy
, icon
->core
->window
, 0, 0, icon
->core
->width
,
552 icon
->core
->height
, True
);
558 wIconUpdate(WIcon
*icon
)
560 WScreen
*scr
= icon
->core
->screen_ptr
;
561 int title_height
= scr
->icon_title_font
->height
;
562 WWindow
*wwin
= icon
->owner
;
564 assert(scr
->icon_tile
!=NULL
);
566 if (icon
->pixmap
!=None
)
567 XFreePixmap(dpy
, icon
->pixmap
);
571 if (wwin
&& WFLAGP(wwin
, always_user_icon
))
574 /* use client specified icon window */
575 if (icon
->icon_win
!=None
) {
576 XWindowAttributes attr
;
578 int width
, height
, depth
;
582 getSize(icon
->icon_win
, &width
, &height
, &depth
);
584 if (width
> wPreferences
.icon_size
) {
586 width
= wPreferences
.icon_size
;
588 if (height
> wPreferences
.icon_size
) {
590 height
= wPreferences
.icon_size
;
593 && (height
+title_height
< wPreferences
.icon_size
)) {
594 pixmap
= XCreatePixmap(dpy
, scr
->w_win
, wPreferences
.icon_size
,
595 wPreferences
.icon_size
, scr
->w_depth
);
596 XSetClipMask(dpy
, scr
->copy_gc
, None
);
597 XCopyArea(dpy
, scr
->icon_tile_pixmap
, pixmap
, scr
->copy_gc
, 0, 0,
598 wPreferences
.icon_size
, wPreferences
.icon_size
, 0, 0);
599 drawIconTitle(scr
, pixmap
, title_height
);
600 theight
= title_height
;
604 XSetWindowBackgroundPixmap(dpy
, icon
->core
->window
,
605 scr
->icon_tile_pixmap
);
608 XSetWindowBorderWidth(dpy
, icon
->icon_win
, 0);
609 XReparentWindow(dpy
, icon
->icon_win
, icon
->core
->window
,
610 (wPreferences
.icon_size
-width
)/2,
611 theight
+(wPreferences
.icon_size
-height
-theight
)/2);
613 XResizeWindow(dpy
, icon
->icon_win
, width
, height
);
615 XMapWindow(dpy
, icon
->icon_win
);
617 XAddToSaveSet(dpy
, icon
->icon_win
);
619 icon
->pixmap
= pixmap
;
621 if (XGetWindowAttributes(dpy
, icon
->icon_win
, &attr
)) {
622 if (attr
.all_event_masks
& ButtonPressMask
) {
623 wHackedGrabButton(Button1
, MOD_MASK
, icon
->core
->window
, True
,
624 ButtonPressMask
, GrabModeSync
, GrabModeAsync
,
625 None
, wCursor
[WCUR_ARROW
]);
628 } else if (wwin
&& wwin
->wm_hints
629 && (wwin
->wm_hints
->flags
& IconPixmapHint
)) {
637 if (!XGetGeometry(dpy
, wwin
->wm_hints
->icon_pixmap
, &jw
,
638 &ji
, &ji
, &w
, &h
, &ju
, &d
)) {
639 icon
->owner
->wm_hints
->flags
&= ~IconPixmapHint
;
643 pixmap
= XCreatePixmap(dpy
, icon
->core
->window
, wPreferences
.icon_size
,
644 wPreferences
.icon_size
, scr
->w_depth
);
645 XSetClipMask(dpy
, scr
->copy_gc
, None
);
646 XCopyArea(dpy
, scr
->icon_tile_pixmap
, pixmap
, scr
->copy_gc
, 0, 0,
647 wPreferences
.icon_size
, wPreferences
.icon_size
, 0, 0);
649 if (w
> wPreferences
.icon_size
)
650 w
= wPreferences
.icon_size
;
651 x
= (wPreferences
.icon_size
-w
)/2;
653 if (icon
->show_title
&& (title_height
< wPreferences
.icon_size
)) {
654 drawIconTitle(scr
, pixmap
, title_height
);
657 if (h
> wPreferences
.icon_size
- title_height
- 2) {
658 h
= wPreferences
.icon_size
- title_height
- 2;
659 y
= title_height
+ 1;
661 y
= (wPreferences
.icon_size
-h
-title_height
)/2+title_height
+ 1;
665 if (w
> wPreferences
.icon_size
)
666 w
= wPreferences
.icon_size
;
667 y
= (wPreferences
.icon_size
-h
)/2;
670 if (wwin
->wm_hints
->flags
& IconMaskHint
)
671 XSetClipMask(dpy
, scr
->copy_gc
, wwin
->wm_hints
->icon_mask
);
673 XSetClipOrigin(dpy
, scr
->copy_gc
, x
, y
);
675 if (d
!= scr
->w_depth
) {
676 XSetForeground(dpy
, scr
->copy_gc
, scr
->black_pixel
);
677 XSetBackground(dpy
, scr
->copy_gc
, scr
->white_pixel
);
678 XCopyPlane(dpy
, wwin
->wm_hints
->icon_pixmap
, pixmap
, scr
->copy_gc
,
679 0, 0, w
, h
, x
, y
, 1);
681 XCopyArea(dpy
, wwin
->wm_hints
->icon_pixmap
, pixmap
, scr
->copy_gc
,
685 XSetClipOrigin(dpy
, scr
->copy_gc
, 0, 0);
687 icon
->pixmap
= pixmap
;
692 icon
->pixmap
= makeIcon(scr
, icon
->image
, icon
->show_title
,
693 icon
->shadowed
, icon
->tile_type
);
695 /* make default icons */
697 if (!scr
->def_icon_pixmap
) {
698 RImage
*image
= NULL
;
702 file
= wDefaultGetIconFile(scr
, NULL
, NULL
, False
);
704 path
= FindImage(wPreferences
.icon_path
, file
);
706 wwarning(_("could not find default icon \"%s\""),file
);
710 image
= RLoadImage(scr
->rcontext
, path
, 0);
712 wwarning(_("could not load default icon \"%s\":%s"),
713 file
, RMessageForError(RErrorCode
));
719 image
= wIconValidateIconSize(scr
, image
);
720 scr
->def_icon_pixmap
= makeIcon(scr
, image
, False
, False
,
722 scr
->def_ticon_pixmap
= makeIcon(scr
, image
, True
, False
,
725 RDestroyImage(image
);
728 if (icon
->show_title
) {
729 XSetWindowBackgroundPixmap(dpy
, icon
->core
->window
,
730 scr
->def_ticon_pixmap
);
732 XSetWindowBackgroundPixmap(dpy
, icon
->core
->window
,
733 scr
->def_icon_pixmap
);
738 if (icon
->pixmap
!= None
) {
739 XSetWindowBackgroundPixmap(dpy
, icon
->core
->window
, icon
->pixmap
);
741 XClearWindow(dpy
, icon
->core
->window
);
749 wIconPaint(WIcon
*icon
)
751 WScreen
*scr
=icon
->core
->screen_ptr
;
752 GC gc
= scr
->icon_title_gc
;
756 if (icon
->force_paint
) {
757 icon
->force_paint
= 0;
762 XClearWindow(dpy
, icon
->core
->window
);
764 /* draw the icon title */
765 if (icon
->show_title
&& icon
->icon_name
!=NULL
) {
769 tmp
= ShrinkString(scr
->icon_title_font
, icon
->icon_name
,
770 wPreferences
.icon_size
-4);
771 w
= wTextWidth(scr
->icon_title_font
->font
, tmp
, l
=strlen(tmp
));
773 if (w
> icon
->core
->width
- 4)
774 x
= (icon
->core
->width
- 4) - w
;
776 x
= (icon
->core
->width
- w
)/2;
778 wDrawString(icon
->core
->window
, scr
->icon_title_font
, gc
,
779 x
, 1 + scr
->icon_title_font
->y
, tmp
, l
);
784 XDrawRectangle(dpy
, icon
->core
->window
, scr
->icon_select_gc
, 0, 0,
785 icon
->core
->width
-1, icon
->core
->height
-1);
789 /******************************************************************/
792 miniwindowExpose(WObjDescriptor
*desc
, XEvent
*event
)
794 wIconPaint(desc
->parent
);
799 miniwindowDblClick(WObjDescriptor
*desc
, XEvent
*event
)
801 WIcon
*icon
= desc
->parent
;
803 assert(icon
->owner
!=NULL
);
805 wDeiconifyWindow(icon
->owner
);
810 miniwindowMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
812 WIcon
*icon
= desc
->parent
;
813 WWindow
*wwin
= icon
->owner
;
815 int x
=wwin
->icon_x
, y
=wwin
->icon_y
;
816 int dx
=event
->xbutton
.x
, dy
=event
->xbutton
.y
;
818 int clickButton
=event
->xbutton
.button
;
821 if (IsDoubleClick(icon
->core
->screen_ptr
, event
)) {
822 miniwindowDblClick(desc
, event
);
827 puts("Moving miniwindow");
829 if (event
->xbutton
.button
==Button1
) {
830 if (event
->xbutton
.state
& MOD_MASK
)
831 wLowerFrame(icon
->core
);
833 wRaiseFrame(icon
->core
);
834 if (event
->xbutton
.state
& ShiftMask
) {
836 wSelectWindow(icon
->owner
, !wwin
->flags
.selected
);
840 else if (event
->xbutton
.button
==Button3
) {
841 WObjDescriptor
*desc
;
843 OpenMiniwindowMenu(wwin
, event
->xbutton
.x_root
,
844 event
->xbutton
.y_root
);
846 /* allow drag select of menu */
847 desc
= &wwin
->screen_ptr
->window_menu
->menu
->descriptor
;
848 event
->xbutton
.send_event
= True
;
849 (*desc
->handle_mousedown
)(desc
, event
);
854 if (XGrabPointer(dpy
, icon
->core
->window
, False
, ButtonMotionMask
855 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
856 GrabModeAsync
, None
, None
, CurrentTime
) !=GrabSuccess
) {
858 wwarning("pointer grab failed for icon move");
862 WMMaskEvent(dpy
, PointerMotionMask
|ButtonReleaseMask
|ButtonPressMask
863 |ButtonMotionMask
|ExposureMask
, &ev
);
871 if (abs(dx
-ev
.xmotion
.x
)>=MOVE_THRESHOLD
872 || abs(dy
-ev
.xmotion
.y
)>=MOVE_THRESHOLD
) {
873 XChangeActivePointerGrab(dpy
, ButtonMotionMask
874 |ButtonReleaseMask
|ButtonPressMask
,
875 wCursor
[WCUR_MOVE
], CurrentTime
);
881 x
= ev
.xmotion
.x_root
- dx
;
882 y
= ev
.xmotion
.y_root
- dy
;
883 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
890 if (ev
.xbutton
.button
!= clickButton
)
893 if (wwin
->icon_x
!=x
|| wwin
->icon_y
!=y
)
894 wwin
->flags
.icon_moved
= 1;
896 XMoveWindow(dpy
, icon
->core
->window
, x
, y
);
901 puts("End miniwindow move");
903 XUngrabPointer(dpy
, CurrentTime
);