From d510f2da913d670df38016328c9fdf4a2e837318 Mon Sep 17 00:00:00 2001 From: "John Ankarstr\\xf6m" Date: Thu, 3 Jun 2021 00:46:01 +0200 Subject: Stop trying to remove timeout It is apparently unnecessary. --- xbattext.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'xbattext.c') diff --git a/xbattext.c b/xbattext.c index 3abbb54..9eecac7 100644 --- a/xbattext.c +++ b/xbattext.c @@ -42,7 +42,7 @@ void update(XtPointer, XtIntervalId *); /* resources */ -struct _res { +struct res { XmFontList font_list; XmFontList alert_font_list; XmFontList charge_font_list; @@ -52,17 +52,17 @@ struct _res { } res; static XtResource res_opts[] = { {"fontList", "FontList", XmRFontList, sizeof(XmFontList), - XtOffset(struct _res*, font_list), XtRImmediate, (caddr_t)NULL}, + XtOffset(struct res*, font_list), XtRImmediate, (caddr_t)NULL}, {"alertFontList", "AlertFontList", XmRFontList, sizeof(XmFontList), - XtOffset(struct _res*, alert_font_list), XtRImmediate, (caddr_t)NULL}, + XtOffset(struct res*, alert_font_list), XtRImmediate, (caddr_t)NULL}, {"chargeFontList", "ChargeFontList", XmRFontList, sizeof(XmFontList), - XtOffset(struct _res*, charge_font_list), XtRImmediate, (caddr_t)NULL}, + XtOffset(struct res*, charge_font_list), XtRImmediate, (caddr_t)NULL}, {"foreground", "foreground", XmRPixel, sizeof(Pixel), - XtOffset(struct _res*, foreground), XtRImmediate, (caddr_t)NULL}, + XtOffset(struct res*, foreground), XtRImmediate, (caddr_t)NULL}, {"alertForeground", "AlertForeground", XmRPixel, sizeof(Pixel), - XtOffset(struct _res*, alert_foreground), XtRImmediate, (caddr_t)NULL}, + XtOffset(struct res*, alert_foreground), XtRImmediate, (caddr_t)NULL}, {"chargeForeground", "ChargeForeground", XmRPixel, sizeof(Pixel), - XtOffset(struct _res*, charge_foreground), XtRImmediate, (caddr_t)NULL}, + XtOffset(struct res*, charge_foreground), XtRImmediate, (caddr_t)NULL}, }; /* application state */ @@ -73,7 +73,6 @@ struct apm_power_info info; Widget toplevel, label; XmString xms; XtAppContext app_context; -XtIntervalId timer = 0; int main(int argc, char* argv[]) @@ -86,27 +85,25 @@ main(int argc, char* argv[]) NULL, NULL); - if ((apmfd = open("/dev/apm", O_RDONLY, 0755)) == -1) + if ((apmfd = open("/dev/apm", O_RDONLY)) == -1) err(1, "open"); if ((s = malloc(5*sizeof(char))) == NULL) err(1, "malloc"); - XtSetLanguageProc(NULL, NULL, NULL); - /* load application resources */ XtGetApplicationResources(toplevel, &res, res_opts, XtNumber(res_opts), NULL, 0); /* create motif label */ - label = XtVaCreateManagedWidget("text", + label = XtVaCreateManagedWidget("label", xmLabelWidgetClass, toplevel, XmNlabel, "", NULL); alert = 0; charge = 0; - update(NULL, &timer); + update(NULL, NULL); XtRealizeWidget(toplevel); XtAppMainLoop(app_context); } @@ -117,12 +114,6 @@ update(XtPointer client_data, XtIntervalId *t) { int i; - /* remove current timer */ - if (t == NULL && timer) { - XtRemoveTimeOut(timer); - timer = 0; - } - /* get battery info */ memset(&info, 0, sizeof(info)); if (ioctl(apmfd, APM_IOC_GETPOWER, &info) == -1) { @@ -187,5 +178,5 @@ set: XtSetValues(label, wargs, i); XmStringFree(xms); /* add new timer */ -end: timer = XtAppAddTimeOut(app_context, INTERVAL * 1000, update, toplevel); +end: XtAppAddTimeOut(app_context, INTERVAL * 1000, update, NULL); } -- cgit v1.2.3