summaryrefslogtreecommitdiff
path: root/app/xclock
diff options
context:
space:
mode:
Diffstat (limited to 'app/xclock')
-rw-r--r--app/xclock/ChangeLog114
-rw-r--r--app/xclock/Clock.c2739
-rw-r--r--app/xclock/Makefile.in7
-rw-r--r--app/xclock/README.md2
-rw-r--r--app/xclock/aclocal.m4422
-rw-r--r--app/xclock/compile17
-rw-r--r--app/xclock/config.h.in3
-rw-r--r--app/xclock/configure453
-rw-r--r--app/xclock/configure.ac8
-rw-r--r--app/xclock/man/Makefile.in1
-rw-r--r--app/xclock/man/xclock.man5
11 files changed, 2022 insertions, 1749 deletions
diff --git a/app/xclock/ChangeLog b/app/xclock/ChangeLog
index 24f22b548..87f5669a7 100644
--- a/app/xclock/ChangeLog
+++ b/app/xclock/ChangeLog
@@ -1,3 +1,115 @@
+commit a1202e71763cfc6aad4ade6e0dda4ac78b857e27
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Thu Apr 7 13:36:13 2022 -0700
+
+ xclock 1.1.1
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit f2acb1dbd75605d64f07740df2d83e73fe1b2ec3
+Author: Thomas Kuehne <thomas@kuehne.cn>
+Date: Sat Dec 11 18:00:11 2021 +0100
+
+ fix -Wabsolute-value compiler warning
+
+ fixes:
+ Clock.c:2011:14: warning: using integer absolute value function ‘abs’ when argument is of floating-point type ‘float’ [-Wabsolute-value]
+ 2011 | (abs(new->clock.update) <= SECOND_HAND_TIME);
+ | ^~~
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit e075308dccafb6f813ba0a8646b73860a7447a01
+Author: Thomas Kuehne <thomas@kuehne.cn>
+Date: Sat Dec 11 17:56:39 2021 +0100
+
+ fix -Wmissing-field-initializers warning
+
+ fixes:
+ Clock.c:269:6: warning: missing initializer for field ‘extension’ of ‘SimpleClassPart’ [-Wmissing-field-initializers]
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 96934f4472f10a1e5fcf53f6cbb9c88d743fa520
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Mon Apr 4 16:51:04 2022 -0700
+
+ Fall back to sin() and cos() calls on systems without sincos()
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 7126b722a055545d25291cd10076f4c3fe52f039
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sun Apr 3 14:21:37 2022 -0700
+
+ xclock 1.1.0
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 65f9bee07f98d384068339bff025cf50d3cecead
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Dec 4 10:50:42 2021 -0800
+
+ Build xz tarballs instead of bzip2
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 3b719d3587d3f8547eff584d949385c3f1926ed0
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Dec 4 10:50:39 2021 -0800
+
+ gitlab CI: add a basic build test
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 8078de47f573fe60ee171647d23b9a097e818cc9
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sun Nov 28 11:28:07 2021 -0800
+
+ Fix spelling/wording issues
+
+ Found by using:
+ codespell --builtin clear,rare,usage,informal,code,names
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 866881cde2f973b50dc2a9279f2a85611ec23974
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sun Aug 1 16:28:13 2021 -0700
+
+ Fix build on Solaris
+
+ Solaris 11 has sqrt() in libc but needs to link with libm for sincos()
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 30be448a408bf8543047008ef823321016b73132
+Author: Keith Packard <keithp@keithp.com>
+Date: Thu Jul 15 23:24:30 2021 -0700
+
+ Update hands smoothly in Render mode
+
+ Draw hour and minute hand every time the clock repaints, placing them
+ at the correct position for the current time.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit ff94d3f086479724261b764b11a0012f5e6cdc63
+Author: rees4905 <jim@rees.org>
+Date: Fri Jun 12 22:27:10 2020 -0500
+
+ man: Indicate that -twelve & -twentyfour only affect brief display
+
+ Signed-off-by: rees4905 <jim@rees.org>
+
+commit 03dba28ffd633839e57af748edae07a2c8b06398
+Author: rees4905 <jim@rees.org>
+Date: Sun Jun 7 21:47:45 2020 -0500
+
+ re-indent Clock.c
+
+ Signed-off-by: rees4905 <jim@rees.org>
+
commit 755004c87b50e6334c07b0f4b9458a32b8c92566
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Jul 14 11:34:07 2019 -0700
@@ -867,7 +979,7 @@ Date: Sat Jul 16 17:16:05 2005 +0000
Xft2/Render (enabled by default)
commit 80d8b6affb2ee823cf18a368ab33535cb1cf1721
-Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
Date: Fri Jul 1 17:55:48 2005 +0000
Build system for xclock
diff --git a/app/xclock/Clock.c b/app/xclock/Clock.c
index dd70d8d96..6611fd2be 100644
--- a/app/xclock/Clock.c
+++ b/app/xclock/Clock.c
@@ -25,7 +25,6 @@ Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
-
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
@@ -76,9 +75,10 @@ SOFTWARE.
/* $XFree86: xc/programs/xclock/Clock.c,v 3.25 2003/07/04 16:24:30 eich Exp $ */
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
+#define _GNU_SOURCE
#include <X11/Xlib.h>
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>
@@ -87,6 +87,7 @@ SOFTWARE.
#include <stdio.h>
#include <X11/Xos.h>
#include <X11/Xaw/XawInit.h>
+#include <math.h>
#if !defined(NO_I18N) && defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
#include <iconv.h>
#include <langinfo.h>
@@ -108,15 +109,14 @@ SOFTWARE.
#endif
#ifndef NO_I18N
-#include <stdlib.h> /* for getenv() */
+#include <stdlib.h> /* for getenv() */
#include <locale.h>
-extern Boolean no_locale; /* if True, use old (unlocalized) behaviour */
+extern Boolean no_locale; /* if True, use old (unlocalized) behaviour */
#endif
-
/* Private Definitions */
-#define VERTICES_IN_HANDS 6 /* to draw triangle */
+#define VERTICES_IN_HANDS 6 /* to draw triangle */
#define PI 3.14159265358979
#define TWOPI (2. * PI)
@@ -134,7 +134,6 @@ extern Boolean no_locale; /* if True, use old (unlocalized) behaviour */
#define min(a, b) ((a) < (b) ? (a) : (b))
/* #define abs(a) ((a) < 0 ? -(a) : (a)) */
-
/* Initialization of defaults */
#define offset(field) XtOffsetOf(ClockRec, clock.field)
@@ -142,138 +141,139 @@ extern Boolean no_locale; /* if True, use old (unlocalized) behaviour */
static XtResource resources[] = {
{XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
- goffset(width), XtRImmediate, (XtPointer) 0},
+ goffset(width), XtRImmediate, (XtPointer) 0},
{XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
- goffset(height), XtRImmediate, (XtPointer) 0},
+ goffset(height), XtRImmediate, (XtPointer) 0},
{XtNupdate, XtCInterval, XtRFloat, sizeof(float),
- offset(update), XtRString, "60.0" },
+ offset(update), XtRString, "60.0"},
#ifndef XRENDER
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
- offset(fgpixel), XtRString, XtDefaultForeground},
+ offset(fgpixel), XtRString, XtDefaultForeground},
#endif
{XtNhand, XtCForeground, XtRPixel, sizeof(Pixel),
- offset(Hdpixel), XtRString, XtDefaultForeground},
+ offset(Hdpixel), XtRString, XtDefaultForeground},
{XtNhighlight, XtCForeground, XtRPixel, sizeof(Pixel),
- offset(Hipixel), XtRString, XtDefaultForeground},
+ offset(Hipixel), XtRString, XtDefaultForeground},
{XtNutime, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(utime), XtRImmediate, (XtPointer) FALSE},
+ offset(utime), XtRImmediate, (XtPointer) FALSE},
{XtNanalog, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(analog), XtRImmediate, (XtPointer) TRUE},
+ offset(analog), XtRImmediate, (XtPointer) TRUE},
{XtNtwentyfour, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(twentyfour), XtRImmediate, (XtPointer) TRUE},
+ offset(twentyfour), XtRImmediate, (XtPointer) TRUE},
{XtNbrief, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(brief), XtRImmediate, (XtPointer) FALSE},
+ offset(brief), XtRImmediate, (XtPointer) FALSE},
{XtNstrftime, XtCString, XtRString, sizeof(String),
- offset(strftime), XtRString, ""},
+ offset(strftime), XtRString, ""},
{XtNchime, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(chime), XtRImmediate, (XtPointer) FALSE },
+ offset(chime), XtRImmediate, (XtPointer) FALSE},
{XtNpadding, XtCMargin, XtRInt, sizeof(int),
- offset(padding), XtRImmediate, (XtPointer) 8},
+ offset(padding), XtRImmediate, (XtPointer) 8},
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
- offset(font), XtRString, XtDefaultFont},
+ offset(font), XtRString, XtDefaultFont},
#ifndef NO_I18N
- {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
- offset(fontSet), XtRString, XtDefaultFontSet},
+ {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
+ offset(fontSet), XtRString, XtDefaultFontSet},
#endif
- {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int),
- offset (backing_store), XtRString, "default"},
+ {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof(int),
+ offset(backing_store), XtRString, "default"},
#ifdef XRENDER
{XtNrender, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(render), XtRImmediate, (XtPointer) FALSE },
+ offset(render), XtRImmediate, (XtPointer) FALSE},
{XtNbuffer, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(buffer), XtRImmediate, (XtPointer) TRUE },
+ offset(buffer), XtRImmediate, (XtPointer) TRUE},
{XtNsharp, XtCBoolean, XtRBoolean, sizeof(Boolean),
- offset(sharp), XtRImmediate, (XtPointer) FALSE },
+ offset(sharp), XtRImmediate, (XtPointer) FALSE},
{XtNforeground, XtCForeground, XtRXftColor, sizeof(XftColor),
- offset(fg_color), XtRString, XtDefaultForeground},
+ offset(fg_color), XtRString, XtDefaultForeground},
{XtNhourColor, XtCForeground, XtRXftColor, sizeof(XftColor),
- offset(hour_color), XtRString, XtDefaultForeground},
+ offset(hour_color), XtRString, XtDefaultForeground},
{XtNminuteColor, XtCForeground, XtRXftColor, sizeof(XftColor),
- offset(min_color), XtRString, XtDefaultForeground},
+ offset(min_color), XtRString, XtDefaultForeground},
{XtNsecondColor, XtCForeground, XtRXftColor, sizeof(XftColor),
- offset(sec_color), XtRString, XtDefaultForeground},
+ offset(sec_color), XtRString, XtDefaultForeground},
{XtNmajorColor, XtCForeground, XtRXftColor, sizeof(XftColor),
- offset(major_color), XtRString, XtDefaultForeground},
+ offset(major_color), XtRString, XtDefaultForeground},
{XtNminorColor, XtCForeground, XtRXftColor, sizeof(XftColor),
- offset(minor_color), XtRString, XtDefaultForeground},
- {XtNface, XtCFace, XtRXftFont, sizeof (XftFont *),
- offset (face), XtRString, ""},
+ offset(minor_color), XtRString, XtDefaultForeground},
+ {XtNface, XtCFace, XtRXftFont, sizeof(XftFont *),
+ offset(face), XtRString, ""},
#endif
};
#undef offset
#undef goffset
-static void ClassInitialize ( void );
-static void Initialize ( Widget request, Widget new, ArgList args,
- Cardinal *num_args );
-static void Realize ( Widget gw, XtValueMask *valueMask,
- XSetWindowAttributes *attrs );
-static void Destroy ( Widget gw );
-static void Resize ( Widget gw );
-static void Redisplay ( Widget gw, XEvent *event, Region region );
-static void clock_tic ( XtPointer client_data, XtIntervalId *id );
-static void erase_hands ( ClockWidget w, struct tm *tm );
-static void ClockAngle ( int tick_units, double *sinp, double *cosp );
-static void DrawLine ( ClockWidget w, Dimension blank_length,
- Dimension length, int tick_units );
-static void DrawHand ( ClockWidget w, Dimension length, Dimension width,
- int tick_units );
-static void DrawSecond ( ClockWidget w, Dimension length, Dimension width,
- Dimension offset, int tick_units );
-static void SetSeg ( ClockWidget w, int x1, int y1, int x2, int y2 );
-static void DrawClockFace ( ClockWidget w );
-static int clock_round ( double x );
-static Boolean SetValues ( Widget gcurrent, Widget grequest, Widget gnew,
- ArgList args, Cardinal *num_args );
+static void ClassInitialize(void);
+static void Initialize(Widget request, Widget new, ArgList args,
+ Cardinal * num_args);
+static void Realize(Widget gw, XtValueMask * valueMask,
+ XSetWindowAttributes * attrs);
+static void Destroy(Widget gw);
+static void Resize(Widget gw);
+static void Redisplay(Widget gw, XEvent * event, Region region);
+static void clock_tic(XtPointer client_data, XtIntervalId * id);
+static void erase_hands(ClockWidget w, struct tm *tm);
+static void ClockAngle(double tick_units, double *sinp, double *cosp);
+static void DrawLine(ClockWidget w, Dimension blank_length,
+ Dimension length, int tick_units);
+static void DrawHand(ClockWidget w, Dimension length, Dimension width,
+ int tick_units);
+static void DrawSecond(ClockWidget w, Dimension length, Dimension width,
+ Dimension offset, int tick_units);
+static void SetSeg(ClockWidget w, int x1, int y1, int x2, int y2);
+static void DrawClockFace(ClockWidget w);
+static int clock_round(double x);
+static Boolean SetValues(Widget gcurrent, Widget grequest, Widget gnew,
+ ArgList args, Cardinal * num_args);
#if !defined(NO_I18N) && defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
static char *clock_to_utf8(const char *str, int in_len);
#endif
ClockClassRec clockClassRec = {
- { /* core fields */
- /* superclass */ (WidgetClass) &simpleClassRec,
- /* class_name */ "Clock",
- /* widget_size */ sizeof(ClockRec),
- /* class_initialize */ ClassInitialize,
- /* class_part_initialize */ NULL,
- /* class_inited */ FALSE,
- /* initialize */ Initialize,
- /* initialize_hook */ NULL,
- /* realize */ Realize,
- /* actions */ NULL,
- /* num_actions */ 0,
- /* resources */ resources,
- /* resource_count */ XtNumber(resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure */ XtExposeCompressMaximal,
- /* compress_enterleave */ TRUE,
- /* visible_interest */ FALSE,
- /* destroy */ Destroy,
- /* resize */ Resize,
- /* expose */ Redisplay,
- /* set_values */ SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_private */ NULL,
- /* tm_table */ NULL,
- /* query_geometry */ XtInheritQueryGeometry,
- /* display_accelerator */ XtInheritDisplayAccelerator,
- /* extension */ NULL
- },
- { /* simple fields */
- /* change_sensitive */ XtInheritChangeSensitive
- },
- { /* clock fields */
- /* ignore */ 0
- }
+ { /* core fields */
+ /* superclass */ (WidgetClass) & simpleClassRec,
+ /* class_name */ "Clock",
+ /* widget_size */ sizeof(ClockRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* resource_count */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ XtExposeCompressMaximal,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ Redisplay,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* simple fields */
+ /* change_sensitive */ XtInheritChangeSensitive,
+ /* extension */ NULL
+ },
+ { /* clock fields */
+ /* ignore */ 0
+ }
};
-WidgetClass clockWidgetClass = (WidgetClass) &clockClassRec;
+WidgetClass clockWidgetClass = (WidgetClass) & clockClassRec;
/****************************************************************
*
@@ -281,44 +281,42 @@ WidgetClass clockWidgetClass = (WidgetClass) &clockClassRec;
*
****************************************************************/
#ifndef USE_XAW_PIXMAP_CVT
-static void CvtStringToPixmap(
- XrmValue* args,
- Cardinal* num_args,
- XrmValuePtr fromVal,
- XrmValuePtr toVal
- )
+static void
+CvtStringToPixmap(XrmValue * args,
+ Cardinal * num_args, XrmValuePtr fromVal, XrmValuePtr toVal)
{
- static Pixmap pmap;
+ static Pixmap pmap;
Pixmap shapemask;
- char *name = (char *)fromVal->addr;
+ char *name = (char *) fromVal->addr;
Screen *screen;
Display *dpy;
if (*num_args != 1)
- XtErrorMsg("wrongParameters","cvtStringToPixmap","XtToolkitError",
- "String to pixmap conversion needs screen argument",
- (String *)NULL, (Cardinal *)NULL);
+ XtErrorMsg("wrongParameters", "cvtStringToPixmap", "XtToolkitError",
+ "String to pixmap conversion needs screen argument",
+ (String *) NULL, (Cardinal *) NULL);
if (strcmp(name, "None") == 0) {
pmap = None;
- } else {
- screen = *((Screen **) args[0].addr);
- dpy = DisplayOfScreen(screen);
+ }
+ else {
+ screen = *((Screen **) args[0].addr);
+ dpy = DisplayOfScreen(screen);
- XpmReadFileToPixmap(dpy, RootWindowOfScreen(screen), name, &pmap,
- &shapemask, NULL);
+ XpmReadFileToPixmap(dpy, RootWindowOfScreen(screen), name, &pmap,
+ &shapemask, NULL);
}
(*toVal).size = sizeof(Pixmap);
- (*toVal).addr = (XPointer) &pmap ;
+ (*toVal).addr = (XPointer) & pmap;
}
#endif
#ifdef XRENDER
static XtConvertArgRec xftColorConvertArgs[] = {
- {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen),
+ {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
sizeof(Screen *)},
- {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.colormap),
+ {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.colormap),
sizeof(Colormap)}
};
@@ -343,144 +341,132 @@ static XtConvertArgRec xftColorConvertArgs[] = {
}
static void
-XmuFreeXftColor (XtAppContext app, XrmValuePtr toVal, XtPointer closure,
- XrmValuePtr args, Cardinal *num_args)
+XmuFreeXftColor(XtAppContext app, XrmValuePtr toVal, XtPointer closure,
+ XrmValuePtr args, Cardinal * num_args)
{
- Screen *screen;
- Colormap colormap;
- XftColor *color;
-
- if (*num_args != 2)
- {
- XtAppErrorMsg (app,
- "freeXftColor", "wrongParameters",
- "XtToolkitError",
- "Freeing an XftColor requires screen and colormap arguments",
- (String *) NULL, (Cardinal *)NULL);
- return;
+ Screen *screen;
+ Colormap colormap;
+ XftColor *color;
+
+ if (*num_args != 2) {
+ XtAppErrorMsg(app,
+ "freeXftColor", "wrongParameters",
+ "XtToolkitError",
+ "Freeing an XftColor requires screen and colormap arguments",
+ (String *) NULL, (Cardinal *) NULL);
+ return;
}
screen = *((Screen **) args[0].addr);
colormap = *((Colormap *) args[1].addr);
color = (XftColor *) toVal->addr;
- XftColorFree (DisplayOfScreen (screen),
- DefaultVisual (DisplayOfScreen (screen),
- XScreenNumberOfScreen (screen)),
- colormap, color);
+ XftColorFree(DisplayOfScreen(screen),
+ DefaultVisual(DisplayOfScreen(screen),
+ XScreenNumberOfScreen(screen)), colormap, color);
}
static Boolean
-XmuCvtStringToXftColor(Display *dpy,
- XrmValue *args, Cardinal *num_args,
- XrmValue *fromVal, XrmValue *toVal,
- XtPointer *converter_data)
+XmuCvtStringToXftColor(Display * dpy,
+ XrmValue * args, Cardinal * num_args,
+ XrmValue * fromVal, XrmValue * toVal,
+ XtPointer * converter_data)
{
- char *spec;
- XRenderColor renderColor;
- XftColor xftColor;
- Screen *screen;
- Colormap colormap;
-
- if (*num_args != 2)
- {
- XtAppErrorMsg (XtDisplayToApplicationContext (dpy),
- "cvtStringToXftColor", "wrongParameters",
- "XtToolkitError",
- "String to render color conversion needs screen and colormap arguments",
- (String *) NULL, (Cardinal *)NULL);
- return False;
+ char *spec;
+ XRenderColor renderColor;
+ XftColor xftColor;
+ Screen *screen;
+ Colormap colormap;
+
+ if (*num_args != 2) {
+ XtAppErrorMsg(XtDisplayToApplicationContext(dpy),
+ "cvtStringToXftColor", "wrongParameters",
+ "XtToolkitError",
+ "String to render color conversion needs screen and colormap arguments",
+ (String *) NULL, (Cardinal *) NULL);
+ return False;
}
screen = *((Screen **) args[0].addr);
colormap = *((Colormap *) args[1].addr);
spec = (char *) fromVal->addr;
- if (strcasecmp (spec, XtDefaultForeground) == 0)
- {
- renderColor.red = 0;
- renderColor.green = 0;
- renderColor.blue = 0;
- renderColor.alpha = 0xffff;
+ if (strcasecmp(spec, XtDefaultForeground) == 0) {
+ renderColor.red = 0;
+ renderColor.green = 0;
+ renderColor.blue = 0;
+ renderColor.alpha = 0xffff;
}
- else if (strcasecmp (spec, XtDefaultBackground) == 0)
- {
- renderColor.red = 0xffff;
- renderColor.green = 0xffff;
- renderColor.blue = 0xffff;
- renderColor.alpha = 0xffff;
+ else if (strcasecmp(spec, XtDefaultBackground) == 0) {
+ renderColor.red = 0xffff;
+ renderColor.green = 0xffff;
+ renderColor.blue = 0xffff;
+ renderColor.alpha = 0xffff;
}
- else if (!XRenderParseColor (dpy, spec, &renderColor))
- return False;
- if (!XftColorAllocValue (dpy,
- DefaultVisual (dpy,
- XScreenNumberOfScreen (screen)),
- colormap,
- &renderColor,
- &xftColor))
- return False;
-
- donestr (XftColor, xftColor, XtRXftColor);
+ else if (!XRenderParseColor(dpy, spec, &renderColor))
+ return False;
+ if (!XftColorAllocValue(dpy,
+ DefaultVisual(dpy,
+ XScreenNumberOfScreen(screen)),
+ colormap, &renderColor, &xftColor))
+ return False;
+
+ donestr(XftColor, xftColor, XtRXftColor);
}
static void
-XmuFreeXftFont (XtAppContext app, XrmValuePtr toVal, XtPointer closure,
- XrmValuePtr args, Cardinal *num_args)
+XmuFreeXftFont(XtAppContext app, XrmValuePtr toVal, XtPointer closure,
+ XrmValuePtr args, Cardinal * num_args)
{
- Screen *screen;
+ Screen *screen;
XftFont *font;
- if (*num_args != 1)
- {
- XtAppErrorMsg (app,
- "freeXftFont", "wrongParameters",
- "XtToolkitError",
- "Freeing an XftFont requires screen argument",
- (String *) NULL, (Cardinal *)NULL);
- return;
+ if (*num_args != 1) {
+ XtAppErrorMsg(app,
+ "freeXftFont", "wrongParameters",
+ "XtToolkitError",
+ "Freeing an XftFont requires screen argument",
+ (String *) NULL, (Cardinal *) NULL);
+ return;
}
screen = *((Screen **) args[0].addr);
font = *((XftFont **) toVal->addr);
if (font)
- XftFontClose (DisplayOfScreen (screen), font);
+ XftFontClose(DisplayOfScreen(screen), font);
}
static Boolean
-XmuCvtStringToXftFont(Display *dpy,
- XrmValue *args, Cardinal *num_args,
- XrmValue *fromVal, XrmValue *toVal,
- XtPointer *converter_data)
+XmuCvtStringToXftFont(Display * dpy,
+ XrmValue * args, Cardinal * num_args,
+ XrmValue * fromVal, XrmValue * toVal,
+ XtPointer * converter_data)
{
- char *name;
+ char *name;
XftFont *font;
- Screen *screen;
+ Screen *screen;
- if (*num_args != 1)
- {
- XtAppErrorMsg (XtDisplayToApplicationContext (dpy),
- "cvtStringToXftFont", "wrongParameters",
- "XtToolkitError",
- "String to XftFont conversion needs screen argument",
- (String *) NULL, (Cardinal *)NULL);
- return False;
+ if (*num_args != 1) {
+ XtAppErrorMsg(XtDisplayToApplicationContext(dpy),
+ "cvtStringToXftFont", "wrongParameters",
+ "XtToolkitError",
+ "String to XftFont conversion needs screen argument",
+ (String *) NULL, (Cardinal *) NULL);
+ return False;
}
screen = *((Screen **) args[0].addr);
name = (char *) fromVal->addr;
- font = XftFontOpenName (dpy,
- XScreenNumberOfScreen (screen),
- name);
- if (font)
- {
- donestr (XftFont *, font, XtRXftFont);
+ font = XftFontOpenName(dpy, XScreenNumberOfScreen(screen), name);
+ if (font) {
+ donestr(XftFont *, font, XtRXftFont);
}
XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRXftFont);
return False;
}
static XtConvertArgRec xftFontConvertArgs[] = {
- {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen),
+ {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
sizeof(Screen *)},
};
@@ -493,255 +479,261 @@ ClassInitialize(void)
XawInitializeWidgetSet();
#else
static XtConvertArgRec scrnConvertArg[] = {
- {XtBaseOffset, (XtPointer) XtOffset(Widget, core.screen),
- sizeof(Screen *)}
+ {XtBaseOffset, (XtPointer) XtOffset(Widget, core.screen),
+ sizeof(Screen *)}
};
- XtAddConverter( XtRString, XtRPixmap, CvtStringToPixmap,
- scrnConvertArg, XtNumber(scrnConvertArg));
+ XtAddConverter(XtRString, XtRPixmap, CvtStringToPixmap,
+ scrnConvertArg, XtNumber(scrnConvertArg));
#endif
- XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore,
- NULL, 0 );
+ XtAddConverter(XtRString, XtRBackingStore, XmuCvtStringToBackingStore,
+ NULL, 0);
#ifdef XRENDER
- XtSetTypeConverter (XtRString, XtRXftColor,
- XmuCvtStringToXftColor,
- xftColorConvertArgs, XtNumber(xftColorConvertArgs),
- XtCacheByDisplay, XmuFreeXftColor);
- XtSetTypeConverter (XtRString, XtRXftFont,
- XmuCvtStringToXftFont,
- xftFontConvertArgs, XtNumber(xftFontConvertArgs),
- XtCacheByDisplay, XmuFreeXftFont);
+ XtSetTypeConverter(XtRString, XtRXftColor,
+ XmuCvtStringToXftColor,
+ xftColorConvertArgs, XtNumber(xftColorConvertArgs),
+ XtCacheByDisplay, XmuFreeXftColor);
+ XtSetTypeConverter(XtRString, XtRXftFont,
+ XmuCvtStringToXftFont,
+ xftFontConvertArgs, XtNumber(xftFontConvertArgs),
+ XtCacheByDisplay, XmuFreeXftFont);
#endif
}
static char *
-TimeString (ClockWidget w, struct tm *tm)
+TimeString(ClockWidget w, struct tm *tm)
{
- if (w->clock.brief)
- {
- if (w->clock.twentyfour)
- {
- static char brief[6];
- snprintf (brief, sizeof(brief), "%02d:%02d", tm->tm_hour, tm->tm_min);
- return brief;
- }
- else
- {
- static char brief[9];
- int hour = tm->tm_hour % 12;
- if (!hour) hour = 12;
- snprintf (brief, sizeof(brief), "%02d:%02d %cM", hour, tm->tm_min,
- tm->tm_hour >= 12 ? 'P' : 'A');
- return brief;
- }
- }
- else if (w->clock.utime)
- {
- static char utime[35];
- Time_t tsec;
- tsec = time(NULL);
- snprintf (utime, sizeof(utime), "%10lu seconds since Epoch",
- (unsigned long)tsec);
- return utime;
- } else if (*w->clock.strftime) {
- /*Note: this code is probably excessively paranoid
- about buffer overflow. The extra size 10 padding
- is also meant as a further guard against programmer
- error, although it is a little controversial*/
- static char ctime[STRFTIME_BUFF_SIZE+10];
- ctime[0] = ctime[STRFTIME_BUFF_SIZE] = '\0';
- if (0 < strftime (ctime, STRFTIME_BUFF_SIZE-1,w->clock.strftime, tm)) {
- ctime[STRFTIME_BUFF_SIZE-1] = '\0';
- return ctime;
- } else {
- return asctime (tm);
- }
- }
- else if (w->clock.twentyfour)
- return asctime (tm);
- else
- {
- static char long12[28];
- strftime(long12, sizeof long12, "%a %b %d %I:%M:%S %p %Y", tm);
- return long12;
- }
+ if (w->clock.brief) {
+ if (w->clock.twentyfour) {
+ static char brief[6];
+
+ snprintf(brief, sizeof(brief), "%02d:%02d", tm->tm_hour,
+ tm->tm_min);
+ return brief;
+ }
+ else {
+ static char brief[9];
+ int hour = tm->tm_hour % 12;
+
+ if (!hour)
+ hour = 12;
+ snprintf(brief, sizeof(brief), "%02d:%02d %cM", hour, tm->tm_min,
+ tm->tm_hour >= 12 ? 'P' : 'A');
+ return brief;
+ }
+ }
+ else if (w->clock.utime) {
+ static char utime[35];
+ Time_t tsec;
+
+ tsec = time(NULL);
+ snprintf(utime, sizeof(utime), "%10lu seconds since Epoch",
+ (unsigned long) tsec);
+ return utime;
+ }
+ else if (*w->clock.strftime) {
+ /*Note: this code is probably excessively paranoid
+ about buffer overflow. The extra size 10 padding
+ is also meant as a further guard against programmer
+ error, although it is a little controversial */
+ static char ctime[STRFTIME_BUFF_SIZE + 10];
+
+ ctime[0] = ctime[STRFTIME_BUFF_SIZE] = '\0';
+ if (0 < strftime(ctime, STRFTIME_BUFF_SIZE - 1, w->clock.strftime, tm)) {
+ ctime[STRFTIME_BUFF_SIZE - 1] = '\0';
+ return ctime;
+ }
+ else {
+ return asctime(tm);
+ }
+ }
+ else if (w->clock.twentyfour)
+ return asctime(tm);
+ else {
+ static char long12[28];
+
+ strftime(long12, sizeof long12, "%a %b %d %I:%M:%S %p %Y", tm);
+ return long12;
+ }
}
/* ARGSUSED */
static void
-Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args)
+Initialize(Widget request, Widget new, ArgList args, Cardinal * num_args)
{
- ClockWidget w = (ClockWidget)new;
- XtGCMask valuemask;
- XGCValues myXGCV;
+ ClockWidget w = (ClockWidget) new;
+ XtGCMask valuemask;
+ XGCValues myXGCV;
int min_height, min_width;
valuemask = GCForeground | GCBackground | GCFont | GCLineWidth;
if (w->clock.font != NULL)
myXGCV.font = w->clock.font->fid;
else
- valuemask &= ~GCFont; /* use server default font */
+ valuemask &= ~GCFont; /* use server default font */
min_width = min_height = ANALOG_SIZE_DEFAULT;
- if(!w->clock.analog) {
- char *str;
- struct tm tm;
- struct timeval tv;
- int len;
+ if (!w->clock.analog) {
+ char *str;
+ struct tm tm;
+ struct timeval tv;
+ int len;
#ifndef NO_I18N
- w->clock.utf8 = False;
-
- if (!no_locale) {
- char *time_locale = setlocale(LC_CTYPE, NULL);
-
- if (strstr(time_locale, "UTF-8") || strstr(time_locale, "utf8")) {
- w->clock.utf8 = True;
- }
-
- /*
- * initialize time format from CFTIME if set, otherwise
- * default to "%c". This emulates ascftime, but we use
- * strftime so we can limit the string buffer size to
- * avoid possible buffer overflow.
- */
- if ((w->clock.strftime == NULL) || (w->clock.strftime[0] == 0)) {
- w->clock.strftime = getenv("CFTIME");
- if (w->clock.strftime == NULL) {
- w->clock.strftime = "%c";
- }
- }
- }
-#endif /* NO_I18N */
-
- X_GETTIMEOFDAY(&tv);
- tm = *localtime(&tv.tv_sec);
- str = TimeString (w, &tm);
- len = strlen(str);
- if (len && str[len - 1] == '\n') str[--len] = '\0';
+ w->clock.utf8 = False;
+
+ if (!no_locale) {
+ char *time_locale = setlocale(LC_CTYPE, NULL);
+
+ if (strstr(time_locale, "UTF-8") || strstr(time_locale, "utf8")) {
+ w->clock.utf8 = True;
+ }
+
+ /*
+ * initialize time format from CFTIME if set, otherwise
+ * default to "%c". This emulates ascftime, but we use
+ * strftime so we can limit the string buffer size to
+ * avoid possible buffer overflow.
+ */
+ if ((w->clock.strftime == NULL) || (w->clock.strftime[0] == 0)) {
+ w->clock.strftime = getenv("CFTIME");
+ if (w->clock.strftime == NULL) {
+ w->clock.strftime = "%c";
+ }
+ }
+ }
+#endif /* NO_I18N */
+
+ X_GETTIMEOFDAY(&tv);
+ tm = *localtime(&tv.tv_sec);
+ str = TimeString(w, &tm);
+ len = strlen(str);
+ if (len && str[len - 1] == '\n')
+ str[--len] = '\0';
#ifdef XRENDER
- if (w->clock.render)
- {
- XGlyphInfo extents;
+ if (w->clock.render) {
+ XGlyphInfo extents;
+
#ifndef NO_I18N
-# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
- char *utf8_str;
-# endif
- if (w->clock.utf8)
- XftTextExtentsUtf8 (XtDisplay (w), w->clock.face,
- (FcChar8 *) str, len, &extents);
-# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
- else if ((utf8_str = clock_to_utf8(str, len)) != NULL) {
- XftTextExtentsUtf8 (XtDisplay (w), w->clock.face,
- (FcChar8 *)utf8_str, strlen(utf8_str), &extents);
- free(utf8_str);
- }
-# endif
- else
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+ char *utf8_str;
+#endif
+ if (w->clock.utf8)
+ XftTextExtentsUtf8(XtDisplay(w), w->clock.face,
+ (FcChar8 *) str, len, &extents);
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+ else if ((utf8_str = clock_to_utf8(str, len)) != NULL) {
+ XftTextExtentsUtf8(XtDisplay(w), w->clock.face,
+ (FcChar8 *) utf8_str, strlen(utf8_str),
+ &extents);
+ free(utf8_str);
+ }
#endif
- XftTextExtents8 (XtDisplay (w), w->clock.face,
- (FcChar8 *) str, len, &extents);
- min_width = extents.xOff + 2 * w->clock.padding;
- min_height = w->clock.face->ascent + w->clock.face->descent +
- 2 * w->clock.padding;
- /*fprintf(stderr, "render min_width %i\n", min_width);*/
- }
- else
+ else
#endif
- { /* not XRENDER block */
+ XftTextExtents8(XtDisplay(w), w->clock.face,
+ (FcChar8 *) str, len, &extents);
+ min_width = extents.xOff + 2 * w->clock.padding;
+ min_height = w->clock.face->ascent + w->clock.face->descent +
+ 2 * w->clock.padding;
+ /*fprintf(stderr, "render min_width %i\n", min_width); */
+ }
+ else
+#endif
+ { /* not XRENDER block */
#ifndef NO_I18N
- if (!no_locale) {
- XFontSetExtents *fse;
-
- if(w->clock.fontSet == NULL) {
- char **missing, *default_str;
- int n_missing;
- w->clock.fontSet = XCreateFontSet( XtDisplay(w),
- XtDefaultFontSet,
- &missing,
- &n_missing,
- &default_str);
- }
- if (w->clock.fontSet != NULL)
- {
- /* don't free this... it's freed with the XFontSet. */
- fse = XExtentsOfFontSet(w->clock.fontSet);
-
- min_width = XmbTextEscapement(w->clock.fontSet,str,
- len)
- + 2 * w->clock.padding;
- min_height = fse->max_logical_extent.height +
- 3 * w->clock.padding;
- } else {
- no_locale = True;
- }
- }
-
- if (no_locale)
-#endif /* NO_I18N */
- {
- if (w->clock.font == NULL)
- w->clock.font = XQueryFont( XtDisplay(w),
- XGContextFromGC(
- DefaultGCOfScreen(XtScreen(w))) );
- min_width = XTextWidth(w->clock.font, str, len) +
- 2 * w->clock.padding;
- min_height = w->clock.font->ascent +
- w->clock.font->descent + 2 * w->clock.padding;
- /*fprintf(stderr, "font min_width %i\n", min_width);*/
- }
- } /* not XRENDER block */
+ if (!no_locale) {
+ XFontSetExtents *fse;
+
+ if (w->clock.fontSet == NULL) {
+ char **missing, *default_str;
+ int n_missing;
+
+ w->clock.fontSet = XCreateFontSet(XtDisplay(w),
+ XtDefaultFontSet,
+ &missing,
+ &n_missing, &default_str);
+ }
+ if (w->clock.fontSet != NULL) {
+ /* don't free this... it's freed with the XFontSet. */
+ fse = XExtentsOfFontSet(w->clock.fontSet);
+
+ min_width = XmbTextEscapement(w->clock.fontSet, str, len) +
+ 2 * w->clock.padding;
+ min_height = fse->max_logical_extent.height +
+ 3 * w->clock.padding;
+ /*fprintf(stderr, "fontset min_width %i\n", min_width); */
+ }
+ else {
+ no_locale = True;
+ }
+ }
+
+ if (no_locale)
+#endif /* NO_I18N */
+ {
+ if (w->clock.font == NULL)
+ w->clock.font = XQueryFont(XtDisplay(w),
+ XGContextFromGC(DefaultGCOfScreen
+ (XtScreen(w))));
+ min_width =
+ XTextWidth(w->clock.font, str, len) + 2 * w->clock.padding;
+ min_height =
+ w->clock.font->ascent + w->clock.font->descent +
+ 2 * w->clock.padding;
+ /*fprintf(stderr, "font min_width %i\n", min_width); */
+ }
+ } /* not XRENDER block */
}
if (w->core.width == 0)
- w->core.width = min_width;
+ w->core.width = min_width;
if (w->core.height == 0)
- w->core.height = min_height;
+ w->core.height = min_height;
- myXGCV.foreground = ClockFgPixel (w);
+ myXGCV.foreground = ClockFgPixel(w);
myXGCV.background = w->core.background_pixel;
if (w->clock.font != NULL)
- myXGCV.font = w->clock.font->fid;
+ myXGCV.font = w->clock.font->fid;
else
- valuemask &= ~GCFont; /* use server default font */
+ valuemask &= ~GCFont; /* use server default font */
myXGCV.line_width = 0;
- w->clock.myGC = XtGetGC((Widget)w, valuemask, &myXGCV);
+ w->clock.myGC = XtGetGC((Widget) w, valuemask, &myXGCV);
valuemask = GCForeground | GCLineWidth | GCGraphicsExposures;
myXGCV.foreground = w->core.background_pixel;
if (w->core.background_pixmap != XtUnspecifiedPixmap) {
- myXGCV.tile = w->core.background_pixmap;
- myXGCV.fill_style = FillTiled;
- valuemask |= (GCTile | GCFillStyle);
+ myXGCV.tile = w->core.background_pixmap;
+ myXGCV.fill_style = FillTiled;
+ valuemask |= (GCTile | GCFillStyle);
}
myXGCV.graphics_exposures = False;
- w->clock.EraseGC = XtGetGC((Widget)w, valuemask, &myXGCV);
+ w->clock.EraseGC = XtGetGC((Widget) w, valuemask, &myXGCV);
valuemask &= ~(GCTile | GCFillStyle);
myXGCV.foreground = w->clock.Hipixel;
- w->clock.HighGC = XtGetGC((Widget)w, valuemask, &myXGCV);
+ w->clock.HighGC = XtGetGC((Widget) w, valuemask, &myXGCV);
valuemask = GCForeground;
myXGCV.foreground = w->clock.Hdpixel;
- w->clock.HandGC = XtGetGC((Widget)w, valuemask, &myXGCV);
+ w->clock.HandGC = XtGetGC((Widget) w, valuemask, &myXGCV);
/* make invalid update's use a default */
- /*if (w->clock.update <= 0) w->clock.update = 60;*/
- w->clock.show_second_hand = (abs((int) w->clock.update) <= SECOND_HAND_TIME);
+ /*if (w->clock.update <= 0) w->clock.update = 60; */
+ w->clock.show_second_hand =
+ (abs((int) w->clock.update) <= SECOND_HAND_TIME);
w->clock.numseg = 0;
w->clock.interval_id = 0;
- memset (&w->clock.otm, '\0', sizeof (w->clock.otm));
+ memset(&w->clock.otm, '\0', sizeof(w->clock.otm));
#ifdef XRENDER
{
- int major, minor;
-
- if (XRenderQueryVersion (XtDisplay (w), &major, &minor) &&
- (major > 0 ||
- (major == 0 && minor >= 4)))
- {
- w->clock.can_polygon = True;
- }
- else
- w->clock.can_polygon = False;
+ int major, minor;
+
+ if (XRenderQueryVersion(XtDisplay(w), &major, &minor) &&
+ (major > 0 || (major == 0 && minor >= 4))) {
+ w->clock.can_polygon = True;
+ }
+ else
+ w->clock.can_polygon = False;
}
w->clock.pixmap = 0;
w->clock.draw = NULL;
@@ -754,100 +746,96 @@ Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args)
#ifdef XRENDER
static void
-RenderPrepare (ClockWidget w, XftColor *color)
+RenderPrepare(ClockWidget w, XftColor * color)
{
- if (!w->clock.draw)
- {
- Drawable d = XtWindow (w);
- if (w->clock.buffer)
- {
- if (!w->clock.pixmap)
- {
- Arg arg[1];
- w->clock.pixmap = XCreatePixmap (XtDisplay (w), d,
- w->core.width,
- w->core.height,
- w->core.depth);
- arg[0].name = XtNbackgroundPixmap;
- arg[0].value = 0;
- XtSetValues ((Widget) w, arg, 1);
- }
- d = w->clock.pixmap;
- }
-
- w->clock.draw = XftDrawCreate (XtDisplay (w), d,
- DefaultVisual (XtDisplay (w),
- DefaultScreen(XtDisplay (w))),
- w->core.colormap);
- w->clock.picture = XftDrawPicture (w->clock.draw);
+ if (!w->clock.draw) {
+ Drawable d = XtWindow(w);
+
+ if (w->clock.buffer) {
+ if (!w->clock.pixmap) {
+ Arg arg[1];
+
+ w->clock.pixmap = XCreatePixmap(XtDisplay(w), d,
+ w->core.width,
+ w->core.height, w->core.depth);
+ arg[0].name = XtNbackgroundPixmap;
+ arg[0].value = 0;
+ XtSetValues((Widget) w, arg, 1);
+ }
+ d = w->clock.pixmap;
+ }
+
+ w->clock.draw = XftDrawCreate(XtDisplay(w), d,
+ DefaultVisual(XtDisplay(w),
+ DefaultScreen(XtDisplay
+ (w))),
+ w->core.colormap);
+ w->clock.picture = XftDrawPicture(w->clock.draw);
}
if (color)
- w->clock.fill_picture = XftDrawSrcPicture (w->clock.draw, color);
+ w->clock.fill_picture = XftDrawSrcPicture(w->clock.draw, color);
}
static void
-RenderClip (ClockWidget w)
+RenderClip(ClockWidget w)
{
- Region r;
- Drawable d;
+ Region r;
+ Drawable d;
- RenderPrepare (w, NULL);
+ RenderPrepare(w, NULL);
if (w->clock.buffer)
- d = w->clock.pixmap;
+ d = w->clock.pixmap;
else
- d = XtWindow (w);
- XFillRectangle (XtDisplay (w), d, w->clock.EraseGC,
- w->clock.damage.x,
- w->clock.damage.y,
- w->clock.damage.width,
- w->clock.damage.height);
- r = XCreateRegion ();
- XUnionRectWithRegion (&w->clock.damage,
- r, r);
- XftDrawSetClip (w->clock.draw, r);
- XDestroyRegion (r);
+ d = XtWindow(w);
+ XFillRectangle(XtDisplay(w), d, w->clock.EraseGC,
+ w->clock.damage.x,
+ w->clock.damage.y,
+ w->clock.damage.width, w->clock.damage.height);
+ r = XCreateRegion();
+ XUnionRectWithRegion(&w->clock.damage, r, r);
+ XftDrawSetClip(w->clock.draw, r);
+ XDestroyRegion(r);
}
static void
-RenderTextBounds (ClockWidget w, char *str, int off, int len,
- XRectangle *bounds, int *xp, int *yp)
+RenderTextBounds(ClockWidget w, char *str, int off, int len,
+ XRectangle * bounds, int *xp, int *yp)
{
- XGlyphInfo head, tail;
- int x, y;
+ XGlyphInfo head, tail;
+ int x, y;
#ifndef NO_I18N
-# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
char *utf8_str;
-# endif
- if (w->clock.utf8)
- {
- XftTextExtentsUtf8 (XtDisplay (w), w->clock.face,
- (FcChar8 *) str, off, &head);
- XftTextExtentsUtf8 (XtDisplay (w), w->clock.face,
- (FcChar8 *) str + off, len - off, &tail);
+#endif
+ if (w->clock.utf8) {
+ XftTextExtentsUtf8(XtDisplay(w), w->clock.face,
+ (FcChar8 *) str, off, &head);
+ XftTextExtentsUtf8(XtDisplay(w), w->clock.face,
+ (FcChar8 *) str + off, len - off, &tail);
}
-# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
- else if ((utf8_str = clock_to_utf8(str, off)) != NULL)
- {
- XftTextExtentsUtf8 (XtDisplay (w), w->clock.face,
- (FcChar8 *)utf8_str, strlen(utf8_str), &head);
- free(utf8_str);
- if ((utf8_str = clock_to_utf8(str+off, len-off)) != NULL) {
- XftTextExtentsUtf8 (XtDisplay (w), w->clock.face,
- (FcChar8 *)utf8_str, strlen(utf8_str), &tail);
- free(utf8_str);
- } else
- goto fallback;
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+ else if ((utf8_str = clock_to_utf8(str, off)) != NULL) {
+ XftTextExtentsUtf8(XtDisplay(w), w->clock.face,
+ (FcChar8 *) utf8_str, strlen(utf8_str), &head);
+ free(utf8_str);
+ if ((utf8_str = clock_to_utf8(str + off, len - off)) != NULL) {
+ XftTextExtentsUtf8(XtDisplay(w), w->clock.face,
+ (FcChar8 *) utf8_str, strlen(utf8_str), &tail);
+ free(utf8_str);
+ }
+ else
+ goto fallback;
}
-# endif
+#endif
else
#endif
{
- fallback:
- XftTextExtents8 (XtDisplay (w), w->clock.face, (FcChar8 *) str,
- off, &head);
- XftTextExtents8 (XtDisplay (w), w->clock.face, (FcChar8 *) str + off,
- len - off, &tail);
+ fallback:
+ XftTextExtents8(XtDisplay(w), w->clock.face, (FcChar8 *) str,
+ off, &head);
+ XftTextExtents8(XtDisplay(w), w->clock.face, (FcChar8 *) str + off,
+ len - off, &tail);
}
/*
@@ -862,41 +850,43 @@ RenderTextBounds (ClockWidget w, char *str, int off, int len,
bounds->y = y - tail.y - 1;
bounds->width = tail.width + 2;
bounds->height = tail.height + 2;
- if (xp) *xp = x;
- if (yp) *yp = y;
+ if (xp)
+ *xp = x;
+ if (yp)
+ *yp = y;
}
static void
-RenderUpdateRectBounds (XRectangle *damage, XRectangle *bounds)
+RenderUpdateRectBounds(XRectangle * damage, XRectangle * bounds)
{
- int x1 = bounds->x;
- int y1 = bounds->y;
- int x2 = bounds->x + bounds->width;
- int y2 = bounds->y + bounds->height;
- int d_x1 = damage->x;
- int d_y1 = damage->y;
- int d_x2 = damage->x + damage->width;
- int d_y2 = damage->y + damage->height;
-
- if (x1 == x2)
- {
- x1 = d_x1;
- x2 = d_x2;
+ int x1 = bounds->x;
+ int y1 = bounds->y;
+ int x2 = bounds->x + bounds->width;
+ int y2 = bounds->y + bounds->height;
+ int d_x1 = damage->x;
+ int d_y1 = damage->y;
+ int d_x2 = damage->x + damage->width;
+ int d_y2 = damage->y + damage->height;
+
+ if (x1 == x2) {
+ x1 = d_x1;
+ x2 = d_x2;
}
- else
- {
- if (d_x1 < x1) x1 = d_x1;
- if (d_x2 > x2) x2 = d_x2;
+ else {
+ if (d_x1 < x1)
+ x1 = d_x1;
+ if (d_x2 > x2)
+ x2 = d_x2;
}
- if (y1 == y2)
- {
- y1 = d_y1;
- y2 = d_y2;
+ if (y1 == y2) {
+ y1 = d_y1;
+ y2 = d_y2;
}
- else
- {
- if (d_y1 < y1) y1 = d_y1;
- if (d_y2 > y2) y2 = d_y2;
+ else {
+ if (d_y1 < y1)
+ y1 = d_y1;
+ if (d_y2 > y2)
+ y2 = d_y2;
}
bounds->x = x1;
@@ -906,16 +896,16 @@ RenderUpdateRectBounds (XRectangle *damage, XRectangle *bounds)
}
static Boolean
-RenderRectIn (XRectangle *rect, XRectangle *bounds)
+RenderRectIn(XRectangle * rect, XRectangle * bounds)
{
- int x1 = bounds->x;
- int y1 = bounds->y;
- int x2 = bounds->x + bounds->width;
- int y2 = bounds->y + bounds->height;
- int r_x1 = rect->x;
- int r_y1 = rect->y;
- int r_x2 = rect->x + rect->width;
- int r_y2 = rect->y + rect->height;
+ int x1 = bounds->x;
+ int y1 = bounds->y;
+ int x2 = bounds->x + bounds->width;
+ int y2 = bounds->y + bounds->height;
+ int r_x1 = rect->x;
+ int r_y1 = rect->y;
+ int r_x2 = rect->x + rect->width;
+ int r_y2 = rect->y + rect->height;
return r_x1 < x2 && x1 < r_x2 && r_y1 < y2 && y1 < r_y2;
}
@@ -927,29 +917,32 @@ RenderRectIn (XRectangle *rect, XRectangle *bounds)
#define YCoord(y,w) ((y) * (w)->clock.y_scale + (w)->clock.y_off)
static void
-RenderUpdateBounds (XPointDouble *points, int npoints, XRectangle *bounds)
+RenderUpdateBounds(XPointDouble * points, int npoints, XRectangle * bounds)
{
- int x1 = bounds->x;
- int y1 = bounds->y;
- int x2 = bounds->x + bounds->width;
- int y2 = bounds->y + bounds->height;
-
- while (npoints--)
- {
- int r_x1 = points[0].x;
- int r_y1 = points[0].y;
- int r_x2 = points[0].x + 1;
- int r_y2 = points[0].y + 1;
-
- if (x1 == x2)
- x2 = x1 = r_x1;
- if (y1 == y2)
- y2 = y1 = r_y1;
- if (r_x1 < x1) x1 = r_x1;
- if (r_y1 < y1) y1 = r_y1;
- if (r_x2 > x2) x2 = r_x2;
- if (r_y2 > y2) y2 = r_y2;
- points++;
+ int x1 = bounds->x;
+ int y1 = bounds->y;
+ int x2 = bounds->x + bounds->width;
+ int y2 = bounds->y + bounds->height;
+
+ while (npoints--) {
+ int r_x1 = points[0].x;
+ int r_y1 = points[0].y;
+ int r_x2 = points[0].x + 1;
+ int r_y2 = points[0].y + 1;
+
+ if (x1 == x2)
+ x2 = x1 = r_x1;
+ if (y1 == y2)
+ y2 = y1 = r_y1;
+ if (r_x1 < x1)
+ x1 = r_x1;
+ if (r_y1 < y1)
+ y1 = r_y1;
+ if (r_x2 > x2)
+ x2 = r_x2;
+ if (r_y2 > y2)
+ y2 = r_y2;
+ points++;
}
bounds->x = x1;
bounds->y = y1;
@@ -958,38 +951,36 @@ RenderUpdateBounds (XPointDouble *points, int npoints, XRectangle *bounds)
}
static Boolean
-RenderCheckBounds (XPointDouble *points, int npoints, XRectangle *bounds)
+RenderCheckBounds(XPointDouble * points, int npoints, XRectangle * bounds)
{
- int x1 = bounds->x;
- int y1 = bounds->y;
- int x2 = bounds->x + bounds->width;
- int y2 = bounds->y + bounds->height;
-
- while (npoints--)
- {
- if (x1 <= points->x && points->x <= x2 &&
- y1 <= points->y && points->y <= y2)
- return True;
- points++;
+ int x1 = bounds->x;
+ int y1 = bounds->y;
+ int x2 = bounds->x + bounds->width;
+ int y2 = bounds->y + bounds->height;
+
+ while (npoints--) {
+ if (x1 <= points->x && points->x <= x2 &&
+ y1 <= points->y && points->y <= y2)
+ return True;
+ points++;
}
return False;
}
static void
-RenderUpdate (ClockWidget w)
+RenderUpdate(ClockWidget w)
{
- if (w->clock.buffer && w->clock.pixmap)
- {
- XCopyArea (XtDisplay (w), w->clock.pixmap,
- XtWindow (w), w->clock.EraseGC,
- w->clock.damage.x, w->clock.damage.y,
- w->clock.damage.width, w->clock.damage.height,
- w->clock.damage.x, w->clock.damage.y);
+ if (w->clock.buffer && w->clock.pixmap) {
+ XCopyArea(XtDisplay(w), w->clock.pixmap,
+ XtWindow(w), w->clock.EraseGC,
+ w->clock.damage.x, w->clock.damage.y,
+ w->clock.damage.width, w->clock.damage.height,
+ w->clock.damage.x, w->clock.damage.y);
}
}
static void
-RenderResetBounds (XRectangle *bounds)
+RenderResetBounds(XRectangle * bounds)
{
bounds->x = 0;
bounds->y = 0;
@@ -998,64 +989,62 @@ RenderResetBounds (XRectangle *bounds)
}
static void
-RenderLine (ClockWidget w, XDouble x1, XDouble y1, XDouble x2, XDouble y2,
- XftColor *color,
- Boolean draw)
+RenderLine(ClockWidget w, XDouble x1, XDouble y1, XDouble x2, XDouble y2,
+ XftColor * color, Boolean draw)
{
- XPointDouble poly[4];
- XDouble dx = (x2 - x1);
- XDouble dy = (y2 - y1);
- XDouble len = sqrt (dx*dx + dy*dy);
- XDouble ldx = (LINE_WIDTH/2.0) * dy / len;
- XDouble ldy = (LINE_WIDTH/2.0) * dx / len;
-
- poly[0].x = XCoord (x1 + ldx, w);
- poly[0].y = YCoord (y1 - ldy, w);
-
- poly[1].x = XCoord (x2 + ldx, w);
- poly[1].y = YCoord (y2 - ldy, w);
-
- poly[2].x = XCoord (x2 - ldx, w);
- poly[2].y = YCoord (y2 + ldy, w);
-
- poly[3].x = XCoord (x1 - ldx, w);
- poly[3].y = YCoord (y1 + ldy, w);
-
- RenderUpdateBounds (poly, 4, &w->clock.damage);
- if (draw)
- {
- if (RenderCheckBounds (poly, 4, &w->clock.damage))
- {
- RenderPrepare (w, color);
- XRenderCompositeDoublePoly (XtDisplay (w),
- PictOpOver,
- w->clock.fill_picture,
- w->clock.picture,
- w->clock.mask_format,
- 0, 0, 0, 0, poly, 4, EvenOddRule);
- }
+ XPointDouble poly[4];
+ XDouble dx = (x2 - x1);
+ XDouble dy = (y2 - y1);
+ XDouble len = sqrt(dx * dx + dy * dy);
+ XDouble ldx = (LINE_WIDTH / 2.0) * dy / len;
+ XDouble ldy = (LINE_WIDTH / 2.0) * dx / len;
+
+ poly[0].x = XCoord(x1 + ldx, w);
+ poly[0].y = YCoord(y1 - ldy, w);
+
+ poly[1].x = XCoord(x2 + ldx, w);
+ poly[1].y = YCoord(y2 - ldy, w);
+
+ poly[2].x = XCoord(x2 - ldx, w);
+ poly[2].y = YCoord(y2 + ldy, w);
+
+ poly[3].x = XCoord(x1 - ldx, w);
+ poly[3].y = YCoord(y1 + ldy, w);
+
+ RenderUpdateBounds(poly, 4, &w->clock.damage);
+ if (draw) {
+ if (RenderCheckBounds(poly, 4, &w->clock.damage)) {
+ RenderPrepare(w, color);
+ XRenderCompositeDoublePoly(XtDisplay(w),
+ PictOpOver,
+ w->clock.fill_picture,
+ w->clock.picture,
+ w->clock.mask_format,
+ 0, 0, 0, 0, poly, 4, EvenOddRule);
+ }
}
else
- RenderUpdateBounds (poly, 4, &w->clock.damage);
+ RenderUpdateBounds(poly, 4, &w->clock.damage);
}
static void
-RenderRotate (ClockWidget w, XPointDouble *out, double x, double y, double s, double c)
+RenderRotate(ClockWidget w, XPointDouble * out, double x, double y, double s,
+ double c)
{
- out->x = XCoord (x * c - y * s, w);
- out->y = YCoord (y * c + x * s, w);
+ out->x = XCoord(x * c - y * s, w);
+ out->y = YCoord(y * c + x * s, w);
}
static void
-RenderHand (ClockWidget w, int tick_units, int size, XftColor *color,
- Boolean draw)
+RenderHand(ClockWidget w, double tick_units, double size, XftColor * color,
+ Boolean draw)
{
- double c, s;
- XPointDouble poly[3];
- double outer_x;
- double inner_y;
+ double c, s;
+ XPointDouble poly[3];
+ double outer_x;
+ double inner_y;
- ClockAngle (tick_units, &c, &s);
+ ClockAngle(tick_units, &c, &s);
s = -s;
/* compute raw positions */
@@ -1063,49 +1052,51 @@ RenderHand (ClockWidget w, int tick_units, int size, XftColor *color,
inner_y = HAND_WIDTH_FRACT / 100.0;
/* rotate them into position */
- RenderRotate (w, &poly[0], outer_x, 0.0, s, c);
- RenderRotate (w, &poly[1], -inner_y, inner_y, s, c);
- RenderRotate (w, &poly[2], -inner_y, -inner_y, s, c);
-
- if (draw)
- {
- if (RenderCheckBounds (poly, 3, &w->clock.damage))
- {
- RenderPrepare (w, color);
- XRenderCompositeDoublePoly (XtDisplay (w),
- PictOpOver,
- w->clock.fill_picture,
- w->clock.picture,
- w->clock.mask_format,
- 0, 0, 0, 0, poly, 3, EvenOddRule);
- }
+ RenderRotate(w, &poly[0], outer_x, 0.0, s, c);
+ RenderRotate(w, &poly[1], -inner_y, inner_y, s, c);
+ RenderRotate(w, &poly[2], -inner_y, -inner_y, s, c);
+
+ if (draw) {
+ if (RenderCheckBounds(poly, 3, &w->clock.damage)) {
+ RenderPrepare(w, color);
+ XRenderCompositeDoublePoly(XtDisplay(w),
+ PictOpOver,
+ w->clock.fill_picture,
+ w->clock.picture,
+ w->clock.mask_format,
+ 0, 0, 0, 0, poly, 3, EvenOddRule);
+ }
}
- RenderUpdateBounds (poly, 3, &w->clock.damage);
+ RenderUpdateBounds(poly, 3, &w->clock.damage);
}
static void
-RenderHands (ClockWidget w, struct tm *tm, Boolean draw)
+RenderHands(ClockWidget w, struct tm *tm, struct timeval *tv, Boolean draw)
{
- RenderHand (w, tm->tm_hour * 300 + tm->tm_min*5, HOUR_HAND_FRACT, &w->clock.hour_color, draw);
- RenderHand (w, tm->tm_min * 60 + tm->tm_sec, MINUTE_HAND_FRACT, &w->clock.min_color, draw);
+ double sec = tm->tm_sec + tv->tv_usec / 1000000.0;
+
+ RenderHand(w, tm->tm_hour * 300 + tm->tm_min * 5 + sec / 12.0, HOUR_HAND_FRACT,
+ &w->clock.hour_color, draw);
+ RenderHand(w, tm->tm_min * 60 + sec, MINUTE_HAND_FRACT,
+ &w->clock.min_color, draw);
}
static void
-RenderSec (ClockWidget w, struct tm *tm, struct timeval *tv, Boolean draw)
+RenderSec(ClockWidget w, struct tm *tm, struct timeval *tv, Boolean draw)
{
- double c, s;
- XPointDouble poly[10];
- double inner_x, middle_x, outer_x, far_x;
- double middle_y;
- double line_y;
- double sec;
+ double c, s;
+ XPointDouble poly[10];
+ double inner_x, middle_x, outer_x, far_x;
+ double middle_y;
+ double line_y;
+ double sec;
sec = tm->tm_sec;
if (w->clock.update < 1.0)
- sec += tv->tv_usec / 1000000.0;
+ sec += tv->tv_usec / 1000000.0;
- ClockAngle ((int) (sec * 60.0), &c, &s);
+ ClockAngle((int) (sec * 60.0), &c, &s);
s = -s;
@@ -1122,91 +1113,98 @@ RenderSec (ClockWidget w, struct tm *tm, struct timeval *tv, Boolean draw)
/*
* Rotate them into position
*/
- RenderRotate (w, &poly[0], -line_y, line_y, s, c);
- RenderRotate (w, &poly[1], inner_x, line_y, s, c);
- RenderRotate (w, &poly[2], middle_x, middle_y, s, c);
- RenderRotate (w, &poly[3], outer_x, line_y, s, c);
- RenderRotate (w, &poly[4], far_x, line_y, s, c);
- RenderRotate (w, &poly[5], far_x, -line_y, s, c);
- RenderRotate (w, &poly[6], outer_x, -line_y, s, c);
- RenderRotate (w, &poly[7], middle_x, -middle_y, s, c);
- RenderRotate (w, &poly[8], inner_x, -line_y, s, c);
- RenderRotate (w, &poly[9], -line_y, -line_y, s, c);
-
- if (draw)
- {
- if (RenderCheckBounds (poly, 10, &w->clock.damage))
- {
- RenderPrepare (w, &w->clock.sec_color);
- XRenderCompositeDoublePoly (XtDisplay (w),
- PictOpOver,
- w->clock.fill_picture,
- w->clock.picture,
- w->clock.mask_format,
- 0, 0, 0, 0, poly, 10, EvenOddRule);
- }
+ RenderRotate(w, &poly[0], -line_y, line_y, s, c);
+ RenderRotate(w, &poly[1], inner_x, line_y, s, c);
+ RenderRotate(w, &poly[2], middle_x, middle_y, s, c);
+ RenderRotate(w, &poly[3], outer_x, line_y, s, c);
+ RenderRotate(w, &poly[4], far_x, line_y, s, c);
+ RenderRotate(w, &poly[5], far_x, -line_y, s, c);
+ RenderRotate(w, &poly[6], outer_x, -line_y, s, c);
+ RenderRotate(w, &poly[7], middle_x, -middle_y, s, c);
+ RenderRotate(w, &poly[8], inner_x, -line_y, s, c);
+ RenderRotate(w, &poly[9], -line_y, -line_y, s, c);
+
+ if (draw) {
+ if (RenderCheckBounds(poly, 10, &w->clock.damage)) {
+ RenderPrepare(w, &w->clock.sec_color);
+ XRenderCompositeDoublePoly(XtDisplay(w),
+ PictOpOver,
+ w->clock.fill_picture,
+ w->clock.picture,
+ w->clock.mask_format,
+ 0, 0, 0, 0, poly, 10, EvenOddRule);
+ }
}
- else
- {
- RenderUpdateBounds (poly, 10, &w->clock.damage);
+ else {
+ RenderUpdateBounds(poly, 10, &w->clock.damage);
}
}
#endif
static void
-Realize(Widget gw, XtValueMask *valueMask, XSetWindowAttributes *attrs)
+Realize(Widget gw, XtValueMask * valueMask, XSetWindowAttributes * attrs)
{
- ClockWidget w = (ClockWidget) gw;
+ ClockWidget w = (ClockWidget) gw;
+
#ifdef notdef
- *valueMask |= CWBitGravity;
- attrs->bit_gravity = ForgetGravity;
+ *valueMask |= CWBitGravity;
+ attrs->bit_gravity = ForgetGravity;
#endif
- switch (w->clock.backing_store) {
- case Always:
- case NotUseful:
- case WhenMapped:
- *valueMask |=CWBackingStore;
- attrs->backing_store = w->clock.backing_store;
- break;
- }
- (*clockWidgetClass->core_class.superclass->core_class.realize)
- (gw, valueMask, attrs);
- Resize(gw);
+ switch (w->clock.backing_store) {
+ case Always:
+ case NotUseful:
+ case WhenMapped:
+ *valueMask |= CWBackingStore;
+ attrs->backing_store = w->clock.backing_store;
+ break;
+ }
+ (*clockWidgetClass->core_class.superclass->core_class.realize)
+ (gw, valueMask, attrs);
+ Resize(gw);
}
static void
Destroy(Widget gw)
{
- ClockWidget w = (ClockWidget) gw;
- if (w->clock.interval_id) XtRemoveTimeOut (w->clock.interval_id);
+ ClockWidget w = (ClockWidget) gw;
+
+ if (w->clock.interval_id)
+ XtRemoveTimeOut(w->clock.interval_id);
#ifdef XRENDER
if (w->clock.picture)
- XRenderFreePicture (XtDisplay(w), w->clock.picture);
+ XRenderFreePicture(XtDisplay(w), w->clock.picture);
if (w->clock.fill_picture)
- XRenderFreePicture (XtDisplay(w), w->clock.fill_picture);
+ XRenderFreePicture(XtDisplay(w), w->clock.fill_picture);
#endif
- XtReleaseGC (gw, w->clock.myGC);
- XtReleaseGC (gw, w->clock.HighGC);
- XtReleaseGC (gw, w->clock.HandGC);
- XtReleaseGC (gw, w->clock.EraseGC);
+ XtReleaseGC(gw, w->clock.myGC);
+ XtReleaseGC(gw, w->clock.HighGC);
+ XtReleaseGC(gw, w->clock.HandGC);
+ XtReleaseGC(gw, w->clock.EraseGC);
}
static void
Resize(Widget gw)
{
ClockWidget w = (ClockWidget) gw;
+
/* don't do this computation if window hasn't been realized yet. */
if (XtIsRealized(gw) && w->clock.analog) {
- /* need signed value since Dimension is unsigned */
- int radius = ((int) min(w->core.width, w->core.height) - (int) (2 * w->clock.padding)) / 2;
- w->clock.radius = (Dimension) max (radius, 1);
-
- w->clock.second_hand_length = (int)(SECOND_HAND_FRACT * w->clock.radius) / 100;
- w->clock.minute_hand_length = (int)(MINUTE_HAND_FRACT * w->clock.radius) / 100;
- w->clock.hour_hand_length = (int)(HOUR_HAND_FRACT * w->clock.radius) / 100;
- w->clock.hand_width = (int)(HAND_WIDTH_FRACT * w->clock.radius) / 100;
- w->clock.second_hand_width = (int)(SECOND_WIDTH_FRACT * w->clock.radius) / 100;
+ /* need signed value since Dimension is unsigned */
+ int radius =
+ ((int) min(w->core.width, w->core.height) -
+ (int) (2 * w->clock.padding)) / 2;
+ w->clock.radius = (Dimension) max(radius, 1);
+
+ w->clock.second_hand_length =
+ (int) (SECOND_HAND_FRACT * w->clock.radius) / 100;
+ w->clock.minute_hand_length =
+ (int) (MINUTE_HAND_FRACT * w->clock.radius) / 100;
+ w->clock.hour_hand_length =
+ (int) (HOUR_HAND_FRACT * w->clock.radius) / 100;
+ w->clock.hand_width = (int) (HAND_WIDTH_FRACT * w->clock.radius) / 100;
+ w->clock.second_hand_width =
+ (int) (SECOND_WIDTH_FRACT * w->clock.radius) / 100;
w->clock.centerX = w->core.width / 2;
w->clock.centerY = w->core.height / 2;
@@ -1216,44 +1214,44 @@ Resize(Widget gw)
w->clock.y_scale = 0.45 * w->core.height;
w->clock.x_off = 0.5 * w->core.width;
w->clock.y_off = 0.5 * w->core.height;
- if (w->clock.pixmap)
- {
- XFreePixmap (XtDisplay (w), w->clock.pixmap);
- w->clock.pixmap = 0;
- if (w->clock.draw)
- {
- XftDrawDestroy (w->clock.draw);
- w->clock.draw = NULL;
- }
- w->clock.picture = 0;
+ if (w->clock.pixmap) {
+ XFreePixmap(XtDisplay(w), w->clock.pixmap);
+ w->clock.pixmap = 0;
+ if (w->clock.draw) {
+ XftDrawDestroy(w->clock.draw);
+ w->clock.draw = NULL;
+ }
+ w->clock.picture = 0;
}
#endif
}
/* ARGSUSED */
static void
-Redisplay(Widget gw, XEvent *event, Region region)
+Redisplay(Widget gw, XEvent * event, Region region)
{
ClockWidget w = (ClockWidget) gw;
+
if (w->clock.analog) {
#ifdef XRENDER
- if (w->clock.render && w->clock.can_polygon)
- XClipBox (region, &w->clock.damage);
- else
+ if (w->clock.render && w->clock.can_polygon)
+ XClipBox(region, &w->clock.damage);
+ else
#endif
- {
- if (w->clock.numseg != 0)
- erase_hands (w, (struct tm *) 0);
- DrawClockFace(w);
- }
- } else {
+ {
+ if (w->clock.numseg != 0)
+ erase_hands(w, (struct tm *) 0);
+ DrawClockFace(w);
+ }
+ }
+ else {
#ifdef XRENDER
- if (w->clock.render)
- XClipBox (region, &w->clock.damage);
+ if (w->clock.render)
+ XClipBox(region, &w->clock.damage);
#endif
- w->clock.prev_time_string[0] = '\0';
+ w->clock.prev_time_string[0] = '\0';
}
- clock_tic((XtPointer)w, (XtIntervalId *)NULL);
+ clock_tic((XtPointer) w, (XtIntervalId *) NULL);
}
#define USEC_MILLIS(us) ((unsigned long) (us) / 1000)
@@ -1294,21 +1292,21 @@ static void
round_time(float _update, struct tm *tm, struct timeval *tv)
{
/* interval in milliseconds */
- unsigned long update = (int) (_update * 1000.0 + 0.5);
+ unsigned long update = (int) (_update * 1000.0 + 0.5);
/* compute milliseconds since midnight */
- unsigned long old_secs = time_seconds(tm);
- unsigned long old_millis = time_millis(tm, tv);
+ unsigned long old_secs = time_seconds(tm);
+ unsigned long old_millis = time_millis(tm, tv);
/* Nearest number of intervals since midnight */
- unsigned long intervals = time_intervals(old_millis, update);
+ unsigned long intervals = time_intervals(old_millis, update);
/* The number of milliseconds for that number of intervals */
- unsigned long new_millis = intervals * update;
- time_t t;
+ unsigned long new_millis = intervals * update;
+ time_t t;
if (new_millis > DAY_MILLIS)
- new_millis = DAY_MILLIS;
+ new_millis = DAY_MILLIS;
/* Compute the time_t of that interval by subtracting off the real
* seconds and adding back in the desired second
@@ -1369,7 +1367,7 @@ round_time(float _update, struct tm *tm, struct timeval *tv)
*
* ord(e)=n/gcd(n,e)=n/e
*
- * from wich follows
+ * from which follows
*
* e=d ==> f: I={0,..,m-1} -> J={0,..,m-1}: j=i*r mod m is bijective
* ==> D={k*d mod n : k in Z} = U.
@@ -1387,7 +1385,7 @@ round_time(float _update, struct tm *tm, struct timeval *tv)
*
* which implements state tracking. This approach doesn't work well
* since the set timeout w does not guarantee a next call at time
- * t(i+1), e.g. due to progam sleeps, time adjustments, and leap
+ * t(i+1), e.g. due to program sleeps, time adjustments, and leap
* seconds. A robust method should only rely on the current time
* tc(i) to identify t(i). The derivation above shows 2 options:
*
@@ -1411,7 +1409,7 @@ waittime(float _update, struct timeval *tv, struct tm *tm)
unsigned long result;
if (next_millis > DAY_MILLIS)
- next_millis = DAY_MILLIS;
+ next_millis = DAY_MILLIS;
result = next_millis - millis;
return result;
@@ -1419,295 +1417,273 @@ waittime(float _update, struct timeval *tv, struct tm *tm)
/* ARGSUSED */
static void
-clock_tic(XtPointer client_data, XtIntervalId *id)
+clock_tic(XtPointer client_data, XtIntervalId * id)
{
- ClockWidget w = (ClockWidget)client_data;
- struct tm tm;
- struct timeval tv;
- char *time_ptr;
- register Display *dpy = XtDisplay(w);
- register Window win = XtWindow(w);
-
- X_GETTIMEOFDAY (&tv);
- tm = *localtime(&tv.tv_sec);
- if (w->clock.update && (id || !w->clock.interval_id))
- w->clock.interval_id =
- XtAppAddTimeOut( XtWidgetToApplicationContext( (Widget) w),
- waittime(w->clock.update, &tv, &tm),
- clock_tic, (XtPointer)w );
-
- round_time(w->clock.update, &tm, &tv);
- /*
- * Beep on the half hour; double-beep on the hour.
- */
- if (w->clock.chime == TRUE) {
- if (w->clock.beeped && (tm.tm_min != 30) &&
- (tm.tm_min != 0))
- w->clock.beeped = FALSE;
- if (((tm.tm_min == 30) || (tm.tm_min == 0))
- && (!w->clock.beeped)) {
- w->clock.beeped = TRUE;
+ ClockWidget w = (ClockWidget) client_data;
+ struct tm tm;
+ struct timeval tv;
+ char *time_ptr;
+ register Display *dpy = XtDisplay(w);
+ register Window win = XtWindow(w);
+
+ X_GETTIMEOFDAY(&tv);
+ tm = *localtime(&tv.tv_sec);
+ if (w->clock.update && (id || !w->clock.interval_id))
+ w->clock.interval_id =
+ XtAppAddTimeOut(XtWidgetToApplicationContext((Widget) w),
+ waittime(w->clock.update, &tv, &tm),
+ clock_tic, (XtPointer) w);
+
+ round_time(w->clock.update, &tm, &tv);
+ /*
+ * Beep on the half hour; double-beep on the hour.
+ */
+ if (w->clock.chime == TRUE) {
+ if (w->clock.beeped && (tm.tm_min != 30) && (tm.tm_min != 0))
+ w->clock.beeped = FALSE;
+ if (((tm.tm_min == 30) || (tm.tm_min == 0))
+ && (!w->clock.beeped)) {
+ w->clock.beeped = TRUE;
#ifdef XKB
- if (tm.tm_min==0) {
- XkbStdBell(dpy,win,50,XkbBI_ClockChimeHour);
- XkbStdBell(dpy,win,50,XkbBI_RepeatingLastBell);
- }
- else {
- XkbStdBell(dpy,win,50,XkbBI_ClockChimeHalf);
- }
+ if (tm.tm_min == 0) {
+ XkbStdBell(dpy, win, 50, XkbBI_ClockChimeHour);
+ XkbStdBell(dpy, win, 50, XkbBI_RepeatingLastBell);
+ }
+ else {
+ XkbStdBell(dpy, win, 50, XkbBI_ClockChimeHalf);
+ }
#else
- XBell(dpy, 50);
- if (tm.tm_min == 0)
- XBell(dpy, 50);
+ XBell(dpy, 50);
+ if (tm.tm_min == 0)
+ XBell(dpy, 50);
#endif
- }
- }
- if( w->clock.analog == FALSE ) {
- int clear_from = w->core.width;
- int i, len, prev_len;
-
- time_ptr = TimeString (w, &tm);
- len = strlen (time_ptr);
- if (len && time_ptr[len - 1] == '\n') time_ptr[--len] = '\0';
- prev_len = strlen (w->clock.prev_time_string);
- for (i = 0; ((i < len) && (i < prev_len) &&
- (w->clock.prev_time_string[i] == time_ptr[i])); i++);
+ }
+ }
+ if (w->clock.analog == FALSE) {
+ int clear_from = w->core.width;
+ int i, len, prev_len;
+
+ time_ptr = TimeString(w, &tm);
+ len = strlen(time_ptr);
+ if (len && time_ptr[len - 1] == '\n')
+ time_ptr[--len] = '\0';
+ prev_len = strlen(w->clock.prev_time_string);
+ for (i = 0; ((i < len) && (i < prev_len) &&
+ (w->clock.prev_time_string[i] == time_ptr[i])); i++);
#ifdef XRENDER
- if (w->clock.render)
- {
- XRectangle old_tail, new_tail, head;
- int x, y;
+ if (w->clock.render) {
+ XRectangle old_tail, new_tail, head;
+ int x, y;
+
#if !defined(NO_I18N) && defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
- char *utf8_str;
+ char *utf8_str;
#endif
- RenderTextBounds (w, w->clock.prev_time_string, i, prev_len,
- &old_tail, NULL, NULL);
- RenderUpdateRectBounds (&old_tail, &w->clock.damage);
- RenderTextBounds (w, time_ptr, i, len,
- &new_tail, NULL, NULL);
- RenderUpdateRectBounds (&new_tail, &w->clock.damage);
-
- while (i)
- {
- RenderTextBounds (w, time_ptr, 0, i, &head, NULL, NULL);
- if (!RenderRectIn (&head, &w->clock.damage))
- break;
- i--;
- }
- RenderTextBounds (w, time_ptr, i, len, &new_tail, &x, &y);
- RenderClip (w);
- RenderPrepare (w, NULL);
+ RenderTextBounds(w, w->clock.prev_time_string, i, prev_len,
+ &old_tail, NULL, NULL);
+ RenderUpdateRectBounds(&old_tail, &w->clock.damage);
+ RenderTextBounds(w, time_ptr, i, len, &new_tail, NULL, NULL);
+ RenderUpdateRectBounds(&new_tail, &w->clock.damage);
+
+ while (i) {
+ RenderTextBounds(w, time_ptr, 0, i, &head, NULL, NULL);
+ if (!RenderRectIn(&head, &w->clock.damage))
+ break;
+ i--;
+ }
+ RenderTextBounds(w, time_ptr, i, len, &new_tail, &x, &y);
+ RenderClip(w);
+ RenderPrepare(w, NULL);
#ifndef NO_I18N
- if (w->clock.utf8) {
- XftDrawStringUtf8 (w->clock.draw,
- &w->clock.fg_color,
- w->clock.face,
- x, y,
- (FcChar8 *) time_ptr + i, len - i);
-
- }
-# if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
- else if ((utf8_str =
- clock_to_utf8(time_ptr + i, len - i)) != NULL) {
- XftDrawStringUtf8 (w->clock.draw,
- &w->clock.fg_color,
- w->clock.face,
- x, y,
- (FcChar8 *)utf8_str, strlen(utf8_str) );
- free(utf8_str);
- }
-# endif
- else
+ if (w->clock.utf8) {
+ XftDrawStringUtf8(w->clock.draw,
+ &w->clock.fg_color,
+ w->clock.face,
+ x, y, (FcChar8 *) time_ptr + i, len - i);
+
+ }
+#if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
+ else if ((utf8_str = clock_to_utf8(time_ptr + i, len - i)) != NULL) {
+ XftDrawStringUtf8(w->clock.draw,
+ &w->clock.fg_color,
+ w->clock.face,
+ x, y, (FcChar8 *) utf8_str, strlen(utf8_str));
+ free(utf8_str);
+ }
+#endif
+ else
#endif
- {
- XftDrawString8 (w->clock.draw,
- &w->clock.fg_color,
- w->clock.face,
- x, y,
- (FcChar8 *) time_ptr + i, len - i);
- }
- RenderUpdate (w);
- RenderResetBounds (&w->clock.damage);
- }
- else
+ {
+ XftDrawString8(w->clock.draw,
+ &w->clock.fg_color,
+ w->clock.face,
+ x, y, (FcChar8 *) time_ptr + i, len - i);
+ }
+ RenderUpdate(w);
+ RenderResetBounds(&w->clock.damage);
+ }
+ else
#endif
#ifndef NO_I18N
- if(!no_locale) {
- if(0 < len) {
- XFontSetExtents *fse
- = XExtentsOfFontSet(w->clock.fontSet);
-
- XmbDrawImageString(dpy,win,w->clock.fontSet,w->clock.myGC,
- (2+w->clock.padding +
- (i?XmbTextEscapement(w->clock.fontSet,
- time_ptr,i):0)),
- 2+w->clock.padding+fse->max_logical_extent.height,
- time_ptr+i,len-i
- );
- /*
- * Clear any left over bits
- */
- clear_from = XmbTextEscapement (w->clock.fontSet,time_ptr,
- len) + 2+w->clock.padding;
- }
- } else
-#endif /* NO_I18N */
- {
- XDrawImageString (dpy, win, w->clock.myGC,
- (1+w->clock.padding +
- XTextWidth (w->clock.font, time_ptr, i)),
- w->clock.font->ascent+w->clock.padding,
- time_ptr + i, len - i);
- /*
- * Clear any left over bits
- */
- clear_from = XTextWidth (w->clock.font, time_ptr, len)
- + 2 + w->clock.padding;
- }
- if (clear_from < (int)w->core.width)
- XClearArea (dpy, win,
- clear_from, 0, w->core.width - clear_from, w->core.height,
- False);
+ if (!no_locale) {
+ if (0 < len) {
+ XFontSetExtents *fse = XExtentsOfFontSet(w->clock.fontSet);
+
+ XmbDrawImageString(dpy, win, w->clock.fontSet, w->clock.myGC,
+ (2 + w->clock.padding +
+ (i ? XmbTextEscapement(w->clock.fontSet,
+ time_ptr, i) : 0)),
+ 2 + w->clock.padding +
+ fse->max_logical_extent.height, time_ptr + i,
+ len - i);
+ /*
+ * Clear any left over bits
+ */
+ clear_from = XmbTextEscapement(w->clock.fontSet, time_ptr,
+ len) + 2 + w->clock.padding;
+ }
+ }
+ else
+#endif /* NO_I18N */
+ {
+ XDrawImageString(dpy, win, w->clock.myGC,
+ (1 + w->clock.padding +
+ XTextWidth(w->clock.font, time_ptr, i)),
+ w->clock.font->ascent + w->clock.padding,
+ time_ptr + i, len - i);
+ /*
+ * Clear any left over bits
+ */
+ clear_from = XTextWidth(w->clock.font, time_ptr, len)
+ + 2 + w->clock.padding;
+ }
+ if (clear_from < (int) w->core.width)
+ XClearArea(dpy, win,
+ clear_from, 0, w->core.width - clear_from,
+ w->core.height, False);
#ifdef HAVE_STRLCPY
- strlcpy (w->clock.prev_time_string+i, time_ptr+i,
- sizeof(w->clock.prev_time_string)-i);
+ strlcpy(w->clock.prev_time_string + i, time_ptr + i,
+ sizeof(w->clock.prev_time_string) - i);
#else
- strncpy (w->clock.prev_time_string+i, time_ptr+i,
- sizeof(w->clock.prev_time_string)-i);
- w->clock.prev_time_string[sizeof(w->clock.prev_time_string)-1] = 0;
+ strncpy(w->clock.prev_time_string + i, time_ptr + i,
+ sizeof(w->clock.prev_time_string) - i);
+ w->clock.prev_time_string[sizeof(w->clock.prev_time_string) - 1] = 0;
#endif
- } else {
- /*
- * The second (or minute) hand is sec (or min)
- * sixtieths around the clock face. The hour hand is
- * (hour + min/60) twelfths of the way around the
- * clock-face. The derivation is left as an excercise
- * for the reader.
- */
-
- /*
- * 12 hour clock.
- */
- if(tm.tm_hour >= 12)
- tm.tm_hour -= 12;
+ }
+ else {
+ /*
+ * The second (or minute) hand is sec (or min)
+ * sixtieths around the clock face. The hour hand is
+ * (hour + min/60) twelfths of the way around the
+ * clock-face. The derivation is left as an exercise
+ * for the reader.
+ */
+
+ /*
+ * 12 hour clock.
+ */
+ if (tm.tm_hour >= 12)
+ tm.tm_hour -= 12;
#ifdef XRENDER
- if (w->clock.render && w->clock.can_polygon)
- {
- w->clock.mask_format = XRenderFindStandardFormat (XtDisplay (w),
- w->clock.sharp ?
- PictStandardA1 :
- PictStandardA8);
- /*
- * Compute repaint area
- */
- if (tm.tm_min != w->clock.otm.tm_min ||
- tm.tm_hour != w->clock.otm.tm_hour ||
- tm.tm_sec != w->clock.otm.tm_sec)
- {
- RenderHands (w, &w->clock.otm, False);
- RenderHands (w, &tm, False);
- }
- if (w->clock.show_second_hand &&
- (tm.tm_sec != w->clock.otm.tm_sec ||
- tv.tv_usec != w->clock.otv.tv_usec))
- {
- RenderSec (w, &w->clock.otm, &w->clock.otv, False);
- RenderSec (w, &tm, &tv, False);
- }
- if (w->clock.damage.width &&
- w->clock.damage.height)
- {
- RenderClip (w);
- DrawClockFace (w);
- RenderHands (w, &tm, True);
- if (w->clock.show_second_hand == TRUE)
- RenderSec (w, &tm, &tv, True);
- }
- w->clock.otm = tm;
- w->clock.otv = tv;
- RenderUpdate (w);
- RenderResetBounds (&w->clock.damage);
- return;
- }
+ if (w->clock.render && w->clock.can_polygon) {
+ w->clock.mask_format = XRenderFindStandardFormat(XtDisplay(w),
+ w->clock.sharp ?
+ PictStandardA1 :
+ PictStandardA8);
+ /*
+ * Compute repaint area
+ */
+ if (tm.tm_min != w->clock.otm.tm_min ||
+ tm.tm_hour != w->clock.otm.tm_hour ||
+ tm.tm_sec != w->clock.otm.tm_sec ||
+ tv.tv_usec != w->clock.otv.tv_usec) {
+ RenderHands(w, &w->clock.otm, &w->clock.otv, False);
+ RenderHands(w, &tm, &tv, False);
+ }
+ if (w->clock.show_second_hand &&
+ (tm.tm_sec != w->clock.otm.tm_sec ||
+ tv.tv_usec != w->clock.otv.tv_usec)) {
+ RenderSec(w, &w->clock.otm, &w->clock.otv, False);
+ RenderSec(w, &tm, &tv, False);
+ }
+ if (w->clock.damage.width && w->clock.damage.height) {
+ RenderClip(w);
+ DrawClockFace(w);
+ RenderHands(w, &tm, &tv, True);
+ if (w->clock.show_second_hand == TRUE)
+ RenderSec(w, &tm, &tv, True);
+ }
+ w->clock.otm = tm;
+ w->clock.otv = tv;
+ RenderUpdate(w);
+ RenderResetBounds(&w->clock.damage);
+ return;
+ }
#endif
- erase_hands (w, &tm);
-
- if (w->clock.numseg == 0 ||
- tm.tm_min != w->clock.otm.tm_min ||
- tm.tm_hour != w->clock.otm.tm_hour ||
- tm.tm_sec != w->clock.otm.tm_sec) {
- w->clock.segbuffptr = w->clock.segbuff;
- w->clock.numseg = 0;
- /*
- * Calculate the hour hand, fill it in with its
- * color and then outline it. Next, do the same
- * with the minute hand. This is a cheap hidden
- * line algorithm.
- */
- DrawHand(w,
- w->clock.minute_hand_length, w->clock.hand_width,
- tm.tm_min * 60 + tm.tm_sec
- );
- if(w->clock.Hdpixel != w->core.background_pixel)
- XFillPolygon( dpy,
- win, w->clock.HandGC,
- w->clock.segbuff, VERTICES_IN_HANDS,
- Convex, CoordModeOrigin
- );
- XDrawLines( dpy,
- win, w->clock.HighGC,
- w->clock.segbuff, VERTICES_IN_HANDS,
- CoordModeOrigin);
- w->clock.hour = w->clock.segbuffptr;
- DrawHand(w,
- w->clock.hour_hand_length, w->clock.hand_width,
- tm.tm_hour * 300 + tm.tm_min * 5
- );
- if(w->clock.Hdpixel != w->core.background_pixel) {
- XFillPolygon(dpy,
- win, w->clock.HandGC,
- w->clock.hour,
- VERTICES_IN_HANDS,
- Convex, CoordModeOrigin
- );
- }
- XDrawLines( dpy,
- win, w->clock.HighGC,
- w->clock.hour, VERTICES_IN_HANDS,
- CoordModeOrigin );
-
- w->clock.sec = w->clock.segbuffptr;
- }
- if (w->clock.show_second_hand == TRUE) {
- w->clock.segbuffptr = w->clock.sec;
- DrawSecond(w,
- w->clock.second_hand_length - 2,
- w->clock.second_hand_width,
- w->clock.minute_hand_length + 2,
- tm.tm_sec * 60 + tv.tv_usec * 60 / 1000000
- );
- if(w->clock.Hdpixel != w->core.background_pixel)
- XFillPolygon( dpy,
- win, w->clock.HandGC,
- w->clock.sec,
- VERTICES_IN_HANDS -2,
- Convex, CoordModeOrigin
- );
- XDrawLines( dpy,
- win, w->clock.HighGC,
- w->clock.sec,
- VERTICES_IN_HANDS-1,
- CoordModeOrigin
- );
-
- }
- w->clock.otm = tm;
- w->clock.otv = tv;
- }
+ erase_hands(w, &tm);
+
+ if (w->clock.numseg == 0 ||
+ tm.tm_min != w->clock.otm.tm_min ||
+ tm.tm_hour != w->clock.otm.tm_hour ||
+ tm.tm_sec != w->clock.otm.tm_sec) {
+ w->clock.segbuffptr = w->clock.segbuff;
+ w->clock.numseg = 0;
+ /*
+ * Calculate the hour hand, fill it in with its
+ * color and then outline it. Next, do the same
+ * with the minute hand. This is a cheap hidden
+ * line algorithm.
+ */
+ DrawHand(w,
+ w->clock.minute_hand_length, w->clock.hand_width,
+ tm.tm_min * 60 + tm.tm_sec);
+ if (w->clock.Hdpixel != w->core.background_pixel)
+ XFillPolygon(dpy,
+ win, w->clock.HandGC,
+ w->clock.segbuff, VERTICES_IN_HANDS,
+ Convex, CoordModeOrigin);
+ XDrawLines(dpy,
+ win, w->clock.HighGC,
+ w->clock.segbuff, VERTICES_IN_HANDS, CoordModeOrigin);
+ w->clock.hour = w->clock.segbuffptr;
+ DrawHand(w,
+ w->clock.hour_hand_length, w->clock.hand_width,
+ tm.tm_hour * 300 + tm.tm_min * 5);
+ if (w->clock.Hdpixel != w->core.background_pixel) {
+ XFillPolygon(dpy,
+ win, w->clock.HandGC,
+ w->clock.hour,
+ VERTICES_IN_HANDS, Convex, CoordModeOrigin);
+ }
+ XDrawLines(dpy,
+ win, w->clock.HighGC,
+ w->clock.hour, VERTICES_IN_HANDS, CoordModeOrigin);
+
+ w->clock.sec = w->clock.segbuffptr;
+ }
+ if (w->clock.show_second_hand == TRUE) {
+ w->clock.segbuffptr = w->clock.sec;
+ DrawSecond(w,
+ w->clock.second_hand_length - 2,
+ w->clock.second_hand_width,
+ w->clock.minute_hand_length + 2,
+ tm.tm_sec * 60 + tv.tv_usec * 60 / 1000000);
+ if (w->clock.Hdpixel != w->core.background_pixel)
+ XFillPolygon(dpy,
+ win, w->clock.HandGC,
+ w->clock.sec,
+ VERTICES_IN_HANDS - 2, Convex, CoordModeOrigin);
+ XDrawLines(dpy,
+ win, w->clock.HighGC,
+ w->clock.sec, VERTICES_IN_HANDS - 1, CoordModeOrigin);
+
+ }
+ w->clock.otm = tm;
+ w->clock.otv = tv;
+ }
}
static void
@@ -1716,195 +1692,57 @@ erase_hands(ClockWidget w, struct tm *tm)
/*
* Erase old hands.
*/
- if(w->clock.numseg > 0) {
- Display *dpy;
- Window win;
-
- dpy = XtDisplay (w);
- win = XtWindow (w);
- if (w->clock.show_second_hand == TRUE) {
- XDrawLines(dpy, win,
- w->clock.EraseGC,
- w->clock.sec,
- VERTICES_IN_HANDS-1,
- CoordModeOrigin);
- if(w->clock.Hdpixel != w->core.background_pixel) {
- XFillPolygon(dpy,
- win, w->clock.EraseGC,
- w->clock.sec,
- VERTICES_IN_HANDS-2,
- Convex, CoordModeOrigin
- );
- }
- }
- if(!tm || tm->tm_min != w->clock.otm.tm_min ||
- tm->tm_hour != w->clock.otm.tm_hour ||
- tm->tm_sec != w->clock.otm.tm_sec)
- {
- XDrawLines( dpy, win,
- w->clock.EraseGC,
- w->clock.segbuff,
- VERTICES_IN_HANDS,
- CoordModeOrigin);
- XDrawLines( dpy, win,
- w->clock.EraseGC,
- w->clock.hour,
- VERTICES_IN_HANDS,
- CoordModeOrigin);
- if(w->clock.Hdpixel != w->core.background_pixel) {
- XFillPolygon( dpy, win,
- w->clock.EraseGC,
- w->clock.segbuff, VERTICES_IN_HANDS,
- Convex, CoordModeOrigin);
- XFillPolygon( dpy, win,
- w->clock.EraseGC,
- w->clock.hour,
- VERTICES_IN_HANDS,
- Convex, CoordModeOrigin);
- }
- }
+ if (w->clock.numseg > 0) {
+ Display *dpy;
+ Window win;
+
+ dpy = XtDisplay(w);
+ win = XtWindow(w);
+ if (w->clock.show_second_hand == TRUE) {
+ XDrawLines(dpy, win,
+ w->clock.EraseGC,
+ w->clock.sec, VERTICES_IN_HANDS - 1, CoordModeOrigin);
+ if (w->clock.Hdpixel != w->core.background_pixel) {
+ XFillPolygon(dpy,
+ win, w->clock.EraseGC,
+ w->clock.sec,
+ VERTICES_IN_HANDS - 2, Convex, CoordModeOrigin);
+ }
+ }
+ if (!tm || tm->tm_min != w->clock.otm.tm_min ||
+ tm->tm_hour != w->clock.otm.tm_hour ||
+ tm->tm_sec != w->clock.otm.tm_sec) {
+ XDrawLines(dpy, win,
+ w->clock.EraseGC,
+ w->clock.segbuff, VERTICES_IN_HANDS, CoordModeOrigin);
+ XDrawLines(dpy, win,
+ w->clock.EraseGC,
+ w->clock.hour, VERTICES_IN_HANDS, CoordModeOrigin);
+ if (w->clock.Hdpixel != w->core.background_pixel) {
+ XFillPolygon(dpy, win,
+ w->clock.EraseGC,
+ w->clock.segbuff, VERTICES_IN_HANDS,
+ Convex, CoordModeOrigin);
+ XFillPolygon(dpy, win,
+ w->clock.EraseGC,
+ w->clock.hour,
+ VERTICES_IN_HANDS, Convex, CoordModeOrigin);
+ }
+ }
}
}
-static double const Sines[] = {
-0.000000, 0.001745, 0.003490, 0.005235, 0.006981, 0.008726, 0.010471, 0.012217,
-0.013962, 0.015707, 0.017452, 0.019197, 0.020942, 0.022687, 0.024432, 0.026176,
-0.027921, 0.029666, 0.031410, 0.033155, 0.034899, 0.036643, 0.038387, 0.040131,
-0.041875, 0.043619, 0.045362, 0.047106, 0.048849, 0.050592, 0.052335, 0.054078,
-0.055821, 0.057564, 0.059306, 0.061048, 0.062790, 0.064532, 0.066273, 0.068015,
-0.069756, 0.071497, 0.073238, 0.074978, 0.076719, 0.078459, 0.080198, 0.081938,
-0.083677, 0.085416, 0.087155, 0.088894, 0.090632, 0.092370, 0.094108, 0.095845,
-0.097582, 0.099319, 0.101056, 0.102792, 0.104528, 0.106264, 0.107999, 0.109734,
-0.111468, 0.113203, 0.114937, 0.116670, 0.118403, 0.120136, 0.121869, 0.123601,
-0.125333, 0.127064, 0.128795, 0.130526, 0.132256, 0.133986, 0.135715, 0.137444,
-0.139173, 0.140901, 0.142628, 0.144356, 0.146083, 0.147809, 0.149535, 0.151260,
-0.152985, 0.154710, 0.156434, 0.158158, 0.159881, 0.161603, 0.163325, 0.165047,
-0.166768, 0.168489, 0.170209, 0.171929, 0.173648, 0.175366, 0.177084, 0.178802,
-0.180519, 0.182235, 0.183951, 0.185666, 0.187381, 0.189095, 0.190808, 0.192521,
-0.194234, 0.195946, 0.197657, 0.199367, 0.201077, 0.202787, 0.204496, 0.206204,
-0.207911, 0.209618, 0.211324, 0.213030, 0.214735, 0.216439, 0.218143, 0.219846,
-0.221548, 0.223250, 0.224951, 0.226651, 0.228350, 0.230049, 0.231747, 0.233445,
-0.235142, 0.236838, 0.238533, 0.240228, 0.241921, 0.243615, 0.245307, 0.246999,
-0.248689, 0.250380, 0.252069, 0.253757, 0.255445, 0.257132, 0.258819, 0.260504,
-0.262189, 0.263873, 0.265556, 0.267238, 0.268919, 0.270600, 0.272280, 0.273959,
-0.275637, 0.277314, 0.278991, 0.280666, 0.282341, 0.284015, 0.285688, 0.287360,
-0.289031, 0.290702, 0.292371, 0.294040, 0.295708, 0.297374, 0.299040, 0.300705,
-0.302369, 0.304033, 0.305695, 0.307356, 0.309016, 0.310676, 0.312334, 0.313992,
-0.315649, 0.317304, 0.318959, 0.320612, 0.322265, 0.323917, 0.325568, 0.327217,
-0.328866, 0.330514, 0.332161, 0.333806, 0.335451, 0.337095, 0.338737, 0.340379,
-0.342020, 0.343659, 0.345298, 0.346935, 0.348572, 0.350207, 0.351841, 0.353474,
-0.355106, 0.356737, 0.358367, 0.359996, 0.361624, 0.363251, 0.364876, 0.366501,
-0.368124, 0.369746, 0.371367, 0.372987, 0.374606, 0.376224, 0.377840, 0.379456,
-0.381070, 0.382683, 0.384295, 0.385906, 0.387515, 0.389123, 0.390731, 0.392337,
-0.393941, 0.395545, 0.397147, 0.398749, 0.400349, 0.401947, 0.403545, 0.405141,
-0.406736, 0.408330, 0.409923, 0.411514, 0.413104, 0.414693, 0.416280, 0.417867,
-0.419452, 0.421035, 0.422618, 0.424199, 0.425779, 0.427357, 0.428935, 0.430511,
-0.432085, 0.433659, 0.435231, 0.436801, 0.438371, 0.439939, 0.441505, 0.443071,
-0.444635, 0.446197, 0.447759, 0.449318, 0.450877, 0.452434, 0.453990, 0.455544,
-0.457097, 0.458649, 0.460199, 0.461748, 0.463296, 0.464842, 0.466386, 0.467929,
-0.469471, 0.471011, 0.472550, 0.474088, 0.475624, 0.477158, 0.478691, 0.480223,
-0.481753, 0.483282, 0.484809, 0.486335, 0.487859, 0.489382, 0.490903, 0.492423,
-0.493941, 0.495458, 0.496973, 0.498487, 0.499999, 0.501510, 0.503019, 0.504527,
-0.506033, 0.507538, 0.509041, 0.510542, 0.512042, 0.513541, 0.515038, 0.516533,
-0.518027, 0.519519, 0.521009, 0.522498, 0.523985, 0.525471, 0.526955, 0.528438,
-0.529919, 0.531398, 0.532876, 0.534352, 0.535826, 0.537299, 0.538770, 0.540240,
-0.541708, 0.543174, 0.544639, 0.546101, 0.547563, 0.549022, 0.550480, 0.551936,
-0.553391, 0.554844, 0.556295, 0.557745, 0.559192, 0.560638, 0.562083, 0.563526,
-0.564967, 0.566406, 0.567843, 0.569279, 0.570713, 0.572145, 0.573576, 0.575005,
-0.576432, 0.577857, 0.579281, 0.580702, 0.582122, 0.583541, 0.584957, 0.586372,
-0.587785, 0.589196, 0.590605, 0.592013, 0.593418, 0.594822, 0.596224, 0.597625,
-0.599023, 0.600420, 0.601815, 0.603207, 0.604599, 0.605988, 0.607375, 0.608761,
-0.610145, 0.611527, 0.612907, 0.614285, 0.615661, 0.617035, 0.618408, 0.619779,
-0.621147, 0.622514, 0.623879, 0.625242, 0.626603, 0.627963, 0.629320, 0.630675,
-0.632029, 0.633380, 0.634730, 0.636078, 0.637423, 0.638767, 0.640109, 0.641449,
-0.642787, 0.644123, 0.645457, 0.646789, 0.648119, 0.649448, 0.650774, 0.652098,
-0.653420, 0.654740, 0.656059, 0.657375, 0.658689, 0.660001, 0.661311, 0.662620,
-0.663926, 0.665230, 0.666532, 0.667832, 0.669130, 0.670426, 0.671720, 0.673012,
-0.674302, 0.675590, 0.676875, 0.678159, 0.679441, 0.680720, 0.681998, 0.683273,
-0.684547, 0.685818, 0.687087, 0.688354, 0.689619, 0.690882, 0.692143, 0.693401,
-0.694658, 0.695912, 0.697165, 0.698415, 0.699663, 0.700909, 0.702153, 0.703394,
-0.704634, 0.705871, 0.707106,
-};
-static double const Cosines[] = {
-1.000000, 0.999998, 0.999993, 0.999986, 0.999975, 0.999961, 0.999945, 0.999925,
-0.999902, 0.999876, 0.999847, 0.999815, 0.999780, 0.999742, 0.999701, 0.999657,
-0.999610, 0.999559, 0.999506, 0.999450, 0.999390, 0.999328, 0.999262, 0.999194,
-0.999122, 0.999048, 0.998970, 0.998889, 0.998806, 0.998719, 0.998629, 0.998536,
-0.998440, 0.998341, 0.998239, 0.998134, 0.998026, 0.997915, 0.997801, 0.997684,
-0.997564, 0.997440, 0.997314, 0.997185, 0.997052, 0.996917, 0.996778, 0.996637,
-0.996492, 0.996345, 0.996194, 0.996041, 0.995884, 0.995724, 0.995561, 0.995396,
-0.995227, 0.995055, 0.994880, 0.994702, 0.994521, 0.994337, 0.994150, 0.993960,
-0.993767, 0.993571, 0.993372, 0.993170, 0.992965, 0.992757, 0.992546, 0.992331,
-0.992114, 0.991894, 0.991671, 0.991444, 0.991215, 0.990983, 0.990747, 0.990509,
-0.990268, 0.990023, 0.989776, 0.989525, 0.989272, 0.989015, 0.988756, 0.988493,
-0.988228, 0.987959, 0.987688, 0.987413, 0.987136, 0.986855, 0.986572, 0.986285,
-0.985996, 0.985703, 0.985407, 0.985109, 0.984807, 0.984503, 0.984195, 0.983885,
-0.983571, 0.983254, 0.982935, 0.982612, 0.982287, 0.981958, 0.981627, 0.981292,
-0.980955, 0.980614, 0.980271, 0.979924, 0.979575, 0.979222, 0.978867, 0.978508,
-0.978147, 0.977783, 0.977415, 0.977045, 0.976672, 0.976296, 0.975916, 0.975534,
-0.975149, 0.974761, 0.974370, 0.973975, 0.973578, 0.973178, 0.972775, 0.972369,
-0.971961, 0.971549, 0.971134, 0.970716, 0.970295, 0.969872, 0.969445, 0.969015,
-0.968583, 0.968147, 0.967709, 0.967267, 0.966823, 0.966376, 0.965925, 0.965472,
-0.965016, 0.964557, 0.964095, 0.963630, 0.963162, 0.962691, 0.962217, 0.961741,
-0.961261, 0.960779, 0.960293, 0.959805, 0.959313, 0.958819, 0.958322, 0.957822,
-0.957319, 0.956813, 0.956304, 0.955793, 0.955278, 0.954760, 0.954240, 0.953716,
-0.953190, 0.952661, 0.952129, 0.951594, 0.951056, 0.950515, 0.949972, 0.949425,
-0.948876, 0.948323, 0.947768, 0.947210, 0.946649, 0.946085, 0.945518, 0.944948,
-0.944376, 0.943800, 0.943222, 0.942641, 0.942057, 0.941470, 0.940880, 0.940288,
-0.939692, 0.939094, 0.938493, 0.937888, 0.937281, 0.936672, 0.936059, 0.935444,
-0.934825, 0.934204, 0.933580, 0.932953, 0.932323, 0.931691, 0.931055, 0.930417,
-0.929776, 0.929132, 0.928485, 0.927836, 0.927183, 0.926528, 0.925870, 0.925209,
-0.924546, 0.923879, 0.923210, 0.922538, 0.921863, 0.921185, 0.920504, 0.919821,
-0.919135, 0.918446, 0.917754, 0.917060, 0.916362, 0.915662, 0.914959, 0.914253,
-0.913545, 0.912834, 0.912120, 0.911403, 0.910683, 0.909961, 0.909236, 0.908508,
-0.907777, 0.907044, 0.906307, 0.905568, 0.904827, 0.904082, 0.903335, 0.902585,
-0.901832, 0.901077, 0.900318, 0.899557, 0.898794, 0.898027, 0.897258, 0.896486,
-0.895711, 0.894934, 0.894154, 0.893371, 0.892585, 0.891797, 0.891006, 0.890212,
-0.889416, 0.888617, 0.887815, 0.887010, 0.886203, 0.885393, 0.884580, 0.883765,
-0.882947, 0.882126, 0.881303, 0.880477, 0.879648, 0.878817, 0.877982, 0.877146,
-0.876306, 0.875464, 0.874619, 0.873772, 0.872922, 0.872069, 0.871213, 0.870355,
-0.869494, 0.868631, 0.867765, 0.866896, 0.866025, 0.865151, 0.864274, 0.863395,
-0.862513, 0.861629, 0.860742, 0.859852, 0.858959, 0.858064, 0.857167, 0.856267,
-0.855364, 0.854458, 0.853550, 0.852640, 0.851726, 0.850811, 0.849892, 0.848971,
-0.848048, 0.847121, 0.846193, 0.845261, 0.844327, 0.843391, 0.842452, 0.841510,
-0.840566, 0.839619, 0.838670, 0.837718, 0.836764, 0.835807, 0.834847, 0.833885,
-0.832921, 0.831954, 0.830984, 0.830012, 0.829037, 0.828060, 0.827080, 0.826098,
-0.825113, 0.824126, 0.823136, 0.822144, 0.821149, 0.820151, 0.819152, 0.818149,
-0.817144, 0.816137, 0.815127, 0.814115, 0.813100, 0.812083, 0.811063, 0.810041,
-0.809016, 0.807989, 0.806960, 0.805928, 0.804893, 0.803856, 0.802817, 0.801775,
-0.800731, 0.799684, 0.798635, 0.797583, 0.796529, 0.795473, 0.794414, 0.793353,
-0.792289, 0.791223, 0.790155, 0.789084, 0.788010, 0.786935, 0.785856, 0.784776,
-0.783693, 0.782608, 0.781520, 0.780430, 0.779337, 0.778243, 0.777145, 0.776046,
-0.774944, 0.773840, 0.772733, 0.771624, 0.770513, 0.769399, 0.768283, 0.767165,
-0.766044, 0.764921, 0.763796, 0.762668, 0.761538, 0.760405, 0.759271, 0.758134,
-0.756995, 0.755853, 0.754709, 0.753563, 0.752414, 0.751264, 0.750111, 0.748955,
-0.747798, 0.746638, 0.745475, 0.744311, 0.743144, 0.741975, 0.740804, 0.739631,
-0.738455, 0.737277, 0.736097, 0.734914, 0.733729, 0.732542, 0.731353, 0.730162,
-0.728968, 0.727772, 0.726574, 0.725374, 0.724171, 0.722967, 0.721760, 0.720551,
-0.719339, 0.718126, 0.716910, 0.715692, 0.714472, 0.713250, 0.712026, 0.710799,
-0.709570, 0.708339, 0.707106,
-};
-
static void
-ClockAngle(int tick_units, double *sinp, double *cosp)
+ClockAngle(double tick_units, double *sinp, double *cosp)
{
- int reduced, upper;
-
- reduced = tick_units % 450;
- upper = tick_units / 450;
- if (upper & 1)
- reduced = 450 - reduced;
- if ((upper + 1) & 2) {
- *sinp = Cosines[reduced];
- *cosp = Sines[reduced];
- } else {
- *sinp = Sines[reduced];
- *cosp = Cosines[reduced];
- }
- if (upper >= 2 && upper < 6)
- *cosp = -*cosp;
- if (upper >= 4)
- *sinp = -*sinp;
+ double angle = tick_units * (M_PI / 180 / 10.0);
+
+#ifdef HAVE_SINCOS
+ sincos(angle, sinp, cosp);
+#else
+ *sinp = sin(angle);
+ *cosp = cos(angle);
+#endif
}
/*
@@ -1922,28 +1760,28 @@ ClockAngle(int tick_units, double *sinp, double *cosp)
*/
static void
DrawLine(ClockWidget w, Dimension blank_length, Dimension length,
- int tick_units)
+ int tick_units)
{
- double dblank_length = (double)blank_length, dlength = (double)length;
- double cosangle, sinangle;
- int cx = w->clock.centerX, cy = w->clock.centerY, x1, y1, x2, y2;
-
- /*
- * Angles are measured from 12 o'clock, clockwise increasing.
- * Since in X, +x is to the right and +y is downward:
- *
- * x = x0 + r * sin(theta)
- * y = y0 - r * cos(theta)
- *
- */
- ClockAngle(tick_units, &sinangle, &cosangle);
-
- /* break this out so that stupid compilers can cope */
- x1 = cx + (int)(dblank_length * sinangle);
- y1 = cy - (int)(dblank_length * cosangle);
- x2 = cx + (int)(dlength * sinangle);
- y2 = cy - (int)(dlength * cosangle);
- SetSeg(w, x1, y1, x2, y2);
+ double dblank_length = (double) blank_length, dlength = (double) length;
+ double cosangle, sinangle;
+ int cx = w->clock.centerX, cy = w->clock.centerY, x1, y1, x2, y2;
+
+ /*
+ * Angles are measured from 12 o'clock, clockwise increasing.
+ * Since in X, +x is to the right and +y is downward:
+ *
+ * x = x0 + r * sin(theta)
+ * y = y0 - r * cos(theta)
+ *
+ */
+ ClockAngle(tick_units, &sinangle, &cosangle);
+
+ /* break this out so that stupid compilers can cope */
+ x1 = cx + (int) (dblank_length * sinangle);
+ y1 = cy - (int) (dblank_length * cosangle);
+ x2 = cx + (int) (dlength * sinangle);
+ y2 = cy - (int) (dlength * cosangle);
+ SetSeg(w, x1, y1, x2, y2);
}
/*
@@ -1959,41 +1797,41 @@ static void
DrawHand(ClockWidget w, Dimension length, Dimension width, int tick_units)
{
- double cosangle, sinangle;
- register double ws, wc;
- Position x, y, x1, y1, x2, y2;
-
- /*
- * Angles are measured from 12 o'clock, clockwise increasing.
- * Since in X, +x is to the right and +y is downward:
- *
- * x = x0 + r * sin(theta)
- * y = y0 - r * cos(theta)
- *
- */
- ClockAngle(tick_units, &sinangle, &cosangle);
- /*
- * Order of points when drawing the hand.
- *
- * 1,4
- * / \
- * / \
- * / \
- * 2 ------- 3
- */
- wc = width * cosangle;
- ws = width * sinangle;
- SetSeg(w,
- x = w->clock.centerX + clock_round(length * sinangle),
- y = w->clock.centerY - clock_round(length * cosangle),
- x1 = w->clock.centerX - clock_round(ws + wc),
- y1 = w->clock.centerY + clock_round(wc - ws)); /* 1 ---- 2 */
- /* 2 */
- SetSeg(w, x1, y1,
- x2 = w->clock.centerX - clock_round(ws - wc),
- y2 = w->clock.centerY + clock_round(wc + ws)); /* 2 ----- 3 */
-
- SetSeg(w, x2, y2, x, y); /* 3 ----- 1(4) */
+ double cosangle, sinangle;
+ register double ws, wc;
+ Position x, y, x1, y1, x2, y2;
+
+ /*
+ * Angles are measured from 12 o'clock, clockwise increasing.
+ * Since in X, +x is to the right and +y is downward:
+ *
+ * x = x0 + r * sin(theta)
+ * y = y0 - r * cos(theta)
+ *
+ */
+ ClockAngle(tick_units, &sinangle, &cosangle);
+ /*
+ * Order of points when drawing the hand.
+ *
+ * 1,4
+ * / \
+ * / \
+ * / \
+ * 2 ------- 3
+ */
+ wc = width * cosangle;
+ ws = width * sinangle;
+ SetSeg(w,
+ x = w->clock.centerX + clock_round(length * sinangle),
+ y = w->clock.centerY - clock_round(length * cosangle),
+ x1 = w->clock.centerX - clock_round(ws + wc),
+ y1 = w->clock.centerY + clock_round(wc - ws)); /* 1 ---- 2 */
+ /* 2 */
+ SetSeg(w, x1, y1,
+ x2 = w->clock.centerX - clock_round(ws - wc),
+ y2 = w->clock.centerY + clock_round(wc + ws)); /* 2 ----- 3 */
+
+ SetSeg(w, x2, y2, x, y); /* 3 ----- 1(4) */
}
/*
@@ -2008,71 +1846,70 @@ DrawHand(ClockWidget w, Dimension length, Dimension width, int tick_units)
*/
static void
DrawSecond(ClockWidget w, Dimension length, Dimension width,
- Dimension offset, int tick_units)
+ Dimension offset, int tick_units)
{
- double cosangle, sinangle;
- register double ms, mc, ws, wc;
- register int mid;
- Position x, y;
-
- /*
- * Angles are measured from 12 o'clock, clockwise increasing.
- * Since in X, +x is to the right and +y is downward:
- *
- * x = x0 + r * sin(theta)
- * y = y0 - r * cos(theta)
- *
- */
- ClockAngle(tick_units, &sinangle, &cosangle);
- /*
- * Order of points when drawing the hand.
- *
- * 1,5
- * / \
- * / \
- * / \
- * 2< >4
- * \ /
- * \ /
- * \ /
- * - 3
- * |
- * |
- * offset
- * |
- * |
- * - + center
- */
-
- mid = (int) (length + offset) / 2;
- mc = mid * cosangle;
- ms = mid * sinangle;
- wc = width * cosangle;
- ws = width * sinangle;
- /*1 ---- 2 */
- SetSeg(w,
- x = w->clock.centerX + clock_round(length * sinangle),
- y = w->clock.centerY - clock_round(length * cosangle),
- w->clock.centerX + clock_round(ms - wc),
- w->clock.centerY - clock_round(mc + ws) );
- SetSeg(w, w->clock.centerX + clock_round(offset *sinangle),
- w->clock.centerY - clock_round(offset * cosangle), /* 2-----3 */
- w->clock.centerX + clock_round(ms + wc),
- w->clock.centerY - clock_round(mc - ws));
- w->clock.segbuffptr->x = x;
- w->clock.segbuffptr++->y = y;
- w->clock.numseg ++;
+ double cosangle, sinangle;
+ register double ms, mc, ws, wc;
+ register int mid;
+ Position x, y;
+
+ /*
+ * Angles are measured from 12 o'clock, clockwise increasing.
+ * Since in X, +x is to the right and +y is downward:
+ *
+ * x = x0 + r * sin(theta)
+ * y = y0 - r * cos(theta)
+ *
+ */
+ ClockAngle(tick_units, &sinangle, &cosangle);
+ /*
+ * Order of points when drawing the hand.
+ *
+ * 1,5
+ * / \
+ * / \
+ * / \
+ * 2< >4
+ * \ /
+ * \ /
+ * \ /
+ * - 3
+ * |
+ * |
+ * offset
+ * |
+ * |
+ * - + center
+ */
+
+ mid = (int) (length + offset) / 2;
+ mc = mid * cosangle;
+ ms = mid * sinangle;
+ wc = width * cosangle;
+ ws = width * sinangle;
+ /*1 ---- 2 */
+ SetSeg(w,
+ x = w->clock.centerX + clock_round(length * sinangle),
+ y = w->clock.centerY - clock_round(length * cosangle),
+ w->clock.centerX + clock_round(ms - wc),
+ w->clock.centerY - clock_round(mc + ws));
+ SetSeg(w, w->clock.centerX + clock_round(offset * sinangle), w->clock.centerY - clock_round(offset * cosangle), /* 2-----3 */
+ w->clock.centerX + clock_round(ms + wc),
+ w->clock.centerY - clock_round(mc - ws));
+ w->clock.segbuffptr->x = x;
+ w->clock.segbuffptr++->y = y;
+ w->clock.numseg++;
}
static void
SetSeg(ClockWidget w, int x1, int y1, int x2, int y2)
{
- w->clock.segbuffptr->x = x1;
- w->clock.segbuffptr++->y = y1;
- w->clock.segbuffptr->x = x2;
- w->clock.segbuffptr++->y = y2;
- w->clock.numseg += 2;
+ w->clock.segbuffptr->x = x1;
+ w->clock.segbuffptr++->y = y1;
+ w->clock.segbuffptr->x = x2;
+ w->clock.segbuffptr++->y = y2;
+ w->clock.numseg += 2;
}
/*
@@ -2082,74 +1919,75 @@ SetSeg(ClockWidget w, int x1, int y1, int x2, int y2)
static void
DrawClockFace(ClockWidget w)
{
- register int i;
- register int delta = (int)(w->clock.radius - w->clock.second_hand_length) / 3;
+ register int i;
+ register int delta =
+ (int) (w->clock.radius - w->clock.second_hand_length) / 3;
- w->clock.segbuffptr = w->clock.segbuff;
- w->clock.numseg = 0;
- for (i = 0; i < 60; i++)
- {
+ w->clock.segbuffptr = w->clock.segbuff;
+ w->clock.numseg = 0;
+ for (i = 0; i < 60; i++) {
#ifdef XRENDER
- if (w->clock.render && w->clock.can_polygon)
- {
- double s, c;
- XDouble x1, y1, x2, y2;
- XftColor *color;
- ClockAngle (i * 60, &s, &c);
- x1 = c;
- y1 = s;
- if (i % 5)
- {
- x2 = c * (MINOR_TICK_FRACT / 100.0);
- y2 = s * (MINOR_TICK_FRACT / 100.0);
- color = &w->clock.minor_color;
- }
- else
- {
- x2 = c * (SECOND_HAND_FRACT / 100.0);
- y2 = s * (SECOND_HAND_FRACT / 100.0);
- color = &w->clock.major_color;
- }
- RenderLine (w, x1, y1, x2, y2, color, True);
- }
- else
+ if (w->clock.render && w->clock.can_polygon) {
+ double s, c;
+ XDouble x1, y1, x2, y2;
+ XftColor *color;
+
+ ClockAngle(i * 60, &s, &c);
+ x1 = c;
+ y1 = s;
+ if (i % 5) {
+ x2 = c * (MINOR_TICK_FRACT / 100.0);
+ y2 = s * (MINOR_TICK_FRACT / 100.0);
+ color = &w->clock.minor_color;
+ }
+ else {
+ x2 = c * (SECOND_HAND_FRACT / 100.0);
+ y2 = s * (SECOND_HAND_FRACT / 100.0);
+ color = &w->clock.major_color;
+ }
+ RenderLine(w, x1, y1, x2, y2, color, True);
+ }
+ else
#endif
- {
- DrawLine(w, ( (i % 5) == 0 ?
- w->clock.second_hand_length :
- (w->clock.radius - delta) ),
- w->clock.radius, i * 60);
- }
- }
+ {
+ DrawLine(w, ((i % 5) == 0 ?
+ w->clock.second_hand_length :
+ (w->clock.radius - delta)), w->clock.radius, i * 60);
+ }
+ }
#ifdef XRENDER
- if (w->clock.render && w->clock.can_polygon)
- return;
+ if (w->clock.render && w->clock.can_polygon)
+ return;
#endif
- /*
- * Go ahead and draw it.
- */
- XDrawSegments(XtDisplay(w), XtWindow(w),
- w->clock.myGC, (XSegment *) &(w->clock.segbuff[0]),
- w->clock.numseg/2);
-
- w->clock.segbuffptr = w->clock.segbuff;
- w->clock.numseg = 0;
+ /*
+ * Go ahead and draw it.
+ */
+ XDrawSegments(XtDisplay(w), XtWindow(w),
+ w->clock.myGC, (XSegment *) & (w->clock.segbuff[0]),
+ w->clock.numseg / 2);
+
+ w->clock.segbuffptr = w->clock.segbuff;
+ w->clock.numseg = 0;
}
static int
clock_round(double x)
{
- return(x >= 0.0 ? (int)(x + .5) : (int)(x - .5));
+ return (x >= 0.0 ? (int) (x + .5) : (int) (x - .5));
}
#ifdef XRENDER
static Boolean
-sameColor (XftColor *old, XftColor *new)
+sameColor(XftColor * old, XftColor * new)
{
- if (old->color.red != new->color.red) return False;
- if (old->color.green != new->color.green) return False;
- if (old->color.blue != new->color.blue) return False;
- if (old->color.alpha != new->color.alpha) return False;
+ if (old->color.red != new->color.red)
+ return False;
+ if (old->color.green != new->color.green)
+ return False;
+ if (old->color.blue != new->color.blue)
+ return False;
+ if (old->color.alpha != new->color.alpha)
+ return False;
return True;
}
#endif
@@ -2157,114 +1995,112 @@ sameColor (XftColor *old, XftColor *new)
/* ARGSUSED */
static Boolean
SetValues(Widget gcurrent, Widget grequest, Widget gnew,
- ArgList args, Cardinal *num_args)
+ ArgList args, Cardinal * num_args)
{
- ClockWidget current = (ClockWidget) gcurrent;
- ClockWidget new = (ClockWidget) gnew;
- Boolean redisplay = FALSE;
- XtGCMask valuemask;
- XGCValues myXGCV;
-
- /* first check for changes to clock-specific resources. We'll accept all
- the changes, but may need to do some computations first. */
-
- if (new->clock.update != current->clock.update) {
- if (current->clock.interval_id)
- XtRemoveTimeOut (current->clock.interval_id);
- if (new->clock.update && XtIsRealized( (Widget) new))
- new->clock.interval_id = XtAppAddTimeOut(
- XtWidgetToApplicationContext(gnew),
- fabsf(new->clock.update)*1000,
- clock_tic, (XtPointer)gnew);
-
- new->clock.show_second_hand =(abs(new->clock.update) <= SECOND_HAND_TIME);
- if (new->clock.show_second_hand != current->clock.show_second_hand)
- redisplay = TRUE;
- }
-
- if (new->clock.padding != current->clock.padding)
- redisplay = TRUE;
-
- if (new->clock.analog != current->clock.analog)
- redisplay = TRUE;
-
- if (new->clock.font != current->clock.font)
- redisplay = TRUE;
+ ClockWidget current = (ClockWidget) gcurrent;
+ ClockWidget new = (ClockWidget) gnew;
+ Boolean redisplay = FALSE;
+ XtGCMask valuemask;
+ XGCValues myXGCV;
+
+ /* first check for changes to clock-specific resources. We'll accept all
+ the changes, but may need to do some computations first. */
+
+ if (new->clock.update != current->clock.update) {
+ if (current->clock.interval_id)
+ XtRemoveTimeOut(current->clock.interval_id);
+ if (new->clock.update && XtIsRealized((Widget) new))
+ new->clock.interval_id =
+ XtAppAddTimeOut(XtWidgetToApplicationContext(gnew),
+ fabsf(new->clock.update) * 1000, clock_tic,
+ (XtPointer) gnew);
+
+ new->clock.show_second_hand =
+ (fabsf(new->clock.update) <= SECOND_HAND_TIME);
+ if (new->clock.show_second_hand != current->clock.show_second_hand)
+ redisplay = TRUE;
+ }
+
+ if (new->clock.padding != current->clock.padding)
+ redisplay = TRUE;
+
+ if (new->clock.analog != current->clock.analog)
+ redisplay = TRUE;
+
+ if (new->clock.font != current->clock.font)
+ redisplay = TRUE;
#ifndef NO_I18N
- if (new->clock.fontSet != current->clock.fontSet)
- redisplay = TRUE;
+ if (new->clock.fontSet != current->clock.fontSet)
+ redisplay = TRUE;
#endif
- if ((ClockFgPixel(new) != ClockFgPixel (current))
- || (new->core.background_pixel != current->core.background_pixel)) {
- valuemask = GCForeground | GCBackground | GCFont | GCLineWidth;
- myXGCV.foreground = ClockFgPixel (new);
- myXGCV.background = new->core.background_pixel;
- myXGCV.font = new->clock.font->fid;
- myXGCV.line_width = 0;
- XtReleaseGC (gcurrent, current->clock.myGC);
- new->clock.myGC = XtGetGC(gcurrent, valuemask, &myXGCV);
- redisplay = TRUE;
- }
-
- if (new->clock.Hipixel != current->clock.Hipixel) {
- valuemask = GCForeground | GCLineWidth;
- myXGCV.foreground = new->clock.Hipixel;
- myXGCV.font = new->clock.font->fid;
- myXGCV.line_width = 0;
- XtReleaseGC (gcurrent, current->clock.HighGC);
- new->clock.HighGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
- redisplay = TRUE;
- }
-
- if (new->clock.Hdpixel != current->clock.Hdpixel) {
- valuemask = GCForeground;
- myXGCV.foreground = new->clock.Hdpixel;
- XtReleaseGC (gcurrent, current->clock.HandGC);
- new->clock.HandGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
- redisplay = TRUE;
- }
-
- if (new->core.background_pixel != current->core.background_pixel) {
- valuemask = GCForeground | GCLineWidth | GCGraphicsExposures;
- myXGCV.foreground = new->core.background_pixel;
- myXGCV.line_width = 0;
- myXGCV.graphics_exposures = False;
- XtReleaseGC (gcurrent, current->clock.EraseGC);
- new->clock.EraseGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
- redisplay = TRUE;
- }
+ if ((ClockFgPixel(new) != ClockFgPixel(current))
+ || (new->core.background_pixel != current->core.background_pixel)) {
+ valuemask = GCForeground | GCBackground | GCFont | GCLineWidth;
+ myXGCV.foreground = ClockFgPixel(new);
+ myXGCV.background = new->core.background_pixel;
+ myXGCV.font = new->clock.font->fid;
+ myXGCV.line_width = 0;
+ XtReleaseGC(gcurrent, current->clock.myGC);
+ new->clock.myGC = XtGetGC(gcurrent, valuemask, &myXGCV);
+ redisplay = TRUE;
+ }
+
+ if (new->clock.Hipixel != current->clock.Hipixel) {
+ valuemask = GCForeground | GCLineWidth;
+ myXGCV.foreground = new->clock.Hipixel;
+ myXGCV.font = new->clock.font->fid;
+ myXGCV.line_width = 0;
+ XtReleaseGC(gcurrent, current->clock.HighGC);
+ new->clock.HighGC = XtGetGC((Widget) gcurrent, valuemask, &myXGCV);
+ redisplay = TRUE;
+ }
+
+ if (new->clock.Hdpixel != current->clock.Hdpixel) {
+ valuemask = GCForeground;
+ myXGCV.foreground = new->clock.Hdpixel;
+ XtReleaseGC(gcurrent, current->clock.HandGC);
+ new->clock.HandGC = XtGetGC((Widget) gcurrent, valuemask, &myXGCV);
+ redisplay = TRUE;
+ }
+
+ if (new->core.background_pixel != current->core.background_pixel) {
+ valuemask = GCForeground | GCLineWidth | GCGraphicsExposures;
+ myXGCV.foreground = new->core.background_pixel;
+ myXGCV.line_width = 0;
+ myXGCV.graphics_exposures = False;
+ XtReleaseGC(gcurrent, current->clock.EraseGC);
+ new->clock.EraseGC = XtGetGC((Widget) gcurrent, valuemask, &myXGCV);
+ redisplay = TRUE;
+ }
#ifdef XRENDER
- if (new->clock.face != current->clock.face)
- redisplay = TRUE;
- if (!sameColor (&new->clock.hour_color, &current->clock.fg_color) ||
- !sameColor (&new->clock.hour_color, &current->clock.hour_color) ||
- !sameColor (&new->clock.min_color, &current->clock.min_color) ||
- !sameColor (&new->clock.sec_color, &current->clock.sec_color) ||
- !sameColor (&new->clock.major_color, &current->clock.major_color) ||
- !sameColor (&new->clock.minor_color, &current->clock.minor_color))
- redisplay = True;
+ if (new->clock.face != current->clock.face)
+ redisplay = TRUE;
+ if (!sameColor(&new->clock.hour_color, &current->clock.fg_color) ||
+ !sameColor(&new->clock.hour_color, &current->clock.hour_color) ||
+ !sameColor(&new->clock.min_color, &current->clock.min_color) ||
+ !sameColor(&new->clock.sec_color, &current->clock.sec_color) ||
+ !sameColor(&new->clock.major_color, &current->clock.major_color) ||
+ !sameColor(&new->clock.minor_color, &current->clock.minor_color))
+ redisplay = True;
if (new->clock.sharp != current->clock.sharp)
- redisplay = True;
+ redisplay = True;
if (new->clock.render != current->clock.render)
- redisplay = True;
- if (new->clock.buffer != current->clock.buffer)
- {
- if (new->clock.pixmap)
- {
- XFreePixmap (XtDisplay (new), new->clock.pixmap);
- new->clock.pixmap = 0;
- }
- if (new->clock.draw)
- {
- XftDrawDestroy (new->clock.draw);
- new->clock.draw = NULL;
- }
- new->clock.picture = 0;
+ redisplay = True;
+ if (new->clock.buffer != current->clock.buffer) {
+ if (new->clock.pixmap) {
+ XFreePixmap(XtDisplay(new), new->clock.pixmap);
+ new->clock.pixmap = 0;
+ }
+ if (new->clock.draw) {
+ XftDrawDestroy(new->clock.draw);
+ new->clock.draw = NULL;
+ }
+ new->clock.picture = 0;
}
#endif
- return (redisplay);
+ return (redisplay);
}
@@ -2281,20 +2117,20 @@ clock_to_utf8(const char *str, int in_len)
size_t ret;
const char *code_set = nl_langinfo(CODESET);
- if (str == NULL ||code_set == NULL || strcasecmp(code_set, "646") == 0)
- return NULL;
+ if (str == NULL || code_set == NULL || strcasecmp(code_set, "646") == 0)
+ return NULL;
if (strcasecmp(code_set, "UTF-8") == 0)
- return strdup(str);
+ return strdup(str);
cd = iconv_open("UTF-8", code_set);
- if (cd == (iconv_t)-1)
- return NULL;
+ if (cd == (iconv_t) - 1)
+ return NULL;
buf_size = MB_LEN_MAX * (in_len + 1);
if ((buf = malloc(buf_size)) == NULL) {
- (void) iconv_close(cd);
- return NULL;
+ (void) iconv_close(cd);
+ return NULL;
}
inptr = str;
@@ -2303,11 +2139,12 @@ clock_to_utf8(const char *str, int in_len)
oleft = buf_size;
ret = iconv(cd, &inptr, &ileft, &outptr, &oleft);
- if (ret == (size_t)(-1) || oleft == 0 ) {
+ if (ret == (size_t) (-1) || oleft == 0) {
free(buf);
buf = NULL;
- } else
- *outptr = '\0';
+ }
+ else
+ *outptr = '\0';
(void) iconv_close(cd);
return buf;
diff --git a/app/xclock/Makefile.in b/app/xclock/Makefile.in
index 630b40cc4..3dd8e8836 100644
--- a/app/xclock/Makefile.in
+++ b/app/xclock/Makefile.in
@@ -209,9 +209,9 @@ am__relativize = \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
-DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2
+DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz
GZIP_ENV = --best
-DIST_TARGETS = dist-bzip2 dist-gzip
+DIST_TARGETS = dist-xz dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
@@ -338,6 +338,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -718,6 +719,7 @@ distdir: $(DISTFILES)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)
+
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
@@ -725,7 +727,6 @@ dist-bzip2: distdir
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
-
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
diff --git a/app/xclock/README.md b/app/xclock/README.md
index 524c49299..3a0fc777e 100644
--- a/app/xclock/README.md
+++ b/app/xclock/README.md
@@ -7,7 +7,7 @@ Xorg mailing list:
https://lists.x.org/mailman/listinfo/xorg
-The master development code repository can be found at:
+The primary development code repository can be found at:
https://gitlab.freedesktop.org/xorg/app/xclock
diff --git a/app/xclock/aclocal.m4 b/app/xclock/aclocal.m4
index 9edf32e9b..1c11ced5a 100644
--- a/app/xclock/aclocal.m4
+++ b/app/xclock/aclocal.m4
@@ -19,8 +19,8 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
-# host-cpu-c-abi.m4 serial 11
-dnl Copyright (C) 2002-2019 Free Software Foundation, Inc.
+# host-cpu-c-abi.m4 serial 13
+dnl Copyright (C) 2002-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -76,7 +76,7 @@ AC_DEFUN([gl_HOST_CPU_C_ABI],
[case "$host_cpu" in
changequote(,)dnl
- i[4567]86 )
+ i[34567]86 )
changequote([,])dnl
gl_cv_host_cpu_c_abi=i386
;;
@@ -478,7 +478,8 @@ EOF
dnl Sets the HOST_CPU_C_ABI_32BIT variable to 'yes' if the C language ABI
-dnl (application binary interface) is a 32-bit one, or to 'no' otherwise.
+dnl (application binary interface) is a 32-bit one, to 'no' if it is a 64-bit
+dnl one, or to 'unknown' if unknown.
dnl This is a simplified variant of gl_HOST_CPU_C_ABI.
AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
[
@@ -488,14 +489,44 @@ AC_DEFUN([gl_HOST_CPU_C_ABI_32BIT],
case "$gl_cv_host_cpu_c_abi" in
i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
gl_cv_host_cpu_c_abi_32bit=yes ;;
- *)
+ x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
gl_cv_host_cpu_c_abi_32bit=no ;;
+ *)
+ gl_cv_host_cpu_c_abi_32bit=unknown ;;
esac
else
case "$host_cpu" in
+ # CPUs that only support a 32-bit ABI.
+ arc \
+ | bfin \
+ | cris* \
+ | csky \
+ | epiphany \
+ | ft32 \
+ | h8300 \
+ | m68k \
+ | microblaze | microblazeel \
+ | nds32 | nds32le | nds32be \
+ | nios2 | nios2eb | nios2el \
+ | or1k* \
+ | or32 \
+ | sh | sh[1234] | sh[1234]e[lb] \
+ | tic6x \
+ | xtensa* )
+ gl_cv_host_cpu_c_abi_32bit=yes
+ ;;
+
+ # CPUs that only support a 64-bit ABI.
+changequote(,)dnl
+ alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
+ | mmix )
+changequote([,])dnl
+ gl_cv_host_cpu_c_abi_32bit=no
+ ;;
+
changequote(,)dnl
- i[4567]86 )
+ i[34567]86 )
changequote([,])dnl
gl_cv_host_cpu_c_abi_32bit=yes
;;
@@ -655,7 +686,7 @@ changequote([,])dnl
;;
*)
- gl_cv_host_cpu_c_abi_32bit=no
+ gl_cv_host_cpu_c_abi_32bit=unknown
;;
esac
fi
@@ -665,7 +696,7 @@ changequote([,])dnl
])
# iconv.m4 serial 21
-dnl Copyright (C) 2000-2002, 2007-2014, 2016-2019 Free Software Foundation,
+dnl Copyright (C) 2000-2002, 2007-2014, 2016-2020 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -954,7 +985,7 @@ size_t iconv();
])
# lib-ld.m4 serial 9
-dnl Copyright (C) 1996-2003, 2009-2019 Free Software Foundation, Inc.
+dnl Copyright (C) 1996-2003, 2009-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -1122,8 +1153,8 @@ fi
AC_LIB_PROG_LD_GNU
])
-# lib-link.m4 serial 28
-dnl Copyright (C) 2001-2019 Free Software Foundation, Inc.
+# lib-link.m4 serial 31
+dnl Copyright (C) 2001-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -1316,6 +1347,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
])
AC_ARG_WITH(PACK[-prefix],
[[ --with-]]PACK[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
@@ -1328,17 +1361,23 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
- if test "$acl_libdirstem2" != "$acl_libdirstem" \
- && test ! -d "$withval/$acl_libdirstem"; then
- additional_libdir="$withval/$acl_libdirstem2"
- fi
+ additional_libdir2="$withval/$acl_libdirstem2"
+ additional_libdir3="$withval/$acl_libdirstem3"
fi
fi
])
+ if test "X$additional_libdir2" = "X$additional_libdir"; then
+ additional_libdir2=
+ fi
+ if test "X$additional_libdir3" = "X$additional_libdir"; then
+ additional_libdir3=
+ fi
dnl Search the library and its dependencies in $additional_libdir and
dnl $LDFLAGS. Using breadth-first-seach.
LIB[]NAME=
@@ -1394,48 +1433,54 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
shrext=
fi
if test $use_additional = yes; then
- dir="$additional_libdir"
- dnl The same code as in the loop below:
- dnl First look for a shared library.
- if test -n "$acl_shlibext"; then
- if test -f "$dir/$libname$shrext"; then
- found_dir="$dir"
- found_so="$dir/$libname$shrext"
- else
- if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
- ver=`(cd "$dir" && \
- for f in "$libname$shrext".*; do echo "$f"; done \
- | sed -e "s,^$libname$shrext\\\\.,," \
- | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
- | sed 1q ) 2>/dev/null`
- if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
- found_dir="$dir"
- found_so="$dir/$libname$shrext.$ver"
+ for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do
+ if test "X$found_dir" = "X"; then
+ eval dir=\$$additional_libdir_variable
+ if test -n "$dir"; then
+ dnl The same code as in the loop below:
+ dnl First look for a shared library.
+ if test -n "$acl_shlibext"; then
+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
+ found_dir="$dir"
+ found_so="$dir/$libname$shrext"
+ else
+ if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+ ver=`(cd "$dir" && \
+ for f in "$libname$shrext".*; do echo "$f"; done \
+ | sed -e "s,^$libname$shrext\\\\.,," \
+ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+ | sed 1q ) 2>/dev/null`
+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
+ found_dir="$dir"
+ found_so="$dir/$libname$shrext.$ver"
+ fi
+ else
+ eval library_names=\"$acl_library_names_spec\"
+ for f in $library_names; do
+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
+ found_dir="$dir"
+ found_so="$dir/$f"
+ break
+ fi
+ done
+ fi
+ fi
fi
- else
- eval library_names=\"$acl_library_names_spec\"
- for f in $library_names; do
- if test -f "$dir/$f"; then
+ dnl Then look for a static library.
+ if test "X$found_dir" = "X"; then
+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
found_dir="$dir"
- found_so="$dir/$f"
- break
+ found_a="$dir/$libname.$acl_libext"
fi
- done
+ fi
+ if test "X$found_dir" != "X"; then
+ if test -f "$dir/$libname.la"; then
+ found_la="$dir/$libname.la"
+ fi
+ fi
fi
fi
- fi
- dnl Then look for a static library.
- if test "X$found_dir" = "X"; then
- if test -f "$dir/$libname.$acl_libext"; then
- found_dir="$dir"
- found_a="$dir/$libname.$acl_libext"
- fi
- fi
- if test "X$found_dir" != "X"; then
- if test -f "$dir/$libname.la"; then
- found_la="$dir/$libname.la"
- fi
- fi
+ done
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIB[]NAME; do
@@ -1445,7 +1490,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
dir=`echo "X$x" | sed -e 's/^X-L//'`
dnl First look for a shared library.
if test -n "$acl_shlibext"; then
- if test -f "$dir/$libname$shrext"; then
+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
@@ -1455,14 +1500,14 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
- if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
- if test -f "$dir/$f"; then
+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
@@ -1473,7 +1518,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
fi
dnl Then look for a static library.
if test "X$found_dir" = "X"; then
- if test -f "$dir/$libname.$acl_libext"; then
+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
@@ -1499,7 +1544,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
dnl standard /usr/lib.
if test "$enable_rpath" = no \
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
- || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
+ || test "X$found_dir" = "X/usr/$acl_libdirstem2" \
+ || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then
dnl No hardcoding is needed.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
@@ -1599,6 +1645,13 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
fi
additional_includedir="$basedir/include"
;;
+ */$acl_libdirstem3 | */$acl_libdirstem3/)
+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'`
+ if test "$name" = '$1'; then
+ LIB[]NAME[]_PREFIX="$basedir"
+ fi
+ additional_includedir="$basedir/include"
+ ;;
esac
if test "X$additional_includedir" != "X"; then
dnl Potentially add $additional_includedir to $INCNAME.
@@ -1649,19 +1702,21 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
for dep in $dependency_libs; do
case "$dep" in
-L*)
- additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
- dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
+ dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+ dnl Potentially add $dependency_libdir to $LIBNAME and $LTLIBNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
dnl 3. if it's already present in $LDFLAGS or the already
dnl constructed $LIBNAME,
dnl 4. if it doesn't exist as a directory.
- if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
- && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
+ if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \
+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \
+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then
haveit=
- if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
- || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
+ if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \
+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \
+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
@@ -1672,29 +1727,29 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-L$additional_libdir"; then
+ if test "X$x" = "X-L$dependency_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
- if test -d "$additional_libdir"; then
- dnl Really add $additional_libdir to $LIBNAME.
- LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
+ if test -d "$dependency_libdir"; then
+ dnl Really add $dependency_libdir to $LIBNAME.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$dependency_libdir"
fi
fi
haveit=
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
- if test "X$x" = "X-L$additional_libdir"; then
+ if test "X$x" = "X-L$dependency_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
- if test -d "$additional_libdir"; then
- dnl Really add $additional_libdir to $LTLIBNAME.
- LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
+ if test -d "$dependency_libdir"; then
+ dnl Really add $dependency_libdir to $LTLIBNAME.
+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$dependency_libdir"
fi
fi
fi
@@ -1842,7 +1897,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
dir="$next"
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem" \
- && test "X$dir" != "X/usr/$acl_libdirstem2"; then
+ && test "X$dir" != "X/usr/$acl_libdirstem2" \
+ && test "X$dir" != "X/usr/$acl_libdirstem3"; then
rpathdirs="$rpathdirs $dir"
fi
next=
@@ -1852,7 +1908,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem" \
- && test "X$dir" != "X/usr/$acl_libdirstem2"; then
+ && test "X$dir" != "X/usr/$acl_libdirstem2" \
+ && test "X$dir" != "X/usr/$acl_libdirstem3"; then
rpathdirs="$rpathdirs $dir"
fi
next= ;;
@@ -1897,8 +1954,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
AC_SUBST([$1])
])
-# lib-prefix.m4 serial 14
-dnl Copyright (C) 2001-2005, 2008-2019 Free Software Foundation, Inc.
+# lib-prefix.m4 serial 17
+dnl Copyright (C) 2001-2005, 2008-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -2046,21 +2103,24 @@ AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
])
dnl AC_LIB_PREPARE_MULTILIB creates
-dnl - a variable acl_libdirstem, containing the basename of the libdir, either
-dnl "lib" or "lib64" or "lib/64",
-dnl - a variable acl_libdirstem2, as a secondary possible value for
-dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
-dnl "lib/amd64".
+dnl - a function acl_is_expected_elfclass, that tests whether standard input
+dn; has a 32-bit or 64-bit ELF header, depending on the host CPU ABI,
+dnl - 3 variables acl_libdirstem, acl_libdirstem2, acl_libdirstem3, containing
+dnl the basename of the libdir to try in turn, either "lib" or "lib64" or
+dnl "lib/64" or "lib32" or "lib/sparcv9" or "lib/amd64" or similar.
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
[
- dnl There is no formal standard regarding lib and lib64.
- dnl On glibc systems, the current practice is that on a system supporting
+ dnl There is no formal standard regarding lib, lib32, and lib64.
+ dnl On most glibc systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
- dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
- dnl the compiler's default mode by looking at the compiler's library search
- dnl path. If at least one of its elements ends in /lib64 or points to a
- dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
- dnl Otherwise we use the default, namely "lib".
+ dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. However, on
+ dnl Arch Linux based distributions, it's the opposite: 32-bit libraries go
+ dnl under $prefix/lib32 and 64-bit libraries go under $prefix/lib.
+ dnl We determine the compiler's default mode by looking at the compiler's
+ dnl library search path. If at least one of its elements ends in /lib64 or
+ dnl points to a directory whose absolute pathname ends in /lib64, we use that
+ dnl for 64-bit ABIs. Similarly for 32-bit ABIs. Otherwise we use the default,
+ dnl namely "lib".
dnl On Solaris systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
@@ -2068,27 +2128,72 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_HOST_CPU_C_ABI_32BIT])
- case "$host_os" in
- solaris*)
- AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
- [AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE(
- [[#ifdef _LP64
- int ok;
- #else
- error fail
- #endif
- ]])],
- [gl_cv_solaris_64bit=yes],
- [gl_cv_solaris_64bit=no])
- ]);;
- esac
+ AC_CACHE_CHECK([for ELF binary format], [gl_cv_elf],
+ [AC_EGREP_CPP([Extensible Linking Format],
+ [#ifdef __ELF__
+ Extensible Linking Format
+ #endif
+ ],
+ [gl_cv_elf=yes],
+ [gl_cv_elf=no])
+ ])
+ if test $gl_cv_elf; then
+ # Extract the ELF class of a file (5th byte) in decimal.
+ # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
+ if od -A x < /dev/null >/dev/null 2>/dev/null; then
+ # Use POSIX od.
+ func_elfclass ()
+ {
+ od -A n -t d1 -j 4 -N 1
+ }
+ else
+ # Use BSD hexdump.
+ func_elfclass ()
+ {
+ dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'
+ echo
+ }
+ fi
+changequote(,)dnl
+ case $HOST_CPU_C_ABI_32BIT in
+ yes)
+ # 32-bit ABI.
+ acl_is_expected_elfclass ()
+ {
+ test "`func_elfclass | sed -e 's/[ ]//g'`" = 1
+ }
+ ;;
+ no)
+ # 64-bit ABI.
+ acl_is_expected_elfclass ()
+ {
+ test "`func_elfclass | sed -e 's/[ ]//g'`" = 2
+ }
+ ;;
+ *)
+ # Unknown.
+ acl_is_expected_elfclass ()
+ {
+ :
+ }
+ ;;
+ esac
+changequote([,])dnl
+ else
+ acl_is_expected_elfclass ()
+ {
+ :
+ }
+ fi
dnl Allow the user to override the result by setting acl_cv_libdirstems.
AC_CACHE_CHECK([for the common suffixes of directories in the library search path],
[acl_cv_libdirstems],
- [acl_libdirstem=lib
+ [dnl Try 'lib' first, because that's the default for libdir in GNU, see
+ dnl <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>.
+ acl_libdirstem=lib
acl_libdirstem2=
+ acl_libdirstem3=
case "$host_os" in
solaris*)
dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
@@ -2096,60 +2201,83 @@ AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
dnl symlink is missing, so we set acl_libdirstem2 too.
- if test $gl_cv_solaris_64bit = yes; then
- acl_libdirstem=lib/64
+ if test $HOST_CPU_C_ABI_32BIT = no; then
+ acl_libdirstem2=lib/64
case "$host_cpu" in
- sparc*) acl_libdirstem2=lib/sparcv9 ;;
- i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
+ sparc*) acl_libdirstem3=lib/sparcv9 ;;
+ i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;
esac
fi
;;
*)
dnl If $CC generates code for a 32-bit ABI, the libraries are
- dnl surely under $prefix/lib, not $prefix/lib64.
- if test "$HOST_CPU_C_ABI_32BIT" != yes; then
- dnl The result is a property of the system. However, non-system
- dnl compilers sometimes have odd library search paths. Therefore
- dnl prefer asking /usr/bin/gcc, if available, rather than $CC.
- searchpath=`(if test -f /usr/bin/gcc \
- && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \
- LC_ALL=C /usr/bin/gcc -print-search-dirs; \
- else \
- LC_ALL=C $CC -print-search-dirs; \
- fi) 2>/dev/null \
- | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
- if test -n "$searchpath"; then
- acl_save_IFS="${IFS= }"; IFS=":"
- for searchdir in $searchpath; do
- if test -d "$searchdir"; then
- case "$searchdir" in
- */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
- */../ | */.. )
- # Better ignore directories of this form. They are misleading.
- ;;
- *) searchdir=`cd "$searchdir" && pwd`
- case "$searchdir" in
- */lib64 ) acl_libdirstem=lib64 ;;
- esac ;;
- esac
- fi
- done
- IFS="$acl_save_IFS"
+ dnl surely under $prefix/lib or $prefix/lib32, not $prefix/lib64.
+ dnl Similarly, if $CC generates code for a 64-bit ABI, the libraries
+ dnl are surely under $prefix/lib or $prefix/lib64, not $prefix/lib32.
+ dnl Find the compiler's search path. However, non-system compilers
+ dnl sometimes have odd library search paths. But we can't simply invoke
+ dnl '/usr/bin/gcc -print-search-dirs' because that would not take into
+ dnl account the -m32/-m31 or -m64 options from the $CC or $CFLAGS.
+ searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \
+ | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
+ if test $HOST_CPU_C_ABI_32BIT != no; then
+ # 32-bit or unknown ABI.
+ if test -d /usr/lib32; then
+ acl_libdirstem2=lib32
+ fi
+ fi
+ if test $HOST_CPU_C_ABI_32BIT != yes; then
+ # 64-bit or unknown ABI.
+ if test -d /usr/lib64; then
+ acl_libdirstem3=lib64
+ fi
+ fi
+ if test -n "$searchpath"; then
+ acl_save_IFS="${IFS= }"; IFS=":"
+ for searchdir in $searchpath; do
+ if test -d "$searchdir"; then
+ case "$searchdir" in
+ */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;
+ */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;
+ */../ | */.. )
+ # Better ignore directories of this form. They are misleading.
+ ;;
+ *) searchdir=`cd "$searchdir" && pwd`
+ case "$searchdir" in
+ */lib32 ) acl_libdirstem2=lib32 ;;
+ */lib64 ) acl_libdirstem3=lib64 ;;
+ esac ;;
+ esac
+ fi
+ done
+ IFS="$acl_save_IFS"
+ if test $HOST_CPU_C_ABI_32BIT = yes; then
+ # 32-bit ABI.
+ acl_libdirstem3=
+ fi
+ if test $HOST_CPU_C_ABI_32BIT = no; then
+ # 64-bit ABI.
+ acl_libdirstem2=
fi
fi
;;
esac
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
- acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2"
+ test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"
+ acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"
])
- # Decompose acl_cv_libdirstems into acl_libdirstem and acl_libdirstem2.
+ dnl Decompose acl_cv_libdirstems into acl_libdirstem, acl_libdirstem2, and
+ dnl acl_libdirstem3.
+changequote(,)dnl
acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
- acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e '/,/s/.*,//'`
+ acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`
+ acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`
+changequote([,])dnl
])
-dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-dnl serial 11 (pkg-config-0.29.1)
-dnl
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 12 (pkg-config-0.29.2)
+
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
dnl
@@ -2190,7 +2318,7 @@ dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
-[m4_define([PKG_MACROS_VERSION], [0.29.1])
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
@@ -2291,7 +2419,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
-AC_MSG_CHECKING([for $1])
+AC_MSG_CHECKING([for $2])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -2301,11 +2429,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
- AC_MSG_RESULT([no])
+ AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
- else
+ else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
@@ -2322,7 +2450,7 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
- AC_MSG_RESULT([no])
+ AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
diff --git a/app/xclock/compile b/app/xclock/compile
index a85b723c7..df363c8fb 100644
--- a/app/xclock/compile
+++ b/app/xclock/compile
@@ -1,9 +1,9 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
-scriptversion=2012-10-14.11; # UTC
+scriptversion=2018-03-07.03; # UTC
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -53,7 +53,7 @@ func_file_conv ()
MINGW*)
file_conv=mingw
;;
- CYGWIN*)
+ CYGWIN* | MSYS*)
file_conv=cygwin
;;
*)
@@ -67,7 +67,7 @@ func_file_conv ()
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
- cygwin/*)
+ cygwin/* | msys/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
@@ -255,7 +255,8 @@ EOF
echo "compile $scriptversion"
exit $?
;;
- cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+ cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
@@ -339,9 +340,9 @@ exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/app/xclock/config.h.in b/app/xclock/config.h.in
index c7cfcf4f8..ce540d8c4 100644
--- a/app/xclock/config.h.in
+++ b/app/xclock/config.h.in
@@ -18,6 +18,9 @@
/* Define to 1 if you have the `pledge' function. */
#undef HAVE_PLEDGE
+/* Define to 1 if you have the `sincos' function. */
+#undef HAVE_SINCOS
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
diff --git a/app/xclock/configure b/app/xclock/configure
index b56ff2372..c2b508854 100644
--- a/app/xclock/configure
+++ b/app/xclock/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for xclock 1.0.9.
+# Generated by GNU Autoconf 2.69 for xclock 1.1.1.
#
# Report bugs to <https://gitlab.freedesktop.org/xorg/app/xclock/issues>.
#
@@ -581,8 +581,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='xclock'
PACKAGE_TARNAME='xclock'
-PACKAGE_VERSION='1.0.9'
-PACKAGE_STRING='xclock 1.0.9'
+PACKAGE_VERSION='1.1.1'
+PACKAGE_STRING='xclock 1.1.1'
PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/app/xclock/issues'
PACKAGE_URL=''
@@ -738,6 +738,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -830,6 +831,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1082,6 +1084,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1219,7 +1230,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1332,7 +1343,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures xclock 1.0.9 to adapt to many kinds of systems.
+\`configure' configures xclock 1.1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1372,6 +1383,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1402,7 +1414,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of xclock 1.0.9:";;
+ short | recursive ) echo "Configuration of xclock 1.1.1:";;
esac
cat <<\_ACEOF
@@ -1531,7 +1543,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-xclock configure 1.0.9
+xclock configure 1.1.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1855,7 +1867,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by xclock $as_me 1.0.9, which was
+It was created by xclock $as_me 1.1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2684,7 +2696,7 @@ fi
# Define the identity of the package.
PACKAGE='xclock'
- VERSION='1.0.9'
+ VERSION='1.1.1'
cat >>confdefs.h <<_ACEOF
@@ -10758,13 +10770,41 @@ else
case "$gl_cv_host_cpu_c_abi" in
i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)
gl_cv_host_cpu_c_abi_32bit=yes ;;
- *)
+ x86_64 | alpha | arm64 | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )
gl_cv_host_cpu_c_abi_32bit=no ;;
+ *)
+ gl_cv_host_cpu_c_abi_32bit=unknown ;;
esac
else
case "$host_cpu" in
- i[4567]86 )
+ # CPUs that only support a 32-bit ABI.
+ arc \
+ | bfin \
+ | cris* \
+ | csky \
+ | epiphany \
+ | ft32 \
+ | h8300 \
+ | m68k \
+ | microblaze | microblazeel \
+ | nds32 | nds32le | nds32be \
+ | nios2 | nios2eb | nios2el \
+ | or1k* \
+ | or32 \
+ | sh | sh1234 | sh1234elb \
+ | tic6x \
+ | xtensa* )
+ gl_cv_host_cpu_c_abi_32bit=yes
+ ;;
+
+ # CPUs that only support a 64-bit ABI.
+ alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \
+ | mmix )
+ gl_cv_host_cpu_c_abi_32bit=no
+ ;;
+
+ i[34567]86 )
gl_cv_host_cpu_c_abi_32bit=yes
;;
@@ -10968,7 +11008,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
*)
- gl_cv_host_cpu_c_abi_32bit=no
+ gl_cv_host_cpu_c_abi_32bit=unknown
;;
esac
fi
@@ -10983,90 +11023,150 @@ $as_echo "$gl_cv_host_cpu_c_abi_32bit" >&6; }
- case "$host_os" in
- solaris*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5
-$as_echo_n "checking for 64-bit host... " >&6; }
-if ${gl_cv_solaris_64bit+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF binary format" >&5
+$as_echo_n "checking for ELF binary format... " >&6; }
+if ${gl_cv_elf+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#ifdef _LP64
- int ok;
- #else
- error fail
- #endif
+#ifdef __ELF__
+ Extensible Linking Format
+ #endif
_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- gl_cv_solaris_64bit=yes
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "Extensible Linking Format" >/dev/null 2>&1; then :
+ gl_cv_elf=yes
else
- gl_cv_solaris_64bit=no
+ gl_cv_elf=no
fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f conftest*
+
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5
-$as_echo "$gl_cv_solaris_64bit" >&6; };;
- esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_elf" >&5
+$as_echo "$gl_cv_elf" >&6; }
+ if test $gl_cv_elf; then
+ # Extract the ELF class of a file (5th byte) in decimal.
+ # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header
+ if od -A x < /dev/null >/dev/null 2>/dev/null; then
+ # Use POSIX od.
+ func_elfclass ()
+ {
+ od -A n -t d1 -j 4 -N 1
+ }
+ else
+ # Use BSD hexdump.
+ func_elfclass ()
+ {
+ dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'
+ echo
+ }
+ fi
+ case $HOST_CPU_C_ABI_32BIT in
+ yes)
+ # 32-bit ABI.
+ acl_is_expected_elfclass ()
+ {
+ test "`func_elfclass | sed -e 's/[ ]//g'`" = 1
+ }
+ ;;
+ no)
+ # 64-bit ABI.
+ acl_is_expected_elfclass ()
+ {
+ test "`func_elfclass | sed -e 's/[ ]//g'`" = 2
+ }
+ ;;
+ *)
+ # Unknown.
+ acl_is_expected_elfclass ()
+ {
+ :
+ }
+ ;;
+ esac
+ else
+ acl_is_expected_elfclass ()
+ {
+ :
+ }
+ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the common suffixes of directories in the library search path" >&5
$as_echo_n "checking for the common suffixes of directories in the library search path... " >&6; }
if ${acl_cv_libdirstems+:} false; then :
$as_echo_n "(cached) " >&6
else
- acl_libdirstem=lib
+ acl_libdirstem=lib
acl_libdirstem2=
+ acl_libdirstem3=
case "$host_os" in
solaris*)
- if test $gl_cv_solaris_64bit = yes; then
- acl_libdirstem=lib/64
+ if test $HOST_CPU_C_ABI_32BIT = no; then
+ acl_libdirstem2=lib/64
case "$host_cpu" in
- sparc*) acl_libdirstem2=lib/sparcv9 ;;
- i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
+ sparc*) acl_libdirstem3=lib/sparcv9 ;;
+ i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;
esac
fi
;;
*)
- if test "$HOST_CPU_C_ABI_32BIT" != yes; then
- searchpath=`(if test -f /usr/bin/gcc \
- && LC_ALL=C /usr/bin/gcc -print-search-dirs >/dev/null 2>/dev/null; then \
- LC_ALL=C /usr/bin/gcc -print-search-dirs; \
- else \
- LC_ALL=C $CC -print-search-dirs; \
- fi) 2>/dev/null \
- | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
- if test -n "$searchpath"; then
- acl_save_IFS="${IFS= }"; IFS=":"
- for searchdir in $searchpath; do
- if test -d "$searchdir"; then
- case "$searchdir" in
- */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
- */../ | */.. )
- # Better ignore directories of this form. They are misleading.
- ;;
- *) searchdir=`cd "$searchdir" && pwd`
- case "$searchdir" in
- */lib64 ) acl_libdirstem=lib64 ;;
- esac ;;
- esac
- fi
- done
- IFS="$acl_save_IFS"
+ searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \
+ | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
+ if test $HOST_CPU_C_ABI_32BIT != no; then
+ # 32-bit or unknown ABI.
+ if test -d /usr/lib32; then
+ acl_libdirstem2=lib32
+ fi
+ fi
+ if test $HOST_CPU_C_ABI_32BIT != yes; then
+ # 64-bit or unknown ABI.
+ if test -d /usr/lib64; then
+ acl_libdirstem3=lib64
+ fi
+ fi
+ if test -n "$searchpath"; then
+ acl_save_IFS="${IFS= }"; IFS=":"
+ for searchdir in $searchpath; do
+ if test -d "$searchdir"; then
+ case "$searchdir" in
+ */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;
+ */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;
+ */../ | */.. )
+ # Better ignore directories of this form. They are misleading.
+ ;;
+ *) searchdir=`cd "$searchdir" && pwd`
+ case "$searchdir" in
+ */lib32 ) acl_libdirstem2=lib32 ;;
+ */lib64 ) acl_libdirstem3=lib64 ;;
+ esac ;;
+ esac
+ fi
+ done
+ IFS="$acl_save_IFS"
+ if test $HOST_CPU_C_ABI_32BIT = yes; then
+ # 32-bit ABI.
+ acl_libdirstem3=
+ fi
+ if test $HOST_CPU_C_ABI_32BIT = no; then
+ # 64-bit ABI.
+ acl_libdirstem2=
fi
fi
;;
esac
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
- acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2"
+ test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"
+ acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_libdirstems" >&5
$as_echo "$acl_cv_libdirstems" >&6; }
- # Decompose acl_cv_libdirstems into acl_libdirstem and acl_libdirstem2.
- acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
- acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e '/,/s/.*,//'`
+ acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`
+ acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`
+ acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`
@@ -11087,6 +11187,8 @@ $as_echo "$acl_cv_libdirstems" >&6; }
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
@@ -11107,6 +11209,8 @@ if test "${with_libiconv_prefix+set}" = set; then :
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"
+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
@@ -11114,15 +11218,19 @@ if test "${with_libiconv_prefix+set}" = set; then :
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
- if test "$acl_libdirstem2" != "$acl_libdirstem" \
- && test ! -d "$withval/$acl_libdirstem"; then
- additional_libdir="$withval/$acl_libdirstem2"
- fi
+ additional_libdir2="$withval/$acl_libdirstem2"
+ additional_libdir3="$withval/$acl_libdirstem3"
fi
fi
fi
+ if test "X$additional_libdir2" = "X$additional_libdir"; then
+ additional_libdir2=
+ fi
+ if test "X$additional_libdir3" = "X$additional_libdir"; then
+ additional_libdir3=
+ fi
LIBICONV=
LTLIBICONV=
INCICONV=
@@ -11168,45 +11276,51 @@ fi
shrext=
fi
if test $use_additional = yes; then
- dir="$additional_libdir"
- if test -n "$acl_shlibext"; then
- if test -f "$dir/$libname$shrext"; then
- found_dir="$dir"
- found_so="$dir/$libname$shrext"
- else
- if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
- ver=`(cd "$dir" && \
- for f in "$libname$shrext".*; do echo "$f"; done \
- | sed -e "s,^$libname$shrext\\\\.,," \
- | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
- | sed 1q ) 2>/dev/null`
- if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
- found_dir="$dir"
- found_so="$dir/$libname$shrext.$ver"
+ for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do
+ if test "X$found_dir" = "X"; then
+ eval dir=\$$additional_libdir_variable
+ if test -n "$dir"; then
+ if test -n "$acl_shlibext"; then
+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
+ found_dir="$dir"
+ found_so="$dir/$libname$shrext"
+ else
+ if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+ ver=`(cd "$dir" && \
+ for f in "$libname$shrext".*; do echo "$f"; done \
+ | sed -e "s,^$libname$shrext\\\\.,," \
+ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+ | sed 1q ) 2>/dev/null`
+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
+ found_dir="$dir"
+ found_so="$dir/$libname$shrext.$ver"
+ fi
+ else
+ eval library_names=\"$acl_library_names_spec\"
+ for f in $library_names; do
+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
+ found_dir="$dir"
+ found_so="$dir/$f"
+ break
+ fi
+ done
+ fi
+ fi
fi
- else
- eval library_names=\"$acl_library_names_spec\"
- for f in $library_names; do
- if test -f "$dir/$f"; then
+ if test "X$found_dir" = "X"; then
+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
found_dir="$dir"
- found_so="$dir/$f"
- break
+ found_a="$dir/$libname.$acl_libext"
fi
- done
+ fi
+ if test "X$found_dir" != "X"; then
+ if test -f "$dir/$libname.la"; then
+ found_la="$dir/$libname.la"
+ fi
+ fi
fi
fi
- fi
- if test "X$found_dir" = "X"; then
- if test -f "$dir/$libname.$acl_libext"; then
- found_dir="$dir"
- found_a="$dir/$libname.$acl_libext"
- fi
- fi
- if test "X$found_dir" != "X"; then
- if test -f "$dir/$libname.la"; then
- found_la="$dir/$libname.la"
- fi
- fi
+ done
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIBICONV; do
@@ -11223,7 +11337,7 @@ fi
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
if test -n "$acl_shlibext"; then
- if test -f "$dir/$libname$shrext"; then
+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
@@ -11233,14 +11347,14 @@ fi
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
- if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
- if test -f "$dir/$f"; then
+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
@@ -11250,7 +11364,7 @@ fi
fi
fi
if test "X$found_dir" = "X"; then
- if test -f "$dir/$libname.$acl_libext"; then
+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
@@ -11272,7 +11386,8 @@ fi
if test "X$found_so" != "X"; then
if test "$enable_rpath" = no \
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
- || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
+ || test "X$found_dir" = "X/usr/$acl_libdirstem2" \
+ || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then
LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
else
haveit=
@@ -11351,6 +11466,13 @@ fi
fi
additional_includedir="$basedir/include"
;;
+ */$acl_libdirstem3 | */$acl_libdirstem3/)
+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'`
+ if test "$name" = 'iconv'; then
+ LIBICONV_PREFIX="$basedir"
+ fi
+ additional_includedir="$basedir/include"
+ ;;
esac
if test "X$additional_includedir" != "X"; then
if test "X$additional_includedir" != "X/usr/include"; then
@@ -11396,12 +11518,14 @@ fi
for dep in $dependency_libs; do
case "$dep" in
-L*)
- additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
- if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
- && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
+ dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+ if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \
+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \
+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then
haveit=
- if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
- || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
+ if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \
+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \
+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
@@ -11420,14 +11544,14 @@ fi
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
- if test "X$x" = "X-L$additional_libdir"; then
+ if test "X$x" = "X-L$dependency_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
- if test -d "$additional_libdir"; then
- LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir"
+ if test -d "$dependency_libdir"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$dependency_libdir"
fi
fi
haveit=
@@ -11441,14 +11565,14 @@ fi
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
- if test "X$x" = "X-L$additional_libdir"; then
+ if test "X$x" = "X-L$dependency_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
- if test -d "$additional_libdir"; then
- LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir"
+ if test -d "$dependency_libdir"; then
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$dependency_libdir"
fi
fi
fi
@@ -11860,8 +11984,8 @@ _ACEOF
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XCLOCK" >&5
-$as_echo_n "checking for XCLOCK... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xaw7 xmu x11 xproto >= 7.0.17" >&5
+$as_echo_n "checking for xaw7 xmu x11 xproto >= 7.0.17... " >&6; }
if test -n "$XCLOCK_CFLAGS"; then
pkg_cv_XCLOCK_CFLAGS="$XCLOCK_CFLAGS"
@@ -11901,7 +12025,7 @@ fi
if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -11928,7 +12052,7 @@ Alternatively, you may set the environment variables XCLOCK_CFLAGS
and XCLOCK_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -11962,8 +12086,8 @@ fi
if test x$use_xft != xno ; then
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XFT" >&5
-$as_echo_n "checking for XFT... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xrender xft" >&5
+$as_echo_n "checking for xrender xft... " >&6; }
if test -n "$XFT_CFLAGS"; then
pkg_cv_XFT_CFLAGS="$XFT_CFLAGS"
@@ -12003,7 +12127,7 @@ fi
if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -12030,7 +12154,7 @@ Alternatively, you may set the environment variables XFT_CFLAGS
and XFT_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -12051,6 +12175,7 @@ else
$as_echo "yes" >&6; }
fi
+ # Solaris 11 has sqrt in libc but needs libm for sincos
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sqrt" >&5
$as_echo_n "checking for library containing sqrt... " >&6; }
if ${ac_cv_search_sqrt+:} false; then :
@@ -12107,6 +12232,64 @@ if test "$ac_res" != no; then :
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sincos" >&5
+$as_echo_n "checking for library containing sincos... " >&6; }
+if ${ac_cv_search_sincos+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sincos ();
+int
+main ()
+{
+return sincos ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' m; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_sincos=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_sincos+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_sincos+:} false; then :
+
+else
+ ac_cv_search_sincos=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sincos" >&5
+$as_echo "$ac_cv_search_sincos" >&6; }
+ac_res=$ac_cv_search_sincos
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+$as_echo "#define HAVE_SINCOS 1" >>confdefs.h
+
+fi
+
XCLOCK_CFLAGS="$XCLOCK_CFLAGS $XFT_CFLAGS"
XCLOCK_LIBS="$XCLOCK_LIBS $XFT_LIBS"
@@ -12128,8 +12311,8 @@ fi
if test x$use_xkb != xno ; then
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XKB" >&5
-$as_echo_n "checking for XKB... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xkbfile" >&5
+$as_echo_n "checking for xkbfile... " >&6; }
if test -n "$XKB_CFLAGS"; then
pkg_cv_XKB_CFLAGS="$XKB_CFLAGS"
@@ -12169,7 +12352,7 @@ fi
if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -12196,7 +12379,7 @@ Alternatively, you may set the environment variables XKB_CFLAGS
and XKB_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -12227,8 +12410,8 @@ fi
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for APPDEFS" >&5
-$as_echo_n "checking for APPDEFS... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xt" >&5
+$as_echo_n "checking for xt... " >&6; }
if test -n "$APPDEFS_CFLAGS"; then
pkg_cv_APPDEFS_CFLAGS="$APPDEFS_CFLAGS"
@@ -12268,7 +12451,7 @@ fi
if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -12295,7 +12478,7 @@ Alternatively, you may set the environment variables APPDEFS_CFLAGS
and APPDEFS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -12863,7 +13046,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by xclock $as_me 1.0.9, which was
+This file was extended by xclock $as_me 1.1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12929,7 +13112,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-xclock config.status 1.0.9
+xclock config.status 1.1.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/app/xclock/configure.ac b/app/xclock/configure.ac
index 896f91bc4..5c76344e0 100644
--- a/app/xclock/configure.ac
+++ b/app/xclock/configure.ac
@@ -24,14 +24,14 @@ dnl Process this file with autoconf to create configure.
# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xclock],
- [1.0.9],
+ [1.1.1],
[https://gitlab.freedesktop.org/xorg/app/xclock/issues],
[xclock])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
# Initialize Automake
-AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_INIT_AUTOMAKE([foreign dist-xz])
# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
m4_ifndef([XORG_MACROS_VERSION],
@@ -51,7 +51,11 @@ dnl Optional dependencies
AC_ARG_WITH(xft, AS_HELP_STRING([--with-xft],[Use Xft2 and Xrender for rendering (Default is YES)]),use_xft="$withval",use_xft="try")
if test x$use_xft != xno ; then
PKG_CHECK_MODULES(XFT, [xrender xft])
+ # Solaris 11 has sqrt in libc but needs libm for sincos
AC_SEARCH_LIBS(sqrt, [m])
+ AC_SEARCH_LIBS(sincos, [m],
+ AC_DEFINE([HAVE_SINCOS], [1],
+ [Define to 1 if you have the `sincos' function.]))
XCLOCK_CFLAGS="$XCLOCK_CFLAGS $XFT_CFLAGS"
XCLOCK_LIBS="$XCLOCK_LIBS $XFT_LIBS"
AC_DEFINE([XRENDER],1,[Define to use X Render Extension])
diff --git a/app/xclock/man/Makefile.in b/app/xclock/man/Makefile.in
index 564561c2c..cffd5194b 100644
--- a/app/xclock/man/Makefile.in
+++ b/app/xclock/man/Makefile.in
@@ -231,6 +231,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/app/xclock/man/xclock.man b/app/xclock/man/xclock.man
index b0a45740d..bc596b4d2 100644
--- a/app/xclock/man/xclock.man
+++ b/app/xclock/man/xclock.man
@@ -76,10 +76,13 @@ for the digital clock's display.
.B \-twelve
This option indicates that a digital clock should display the time in
twelve hour format.
+This is only effective for the brief display.
.TP 8
.B \-twentyfour
This option indicates that a digital clock should display the time in
-twenty-four hour format. This is the default when a digital clock is used.
+twenty-four hour format.
+This is only effective for the brief display.
+This is the default when a digital clock is used.
.TP 8
.B \-chime
This option indicates that the clock should chime