Date: Thu, 9 Sep 2004 19:27:15 +0200 (CEST) From: Oliver Breuninger <ob@breuninger.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/71535: port sysutils/xbatt modification Message-ID: <200409091727.i89HRFED004752@pop3.mail-relay.com> Resent-Message-ID: <200409091730.i89HUB2i009618@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 71535 >Category: ports >Synopsis: port sysutils/xbatt modification >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Sep 09 17:30:10 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Oliver Breuninger >Release: FreeBSD 4.10-RELEASE i386 >Organization: >Environment: System: FreeBSD bs-tosh.breuninger.org 4.10-RELEASE FreeBSD 4.10-RELEASE #4: Fri Aug 6 10:41:21 CEST 2004 root@bs-tosh.breuninger.org:/usr/src/sys/compile/TOSHIBA i386 >Description: modification for sysutils/xbatt to show the remaining battery life time in hours and minutes. >How-To-Repeat: >Fix: --- xbatt.c.orig Fri Sep 11 10:47:12 1998 +++ xbatt.c Mon Aug 13 21:35:10 2001 @@ -80,4 +80,5 @@ #include "bitmaps/digit9.xbm" #include "bitmaps/percent.xbm" +#include "bitmaps/colon.xbm" /* reflash Interval (in seconds) */ @@ -105,4 +106,5 @@ u_int acline; u_int charge; + u_int life; /* &&& ob: remaining seconds */ }; static struct status lastStat = {APM_STAT_UNKNOWN, APM_STAT_UNKNOWN, @@ -340,19 +342,25 @@ case APM_STAT_BATT_HIGH: ret.remain = 100; + ret.life = 0; break; case APM_STAT_BATT_LOW: ret.remain = 40; + ret.life = 0; break; case APM_STAT_BATT_CRITICAL: ret.remain = 10; + ret.life = 0; break; default: /* expected to be APM_STAT_UNKNOWN */ ret.remain = APM_STAT_UNKNOWN; + ret.life = 0; } } else if (info.ai_batt_life > 100) { /* some APM BIOSes return values slightly > 100 */ ret.remain = 100; + ret.life = 0; } else { ret.remain = info.ai_batt_life; + ret.life = info.ai_batt_time; } @@ -451,4 +459,7 @@ Pixmap bmp; int ret; + int lifemin; + int lifehour; + int d; /* free old data */ @@ -518,9 +529,9 @@ BlackPixel(XtDisplay(toplevel), DefaultScreen(XtDisplay(toplevel)))); - XDrawRectangle(XtDisplay(toplevel), xpmData, gc, 17, 17, 14, 8); + XDrawRectangle(XtDisplay(toplevel), xpmData, gc, 16, 14, 16, 14); XSetForeground(XtDisplay(toplevel), gc, WhitePixel(XtDisplay(toplevel), DefaultScreen(XtDisplay(toplevel)))); - XFillRectangle(XtDisplay(toplevel), xpmData, gc, 18, 18, 13, 7); + XFillRectangle(XtDisplay(toplevel), xpmData, gc, 17, 15, 15, 13); if (s.remain == 100) { @@ -538,8 +549,8 @@ XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, full_width, full_height, - 19, 19, 1); + 19, 16, 1); XFreePixmap(XtDisplay(toplevel), bm); } else { - int d = s.remain / 10; + d = s.remain / 10; bm = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(toplevel), @@ -555,5 +566,5 @@ 1); XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, 3, 5, - 19, 19, 1); + 19, 16, 1); XFreePixmap(XtDisplay(toplevel), bm); @@ -572,5 +583,5 @@ 1); XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, 3, 5, - 23, 19, 1); + 23, 16, 1); XFreePixmap(XtDisplay(toplevel), bm); @@ -588,7 +599,80 @@ 1); XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, 3, 5, - 27, 19, 1); + 27, 16, 1); XFreePixmap(XtDisplay(toplevel), bm); } + +/* &&& ob: remaining seconds */ + + lifemin = ((s.life + 30) / 60) % 60; + lifehour = (s.life + 30) / 3600; + + d = lifehour % 10; + bm = XCreatePixmapFromBitmapData(XtDisplay(toplevel), + XtWindow(toplevel), + digits[d].bits, + digits[d].width, + digits[d].height, + BlackPixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + WhitePixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + 1); + XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, 3, 5, + 18, 22, 1); + XFreePixmap(XtDisplay(toplevel), bm); + + bm = XCreatePixmapFromBitmapData(XtDisplay(toplevel), + XtWindow(toplevel), + colon_bits, + colon_width, + colon_height, + BlackPixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + WhitePixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + 1); + XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, 3, 5, + 21, 22, 1); + XFreePixmap(XtDisplay(toplevel), bm); + + d = lifemin / 10; + bm = XCreatePixmapFromBitmapData(XtDisplay(toplevel), + XtWindow(toplevel), + digits[d].bits, + digits[d].width, + digits[d].height, + BlackPixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + WhitePixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + 1); + XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, 3, 5, + 24, 22, 1); + XFreePixmap(XtDisplay(toplevel), bm); + + d = lifemin % 10; + bm = XCreatePixmapFromBitmapData(XtDisplay(toplevel), + XtWindow(toplevel), + digits[d].bits, + digits[d].width, + digits[d].height, + BlackPixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + WhitePixel(XtDisplay(toplevel), + DefaultScreen( + XtDisplay(toplevel))), + 1); + XCopyPlane(XtDisplay(toplevel), bm, xpmData, gc, 0, 0, 3, 5, + 28, 22, 1); + XFreePixmap(XtDisplay(toplevel), bm); + } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200409091727.i89HRFED004752>