*** FvwmTaskBar.c.old Thu Jun 26 07:57:20 1997 --- FvwmTaskBar.c Thu Jun 19 12:41:36 1997 *************** *** 147,154 **** Colormap PictureCMap; ! char *IconPath = NULL, ! *PixmapPath = NULL; /****************************************************************************** Main - Setup the XConnection,request the window list and loop forever --- 147,154 ---- Colormap PictureCMap; ! char *IconPath = FVWM_ICONDIR, ! *PixmapPath = FVWM_ICONDIR; /****************************************************************************** Main - Setup the XConnection,request the window list and loop forever *************** *** 483,489 **** RemoveButton(&buttons, buttons.head->count); for (item=windows.head; item; item=item->next) ! if (DeskNumber == item->Desk || (item->flags & STICKY)) AddButton(&buttons, item->name, &(item->p), BUTTON_UP, item->count); RedrawWindow(1); --- 483,490 ---- RemoveButton(&buttons, buttons.head->count); for (item=windows.head; item; item=item->next) ! if (DeskNumber == item->Desk || ((item->flags & STICKY) && ! !(item->flags & ICONIFIED))) AddButton(&buttons, item->name, &(item->p), BUTTON_UP, item->count); RedrawWindow(1); *************** *** 647,653 **** else if(strncasecmp(tline,CatString3(Module, "AutoStick",""), Clength+9)==0) AutoStick=True; else if(strncasecmp(tline,CatString3(Module, "AutoHide",""), ! Clength+4)==0) { AutoHide=True; AutoStick=True; } else if(strncasecmp(tline,CatString3(Module, "UseIconNames",""), Clength+12)==0) UseIconNames=True; else if(strncasecmp(tline,CatString3(Module, "ShowTransients",""), --- 648,654 ---- else if(strncasecmp(tline,CatString3(Module, "AutoStick",""), Clength+9)==0) AutoStick=True; else if(strncasecmp(tline,CatString3(Module, "AutoHide",""), ! Clength+8)==0) { AutoHide=True; AutoStick=True; } else if(strncasecmp(tline,CatString3(Module, "UseIconNames",""), Clength+12)==0) UseIconNames=True; else if(strncasecmp(tline,CatString3(Module, "ShowTransients",""), *************** *** 663,669 **** Clength+13)==0) { /* tell fvwm to launch the module for us */ ! str = safemalloc(strlen(&tline[Clength+13]) + 6); sprintf(str, "Module %s",&tline[Clength+13]); ConsoleMessage("Trying to: %s", str); SendFvwmPipe(str, 0); --- 664,670 ---- Clength+13)==0) { /* tell fvwm to launch the module for us */ ! str = safemalloc(strlen(&tline[Clength+13]) + 8); sprintf(str, "Module %s",&tline[Clength+13]); ConsoleMessage("Trying to: %s", str); SendFvwmPipe(str, 0); *************** *** 835,840 **** --- 836,844 ---- XEvent Event; int x, x1, y, y1, redraw; static unsigned long lasttime = 0L; + #if 1 /* beynon */ + Time time = 0L; + #endif /* beynon */ while(XPending(dpy)) { redraw = -1; *************** *** 856,861 **** --- 860,868 ---- if (num != -1) SendFvwmPipe("Focus 0", ItemID(&windows, num)); } ButPressed = -1; + #if 1 /* beynon */ + time = Event.xbutton.time; + #endif /* beynon */ break; case ButtonPress: *************** *** 890,895 **** --- 897,905 ---- } */ redraw = 0; + #if 1 /* beynon */ + time = Event.xbutton.time; + #endif /* beynon */ break; case Expose: *************** *** 898,908 **** --- 908,924 ---- redraw = 0; else redraw = 1; + #if 1 /* beynon */ + /* time = ; */ + #endif /* beynon */ break; case ClientMessage: if ((Event.xclient.format==32) && (Event.xclient.data.l[0]==wm_del_win)) ShutMeDown(0); + #if 1 /* beynon */ + /* time = ; */ + #endif /* beynon */ break; case EnterNotify: *************** *** 924,931 **** if (num != -1 && num != ButPressed) SendFvwmPipe("Focus 0", ItemID(&windows, num)); } ! ! CheckForTip(Event.xmotion.x, Event.xmotion.y); break; case LeaveNotify: --- 940,951 ---- if (num != -1 && num != ButPressed) SendFvwmPipe("Focus 0", ItemID(&windows, num)); } ! #if 1 /* beynon */ ! CheckForTip(Event.xcrossing.x, Event.xcrossing.y); ! time = Event.xcrossing.time; ! #else /* beynon */ ! CheckForTip(Event.xmotion.x, Event.xmotion.y); ! #endif /* beynon */ break; case LeaveNotify: *************** *** 951,956 **** --- 971,979 ---- } } } + #if 1 /* beynon */ + time = Event.xcrossing.time; + #endif /* beynon */ break; case MotionNotify: *************** *** 972,977 **** --- 995,1003 ---- } CheckForTip(Event.xmotion.x, Event.xmotion.y); + #if 1 /* beynon */ + time = Event.xmotion.time; + #endif /* beynon */ break; case ConfigureNotify: *************** *** 989,1002 **** win_y = Event.xconfigure.y; } } break; } if (redraw >= 0) RedrawWindow(redraw); ! if (Event.xkey.time - lasttime > UpdateInterval*1000L) { DrawGoodies(); ! lasttime = Event.xkey.time; } } --- 1015,1031 ---- win_y = Event.xconfigure.y; } } + #if 1 /* beynon */ + /* time = ; */ + #endif /* beynon */ break; } if (redraw >= 0) RedrawWindow(redraw); ! if (time - lasttime > UpdateInterval*1000L) { DrawGoodies(); ! lasttime = time; } } *** FvwmTaskBar.man.old Thu Jun 26 07:57:41 1997 --- FvwmTaskBar.man Thu Apr 3 07:46:06 1997 *************** *** 166,171 **** --- 166,184 ---- .IP "*FvwmTaskBarIgnoreOldMail" If set, draw no bitmap if there is no new mail. + .IP "*FvwmTaskBarAutoMailTip \fI[type]\fP" + This option controls the auto-display of new mail in a multi-line + tip window. Three possible values are allowed for the optional + type argument: MailFileTouched, MailFileBigger, or MailFileAnyChange. + MailFileTouched means the mail spool file has been modified since + the last access, MailFileBigger is when the mail spool file gets + larger in size, and MailFileAnyChange is when the mail spool file + gets larger or smaller. These conditions control when the AutoMailTip + window is displayed. The default is MailFileAnyChange. + + .IP "*FvwmTaskBarMailTipUnblankScreen" + If set, the screen will be un-blanked when the mail tip is drawn. + .SH "" The following options deal with the Start button at the left of the taskbar: *** Goodies.c.old Thu Jun 26 07:58:00 1997 --- Goodies.c Thu May 8 09:39:55 1997 *************** *** 36,41 **** --- 36,57 ---- int BellVolume = DEFAULT_BELL_VOLUME; Pixmap mailpix, wmailpix, pmask, pclip; int NoMailCheck = False; + + #if 1 /* beynon */ + char *GetMailHeaders(void); + + char *MailBuf = NULL; + MailHdr_S *MailHdr = NULL, *MailHdr_tail; + int MailHdrSize = 0; + int AutoMailTip = False; + int MailTipUnblankScreen = False; + enum { eAnyChange, eBigger, eTouched } AutoMailTip_Type; + int mailchanged; + + char *NewMailCmd = "", + *HourlyCmd = ""; + #endif /* beynon */ + char *DateFore = "black", *DateBack = "LightYellow", *MailCmd = "Exec xterm -e mail"; *************** *** 50,57 **** --- 66,78 ---- #define gray_height 8 extern unsigned char gray_bits[]; + #if 1 /* beynon */ + /* x y w h tw th open type *text win **lines nlines free */ + TipStruct Tip = { 0, 0, 0, 0, 0, 0, 0, 0, NULL, None, NULL, 0, 0 }; + #else /* beynon */ /* x y w h tw th open type *text win */ TipStruct Tip = { 0, 0, 0, 0, 0, 0, 0, 0, NULL, None }; + #endif /* beynon */ /* Parse 'goodies' specific resources */ *************** *** 89,94 **** --- 110,139 ---- Clength+8)==0) { ShowTips = True; } + #if 1 /* beynon */ + else if (strncasecmp(tline, CatString3(Module, "NewMailCommand", ""), + Clength+14)==0) { + CopyString(&NewMailCmd, &tline[Clength+15]); + } else if (strncasecmp(tline, CatString3(Module, "HourlyCommand", ""), + Clength+13)==0) { + CopyString(&HourlyCmd, &tline[Clength+14]); + } else if (strncasecmp(tline, CatString3(Module, "AutoMailTip", ""), + Clength+11)==0) { + AutoMailTip = True; + if (strcasecmp(&tline[Clength+12], "MailFileTouched") == 0) { + AutoMailTip_Type = eTouched; + } else if (strcasecmp(&tline[Clength+12], "MailFileBigger") == 0) { + AutoMailTip_Type = eBigger; + } else if (strcasecmp(&tline[Clength+12], "MailFileAnyChange") == 0) { + AutoMailTip_Type = eAnyChange; + } else { + AutoMailTip_Type = eAnyChange; + } + } else if (strncasecmp(tline, CatString3(Module, "MailTipUnblankScreen", ""), + Clength+20)==0) { + MailTipUnblankScreen = True; + } + #endif /* beynon */ } void InitGoodies() { *************** *** 160,165 **** --- 205,213 ---- static char str[40]; static time_t timer; static int last_mail_check = -1; + #if 1 /* beynon */ + static int last_hour = -1; + #endif /* beynon */ time(&timer); tms = localtime(&timer); *************** *** 170,175 **** --- 218,233 ---- strftime(str, 15, "%R", tms); } + #if 1 /* beynon */ + /* check if a new hour */ + if (HourlyCmd[0]) { + if (tms->tm_min == 0 && tms->tm_hour != last_hour) { + last_hour = tms->tm_hour; + SendFvwmPipe(HourlyCmd, 0); + } + } + #endif /* beynon */ + Draw3dBox(win, win_width - stwin_width, 0, stwin_width, RowHeight); XDrawString(dpy,win,statusgc, win_width - stwin_width + 4, *************** *** 180,187 **** --- 238,272 ---- if (timer - last_mail_check >= 10) { cool_get_inboxstatus(); last_mail_check = timer; + #if 1 /* beynon */ + if (newmail) { + if (NewMailCmd[0]) { + SendFvwmPipe(NewMailCmd, 0); + } else { + XBell(dpy, BellVolume); + } + } + if (anymail && + ((AutoMailTip_Type == eAnyChange && mailchanged) || + (AutoMailTip_Type == eBigger && newmail) || + (AutoMailTip_Type == eTouched && unreadmail))) { + if (Tip.open || AutoMailTip) { + if (Tip.type == MAIL_TIP || AutoMailTip) { + CreateMailTipWindow(); /* This will delete an old window */ + } + RedrawTipWindow(); + if (!Tip.open && AutoMailTip) ShowTipWindow(1); + } + } else if (!anymail) { + if (Tip.open && Tip.type == MAIL_TIP) { + if (Tip.win != None) DestroyTipWindow(); + Tip.type = NO_TIP; + } + } + #else /* beynon */ if (newmail) XBell(dpy, BellVolume); + #endif /* beynon */ } if (!mailcleared && (unreadmail || newmail)) *************** *** 231,247 **** --- 316,365 ---- } void CreateMailTipWindow() { + #if 1 /* beynon */ + char *str; + + if (!anymail) { + if (Tip.win != None) DestroyTipWindow(); + Tip.type = NO_TIP; + return; + } + if (AutoMailTip) { + str = GetMailHeaders(); + PopupTipWindow(win_width, 0, str); + free(str); + if (MailTipUnblankScreen) { + XForceScreenSaver(dpy, ScreenSaverReset); + } + } else { + char tmp[20]; + sprintf(tmp, "You have %smail", (newmail || unreadmail) ? "new " : ""); + PopupTipWindow(win_width, 0, tmp); + } + Tip.type = MAIL_TIP; + #else /* beynon */ char str[20]; if (!anymail) return; sprintf(str, "You have %smail", (newmail || unreadmail) ? "new " : ""); PopupTipWindow(win_width, 0, str); + #endif /* beynon */ } void RedrawTipWindow() { if (Tip.text) { + #if 1 /* beynon */ + int i, y; + y = StatusFont->ascent + StatusFont->descent; + for (i=0; iascent + StatusFont->descent + 4); + } + #else /* beynon */ XDrawString(dpy, Tip.win, dategc, 3, Tip.th-4, Tip.text, strlen(Tip.text)); + #endif /* beynon */ XRaiseWindow(dpy, Tip.win); /*****************/ } } *************** *** 249,261 **** void PopupTipWindow(int px, int py, char *text) { int newx, newy; Window child; ! if (!ShowTips) return; if (Tip.win != None) DestroyTipWindow(); Tip.tw = XTextWidth(StatusFont, text, strlen(text)) + 6; Tip.th = StatusFont->ascent + StatusFont->descent + 4; XTranslateCoordinates(dpy, win, Root, px, py, &newx, &newy, &child); Tip.x = newx; --- 367,401 ---- void PopupTipWindow(int px, int py, char *text) { int newx, newy; Window child; ! #if 1 /* beynon */ ! int tw; ! char *sb; ! #endif /* beynon */ ! if (!ShowTips) return; if (Tip.win != None) DestroyTipWindow(); + UpdateString(&Tip.text, text); + + #if 1 /* beynon */ + /* parse string, and find width and height */ + Tip.tw = Tip.th = 0; + sb = strtok(Tip.text, "\n"); + for (Tip.nlines = 0; Tip.nlines < MAX_TIP_LINES; Tip.nlines++) { + if (sb == NULL) break; + Tip.lines[Tip.nlines] = sb; + + tw = XTextWidth(StatusFont, sb, strlen(sb)) + 6; + if (tw > Tip.tw) Tip.tw = tw; + Tip.th += StatusFont->ascent + StatusFont->descent + 4; + + sb = strtok(NULL, "\n"); + } + #else /* beynon */ Tip.tw = XTextWidth(StatusFont, text, strlen(text)) + 6; Tip.th = StatusFont->ascent + StatusFont->descent + 4; + #endif /* beynon */ XTranslateCoordinates(dpy, win, Root, px, py, &newx, &newy, &child); Tip.x = newx; *************** *** 270,276 **** if (Tip.x+Tip.tw+4 > ScreenWidth-5) Tip.x = ScreenWidth-Tip.tw-9; if (Tip.x < 5) Tip.x = 5; - UpdateString(&Tip.text, text); CreateTipWindow(Tip.x, Tip.y, Tip.w, Tip.h); if (Tip.open) XMapRaised(dpy, Tip.win); } --- 410,415 ---- *************** *** 372,377 **** --- 511,519 ---- off_t newsize; struct stat st; int fd; + #if 1 /* beynon */ + int rtn; + #endif /* beynon */ fd = open (mailpath, O_RDONLY, 0); if (fd < 0) *************** *** 380,391 **** newmail = 0; unreadmail = 0; newsize = 0; } else { fstat(fd, &st); - close(fd); newsize = st.st_size; if (newsize > 0) anymail = 1; --- 522,538 ---- newmail = 0; unreadmail = 0; newsize = 0; + #if 1 /* beynon */ + mailchanged = 0; + #endif /* beynon */ } else { fstat(fd, &st); newsize = st.st_size; + #if 0 /* beynon */ + close(fd); + #endif /* beynon */ if (newsize > 0) anymail = 1; *************** *** 403,408 **** --- 550,568 ---- } else newmail = 0; + + #if 1 /* beynon */ + if ((mailchanged = (newsize != oldsize))) { + if (MailBuf) { free(MailBuf); MailBuf = NULL; } + MailBuf = (char *)safemalloc(newsize+1); + if ((rtn = read(fd, MailBuf, newsize)) == newsize) { + MailBuf[newsize] = '\0'; + } else { + MailBuf[0] = '\0'; + } + } + close(fd); + #endif /* beynon */ } oldsize = newsize; *************** *** 418,420 **** --- 578,710 ---- lastclick = event.xbutton.time; mailcleared = 1; } + + + #if 1 /* beynon */ + char line[256]; + + void FreeMailHdrs(MailHdr_S *p) { + if (!p) return; + if (p->pNext) { + FreeMailHdrs(p->pNext); + } + if (p->sbFrom) free(p->sbFrom); + if (p->sbSubj) free(p->sbSubj); + free(p); + } + + char *GetsBuf(char *buf) { + int i; + char ch; + static char *pCurr; + if (buf) pCurr = buf; + if (*pCurr == '\0') return NULL; + for (i=0; i<256; i++, pCurr++) { + ch = *pCurr; + if (ch == '\n' || ch == '\0') { + if (ch != '\0') pCurr++; + line[i] = '\0'; + break; + } + line[i] = ch; + } + return line; + } + + int LeftWhitespace(char *sb) { + int wRtn = 0; + while (strchr(" \t\n\0", *sb++)) { + wRtn++; + } + return wRtn; + } + + char *RightWhitespace(char *sb) { + int i = strlen(sb); + char *p = sb + i; + if (i==0) return; + while (p >= sb && strchr(" \t\n\0", *--p)) { + *p = '\0'; + } + return sb; + } + + void ParseMailHeaders(char *buf) { + char *pLine; + MailHdr_S *pMailHdrNew; + + if (MailHdr != NULL) { + FreeMailHdrs(MailHdr); + MailHdr = MailHdr_tail = NULL; + MailHdrSize = 0; + } + /* walk through buffer to extract mail headers */ + pLine = GetsBuf(buf); + while (pLine != NULL) { + if (strncmp(pLine, HDR_DELIM, HDR_DELIM_LEN) == 0) { + pMailHdrNew = (MailHdr_S *)safemalloc(sizeof(MailHdr_S)); + pMailHdrNew->sbFrom = pMailHdrNew->sbSubj = NULL; + pMailHdrNew->pNext = NULL; + if (!MailHdr) { + MailHdr = MailHdr_tail = pMailHdrNew; + } else { /* append to list */ + MailHdr_tail->pNext = pMailHdrNew; + MailHdr_tail = pMailHdrNew; + } + MailHdrSize++; + } else if (!pMailHdrNew->sbFrom && + strncmp(pLine, HDR_FROM, HDR_FROM_LEN) == 0) { + UpdateString(&pMailHdrNew->sbFrom, + pLine + HDR_FROM_LEN + LeftWhitespace(pLine+HDR_FROM_LEN)); + RightWhitespace(pMailHdrNew->sbFrom); + } else if (!pMailHdrNew->sbSubj && + strncmp(pLine, HDR_SUBJ, HDR_SUBJ_LEN) == 0) { + UpdateString(&pMailHdrNew->sbSubj, + pLine + HDR_SUBJ_LEN + LeftWhitespace(pLine+HDR_SUBJ_LEN)); + RightWhitespace(pMailHdrNew->sbSubj); + } + + pLine = GetsBuf(NULL); + } + } + + char *StrNCpyPad(char *sbDst, char *sbSrc, int n, char chPad) { + int i; + for (i=0; isbFrom, 20, ' '); + sbTmp += 20; + *sbTmp++ = ' '; + StrNCpyPad(sbTmp, p->sbSubj, 30, ' '); + sbTmp += 30; + *sbTmp++ = '\n'; + p = p->pNext; + } + *sbTmp = '\0'; + + return sbRtn; + }; + + #endif /* beynon */ *** Goodies.h.old Thu Jun 26 07:58:19 1997 --- Goodies.h Mon Mar 3 11:49:30 1997 *************** *** 7,16 **** --- 7,37 ---- #define MAIL_TIP (-3) #define START_TIP (-4) + #if 1 /* beynon */ + extern int AutoMailTip; + + #define MAX_TIP_LINES 30 + #define HDR_DELIM "From " + #define HDR_DELIM_LEN 5 + #define HDR_FROM "From: " + #define HDR_FROM_LEN 6 + #define HDR_SUBJ "Subject: " + #define HDR_SUBJ_LEN 9 + typedef struct MailHdr_s { + char *sbFrom, *sbSubj; + struct MailHdr_s *pNext; + } MailHdr_S; + #endif /* beynon */ + typedef struct { int x, y, w, h, tw, th, open, type; char *text; Window win; + #if 1 /* beynon */ + char *lines[MAX_TIP_LINES]; + int nlines; + int fFree; + #endif /* beynon */ } TipStruct; void GoodiesParseConfig(char *tline, char *Module); *** Makefile.in.old Thu Jun 26 07:58:43 1997 --- Makefile.in Wed Mar 19 18:56:01 1997 *************** *** 15,21 **** fvwm_name=@fvwm_name@ # # This is where the modules will be installed ! fvwm_dir=@prefix@/lib/X11/@fvwm_name@ # # Libs --- 15,22 ---- fvwm_name=@fvwm_name@ # # This is where the modules will be installed ! #fvwm_dir=@prefix@/lib/X11/@fvwm_name@ ! fvwm_dir=@libdir@ # # Libs *************** *** 25,31 **** FVWM_LIBRARY=-l${fvwm_name} LIBS=-L${top_srcdir}/libs ${x_libraries} ${FVWM_LIBRARY} ${XPM_LIBRARY} ${XEXT_LIBRARY} ${X_LIBRARY} ! EXTRA_DEFINES=-DXPM -DSHAPE CC=@CC@ INCLUDES=-I${top_srcdir}/include ${x_includes} CFLAGS=${INCLUDES} @CFLAGS@ ${EXTRA_DEFINES} --- 26,32 ---- FVWM_LIBRARY=-l${fvwm_name} LIBS=-L${top_srcdir}/libs ${x_libraries} ${FVWM_LIBRARY} ${XPM_LIBRARY} ${XEXT_LIBRARY} ${X_LIBRARY} ! EXTRA_DEFINES=-DXPM -DSHAPE -DFVWM_ICONDIR=\"${fvwm_icons}\" CC=@CC@ INCLUDES=-I${top_srcdir}/include ${x_includes} CFLAGS=${INCLUDES} @CFLAGS@ ${EXTRA_DEFINES}