2 * Copyright 1989 Massachusetts Institute of Technology
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of M.I.T. not be used in advertising
9 * or publicity pertaining to distribution of the software without specific,
10 * written prior permission. M.I.T. makes no representations about the
11 * suitability of this software for any purpose. It is provided "as is"
12 * without express or implied warranty.
14 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
16 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 /**********************************************************************
24 * $XConsortium: icons.c,v 1.22 91/07/12 09:58:38 dave Exp $
26 * Icon releated routines
28 * 10-Apr-89 Tom LaStrange Initial Version.
30 **********************************************************************/
42 extern void splitRegionEntry();
43 extern int roundEntryUp();
44 extern RegionEntry *prevRegionEntry();
45 extern void mergeRegionEntries();
46 extern void downRegionEntry();
47 extern RootRegion *AddRegion();
49 #define iconWidth(w) (Scr->IconBorderWidth * 2 + w->icon_w_width)
50 #define iconHeight(w) (Scr->IconBorderWidth * 2 + w->icon_w_height)
52 void PlaceIcon(tmp_win, def_x, def_y, final_x, final_y)
55 int *final_x, *final_y;
62 for (rr = Scr->FirstIconRegion; rr; rr = rr->next) {
63 w = roundEntryUp (iconWidth (tmp_win), rr->stepx);
64 h = roundEntryUp (iconHeight (tmp_win), rr->stepy);
65 for (re = rr->entries; re; re=re->next) {
68 /* don't include grid spacing - djhjr - 5/22/99
69 if (re->w >= w && re->h >= h)
71 if (re->w >= iconWidth(tmp_win) && re->h >= iconHeight(tmp_win))
78 splitRegionEntry (re, rr->grav1, rr->grav2, w, h);
79 re->usedby = USEDBY_TWIN;
80 re->u.twm_win = tmp_win;
82 /* evenly spaced icon placement - djhjr - 4/24/99
83 *final_x = re->x + (re->w - iconWidth (tmp_win)) / 2;
84 *final_y = re->y + (re->h - iconHeight (tmp_win)) / 2;
89 /* adjust for region gravity - djhjr 4/26/99 */
90 if (rr->grav2 == D_EAST)
91 *final_x += re->w - iconWidth(tmp_win);
92 if (rr->grav1 == D_SOUTH)
93 *final_y += re->h - iconHeight(tmp_win);
103 FindIconEntry (tmp_win, rrp)
110 for (rr = Scr->FirstIconRegion; rr; rr = rr->next) {
111 for (re = rr->entries; re; re=re->next)
112 if (re->u.twm_win == tmp_win) {
121 void IconUp (tmp_win)
126 struct RootRegion *rr;
129 * If the client specified a particular location, let's use it (this might
130 * want to be an option at some point). Otherwise, try to fit within the
133 if (tmp_win->wmhints && (tmp_win->wmhints->flags & IconPositionHint))
136 if (tmp_win->icon_moved) {
137 if (!XGetGeometry (dpy, tmp_win->icon_w, &JunkRoot, &defx, &defy,
138 &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth))
141 /* evenly spaced icon placement - djhjr - 4/24/99
142 x = defx + ((int) JunkWidth) / 2;
143 y = defy + ((int) JunkHeight) / 2;
148 for (rr = Scr->FirstIconRegion; rr; rr = rr->next) {
149 if (x >= rr->x && x < (rr->x + rr->w) &&
150 y >= rr->y && y < (rr->y + rr->h))
153 if (!rr) return; /* outside icon regions, leave alone */
158 PlaceIcon(tmp_win, defx, defy, &x, &y);
159 if (x != defx || y != defy) {
160 XMoveWindow (dpy, tmp_win->icon_w, x, y);
161 tmp_win->icon_moved = FALSE; /* since we've restored it */
172 re = FindIconEntry (tmp_win, &rr);
174 downRegionEntry(rr, re);
178 AddIconRegion(geom, grav1, grav2, stepx, stepy)
180 int grav1, grav2, stepx, stepy;
184 rr = AddRegion(geom, grav1, grav2, stepx, stepy);
186 if (Scr->LastIconRegion)
187 Scr->LastIconRegion->next = rr;
188 Scr->LastIconRegion = rr;
189 if (!Scr->FirstIconRegion)
190 Scr->FirstIconRegion = rr;
193 #ifdef ORIGINAL_PIXMAPS
194 void CreateIconWindow(tmp_win, def_x, def_y)
198 unsigned long event_mask;
199 unsigned long valuemask; /* mask for create windows */
200 XSetWindowAttributes attributes; /* attributes for create windows */
201 Pixmap pm = None; /* tmp pixmap variable */
202 int final_x, final_y;
205 /* djhjr - 4/27/96 */
206 GetColorFromList(Scr->IconBorderColorL, tmp_win->full_name, &tmp_win->class,
207 &tmp_win->icon_border);
208 GetColorFromList(Scr->IconForegroundL, tmp_win->full_name, &tmp_win->class,
209 &tmp_win->iconc.fore);
210 GetColorFromList(Scr->IconBackgroundL, tmp_win->full_name, &tmp_win->class,
211 &tmp_win->iconc.back);
214 if (Scr->use3Diconmanagers && !Scr->BeNiceToColormap) GetShadeColors(&tmp_win->iconc);
216 /* was 'Scr->use3Dicons' - djhjr - 8/11/98 */
217 if (Scr->IconBevelWidth > 0 && !Scr->BeNiceToColormap) GetShadeColors(&tmp_win->iconc);
219 FB(tmp_win->iconc.fore, tmp_win->iconc.back);
221 tmp_win->forced = FALSE;
222 tmp_win->icon_not_ours = FALSE;
224 /* now go through the steps to get an icon window, if ForceIcon is
225 * set, then no matter what else is defined, the bitmap from the
226 * .twmrc file is used
233 icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
234 if (icon_name == NULL)
235 icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
239 if (icon_name != NULL)
241 if ((bm = (Pixmap)LookInNameList(Scr->Icons, icon_name)) == None)
243 if ((bm = GetBitmap (icon_name)) != None)
244 /* added 'type' argument - djhjr - 10/20/01 */
245 AddToList(&Scr->Icons, icon_name, LTYPE_EXACT_NAME,
252 XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
253 (unsigned int *) &tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height,
254 &JunkBW, &JunkDepth);
256 pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width,
257 tmp_win->icon_height, Scr->d_depth);
259 /* the copy plane works on color ! */
260 XCopyPlane(dpy, bm, pm, Scr->NormalGC,
261 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
263 tmp_win->forced = TRUE;
267 /* if the pixmap is still NULL, we didn't get one from the above code,
268 * that could mean that ForceIcon was not set, or that the window
269 * was not in the Icons list, now check the WM hints for an icon
271 if (pm == None && tmp_win->wmhints &&
272 tmp_win->wmhints->flags & IconPixmapHint)
275 XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap,
276 &JunkRoot, &JunkX, &JunkY,
277 (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height, &JunkBW, &JunkDepth);
279 pm = XCreatePixmap(dpy, Scr->Root,
280 tmp_win->icon_width, tmp_win->icon_height,
283 XCopyPlane(dpy, tmp_win->wmhints->icon_pixmap, pm, Scr->NormalGC,
284 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
287 /* if we still haven't got an icon, let's look in the Icon list
288 * if ForceIcon is not set
290 if (pm == None && !Scr->ForceIcon)
295 icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
296 if (icon_name == NULL)
297 icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
301 if (icon_name != NULL)
303 if ((bm = (Pixmap)LookInNameList(Scr->Icons, icon_name)) == None)
305 if ((bm = GetBitmap (icon_name)) != None)
306 /* added 'type' argument - djhjr - 10/20/01 */
307 AddToList(&Scr->Icons, icon_name, LTYPE_EXACT_NAME,
314 XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
315 (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height,
316 &JunkBW, &JunkDepth);
318 pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width,
319 tmp_win->icon_height, Scr->d_depth);
321 /* the copy plane works on color ! */
322 XCopyPlane(dpy, bm, pm, Scr->NormalGC,
323 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
327 /* if we still don't have an icon, assign the UnknownIcon */
329 if (pm == None && Scr->UnknownPm != None)
331 tmp_win->icon_width = Scr->UnknownWidth;
332 tmp_win->icon_height = Scr->UnknownHeight;
334 pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width,
335 tmp_win->icon_height, Scr->d_depth);
337 /* the copy plane works on color ! */
338 XCopyPlane(dpy, Scr->UnknownPm, pm, Scr->NormalGC,
339 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
344 tmp_win->icon_height = 0;
345 tmp_win->icon_width = 0;
350 /* added pixel specs - djhjr - 12/28/98 */
351 valuemask = CWBackPixmap | CWBackPixel;
352 attributes.background_pixmap = pm;
353 attributes.background_pixel = tmp_win->iconc.fore;
356 /* djhjr - 9/14/03 */
357 #ifndef NO_I18N_SUPPORT
358 tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont,
360 tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
362 tmp_win->icon_name, strlen(tmp_win->icon_name));
365 tmp_win->icon_w_width += 6;
366 if (tmp_win->icon_w_width < tmp_win->icon_width)
368 tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width)/2;
369 tmp_win->icon_x += 3;
370 tmp_win->icon_w_width = tmp_win->icon_width;
377 tmp_win->icon_w_width += 8;
378 if (tmp_win->icon_w_width < tmp_win->icon_width + 8)
380 tmp_win->icon_x = (((tmp_win->icon_width + 8) - tmp_win->icon_w_width)/2) + 4;
381 tmp_win->icon_w_width = tmp_win->icon_width + 8;
387 tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height;
389 tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height + 2;
392 tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 4;
395 tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 6;
397 tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 8;
400 if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)
402 tmp_win->icon_w = tmp_win->wmhints->icon_window;
403 if (tmp_win->forced ||
404 XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &JunkX, &JunkY,
405 (unsigned int *)&tmp_win->icon_w_width, (unsigned int *)&tmp_win->icon_w_height,
406 &JunkBW, &JunkDepth) == 0)
408 tmp_win->icon_w = None;
409 tmp_win->wmhints->flags &= ~IconWindowHint;
413 tmp_win->icon_not_ours = TRUE;
414 event_mask = EnterWindowMask | LeaveWindowMask;
419 tmp_win->icon_w = None;
423 /* was 'Scr->use3Dicons' and 'Scr->BorderBevelWidth' - djhjr - 8/11/98 */
424 if (Scr->IconBevelWidth > 0)
426 tmp_win->icon_w_width += 2 * Scr->IconBevelWidth;
427 tmp_win->icon_w_height += 2 * Scr->IconBevelWidth;
429 tmp_win->icon_x += Scr->IconBevelWidth;
430 tmp_win->icon_y += Scr->IconBevelWidth;
433 if (tmp_win->icon_w == None)
435 tmp_win->icon_w = XCreateSimpleWindow(dpy, Scr->Root,
437 tmp_win->icon_w_width, tmp_win->icon_w_height,
438 Scr->IconBorderWidth, tmp_win->icon_border, tmp_win->iconc.back);
439 event_mask = ExposureMask;
442 XSelectInput (dpy, tmp_win->icon_w,
443 KeyPressMask | ButtonPressMask | ButtonReleaseMask |
446 tmp_win->icon_bm_w = None;
448 (! (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)))
457 if (tmp_win->icon_w_width == tmp_win->icon_width)
460 x = (tmp_win->icon_w_width - tmp_win->icon_width)/2;
463 /* was 'Scr->use3Dicons' and 'Scr->BorderBevelWidth' - djhjr - 8/11/98 */
464 if (Scr->IconBevelWidth > 0)
465 y += Scr->IconBevelWidth;
467 tmp_win->icon_bm_w = XCreateWindow (dpy, tmp_win->icon_w, x, y,
468 (unsigned int)tmp_win->icon_width,
469 (unsigned int)tmp_win->icon_height,
470 (unsigned int) 0, Scr->d_depth,
471 (unsigned int) CopyFromParent,
472 Scr->d_visual, valuemask,
476 /* I need to figure out where to put the icon window now, because
477 * getting here means that I am going to make the icon visible
479 if (tmp_win->wmhints &&
480 tmp_win->wmhints->flags & IconPositionHint)
482 final_x = tmp_win->wmhints->icon_x;
483 final_y = tmp_win->wmhints->icon_y;
487 PlaceIcon(tmp_win, def_x, def_y, &final_x, &final_y);
490 if (final_x > Scr->MyDisplayWidth)
491 final_x = Scr->MyDisplayWidth - tmp_win->icon_w_width -
492 (2 * Scr->IconBorderWidth);
494 if (final_y > Scr->MyDisplayHeight)
495 final_y = Scr->MyDisplayHeight - tmp_win->icon_height -
496 Scr->IconFont.height - 4 - (2 * Scr->IconBorderWidth);
498 XMoveWindow(dpy, tmp_win->icon_w, final_x, final_y);
499 tmp_win->iconified = TRUE;
501 XMapSubwindows(dpy, tmp_win->icon_w);
502 XSaveContext(dpy, tmp_win->icon_w, TwmContext, (caddr_t)tmp_win);
503 XSaveContext(dpy, tmp_win->icon_w, ScreenContext, (caddr_t)Scr);
504 XDefineCursor(dpy, tmp_win->icon_w, Scr->IconCursor);
505 if (pm) XFreePixmap (dpy, pm);
508 #else /* ORIGINAL_PIXMAPS */
510 * to help clean up CreateIconWindow() below - djhjr - 8/13/98
511 * added background color and XPM indicator - djhjr - 12/28/98
514 GetIconImage(name, background, numcolors)
517 unsigned int *numcolors;
522 int bitmap_height, bitmap_width;
524 iconimage = (Image *)LookInNameList(Scr->Icons, name);
525 if (iconimage == NULL)
527 bm = FindBitmap(name, &bitmap_width, &bitmap_height);
530 iconimage = (Image *)malloc(sizeof(Image));
531 iconimage->mask = None;
532 iconimage->height = bitmap_height;
533 iconimage->width = bitmap_width;
534 iconimage->pixmap = XCreatePixmap(dpy, Scr->Root, bitmap_width,
535 bitmap_height, Scr->d_depth);
537 XGetGeometry(dpy, bm,
538 &JunkRoot, &JunkX, &JunkY,
539 &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth);
542 * XCopyArea() seems to be necessary for some apps that change
543 * their icons - djhjr - rem'd 8/23/98, re-instated 11/15/98
545 if (JunkDepth == Scr->d_depth)
546 XCopyArea(dpy, bm, iconimage->pixmap,
547 Scr->NormalGC, 0, 0, iconimage->width, iconimage->height,
550 XCopyPlane(dpy, bm, iconimage->pixmap,
551 Scr->NormalGC, 0, 0, iconimage->width, iconimage->height,
554 iconimage->mask = XCreatePixmap(dpy, Scr->Root,
555 iconimage->width, iconimage->height, 1);
558 gc = XCreateGC(dpy, iconimage->mask, 0, NULL);
561 XCopyArea(dpy, bm, iconimage->mask,
562 gc, 0, 0, iconimage->width, iconimage->height, 0, 0);
567 XFreePixmap(dpy, bm);
569 #ifndef NO_XPM_SUPPORT
572 /* added color argument - djhjr - 9/28/99 */
573 iconimage = FindImage(name, background);
577 if (iconimage != NULL)
578 /* added 'type' argument - djhjr - 10/20/01 */
579 AddToList(&Scr->Icons, name, LTYPE_EXACT_NAME,
583 /* djhjr - 12/28/98 */
585 #ifndef NO_XPM_SUPPORT
586 if (iconimage != NULL)
587 *numcolors = SetPixmapsBackground(iconimage, Scr->Root, background);
594 * Submitted by Jason Gloudon
597 CreateIconWindow(tmp_win, def_x, def_y)
601 unsigned long event_mask;
602 unsigned long valuemask; /* mask for create windows */
603 XSetWindowAttributes attributes; /* attributes for create windows */
604 Pixmap pm; /* tmp pixmap variable */
607 int x, final_x, final_y;
608 unsigned int pm_numcolors = 0; /* djhjr - 12/28/98 */
610 /* djhjr - 4/27/96 */
611 GetColorFromList(Scr->IconBorderColorL, tmp_win->full_name, &tmp_win->class,
612 &tmp_win->icon_border);
613 GetColorFromList(Scr->IconForegroundL, tmp_win->full_name, &tmp_win->class,
614 &tmp_win->iconc.fore);
615 GetColorFromList(Scr->IconBackgroundL, tmp_win->full_name, &tmp_win->class,
616 &tmp_win->iconc.back);
619 if (Scr->use3Diconmanagers && !Scr->BeNiceToColormap) GetShadeColors(&tmp_win->iconc);
621 /* was 'Scr->use3Dicons' - djhjr - 8/11/98 */
622 if (Scr->IconBevelWidth > 0 && !Scr->BeNiceToColormap) GetShadeColors(&tmp_win->iconc);
624 FB(tmp_win->iconc.fore, tmp_win->iconc.back);
626 tmp_win->forced = FALSE;
627 tmp_win->icon_not_ours = FALSE;
632 * now go through the steps to get an icon window, if ForceIcon is
633 * set, then no matter what else is defined, the bitmap from the
634 * .vtwmrc file is used
638 icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
639 if (icon_name == NULL)
640 icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
643 if (icon_name != NULL)
644 /* added background and XPM indicator - djhjr - 12/28/98 */
645 iconimage = GetIconImage(icon_name, tmp_win->iconc.back,
648 if (iconimage != NULL)
650 tmp_win->icon_width = iconimage->width;
651 tmp_win->icon_height = iconimage->height;
653 pm = iconimage->pixmap;
654 tmp_win->forced = TRUE;
659 * if the pixmap is still NULL, we didn't get one from the above code,
660 * that could mean that ForceIcon was not set, or that the window
661 * was not in the Icons list, now check the WM hints for an icon
663 if (pm == None && tmp_win->wmhints &&
664 tmp_win->wmhints->flags & IconPixmapHint)
667 XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap,
668 &JunkRoot, &JunkX, &JunkY,
669 (unsigned int *)&tmp_win->icon_width,
670 (unsigned int *)&tmp_win->icon_height, &JunkBW, &JunkDepth);
672 pm = XCreatePixmap(dpy, Scr->Root,
673 tmp_win->icon_width, tmp_win->icon_height,
676 XCopyPlane(dpy, tmp_win->wmhints->icon_pixmap, pm, Scr->NormalGC,
677 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
679 XFreePixmap(dpy, pm);
681 XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap,
682 &JunkRoot, &JunkX, &JunkY,
683 &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth);
685 pm_numcolors = 3; /* Submitted by Caveh Frank Jalali */
687 iconimage = (Image*)malloc(sizeof(Image));
688 iconimage->mask = None;
689 iconimage->width = JunkWidth;
690 iconimage->height = JunkHeight;
691 iconimage->pixmap = XCreatePixmap(dpy, Scr->Root, iconimage->width,
692 iconimage->height, Scr->d_depth);
694 if (JunkDepth == Scr->d_depth)
695 XCopyArea(dpy, tmp_win->wmhints->icon_pixmap, iconimage->pixmap,
696 Scr->NormalGC, 0, 0, iconimage->width, iconimage->height,
699 XCopyPlane(dpy, tmp_win->wmhints->icon_pixmap, iconimage->pixmap,
700 Scr->NormalGC, 0, 0, iconimage->width, iconimage->height,
703 if ((tmp_win->wmhints->flags & IconMaskHint) &&
704 XGetGeometry(dpy, tmp_win->wmhints->icon_mask,
705 &JunkRoot, &JunkX, &JunkY, &JunkWidth, &JunkHeight,
706 &JunkBW, &JunkDepth) &&
711 iconimage->mask = XCreatePixmap(dpy, Scr->Root,
712 JunkWidth, JunkHeight, 1);
715 gc = XCreateGC(dpy, iconimage->mask, 0, NULL);
718 XCopyArea(dpy, tmp_win->wmhints->icon_mask, iconimage->mask,
719 gc, 0, 0, JunkWidth, JunkHeight, 0, 0);
725 if (iconimage != NULL)
727 tmp_win->icon_width = iconimage->width;
728 tmp_win->icon_height = iconimage->height;
730 pm = iconimage->pixmap;
735 * if we still haven't got an icon, let's look in the Icon list
736 * if ForceIcon is not set
738 if (pm == None && !Scr->ForceIcon)
740 icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
741 if (icon_name == NULL)
742 icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
745 if (icon_name != NULL)
746 /* added background and XPM indicator - djhjr - 12/28/98 */
747 iconimage = GetIconImage(icon_name, tmp_win->iconc.back,
750 if (iconimage != NULL)
752 tmp_win->icon_width = iconimage->width;
753 tmp_win->icon_height = iconimage->height;
755 pm = iconimage->pixmap;
760 * if we still don't have an icon, assign the UnknownIcon
763 if (pm == None && Scr->UnknownPm != None)
765 tmp_win->icon_width = Scr->UnknownWidth;
766 tmp_win->icon_height = Scr->UnknownHeight;
768 pm = XCreatePixmap(dpy, Scr->Root, tmp_win->icon_width,
769 tmp_win->icon_height, Scr->d_depth);
771 * the copy plane works on color ! *
772 XCopyPlane(dpy, Scr->UnknownPm, pm, Scr->NormalGC,
773 0,0, tmp_win->icon_width, tmp_win->icon_height, 0, 0, 1 );
775 XFreePixmap(dpy, pm);
778 if (pm == None && Scr->unknownName != NULL)
780 /* added background and XPM indicator - djhjr - 12/28/98 */
781 iconimage = GetIconImage(Scr->unknownName, tmp_win->iconc.back,
784 if (iconimage != NULL)
786 tmp_win->icon_width = iconimage->width;
787 tmp_win->icon_height = iconimage->height;
789 pm = iconimage->pixmap;
795 tmp_win->icon_height = 0;
796 tmp_win->icon_width = 0;
801 valuemask = CWBackPixmap;
802 attributes.background_pixmap = pm;
804 /* djhjr - 12/28/98 */
805 if (pm_numcolors <= 2) /* not a pixmap */
807 valuemask |= CWBackPixel;
808 attributes.background_pixel = tmp_win->iconc.fore;
812 /* djhjr - 9/14/03 */
813 #ifndef NO_I18N_SUPPORT
814 tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont,
816 tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
818 tmp_win->icon_name, strlen(tmp_win->icon_name));
821 tmp_win->icon_w_width += 6;
822 if (tmp_win->icon_w_width < tmp_win->icon_width)
824 tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width)/2;
825 tmp_win->icon_x += 3;
826 tmp_win->icon_w_width = tmp_win->icon_width;
833 tmp_win->icon_w_width += 8;
834 if (tmp_win->icon_w_width < tmp_win->icon_width + 8)
836 tmp_win->icon_x = (((tmp_win->icon_width + 8) - tmp_win->icon_w_width)/2) + 4;
837 tmp_win->icon_w_width = tmp_win->icon_width + 8;
843 tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height;
845 tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height + 2;
848 tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 4;
851 tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 6;
853 tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 8;
856 if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)
858 tmp_win->icon_w = tmp_win->wmhints->icon_window;
859 if (tmp_win->forced ||
860 XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &JunkX, &JunkY,
861 (unsigned int *)&tmp_win->icon_w_width, (unsigned int *)&tmp_win->icon_w_height,
862 &JunkBW, &JunkDepth) == 0)
864 tmp_win->icon_w = None;
865 tmp_win->wmhints->flags &= ~IconWindowHint;
869 tmp_win->icon_not_ours = TRUE;
870 event_mask = EnterWindowMask | LeaveWindowMask;
875 tmp_win->icon_w = None;
879 /* was 'Scr->use3Dicons' and 'Scr->BorderBevelWidth' - djhjr - 8/11/98 */
880 if (Scr->IconBevelWidth > 0)
882 tmp_win->icon_w_width += 2 * Scr->IconBevelWidth;
883 tmp_win->icon_w_height += 2 * Scr->IconBevelWidth;
885 tmp_win->icon_x += Scr->IconBevelWidth;
886 tmp_win->icon_y += Scr->IconBevelWidth;
889 if (tmp_win->icon_w == None)
891 tmp_win->icon_w = XCreateSimpleWindow(dpy, Scr->Root,
893 tmp_win->icon_w_width, tmp_win->icon_w_height,
894 Scr->IconBorderWidth, tmp_win->icon_border, tmp_win->iconc.back);
895 event_mask = ExposureMask;
898 XSelectInput (dpy, tmp_win->icon_w,
899 KeyPressMask | ButtonPressMask | ButtonReleaseMask |
902 tmp_win->icon_bm_w = None;
904 (! (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)))
913 if (tmp_win->icon_w_width == tmp_win->icon_width)
916 x = (tmp_win->icon_w_width - tmp_win->icon_width)/2;
919 /* was 'Scr->use3Dicons' and 'Scr->BorderBevelWidth' - djhjr - 8/11/98 */
920 if (Scr->IconBevelWidth > 0)
921 y += Scr->IconBevelWidth;
923 tmp_win->icon_bm_w = XCreateWindow (dpy, tmp_win->icon_w, x, y,
924 (unsigned int)tmp_win->icon_width,
925 (unsigned int)tmp_win->icon_height,
926 (unsigned int) 0, Scr->d_depth,
927 (unsigned int) CopyFromParent,
928 Scr->d_visual, valuemask,
932 if (iconimage != NULL && iconimage->mask != None)
933 XShapeCombineMask(dpy,tmp_win->icon_bm_w , ShapeBounding, 0, 0,
934 iconimage->mask, ShapeSet);
937 /* I need to figure out where to put the icon window now, because
938 * getting here means that I am going to make the icon visible
940 if (tmp_win->wmhints &&
941 tmp_win->wmhints->flags & IconPositionHint)
943 final_x = tmp_win->wmhints->icon_x;
944 final_y = tmp_win->wmhints->icon_y;
948 PlaceIcon(tmp_win, def_x, def_y, &final_x, &final_y);
951 if (final_x > Scr->MyDisplayWidth)
952 final_x = Scr->MyDisplayWidth - tmp_win->icon_w_width -
953 (2 * Scr->IconBorderWidth);
955 if (final_y > Scr->MyDisplayHeight)
956 final_y = Scr->MyDisplayHeight - tmp_win->icon_height -
957 Scr->IconFont.height - 4 - (2 * Scr->IconBorderWidth);
959 XMoveWindow(dpy, tmp_win->icon_w, final_x, final_y);
960 tmp_win->iconified = TRUE;
962 XMapSubwindows(dpy, tmp_win->icon_w);
963 XSaveContext(dpy, tmp_win->icon_w, TwmContext, (caddr_t)tmp_win);
964 XSaveContext(dpy, tmp_win->icon_w, ScreenContext, (caddr_t)Scr);
965 XDefineCursor(dpy, tmp_win->icon_w, Scr->IconCursor);
969 #endif /* ORIGINAL_PIXMAPS */