home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.x
- From: R.Caley@ed.ac.uk (Richard Caley)
- Subject: v19i001: wclock - Wclock - another X clock, Patch01
- Message-ID: <1993Mar4.160446.16453@sparky.imd.sterling.com>
- X-Md4-Signature: dece884eddf8d0e4c93245e1c9e9b73c
- Date: Thu, 4 Mar 1993 16:04:46 GMT
- Approved: chris@sparky.imd.sterling.com
-
- Submitted-by: R.Caley@ed.ac.uk (Richard Caley)
- Posting-number: Volume 19, Issue 1
- Archive-name: wclock/patch01
- Environment: X11
- Patch-To: wclock: Volume 18, Issue 11-14
-
- Here is a patch to wclock (Volume 18, Issue 11). It's main purpose is
- to put in a couple of missing declarations which were causing protocol
- errors sometimes, especially under R5. It also removes a compilation
- problem with R5, adds some support for servers which don't have the
- shape extension improves the Imakefile and fixes a few typos and bad
- habits. See the patched README for credits. Apologies if I missed
- anyone out.
-
-
- --- 8< --- 8< --- 8< --- CUT HERE --- 8< --- 8< --- 8< ---
- ===================================================================
- RCS file: RCS/Imakefile,v
- retrieving revision 1.1
- diff -c -r1.1 Imakefile
- *** /tmp/RCSAa26520 Fri Jul 31 16:00:58 1992
- --- Imakefile Fri Jul 31 16:05:55 1992
- ***************
- *** 6,11 ****
- --- 6,14 ----
-
- SRCS= wclock.c Wclock.c Outline.c
- OBJS= wclock.o Wclock.o Outline.o
- + BITMAPS = eye.mask eye.mask1 eye.xbm rose.mask rose.xbm
-
- ComplexProgramTarget(wclock)
- InstallAppDefaults(Wclock)
- + InstallMultiple($(BITMAPS),$(INCDIR)/bitmaps)
- +
- ===================================================================
- RCS file: RCS/Makefile.std,v
- retrieving revision 1.1
- diff -c -r1.1 Makefile.std
- *** /tmp/RCSAa26520 Fri Jul 31 16:00:58 1992
- --- Makefile.std Fri Jul 31 16:05:55 1992
- ***************
- *** 26,31 ****
- --- 26,34 ----
- DEFINES=-DSHAPE
- CDEBUGFLAGS=-O
-
- + # add -Bstatic if you get link errors about get_wmShellWidgetClass
- + # in open windows.
- +
- CFLAGS= $(CDEBUGFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(LIB_DIRS)
-
- wclock: $(WCLOCK_OBJ)
- ===================================================================
- RCS file: RCS/OutlineP.h,v
- retrieving revision 1.1
- diff -c -r1.1 OutlineP.h
- *** /tmp/RCSAa26520 Fri Jul 31 16:00:59 1992
- --- OutlineP.h Fri Jul 31 16:05:56 1992
- ***************
- *** 31,37 ****
-
- #include "Outline.h"
-
- ! #define XtNbitmap "bitmap"
- #define XtNcircle "circle"
- #define XtNnoOutline "none"
-
- --- 31,39 ----
-
- #include "Outline.h"
-
- ! #ifndef XtNbitmap
- ! # define XtNbitmap "bitmap"
- ! #endif
- #define XtNcircle "circle"
- #define XtNnoOutline "none"
-
- ===================================================================
- RCS file: RCS/README,v
- retrieving revision 1.2
- diff -c -r1.2 README
- *** /tmp/RCSAa26520 Fri Jul 31 16:01:00 1992
- --- README Fri Jul 31 16:05:57 1992
- ***************
- *** 7,22 ****
- piece. I, being strange, actually do use it.
-
- There are three sets of defaults in the application defaults file,
- ! the two non-default sets are named roseClock and eyeClock
-
- ! It should work as is. Just make it and install the defaults (or stick
- ! them in your Xdefaults). The more interesting behaviour depends on the
- ! MIT Shape extension, so if you haven't got that you will be stuck with
- ! a boring clock. It is a good idea to make sure your window manager
- ! doesn't decorate the clock as this (a) spoils the effect and (b)
- ! causes the WM (well, tvtwm at least) to get very frustrated
- ! redecorating when the clock reshapes itself.
-
- Start it as
- wclock -debug 60 -update 5
-
- --- 7,29 ----
- piece. I, being strange, actually do use it.
-
- There are three sets of defaults in the application defaults file,
- ! the two non-default sets are named roseClock and eyeClock.
-
- ! It should work as is. If you have it, do xmkmf and then make,
- ! otherwise edit Makefile.std to set things up for your site and make
- ! using that. Make sure you install the application defaults file since
- ! wclock has quite an interesting one. Also install the bitmaps
- ! somewhere. OpenWidows 3.0 people might need to link wclock statically
- ! since there seem to be a couple of unresolvable references in the Xmu
- ! sharable library.
-
- + The more interesting behaviour depends on the MIT Shape extension, so
- + if you haven't got that you will be stuck with a boring clock. It is a
- + good idea to make sure your window manager doesn't decorate the clock
- + as this (a) spoils the effect and (b) causes the WM (well, tvtwm at
- + least) to get very frustrated redecorating when the clock reshapes
- + itself.
- +
- Start it as
- wclock -debug 60 -update 5
-
- ***************
- *** 31,36 ****
- --- 38,46 ----
-
- to see what else is possible.
-
- + Credits
- + =======
- +
- Having read and taken to heart Henry Spencer's advice on not reinventing
- wheels, I produced wclock by cannibalising bits of xclock, xcal and
- xbiff. Kudos to those who did the hard bits (see manual page).
- ***************
- *** 39,45 ****
- have had them for a while and don't know who originally did them. The
- eye belongs to Kate Bush, in case you're interested.
-
- ! - Richard Caley
-
- --
- R.Caley@ed.ac.uk _O_
- --- 49,83 ----
- have had them for a while and don't know who originally did them. The
- eye belongs to Kate Bush, in case you're interested.
-
- ! The following people told me how to fix problems.
- !
- ! Simon Leinen
- ! paolo petta
- ! Peter Miller
- !
- ! Changes
- ! =======
- !
- ! Simon Leinen, paolo petta, RJC:
- ! Put back some missing initialisations in WClock.c
- !
- ! Simon Leinen:
- ! Added bitmap install rules to Imakefile (Simon Leinen)
- ! Extra checks in WClock before freeing things.
- ! Added cast to Ansify it a little.
- !
- ! RJC:
- ! Check for shape extension at run time.
- ! Sorted out some confusions between NULL,NULLQUARK and None.
- ! Checked if XtNbitmap was already defined.
- ! Put in some basic support for servers without the shape extension.
- !
- ! Patchlevel1
- ! -----------
- !
- ! RJC:
- ! Fixed colour behaviour and corrected some spelling errors in the
- ! documentation.
-
- --
- R.Caley@ed.ac.uk _O_
- ===================================================================
- RCS file: RCS/Wclock.c,v
- retrieving revision 1.2
- diff -c -r1.2 Wclock.c
- *** /tmp/RCSAa26520 Fri Jul 31 16:01:00 1992
- --- Wclock.c Fri Jul 31 16:05:57 1992
- ***************
- *** 46,52 ****
-
- extern long time();
- static void Wclock_tic(), draw_segment();
- !
- /* Private Definitions */
-
- #define PI 3.14159265358979
- --- 46,52 ----
-
- extern long time();
- static void Wclock_tic(), draw_segment();
- !
- /* Private Definitions */
-
- #define PI 3.14159265358979
- ***************
- *** 60,65 ****
- --- 60,67 ----
- #define min(a, b) ((a) < (b) ? (a) : (b))
- #define abs(a) ((a) < 0 ? -(a) : (a))
-
- + static int haveShape=False;
- + static int ShapeEventBase, ShapeErrorBase;
-
- /* Initialization of defaults */
-
- ***************
- *** 133,139 ****
- /* num_actions */ 0,
- /* resources */ resources,
- /* resource_count */ XtNumber(resources),
- ! /* xrm_class */ NULL,
- /* compress_motion */ TRUE,
- /* compress_exposure */ TRUE,
- /* compress_enterleave */ TRUE,
- --- 135,141 ----
- /* num_actions */ 0,
- /* resources */ resources,
- /* resource_count */ XtNumber(resources),
- ! /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure */ TRUE,
- /* compress_enterleave */ TRUE,
- ***************
- *** 170,175 ****
- --- 172,178 ----
- NULL, 0 );
- XtAddConverter( XtRString, XtROutline, OutlineConverter,
- NULL, 0 );
- +
- }
-
- /* ARGSUSED */
- ***************
- *** 184,189 ****
- --- 187,196 ----
-
- valuemask = GCForeground | GCBackground | GCLineWidth |GCFunction;
-
- + #ifdef SHAPE
- + if (!haveShape)
- + haveShape=XShapeQueryExtension (dpy, &ShapeEventBase, &ShapeErrorBase);
- + #endif
-
- if ( w->Wclock.backgroundBitmap != None )
- {
- ***************
- *** 223,228 ****
- --- 230,239 ----
-
- w->Wclock.invertGC = NULL;
-
- + w->Wclock.outlinePM = None;
- +
- + w->Wclock.segmentPM = None;
- +
- if (w->Wclock.update <= 0)
- w->Wclock.update = 60; /* make invalid update's use a default */
- w->Wclock.interval_id = 0;
- ***************
- *** 268,275 ****
- XtDestroyGC (w->Wclock.unsetGC);
- if (w->Wclock.invertGC != NULL)
- XtDestroyGC (w->Wclock.invertGC);
- ! XFreePixmap (dpy, w->Wclock.segmentPM);
- ! XFreePixmap (dpy, w->Wclock.outlinePM);
- }
-
-
- --- 279,288 ----
- XtDestroyGC (w->Wclock.unsetGC);
- if (w->Wclock.invertGC != NULL)
- XtDestroyGC (w->Wclock.invertGC);
- ! if (w->Wclock.segmentPM != None)
- ! XFreePixmap (dpy, w->Wclock.segmentPM);
- ! if (w->Wclock.outlinePM != None)
- ! XFreePixmap (dpy, w->Wclock.outlinePM);
- }
-
-
- ***************
- *** 451,456 ****
- --- 464,471 ----
- Window win=XtWindow(w);
- int x=0, y=0;
-
- + if (haveShape)
- + {
- #ifdef SHAPE
- XShapeCombineMask (XtDisplay(w), win,
- ShapeBounding, x, y,
- ***************
- *** 457,463 ****
- outline,
- ShapeSet);
-
- ! if (additional != NULL)
- XShapeCombineMask (XtDisplay(w), win,
- ShapeBounding, x, y,
- additional,
- --- 472,478 ----
- outline,
- ShapeSet);
-
- ! if (additional != None)
- XShapeCombineMask (XtDisplay(w), win,
- ShapeBounding, x, y,
- additional,
- ***************
- *** 477,483 ****
- outline,
- ShapeSet);
-
- ! if (additional != NULL)
- XShapeCombineMask (XtDisplay(parent), XtWindow(parent),
- ShapeBounding, x, y,
- additional,
- --- 492,498 ----
- outline,
- ShapeSet);
-
- ! if (additional != None)
- XShapeCombineMask (XtDisplay(parent), XtWindow(parent),
- ShapeBounding, x, y,
- additional,
- ***************
- *** 484,489 ****
- --- 499,536 ----
- ShapeIntersect);
- }
- #endif
- + }
- + else
- + {
- + Pixmap bg;
- +
- + if ((bg=XCreatePixmap(XtDisplay(w), win,
- + w->core.width,
- + w->core.height,
- + 1))==None)
- + return;
- +
- + XFillRectangle(XtDisplay(w), bg, w->Wclock.setGC,
- + 0, 0, w->core.width, w->core.height);
- +
- + if (additional)
- + XSetClipMask(XtDisplay(w), w->Wclock.unsetGC, additional);
- +
- + XCopyPlane(XtDisplay(w), outline, bg, w->Wclock.unsetGC,
- + 0, 0, w->core.width, w->core.height,0,0,1);
- +
- + if (additional)
- + XSetClipMask(XtDisplay(w), w->Wclock.unsetGC, None);
- +
- + XSetClipMask(XtDisplay(w), w->Wclock.EraseGC, bg);
- +
- + XFillRectangle(XtDisplay(w), win, w->Wclock.EraseGC,
- + 0, 0, w->core.width, w->core.height);
- +
- + XSetClipMask(XtDisplay(w), w->Wclock.EraseGC, None);
- +
- + XFreePixmap(XtDisplay(w),bg);
- + }
- }
-
- static void Resize (gw)
- ***************
- *** 500,509 ****
- w->Wclock.centerX = w->core.width / 2;
- w->Wclock.centerY = w->core.height / 2;
-
- ! if (w->Wclock.segmentPM != NULL)
- XFreePixmap (dpy, w->Wclock.segmentPM);
-
- ! if (w->Wclock.outlinePM != NULL )
- XFreePixmap (dpy, w->Wclock.outlinePM);
-
- w->Wclock.segmentPM = XCreatePixmap(dpy, win,
- --- 547,556 ----
- w->Wclock.centerX = w->core.width / 2;
- w->Wclock.centerY = w->core.height / 2;
-
- ! if (w->Wclock.segmentPM != None)
- XFreePixmap (dpy, w->Wclock.segmentPM);
-
- ! if (w->Wclock.outlinePM != None )
- XFreePixmap (dpy, w->Wclock.outlinePM);
-
- w->Wclock.segmentPM = XCreatePixmap(dpy, win,
- ***************
- *** 589,595 ****
- tm.tm_hour -= 12;
-
-
- ! if (tm.tm_min != w->Wclock.otm.tm_min ||
- tm.tm_hour != w->Wclock.otm.tm_hour)
- {
- int twelvemins = tm.tm_min / 12; /* how many fifths of an hour */
- --- 636,642 ----
- tm.tm_hour -= 12;
-
-
- ! if (!id|| tm.tm_min != w->Wclock.otm.tm_min ||
- tm.tm_hour != w->Wclock.otm.tm_hour)
- {
- int twelvemins = tm.tm_min / 12; /* how many fifths of an hour */
- ***************
- *** 613,619 ****
- if ( w->Wclock.plotSegment )
- {
- XClearWindow(dpy, win);
- ! draw_segment(dpy, win, w->Wclock.setGC,
- w->Wclock.centerX,
- w->Wclock.centerY,
- CONVERT_A(tm.tm_hour * TWOPI/12 + twelvemins * TWOPI/60),
- --- 660,666 ----
- if ( w->Wclock.plotSegment )
- {
- XClearWindow(dpy, win);
- ! draw_segment(dpy, win, w->Wclock.EraseGC,
- w->Wclock.centerX,
- w->Wclock.centerY,
- CONVERT_A(tm.tm_hour * TWOPI/12 + twelvemins * TWOPI/60),
- ***************
- *** 777,783 ****
- if (new->Wclock.update != current->Wclock.update) {
- if (current->Wclock.interval_id)
- XtRemoveTimeOut (current->Wclock.interval_id);
- ! if (XtIsRealized(new))
- new->Wclock.interval_id = XtAppAddTimeOut(
- XtWidgetToApplicationContext(gnew),
- new->Wclock.update*1000,
- --- 824,830 ----
- if (new->Wclock.update != current->Wclock.update) {
- if (current->Wclock.interval_id)
- XtRemoveTimeOut (current->Wclock.interval_id);
- ! if (XtIsRealized((Widget)new))
- new->Wclock.interval_id = XtAppAddTimeOut(
- XtWidgetToApplicationContext(gnew),
- new->Wclock.update*1000,
- ===================================================================
- RCS file: RCS/patchlevel.h,v
- retrieving revision 1.2
- diff -c -r1.2 patchlevel.h
- *** /tmp/RCSAa26520 Fri Jul 31 16:01:02 1992
- --- patchlevel.h Fri Jul 31 16:06:00 1992
- ***************
- *** 3,6 ****
- * version tracking.
- */
-
- ! #define PATCHLEVEL 1
- --- 3,6 ----
- * version tracking.
- */
-
- ! #define PATCHLEVEL 2
- ===================================================================
- RCS file: RCS/wclock.c,v
- retrieving revision 1.2
- diff -c -r1.2 wclock.c
- *** /tmp/RCSAa26520 Fri Jul 31 16:01:04 1992
- --- wclock.c Fri Jul 31 16:06:01 1992
- ***************
- *** 139,144 ****
- --- 139,145 ----
- (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
- &wm_delete_window, 1);
- XtAppMainLoop (app_con);
- + exit(0);
- }
-
-
- ===================================================================
- RCS file: RCS/wclock.man,v
- retrieving revision 1.2
- diff -c -r1.2 wclock.man
- *** /tmp/RCSAa26520 Fri Jul 31 16:01:04 1992
- --- wclock.man Fri Jul 31 16:06:02 1992
- ***************
- *** 9,15 ****
- [-extoutline \fIoutline\fR] [-intoutline \fIoutline\fR]
- [-extbitmap \fIbitmap\fR] [-intbitmap \fIbitmap\fR]
- [-extpercent \fIint\fR] [-intpercent \fIint\fR]
- ! [-slicewidth \fIsec\fR] [-slicespace \fIsec\fR] [-sliceofset \fIsec\fR]
- [-update \fIseconds\fR] [-bitmap \fIbitmap\fR]
-
- .SH DESCRIPTION
- --- 9,15 ----
- [-extoutline \fIoutline\fR] [-intoutline \fIoutline\fR]
- [-extbitmap \fIbitmap\fR] [-intbitmap \fIbitmap\fR]
- [-extpercent \fIint\fR] [-intpercent \fIint\fR]
- ! [-slicewidth \fIsec\fR] [-slicespace \fIsec\fR] [-sliceoffset \fIsec\fR]
- [-update \fIseconds\fR] [-bitmap \fIbitmap\fR]
-
- .SH DESCRIPTION
- ===================================================================
-
-
- --- 8< --- 8< --- 8< --- CUT HERE --- 8< --- 8< --- 8< ---
-
- exit 0 # Just in case...
- --
- // chris@IMD.Sterling.COM | Send comp.sources.x submissions to:
- \X/ Amiga - The only way to fly! |
- "It's intuitively obvious to the most | sources-x@imd.sterling.com
- casual observer..." |
-