Lines Matching defs:icon
51 static void ReshapeIcon(Icon *icon);
53 static Image *LookupIconNameOrClass(TwmWindow *tmp_win, Icon *icon,
209 * Figure out where to put a window's icon based on the IconRegion
212 * location in final_[xy], and also sets the IconRegion in tmp_win->icon
223 const int iconWidth = tmp_win->icon->border_width * 2
224 + (Scr->ShrinkIconTitles ? tmp_win->icon->width
225 : tmp_win->icon->w_width);
226 const int iconHeight = tmp_win->icon->border_width * 2
227 + tmp_win->icon->w_height;
238 * size, based on the icon's side itself and the grid for
287 oldir = tmp_win->icon->ir;
342 /* Tell the win/icon what region it's in, and the entry what's in it */
343 tmp_win->icon->ir = ir;
351 tmp_win->icon->ir = NULL;
357 if(Scr->ShrinkIconTitles && tmp_win->icon->has_title) {
358 *final_x -= GetIconOffset(tmp_win->icon);
359 if(tmp_win->icon->ir != oldir) {
360 ReshapeIcon(tmp_win->icon);
369 * Look up an IconEntry holding the icon for a given window, and
436 * Next, the bits related to creating and putting together the icon
444 * Create the window scaffolding for an icon. Called when we need to
455 Icon *icon;
459 icon = malloc(sizeof(struct Icon));
461 icon->otp = NULL;
462 icon->border = Scr->IconBorderColor;
463 icon->iconc.fore = Scr->IconC.fore;
464 icon->iconc.back = Scr->IconC.back;
465 icon->title_shrunk = false;
468 &icon->border);
470 &icon->iconc.fore);
472 &icon->iconc.back);
474 GetShadeColors(&icon->iconc);
477 FB(icon->iconc.fore, icon->iconc.back);
479 icon->match = match_none;
480 icon->image = NULL;
481 icon->ir = NULL;
484 icon->w_not_ours = false;
488 /* now go through the steps to get an icon window, if ForceIcon is
493 image = LookupIconNameOrClass(tmp_win, icon, &pattern);
498 * Look to see if there is a _NET_WM_ICON property to provide an icon.
503 icon->match = match_net_wm_icon;
504 icon->width = image->width;
505 icon->height = image->height;
506 icon->image = image;
513 * was not in the Icons list, now check the WM hints for an icon
532 icon->width = image->width;
533 icon->height = image->height;
534 icon->match = match_icon_pixmap_hint;
552 icon->image = image;
556 /* if we still haven't got an icon, let's look in the Icon list
560 image = LookupIconNameOrClass(tmp_win, icon, &pattern);
563 /* if we still don't have an icon, assign the UnknownIcon */
566 icon->match = match_unknown_default;
567 icon->width = image->width;
568 icon->height = image->height;
569 icon->image = image;
573 icon->height = 0;
574 icon->width = 0;
582 icon->border_width = Scr->IconBorderWidth;
586 icon->w_width = icon->width;
587 icon->w_height = icon->height;
588 icon->x = 0;
589 icon->y = 0;
590 icon->has_title = false;
599 icon->w_width = logical_rect.width;
601 icon->w_width += 2 * (Scr->IconManagerShadowDepth + ICON_MGR_IBORDER);
602 if(icon->w_width > Scr->MaxIconTitleWidth) {
603 icon->w_width = Scr->MaxIconTitleWidth;
605 if(icon->w_width < icon->width) {
606 icon->x = (icon->width - icon->w_width) / 2;
607 icon->x += Scr->IconManagerShadowDepth + ICON_MGR_IBORDER;
608 icon->w_width = icon->width;
611 icon->x = Scr->IconManagerShadowDepth + ICON_MGR_IBORDER;
613 icon->y = icon->height + Scr->IconFont.height + Scr->IconManagerShadowDepth;
614 icon->w_height = icon->height + Scr->IconFont.height +
616 icon->has_title = true;
617 if(icon->height) {
618 icon->border_width = 0;
624 icon->w = tmp_win->wmhints->icon_window;
626 XGetGeometry(dpy, icon->w, &JunkRoot, &JunkX, &JunkY,
627 (unsigned int *)&icon->w_width, (unsigned int *)&icon->w_height,
629 icon->w = None;
634 icon->w_not_ours = true;
635 icon->width = icon->w_width;
636 icon->height = icon->w_height;
637 icon->image = image;
638 icon->has_title = false;
643 icon->w = None;
649 icon->border_width = 0;
651 if(icon->w == None) {
652 icon->w = XCreateSimpleWindow(dpy, Scr->Root,
654 icon->w_width, icon->w_height,
655 icon->border_width, icon->border, icon->iconc.back);
664 if(icon->w_not_ours) {
667 XGetWindowAttributes(dpy, icon->w, &wattr);
672 XSelectInput(dpy, icon->w, event_mask);
674 if(icon->width == 0) {
675 icon->width = icon->w_width;
677 icon->bm_w = None;
681 x = GetIconOffset(icon);
682 icon->bm_w = XCreateWindow(dpy, icon->w, x, 0,
683 icon->width,
684 icon->height,
690 XShapeCombineMask(dpy, icon->bm_w, ShapeBounding, 0, 0, image->mask, ShapeSet);
691 XShapeCombineMask(dpy, icon->w, ShapeBounding, x, 0, image->mask, ShapeSet);
693 else if(icon->has_title) {
696 rect.width = icon->width;
697 rect.height = icon->height;
698 XShapeCombineRectangles(dpy, icon->w, ShapeBounding,
701 if(icon->has_title) {
704 rect.y = icon->height;
705 rect.width = icon->width;
706 rect.height = icon->w_height - icon->height;
707 icon->title_shrunk = true;
711 rect.y = icon->height;
712 rect.width = icon->w_width;
713 rect.height = icon->w_height - icon->height;
714 icon->title_shrunk = false;
716 XShapeCombineRectangles(dpy, icon->w, ShapeBounding,
722 AddToList(&tmp_win->iconslist, pattern, icon);
725 tmp_win->icon = icon;
726 /* I need to figure out where to put the icon window now, because
727 * getting here means that I am going to make the icon visible
742 final_x = Scr->rootw - icon->w_width - (2 * Scr->IconBorderWidth);
744 if(Scr->ShrinkIconTitles && icon->bm_w) {
745 if(final_x + (icon->w_width - icon->width) < 0) {
755 final_y = Scr->rooth - icon->height -
761 XMoveWindow(dpy, icon->w, final_x, final_y);
762 icon->w_x = final_x;
763 icon->w_y = final_y;
768 XMapSubwindows(dpy, icon->w);
769 XSaveContext(dpy, icon->w, TwmContext, (XPointer)tmp_win);
770 XSaveContext(dpy, icon->w, ScreenContext, (XPointer)Scr);
771 XDefineCursor(dpy, icon->w, Scr->IconCursor);
778 * Call it before deleting TwmWindow.icon, since we need to check
797 Icon *icon = (Icon *)nptr->ptr;
798 if(icon != tmp_win->icon) {
799 DeleteIcon(icon);
814 DeleteIcon(Icon *icon)
816 if(icon->w && !icon->w_not_ours) {
817 XDestroyWindow(dpy, icon->w);
819 ReleaseIconImage(icon);
820 free(icon);
825 * Delete the Image from an icon, if it is not a shared one. match_list
831 ReleaseIconImage(Icon *icon)
833 if(icon->match == match_icon_pixmap_hint ||
834 icon->match == match_net_wm_icon) {
835 FreeImage(icon->image);
845 * Bringing an icon up or down.
852 * Show up an icon. Note that neither IconUp nor IconDown actually map
853 * or unmap the icon window; that's handled by the callers. These
867 * icon region.
877 if(!XGetGeometry(dpy, tmp_win->icon->w, &JunkRoot, &defx, &defy,
892 return; /* outside icon regions, leave alone */
900 XMoveWindow(dpy, tmp_win->icon->w, x, y);
901 tmp_win->icon->w_x = x;
902 tmp_win->icon->w_y = y;
911 * Remove an icon from its displayed IconEntry. x-ref comment on
957 * Funcs related to drawing the icon.
964 * Slightly misnamed: draws the text label under an icon.
970 Icon *icon;
974 if(!tmp_win || !tmp_win->icon) {
977 icon = tmp_win->icon;
978 if(!icon->has_title) {
983 width = icon->w_width;
984 if(Scr->ShrinkIconTitles && icon->title_shrunk) {
985 x = GetIconOffset(icon);
986 width = icon->width;
995 Draw3DBorder(icon->w, x, icon->height, width,
998 Scr->IconManagerShadowDepth, icon->iconc, off, false, false);
1007 FB(icon->iconc.fore, icon->iconc.back);
1008 XmbDrawString(dpy, icon->w, Scr->IconFont.font_set, Scr->NormalGC,
1011 icon->y, tmp_win->icon_name, len);
1023 Icon *icon;
1026 if(!tmp_win || !tmp_win->icon) {
1029 icon = tmp_win->icon;
1030 if(!icon->has_title) {
1033 if(icon->w_width == icon->width) {
1036 if(icon->height == 0) {
1040 rect.x = GetIconOffset(icon);
1042 rect.width = icon->width;
1043 rect.height = icon->w_height;
1044 XShapeCombineRectangles(dpy, icon->w, ShapeBounding, 0, 0, &rect, 1,
1046 icon->title_shrunk = true;
1047 XClearArea(dpy, icon->w, 0, icon->height, icon->w_width,
1048 icon->w_height - icon->height, True);
1055 Icon *icon;
1058 if(!tmp_win || !tmp_win->icon) {
1061 icon = tmp_win->icon;
1062 if(!icon->has_title) {
1065 if(icon->w_width == icon->width) {
1068 if(icon->height == 0) {
1073 rect.y = icon->height;
1074 rect.width = icon->w_width;
1075 rect.height = icon->w_height - icon->height;
1076 XShapeCombineRectangles(dpy, icon->w, ShapeBounding, 0, 0, &rect, 1, ShapeUnion,
1078 icon->title_shrunk = false;
1079 XClearArea(dpy, icon->w, 0, icon->height, icon->w_width,
1080 icon->w_height - icon->height, True);
1091 ReshapeIcon(Icon *icon)
1096 if(!icon) {
1099 x = GetIconOffset(icon);
1100 XMoveWindow(dpy, icon->bm_w, x, 0);
1102 if(icon->image && icon->image->mask) {
1103 XShapeCombineMask(dpy, icon->w, ShapeBounding, x, 0, icon->image->mask,
1109 rect.width = icon->width;
1110 rect.height = icon->height;
1111 XShapeCombineRectangles(dpy, icon->w, ShapeBounding, 0, 0, &rect, 1, ShapeSet,
1115 rect.y = icon->height;
1116 rect.width = icon->width;
1117 rect.height = icon->w_height - icon->height;
1118 XShapeCombineRectangles(dpy, icon->w, ShapeBounding, 0, 0, &rect, 1, ShapeUnion,
1124 * Figure horizontal positioning/offset for the icon image within its
1128 GetIconOffset(Icon *icon)
1132 if(!icon) {
1136 justif = icon->ir ? icon->ir->TitleJustification : Scr->IconJustification;
1142 return ((icon->w_width - icon->width) / 2);
1145 return (icon->w_width - icon->width);
1157 * [Re-]lookup the image for an icon and [re-]layout it.
1162 Icon *icon, *old_icon;
1165 old_icon = win->icon;
1171 icon = NULL;
1173 icon = LookInNameList(win->iconslist, pattern);
1176 icon = LookInNameList(win->iconslist, pattern);
1180 icon = LookInNameList(win->iconslist, pattern);
1186 if(icon != NULL) {
1187 if(old_icon == icon) {
1196 win->icon = icon;
1200 XMapWindow(dpy, win->icon->w);
1203 win->icon = icon;
1215 * If the icon name/class was found on one of the above lists,
1227 XMapWindow(dpy, win->icon->w);
1231 win->icon = NULL;
1240 * Resize the icon window, and reposition the image and name within it.
1265 if(!win->icon || !win->icon->w) {
1270 if(win->icon->w_not_ours) {
1278 win->icon->w_width = logical_rect.width;
1279 win->icon->w_width += 2 * (Scr->IconManagerShadowDepth + ICON_MGR_IBORDER);
1280 if(win->icon->w_width > Scr->MaxIconTitleWidth) {
1281 win->icon->w_width = Scr->MaxIconTitleWidth;
1284 if(win->icon->w_width < win->icon->width) {
1285 win->icon->x = (win->icon->width - win->icon->w_width) / 2;
1286 win->icon->x += Scr->IconManagerShadowDepth + ICON_MGR_IBORDER;
1287 win->icon->w_width = win->icon->width;
1290 win->icon->x = Scr->IconManagerShadowDepth + ICON_MGR_IBORDER;
1293 x = GetIconOffset(win->icon);
1294 win->icon->y = win->icon->height + Scr->IconFont.height +
1296 win->icon->w_height = win->icon->height + Scr->IconFont.height +
1299 XResizeWindow(dpy, win->icon->w, win->icon->w_width,
1300 win->icon->w_height);
1301 if(win->icon->bm_w) {
1304 XMoveWindow(dpy, win->icon->bm_w, x, 0);
1305 XMapWindow(dpy, win->icon->bm_w);
1306 if(win->icon->image && win->icon->image->mask) {
1307 XShapeCombineMask(dpy, win->icon->bm_w, ShapeBounding, 0, 0,
1308 win->icon->image->mask, ShapeSet);
1309 XShapeCombineMask(dpy, win->icon->w, ShapeBounding, x, 0,
1310 win->icon->image->mask, ShapeSet);
1312 else if(win->icon->has_title) {
1315 rect.width = win->icon->width;
1316 rect.height = win->icon->height;
1317 XShapeCombineRectangles(dpy, win->icon->w, ShapeBounding,
1320 if(win->icon->has_title) {
1321 if(Scr->ShrinkIconTitles && win->icon->title_shrunk) {
1323 rect.y = win->icon->height;
1324 rect.width = win->icon->width;
1325 rect.height = win->icon->w_height - win->icon->height;
1329 rect.y = win->icon->height;
1330 rect.width = win->icon->w_width;
1331 rect.height = win->icon->w_height - win->icon->height;
1333 XShapeCombineRectangles(dpy, win->icon->w, ShapeBounding, 0,
1338 win->icon->title_shrunk &&
1344 XClearArea(dpy, win->icon->w, 0, 0, 0, 0, True);
1374 * image, record its provenance inside *icon, and pass back what pattern
1378 LookupIconNameOrClass(TwmWindow *tmp_win, Icon *icon, char **pattern)
1407 if((image = GetImage(icon_name, icon->iconc)) != NULL) {
1408 icon->match = matched;
1409 icon->image = image;
1410 icon->width = image->width;
1411 icon->height = image->height;
1415 icon->match = match_none;