*** xpbiff.c.org Tue Nov 3 15:49:43 1998 --- xpbiff.c Mon Nov 9 11:30:47 1998 *************** *** 70,79 **** #include #include #include #ifndef min #define min(x,y) ((x) < (y)? (x): (y)) #endif - #endif /* SUN_AUDIO */ #ifndef X11R3 #include --- 70,83 ---- #include #include #include + #endif /* SUN_AUDIO */ + + #ifndef max + #define max(x,y) ((x) > (y)? (x): (y)) + #endif #ifndef min #define min(x,y) ((x) < (y)? (x): (y)) #endif #ifndef X11R3 #include *************** *** 299,304 **** --- 303,310 ---- Boolean Raise; Boolean stay_raised; Boolean animate; + Boolean center; + Boolean closeColors; Boolean popup; Boolean bell; Boolean popdown; *************** *** 382,387 **** --- 388,397 ---- (Cardinal)&stay_raised, XtRImmediate, (XtPointer)False}, {"animate", "Animate", XtRBoolean, sizeof(Boolean), (Cardinal)&animate, XtRImmediate, (XtPointer)True}, + {"center", "Center", XtRBoolean, sizeof(Boolean), + (Cardinal)¢er, XtRImmediate, (XtPointer)False}, + {"closeColors", "CloseColors", XtRBoolean, sizeof(Boolean), + (Cardinal)&closeColors, XtRImmediate, (XtPointer)True}, {"popup", "Popup", XtRBoolean, sizeof(Boolean), (Cardinal)&popup, XtRImmediate, (XtPointer)True}, {"popupTime", "PopupTime", XtRInt, sizeof(int), *************** *** 435,440 **** --- 445,454 ---- {"-raise", "*raise", XrmoptionNoArg, "true"}, {"-noraise", "*raise", XrmoptionNoArg, "false"}, {"-keepup", "*stayRaised", XrmoptionNoArg, "true"}, + {"-center", "*center", XrmoptionNoArg, "true"}, + {"-nocenter", "*center", XrmoptionNoArg, "false"}, + {"-closecolors", "*closeColors", XrmoptionNoArg, "true"}, + {"-noclosecolors", "*closeColors", XrmoptionNoArg, "false"}, {"-popup", "*popup", XrmoptionNoArg, "true"}, {"-nopopup", "*popup", XrmoptionNoArg, "false"}, {"-animate", "*animate", XrmoptionNoArg, "true"}, *************** *** 512,517 **** --- 526,532 ---- static char *overrideTranslations = ": expose() \n\ : expose() \n\ + : expose() \n\ : select()"; int dummy; *************** *** 631,636 **** --- 646,655 ---- fprintf(stderr, " [-polling_time time(msec)]\n"); #endif fprintf(stderr, " [-noraise]\n"); + fprintf(stderr, " [-center]\n"); + fprintf(stderr, " [-nocenter]\n"); + fprintf(stderr, " [-closecolors]\n"); + fprintf(stderr, " [-noclosecolors]\n"); fprintf(stderr, " [-nopopup]\n"); fprintf(stderr, " [-animate]\n"); fprintf(stderr, " [-noanimate]\n"); *************** *** 727,735 **** } i = 0; ! XtSetArg(args[i], XtNwidth, noPinfo.width); i++; ! XtSetArg(args[i], XtNheight, noPinfo.height); i++; XtSetValues(biff, args, i); --- 746,754 ---- } i = 0; ! XtSetArg(args[i], XtNwidth, (center!=True)?noPinfo.width:(max(noPinfo.width,arrivePinfo.width))); i++; ! XtSetArg(args[i], XtNheight, (center!=True)?noPinfo.height:(max(noPinfo.height,arrivePinfo.height))); i++; XtSetValues(biff, args, i); *************** *** 840,898 **** void redraw_window() { if (current_status == ARRIVE) { if (arrivePinfo.depth == 1) XCopyPlane(XtDisplay(toplevel), arrivePinfo.pixmap, XtWindow(biff), gcArrive, ! 0, 0, arrivePinfo.width, arrivePinfo.height, 0, 0, 1); else XCopyArea(XtDisplay(toplevel), arrivePinfo.pixmap, XtWindow(biff), gcArrive, ! 0, 0, arrivePinfo.width, arrivePinfo.height, 0, 0); } else { if (noPinfo.depth == 1) XCopyPlane(XtDisplay(toplevel), noPinfo.pixmap, XtWindow(biff), gcNo, ! 0, 0, noPinfo.width, noPinfo.height, 0, 0, 1); else XCopyArea(XtDisplay(toplevel), noPinfo.pixmap, XtWindow(biff), ! gcNo, 0, 0, noPinfo.width, noPinfo.height, 0, 0); } } #ifdef SHAPE void shape_window() { if (shape == True) { if (current_status == ARRIVE) { if (arrivePinfo.mask == None) { XRectangle rect; rect.x = rect.y = 0; rect.width = arrivePinfo.width; rect.height = arrivePinfo.height; XShapeCombineRectangles(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, 0, 0, &rect, 1, ShapeSet, 0); } else XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, 0, 0, arrivePinfo.mask, ShapeSet); } else { if (noPinfo.mask == None) { XRectangle rect; rect.x = rect.y = 0; rect.width = noPinfo.width; rect.height = noPinfo.height; XShapeCombineRectangles(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, 0, 0, &rect, 1, ShapeSet, 0); } else XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, 0, 0, noPinfo.mask, ShapeSet); } } --- 859,962 ---- void redraw_window() { + Window root; + int x, y, width, height, border, depth; + + if (center == True) + XGetGeometry(XtDisplay(toplevel), XtWindow(biff), &root, + &x, &y, &width, &height, &border, &depth); + if (current_status == ARRIVE) { + if (center != True) { + x = 0; + y = 0; + } else { + x = (width-arrivePinfo.width)/2; + y = (height-arrivePinfo.height)/2; + XClearWindow(XtDisplay(toplevel), XtWindow(biff)); + } if (arrivePinfo.depth == 1) XCopyPlane(XtDisplay(toplevel), arrivePinfo.pixmap, XtWindow(biff), gcArrive, ! 0, 0, arrivePinfo.width, arrivePinfo.height, x, y, 1); else XCopyArea(XtDisplay(toplevel), arrivePinfo.pixmap, XtWindow(biff), gcArrive, ! 0, 0, arrivePinfo.width, arrivePinfo.height, x, y); } else { + if (center != True) { + x = 0; + y = 0; + } else { + x = (width-noPinfo.width)/2; + y = (height-noPinfo.height)/2; + XClearWindow(XtDisplay(toplevel), XtWindow(biff)); + } if (noPinfo.depth == 1) XCopyPlane(XtDisplay(toplevel), noPinfo.pixmap, XtWindow(biff), gcNo, ! 0, 0, noPinfo.width, noPinfo.height, x, y, 1); else XCopyArea(XtDisplay(toplevel), noPinfo.pixmap, XtWindow(biff), ! gcNo, ! 0, 0, noPinfo.width, noPinfo.height, x, y); } } #ifdef SHAPE void shape_window() { + Window root; + int x, y, width, height, border, depth; + + if (center == True) + XGetGeometry(XtDisplay(toplevel), XtWindow(biff), &root, + &x, &y, &width, &height, &border, &depth); + if (shape == True) { if (current_status == ARRIVE) { + if (center != True) { + x = 0; + y = 0; + } else { + x = (width-arrivePinfo.width)/2; + y = (height-arrivePinfo.height)/2; + } if (arrivePinfo.mask == None) { XRectangle rect; rect.x = rect.y = 0; rect.width = arrivePinfo.width; rect.height = arrivePinfo.height; XShapeCombineRectangles(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, x, y, &rect, 1, ShapeSet, 0); } else XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, x, y, arrivePinfo.mask, ShapeSet); } else { + if (center != True) { + x = 0; + y = 0; + } else { + x = (width-noPinfo.width)/2; + y = (height-noPinfo.height)/2; + } if (noPinfo.mask == None) { XRectangle rect; rect.x = rect.y = 0; rect.width = noPinfo.width; rect.height = noPinfo.height; XShapeCombineRectangles(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, x, y, &rect, 1, ShapeSet, 0); } else XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, x, y, noPinfo.mask, ShapeSet); } } *************** *** 955,960 **** --- 1019,1029 ---- xpm_attr.valuemask |= XpmColorKey; xpm_attr.color_key = XPM_MONO; } + + if (closeColors) { + xpm_attr.valuemask |= XpmCloseness; + xpm_attr.closeness = 40000; + } if(XpmReadFileToPixmap(XtDisplay(toplevel), XRootWindowOfScreen(XtScreen(toplevel)), *************** *** 1032,1039 **** mail_size = file_stat.st_size; if (popup == True) mail_header = GetMailHeader(); ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); if (Raise == True) XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); if (animate == True) --- 1101,1112 ---- mail_size = file_stat.st_size; if (popup == True) mail_header = GetMailHeader(); ! if ((noPinfo.width != arrivePinfo.width ! || (noPinfo.height != arrivePinfo.height)) ! && center != True) { ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); ! } if (Raise == True) XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); if (animate == True) *************** *** 1056,1063 **** /* more come! only ringing bell. */ if (popup == True) BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); if (Raise == True) XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); if (animate == True) --- 1129,1140 ---- /* more come! only ringing bell. */ if (popup == True) BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); ! if ((noPinfo.width != arrivePinfo.width ! || (noPinfo.height != arrivePinfo.height)) ! && center != True) { ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); ! } if (Raise == True) XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); if (animate == True) *************** *** 1083,1090 **** /* No mail */ if (current_status == ARRIVE) { current_status = NO; ! XtResizeWidget(toplevel, noPinfo.width, noPinfo.height, 1); ! XtResizeWidget(biff, noPinfo.width, noPinfo.height, 0); redraw_window(); #ifdef SHAPE shape_window(); --- 1160,1171 ---- /* No mail */ if (current_status == ARRIVE) { current_status = NO; ! if ((noPinfo.width != arrivePinfo.width ! || (noPinfo.height != arrivePinfo.height)) ! && center != True) { ! XtResizeWidget(toplevel, noPinfo.width, noPinfo.height, 1); ! XtResizeWidget(biff, noPinfo.width, noPinfo.height, 0); ! } redraw_window(); #ifdef SHAPE shape_window(); *************** *** 1109,1114 **** --- 1190,1208 ---- XPoint points[4]; double r, angle, t1, t2, t3, t4; + Window root; + int x, y, width, height, border, depth; + + if (center == True) { + XGetGeometry(XtDisplay(toplevel), XtWindow(biff), &root, + &x, &y, &width, &height, &border, &depth); + x = (width-arrivePinfo.width)/2; + y = (height-arrivePinfo.height)/2; + } else { + x = 0; + y = 0; + } + #ifdef SHAPE if(shape == True) { XRectangle rect; *************** *** 1116,1122 **** rect.width = arrivePinfo.width; rect.height = arrivePinfo.height; XShapeCombineRectangles(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, 0, 0, &rect, 1, ShapeSet, 0); } #endif --- 1210,1216 ---- rect.width = arrivePinfo.width; rect.height = arrivePinfo.height; XShapeCombineRectangles(XtDisplay(toplevel), XtWindow(toplevel), ! ShapeBounding, x, y, &rect, 1, ShapeSet, 0); } #endif *************** *** 1139,1145 **** XFillRectangle(XtDisplay(toplevel), workPixmap, gcAnimateBack, 0, 0, arrivePinfo.width, arrivePinfo.height); XFillPolygon(XtDisplay(toplevel), workPixmap, gcAnimate, points, 4, Convex, CoordModeOrigin); ! XCopyArea(XtDisplay(toplevel), workPixmap, XtWindow(biff), gcAnimate, 0, 0, arrivePinfo.width, arrivePinfo.height, 0, 0); } } --- 1233,1239 ---- XFillRectangle(XtDisplay(toplevel), workPixmap, gcAnimateBack, 0, 0, arrivePinfo.width, arrivePinfo.height); XFillPolygon(XtDisplay(toplevel), workPixmap, gcAnimate, points, 4, Convex, CoordModeOrigin); ! XCopyArea(XtDisplay(toplevel), workPixmap, XtWindow(biff), gcAnimate, 0, 0, arrivePinfo.width, arrivePinfo.height, x, y); } } *************** *** 1251,1258 **** mail_size = file_stat.st_size; if (popup == True) mail_header = GetMailHeader(); ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); if (Raise == True) XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); if (animate == True) --- 1345,1356 ---- mail_size = file_stat.st_size; if (popup == True) mail_header = GetMailHeader(); ! if ((noPinfo.width != arrivePinfo.width ! || (noPinfo.height != arrivePinfo.height)) ! && center != True) { ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); ! } if (Raise == True) XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); if (animate == True) *************** *** 2017,2024 **** } current_status = ARRIVE; ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); if (popup == True) { BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); } --- 2115,2126 ---- } current_status = ARRIVE; ! if ((noPinfo.width != arrivePinfo.width ! || (noPinfo.height != arrivePinfo.height)) ! && center != True) { ! XtResizeWidget(toplevel, arrivePinfo.width, arrivePinfo.height, 1); ! XtResizeWidget(biff, arrivePinfo.width, arrivePinfo.height, 0); ! } if (popup == True) { BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); } *************** *** 2048,2056 **** } else if (mail_size < saved_mail_size){ /* No mail */ current_status = NO; ! XtResizeWidget(toplevel, noPinfo.width, noPinfo.height, 1); ! XtResizeWidget(biff, noPinfo.width, noPinfo.height, 0); ! redraw_window(); #ifdef SHAPE shape_window(); --- 2150,2161 ---- } else if (mail_size < saved_mail_size){ /* No mail */ current_status = NO; ! if ((noPinfo.width != arrivePinfo.width ! || (noPinfo.height != arrivePinfo.height)) ! && center != True) { ! XtResizeWidget(toplevel, noPinfo.width, noPinfo.height, 1); ! XtResizeWidget(biff, noPinfo.width, noPinfo.height, 0); ! } redraw_window(); #ifdef SHAPE shape_window();