home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / wclock / patch01 next >
Encoding:
Text File  |  1993-04-28  |  14.9 KB  |  526 lines

  1. Newsgroups: comp.sources.x
  2. From: R.Caley@ed.ac.uk (Richard Caley)
  3. Subject: v19i001:  wclock - Wclock - another X clock, Patch01
  4. Message-ID: <1993Mar4.160446.16453@sparky.imd.sterling.com>
  5. X-Md4-Signature: dece884eddf8d0e4c93245e1c9e9b73c
  6. Date: Thu, 4 Mar 1993 16:04:46 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: R.Caley@ed.ac.uk (Richard Caley)
  10. Posting-number: Volume 19, Issue 1
  11. Archive-name: wclock/patch01
  12. Environment: X11
  13. Patch-To: wclock: Volume 18, Issue 11-14
  14.  
  15. Here is a patch to wclock (Volume 18, Issue 11).  It's main purpose is
  16. to put in a couple of missing declarations which were causing protocol
  17. errors sometimes, especially under R5.  It also removes a compilation
  18. problem with R5, adds some support for servers which don't have the
  19. shape extension improves the Imakefile and fixes a few typos and bad
  20. habits. See the patched README for credits. Apologies if I missed
  21. anyone out. 
  22.  
  23.  
  24.  --- 8< --- 8< --- 8< --- CUT HERE  --- 8< --- 8< --- 8< --- 
  25. ===================================================================
  26. RCS file: RCS/Imakefile,v
  27. retrieving revision 1.1
  28. diff -c -r1.1 Imakefile
  29. *** /tmp/RCSAa26520    Fri Jul 31 16:00:58 1992
  30. --- Imakefile    Fri Jul 31 16:05:55 1992
  31. ***************
  32. *** 6,11 ****
  33. --- 6,14 ----
  34.   
  35.   SRCS=  wclock.c Wclock.c Outline.c
  36.   OBJS=  wclock.o Wclock.o Outline.o
  37. + BITMAPS = eye.mask eye.mask1 eye.xbm rose.mask rose.xbm
  38.   
  39.   ComplexProgramTarget(wclock)
  40.   InstallAppDefaults(Wclock)
  41. + InstallMultiple($(BITMAPS),$(INCDIR)/bitmaps)
  42. ===================================================================
  43. RCS file: RCS/Makefile.std,v
  44. retrieving revision 1.1
  45. diff -c -r1.1 Makefile.std
  46. *** /tmp/RCSAa26520    Fri Jul 31 16:00:58 1992
  47. --- Makefile.std    Fri Jul 31 16:05:55 1992
  48. ***************
  49. *** 26,31 ****
  50. --- 26,34 ----
  51.   DEFINES=-DSHAPE
  52.   CDEBUGFLAGS=-O
  53.   
  54. + # add -Bstatic if you get link errors about get_wmShellWidgetClass
  55. + #    in open windows. 
  56.   CFLAGS= $(CDEBUGFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(LIB_DIRS)
  57.   
  58.   wclock: $(WCLOCK_OBJ)
  59. ===================================================================
  60. RCS file: RCS/OutlineP.h,v
  61. retrieving revision 1.1
  62. diff -c -r1.1 OutlineP.h
  63. *** /tmp/RCSAa26520    Fri Jul 31 16:00:59 1992
  64. --- OutlineP.h    Fri Jul 31 16:05:56 1992
  65. ***************
  66. *** 31,37 ****
  67.   
  68.   #include "Outline.h"
  69.   
  70. ! #define XtNbitmap    "bitmap"
  71.   #define XtNcircle    "circle"
  72.   #define XtNnoOutline "none"
  73.   
  74. --- 31,39 ----
  75.   
  76.   #include "Outline.h"
  77.   
  78. ! #ifndef XtNbitmap
  79. ! #    define XtNbitmap    "bitmap"
  80. ! #endif
  81.   #define XtNcircle    "circle"
  82.   #define XtNnoOutline "none"
  83.   
  84. ===================================================================
  85. RCS file: RCS/README,v
  86. retrieving revision 1.2
  87. diff -c -r1.2 README
  88. *** /tmp/RCSAa26520    Fri Jul 31 16:01:00 1992
  89. --- README    Fri Jul 31 16:05:57 1992
  90. ***************
  91. *** 7,22 ****
  92.   piece. I, being strange, actually do use it.
  93.   
  94.   There are three sets of defaults in the application defaults file,
  95. ! the two non-default sets are named roseClock and eyeClock
  96.   
  97. ! It should work as is.  Just make it and install the defaults (or stick
  98. ! them in your Xdefaults). The more interesting behaviour depends on the
  99. ! MIT Shape extension, so if you haven't got that you will be stuck with
  100. ! a boring clock. It is a good idea to make sure your window manager
  101. ! doesn't decorate the clock as this (a) spoils the effect and (b)
  102. ! causes the WM (well, tvtwm at least) to get very frustrated
  103. ! redecorating when the clock reshapes itself.
  104.   
  105.   Start it as
  106.       wclock -debug 60 -update 5
  107.   
  108. --- 7,29 ----
  109.   piece. I, being strange, actually do use it.
  110.   
  111.   There are three sets of defaults in the application defaults file,
  112. ! the two non-default sets are named roseClock and eyeClock. 
  113.   
  114. ! It should work as is.  If you have it, do xmkmf and then make,
  115. ! otherwise edit Makefile.std to set things up for your site and make
  116. ! using that. Make sure you install the application defaults file since
  117. ! wclock has quite an interesting one. Also install the bitmaps
  118. ! somewhere. OpenWidows 3.0 people might need to link wclock statically
  119. ! since there seem to be a couple of unresolvable references in the Xmu
  120. ! sharable library. 
  121.   
  122. + The more interesting behaviour depends on the MIT Shape extension, so
  123. + if you haven't got that you will be stuck with a boring clock. It is a
  124. + good idea to make sure your window manager doesn't decorate the clock
  125. + as this (a) spoils the effect and (b) causes the WM (well, tvtwm at
  126. + least) to get very frustrated redecorating when the clock reshapes
  127. + itself.
  128.   Start it as
  129.       wclock -debug 60 -update 5
  130.   
  131. ***************
  132. *** 31,36 ****
  133. --- 38,46 ----
  134.   
  135.   to see what else is possible.
  136.   
  137. + Credits
  138. + =======
  139.   Having read and taken to heart Henry Spencer's advice on not reinventing
  140.   wheels, I produced wclock by cannibalising bits of xclock, xcal and
  141.   xbiff. Kudos to those who did the hard bits (see manual page).
  142. ***************
  143. *** 39,45 ****
  144.   have had them for a while and don't know who originally did them.  The
  145.   eye belongs to Kate Bush, in case you're interested. 
  146.   
  147. !     - Richard Caley
  148.   
  149.   --
  150.   R.Caley@ed.ac.uk            _O_
  151. --- 49,83 ----
  152.   have had them for a while and don't know who originally did them.  The
  153.   eye belongs to Kate Bush, in case you're interested. 
  154.   
  155. ! The following people told me how to fix problems.
  156. !     Simon Leinen
  157. !     paolo petta
  158. !     Peter Miller
  159. !     
  160. ! Changes
  161. ! =======
  162. ! Simon Leinen, paolo petta, RJC:
  163. !     Put back some missing initialisations in WClock.c
  164. ! Simon Leinen:
  165. !     Added bitmap install rules to Imakefile (Simon Leinen)
  166. !     Extra checks in WClock before freeing things.
  167. !     Added cast to Ansify it a little.
  168. ! RJC:
  169. !     Check for shape extension at run time.
  170. !     Sorted out some confusions between NULL,NULLQUARK and None.
  171. !     Checked if XtNbitmap was already defined.
  172. !     Put in some basic support for servers without the shape extension.
  173. ! Patchlevel1
  174. ! -----------
  175. ! RJC:
  176. !     Fixed colour behaviour and corrected some spelling errors in the
  177. !     documentation. 
  178.   
  179.   --
  180.   R.Caley@ed.ac.uk            _O_
  181. ===================================================================
  182. RCS file: RCS/Wclock.c,v
  183. retrieving revision 1.2
  184. diff -c -r1.2 Wclock.c
  185. *** /tmp/RCSAa26520    Fri Jul 31 16:01:00 1992
  186. --- Wclock.c    Fri Jul 31 16:05:57 1992
  187. ***************
  188. *** 46,52 ****
  189.   
  190.   extern long time();
  191.   static void Wclock_tic(), draw_segment();
  192. !     
  193.   /* Private Definitions */
  194.   
  195.   #define PI            3.14159265358979
  196. --- 46,52 ----
  197.   
  198.   extern long time();
  199.   static void Wclock_tic(), draw_segment();
  200.   /* Private Definitions */
  201.   
  202.   #define PI            3.14159265358979
  203. ***************
  204. *** 60,65 ****
  205. --- 60,67 ----
  206.   #define min(a, b) ((a) < (b) ? (a) : (b))
  207.   #define abs(a) ((a) < 0 ? -(a) : (a))
  208.   
  209. + static int haveShape=False;
  210. + static int ShapeEventBase, ShapeErrorBase;
  211.   
  212.   /* Initialization of defaults */
  213.   
  214. ***************
  215. *** 133,139 ****
  216.       /* num_actions        */    0,
  217.       /* resources        */    resources,
  218.       /* resource_count        */    XtNumber(resources),
  219. !     /* xrm_class        */    NULL,
  220.       /* compress_motion        */    TRUE,
  221.       /* compress_exposure    */    TRUE,
  222.       /* compress_enterleave    */    TRUE,
  223. --- 135,141 ----
  224.       /* num_actions        */    0,
  225.       /* resources        */    resources,
  226.       /* resource_count        */    XtNumber(resources),
  227. !     /* xrm_class        */    NULLQUARK,
  228.       /* compress_motion        */    TRUE,
  229.       /* compress_exposure    */    TRUE,
  230.       /* compress_enterleave    */    TRUE,
  231. ***************
  232. *** 170,175 ****
  233. --- 172,178 ----
  234.               NULL, 0 );
  235.       XtAddConverter( XtRString, XtROutline, OutlineConverter,
  236.               NULL, 0 );
  237.   }
  238.   
  239.   /* ARGSUSED */
  240. ***************
  241. *** 184,189 ****
  242. --- 187,196 ----
  243.   
  244.       valuemask = GCForeground | GCBackground | GCLineWidth |GCFunction;
  245.   
  246. + #ifdef SHAPE
  247. +     if (!haveShape)
  248. +     haveShape=XShapeQueryExtension (dpy, &ShapeEventBase, &ShapeErrorBase);
  249. + #endif
  250.   
  251.       if ( w->Wclock.backgroundBitmap != None )
  252.           {
  253. ***************
  254. *** 223,228 ****
  255. --- 230,239 ----
  256.   
  257.       w->Wclock.invertGC = NULL;
  258.   
  259. +     w->Wclock.outlinePM = None;
  260. +     w->Wclock.segmentPM = None;
  261.       if (w->Wclock.update <= 0)
  262.       w->Wclock.update = 60;    /* make invalid update's use a default */
  263.       w->Wclock.interval_id = 0;
  264. ***************
  265. *** 268,275 ****
  266.        XtDestroyGC (w->Wclock.unsetGC);
  267.        if (w->Wclock.invertGC != NULL)
  268.        XtDestroyGC (w->Wclock.invertGC);
  269. !      XFreePixmap (dpy, w->Wclock.segmentPM);
  270. !      XFreePixmap (dpy, w->Wclock.outlinePM);
  271.   }
  272.   
  273.   
  274. --- 279,288 ----
  275.        XtDestroyGC (w->Wclock.unsetGC);
  276.        if (w->Wclock.invertGC != NULL)
  277.        XtDestroyGC (w->Wclock.invertGC);
  278. !      if (w->Wclock.segmentPM != None)
  279. !      XFreePixmap (dpy, w->Wclock.segmentPM);
  280. !      if (w->Wclock.outlinePM != None)
  281. !      XFreePixmap (dpy, w->Wclock.outlinePM);
  282.   }
  283.   
  284.   
  285. ***************
  286. *** 451,456 ****
  287. --- 464,471 ----
  288.   Window win=XtWindow(w);
  289.   int x=0, y=0;
  290.   
  291. + if (haveShape)
  292. +     {
  293.   #ifdef SHAPE
  294.       XShapeCombineMask (XtDisplay(w), win,
  295.                  ShapeBounding, x, y, 
  296. ***************
  297. *** 457,463 ****
  298.                  outline,
  299.                  ShapeSet);
  300.   
  301. !     if (additional != NULL)
  302.       XShapeCombineMask (XtDisplay(w), win,
  303.                  ShapeBounding, x, y, 
  304.                  additional,
  305. --- 472,478 ----
  306.                  outline,
  307.                  ShapeSet);
  308.   
  309. !     if (additional != None)
  310.       XShapeCombineMask (XtDisplay(w), win,
  311.                  ShapeBounding, x, y, 
  312.                  additional,
  313. ***************
  314. *** 477,483 ****
  315.                  outline,
  316.                  ShapeSet);
  317.   
  318. !     if (additional != NULL)
  319.           XShapeCombineMask (XtDisplay(parent), XtWindow(parent),
  320.                      ShapeBounding, x, y, 
  321.                      additional,
  322. --- 492,498 ----
  323.                  outline,
  324.                  ShapeSet);
  325.   
  326. !     if (additional != None)
  327.           XShapeCombineMask (XtDisplay(parent), XtWindow(parent),
  328.                      ShapeBounding, x, y, 
  329.                      additional,
  330. ***************
  331. *** 484,489 ****
  332. --- 499,536 ----
  333.                      ShapeIntersect);
  334.       }
  335.   #endif
  336. +     }
  337. + else
  338. +     {
  339. +     Pixmap bg;
  340. +     if ((bg=XCreatePixmap(XtDisplay(w), win,
  341. +              w->core.width,
  342. +              w->core.height,
  343. +              1))==None)
  344. +     return;
  345. +     XFillRectangle(XtDisplay(w), bg, w->Wclock.setGC,
  346. +            0, 0, w->core.width, w->core.height);
  347. +     if (additional)
  348. +     XSetClipMask(XtDisplay(w), w->Wclock.unsetGC, additional);
  349. +     
  350. +     XCopyPlane(XtDisplay(w), outline, bg, w->Wclock.unsetGC,
  351. +            0, 0, w->core.width, w->core.height,0,0,1);
  352. +     if (additional)
  353. +     XSetClipMask(XtDisplay(w), w->Wclock.unsetGC, None);
  354. +     XSetClipMask(XtDisplay(w), w->Wclock.EraseGC, bg);
  355. +     XFillRectangle(XtDisplay(w), win, w->Wclock.EraseGC,
  356. +            0, 0, w->core.width, w->core.height);
  357. +     
  358. +     XSetClipMask(XtDisplay(w), w->Wclock.EraseGC, None);
  359. +     XFreePixmap(XtDisplay(w),bg);
  360. +     }
  361.   }
  362.   
  363.   static void Resize (gw) 
  364. ***************
  365. *** 500,509 ****
  366.           w->Wclock.centerX = w->core.width / 2;
  367.           w->Wclock.centerY = w->core.height / 2;
  368.   
  369. !     if (w->Wclock.segmentPM != NULL)
  370.           XFreePixmap (dpy, w->Wclock.segmentPM);
  371.   
  372. !     if (w->Wclock.outlinePM != NULL )
  373.           XFreePixmap (dpy, w->Wclock.outlinePM);
  374.   
  375.       w->Wclock.segmentPM = XCreatePixmap(dpy, win,
  376. --- 547,556 ----
  377.           w->Wclock.centerX = w->core.width / 2;
  378.           w->Wclock.centerY = w->core.height / 2;
  379.   
  380. !     if (w->Wclock.segmentPM != None)
  381.           XFreePixmap (dpy, w->Wclock.segmentPM);
  382.   
  383. !     if (w->Wclock.outlinePM != None )
  384.           XFreePixmap (dpy, w->Wclock.outlinePM);
  385.   
  386.       w->Wclock.segmentPM = XCreatePixmap(dpy, win,
  387. ***************
  388. *** 589,595 ****
  389.           tm.tm_hour -= 12;
  390.   
  391.       
  392. !     if (tm.tm_min != w->Wclock.otm.tm_min ||
  393.           tm.tm_hour != w->Wclock.otm.tm_hour) 
  394.           {
  395.           int twelvemins = tm.tm_min / 12; /* how many fifths of an hour */
  396. --- 636,642 ----
  397.           tm.tm_hour -= 12;
  398.   
  399.       
  400. !     if (!id|| tm.tm_min != w->Wclock.otm.tm_min ||
  401.           tm.tm_hour != w->Wclock.otm.tm_hour) 
  402.           {
  403.           int twelvemins = tm.tm_min / 12; /* how many fifths of an hour */
  404. ***************
  405. *** 613,619 ****
  406.           if ( w->Wclock.plotSegment )
  407.           {
  408.           XClearWindow(dpy, win);
  409. !         draw_segment(dpy, win, w->Wclock.setGC,
  410.                    w->Wclock.centerX,
  411.                    w->Wclock.centerY,
  412.                    CONVERT_A(tm.tm_hour * TWOPI/12 + twelvemins * TWOPI/60),
  413. --- 660,666 ----
  414.           if ( w->Wclock.plotSegment )
  415.           {
  416.           XClearWindow(dpy, win);
  417. !         draw_segment(dpy, win, w->Wclock.EraseGC,
  418.                    w->Wclock.centerX,
  419.                    w->Wclock.centerY,
  420.                    CONVERT_A(tm.tm_hour * TWOPI/12 + twelvemins * TWOPI/60),
  421. ***************
  422. *** 777,783 ****
  423.         if (new->Wclock.update != current->Wclock.update) {
  424.         if (current->Wclock.interval_id)
  425.             XtRemoveTimeOut (current->Wclock.interval_id);
  426. !       if (XtIsRealized(new))
  427.             new->Wclock.interval_id = XtAppAddTimeOut( 
  428.                                            XtWidgetToApplicationContext(gnew),
  429.                        new->Wclock.update*1000,
  430. --- 824,830 ----
  431.         if (new->Wclock.update != current->Wclock.update) {
  432.         if (current->Wclock.interval_id)
  433.             XtRemoveTimeOut (current->Wclock.interval_id);
  434. !       if (XtIsRealized((Widget)new))
  435.             new->Wclock.interval_id = XtAppAddTimeOut( 
  436.                                            XtWidgetToApplicationContext(gnew),
  437.                        new->Wclock.update*1000,
  438. ===================================================================
  439. RCS file: RCS/patchlevel.h,v
  440. retrieving revision 1.2
  441. diff -c -r1.2 patchlevel.h
  442. *** /tmp/RCSAa26520    Fri Jul 31 16:01:02 1992
  443. --- patchlevel.h    Fri Jul 31 16:06:00 1992
  444. ***************
  445. *** 3,6 ****
  446.    * version tracking.
  447.    */
  448.   
  449. ! #define PATCHLEVEL 1
  450. --- 3,6 ----
  451.    * version tracking.
  452.    */
  453.   
  454. ! #define PATCHLEVEL 2
  455. ===================================================================
  456. RCS file: RCS/wclock.c,v
  457. retrieving revision 1.2
  458. diff -c -r1.2 wclock.c
  459. *** /tmp/RCSAa26520    Fri Jul 31 16:01:04 1992
  460. --- wclock.c    Fri Jul 31 16:06:01 1992
  461. ***************
  462. *** 139,144 ****
  463. --- 139,145 ----
  464.       (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
  465.                   &wm_delete_window, 1);
  466.       XtAppMainLoop (app_con);
  467. +     exit(0);
  468.   }
  469.   
  470.   
  471. ===================================================================
  472. RCS file: RCS/wclock.man,v
  473. retrieving revision 1.2
  474. diff -c -r1.2 wclock.man
  475. *** /tmp/RCSAa26520    Fri Jul 31 16:01:04 1992
  476. --- wclock.man    Fri Jul 31 16:06:02 1992
  477. ***************
  478. *** 9,15 ****
  479.          [-extoutline \fIoutline\fR] [-intoutline \fIoutline\fR]
  480.          [-extbitmap \fIbitmap\fR] [-intbitmap \fIbitmap\fR]
  481.          [-extpercent \fIint\fR] [-intpercent \fIint\fR]
  482. !        [-slicewidth \fIsec\fR] [-slicespace \fIsec\fR] [-sliceofset \fIsec\fR]
  483.          [-update \fIseconds\fR] [-bitmap \fIbitmap\fR]
  484.   
  485.   .SH DESCRIPTION
  486. --- 9,15 ----
  487.          [-extoutline \fIoutline\fR] [-intoutline \fIoutline\fR]
  488.          [-extbitmap \fIbitmap\fR] [-intbitmap \fIbitmap\fR]
  489.          [-extpercent \fIint\fR] [-intpercent \fIint\fR]
  490. !        [-slicewidth \fIsec\fR] [-slicespace \fIsec\fR] [-sliceoffset \fIsec\fR]
  491.          [-update \fIseconds\fR] [-bitmap \fIbitmap\fR]
  492.   
  493.   .SH DESCRIPTION
  494. ===================================================================
  495.  
  496.  
  497.  --- 8< --- 8< --- 8< --- CUT HERE  --- 8< --- 8< --- 8< --- 
  498.  
  499. exit 0 # Just in case...
  500. -- 
  501.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  502. \X/  Amiga - The only way to fly!      |
  503.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  504.   casual observer..."                  |
  505.