Official patch #11 for calctol v2.4; please apply it.

Rich Burridge richb at sunaus.oz
Wed Aug 8 17:20:07 AEST 1990


This is official patch #11 for calctool v2.4; please apply it.

It make the following change:

    *  From Steve Nahm <sxn at Eng.Sun.COM>
       The XView version didn't correctly run under Open Windows v2.0(FCS).

Use Larry Walls patch program to apply this patch then recompile.

If you are missing any patches for calctool v2.4, then you can send a message
to rb-archive-server at Aus.Sun.COM containing the line:

send calctool patchn

where n is the number of the patch you are missing. Note that you might
need to add a path line to this message, in order for the archive server
to find the correct return path to you. For example:

path uunet.uu.net!hostname!username

------CUT HERE------patch.11------CUT HERE------

------- patchlevel.h -------
*** /tmp/da01556	Wed Aug  8 17:03:54 1990
--- patchlevel.h	Wed Aug  8 14:38:47 1990
***************
*** 14,17 ****
   *  reported to me then an attempt will be made to fix them.
   */
  
! #define  PATCHLEVEL  10
--- 14,17 ----
   *  reported to me then an attempt will be made to fix them.
   */
  
! #define  PATCHLEVEL  11

------- xview.c -------
*** /tmp/da01559	Wed Aug  8 17:03:55 1990
--- xview.c	Wed Aug  8 16:49:29 1990
***************
*** 25,63 ****
  #include <xview/cursor.h>
  #include <xview/sel_svc.h>
  #include <xview/sel_attrs.h>
  
  #define  MENU_SET                       (void) menu_set
  #define  NOTIFY_DO_DISPATCH             (void) notify_do_dispatch
  #define  NOTIFY_INTERPOSE_DESTROY_FUNC  (void) notify_interpose_destroy_func
- #define  PW_SETCMSNAME                  (void) pw_setcmsname
- #define  PW_PUTCOLORMAP                 (void) pw_putcolormap
- #define  PW_TTEXT                       (void) pw_ttext
- #define  PW_WRITEBACKGROUND             (void) pw_writebackground
  #define  SELN_QUERY                     (void) seln_query
  #define  XV_SET                         (void) xv_set
  #define  WINDOW_DONE                    (void) window_done
  
  void func_key_proc() ;
  int menu_proc() ;
  
  Canvas kcanvas, rcanvas ;
  Event *cur_event ;
  Frame frame, rframe ;
  Icon calctool_icon ;
  Menu menus[MAXMENUS] ;
  Notify_value destroy_proc() ;
- Canvas_paint_window pw, cpw, rcpw ;
  Seln_client sel_client ;
  Seln_holder holder ;
  Seln_rank rank = SELN_PRIMARY ;
  Seln_result get_proc(), reply_proc() ;
- Xv_cmsdata cms_data ;
  Xv_Cursor help_cursor, main_cursor ;
- Xv_font bfont, font, nfont, sfont ;
  
! char colorname[CMS_NAMESIZE] ;
! u_char red[CALC_COLORSIZE], green[CALC_COLORSIZE], blue[CALC_COLORSIZE] ;
  
  enum menu_type curmenu ;   /* Current menu (if any) being processed. */
  int started ;              /* Set just before window is displayed. */
  
--- 25,73 ----
  #include <xview/cursor.h>
  #include <xview/sel_svc.h>
  #include <xview/sel_attrs.h>
+ #include <X11/Xlib.h>
  
  #define  MENU_SET                       (void) menu_set
  #define  NOTIFY_DO_DISPATCH             (void) notify_do_dispatch
  #define  NOTIFY_INTERPOSE_DESTROY_FUNC  (void) notify_interpose_destroy_func
  #define  SELN_QUERY                     (void) seln_query
  #define  XV_SET                         (void) xv_set
  #define  WINDOW_DONE                    (void) window_done
  
+ #define  BIGFONT               "lucidasanstypewriter-18"
+ #define  DEFFONT               "fixed"
+ #define  NORMALFONT            "lucidasanstypewriter-12"
+ #define  SMALLFONT             "lucidasanstypewriter-10"
+ 
  void func_key_proc() ;
  int menu_proc() ;
  
  Canvas kcanvas, rcanvas ;
+ Canvas_paint_window cpw, rcpw ;
  Event *cur_event ;
  Frame frame, rframe ;
  Icon calctool_icon ;
  Menu menus[MAXMENUS] ;
  Notify_value destroy_proc() ;
  Seln_client sel_client ;
  Seln_holder holder ;
  Seln_rank rank = SELN_PRIMARY ;
  Seln_result get_proc(), reply_proc() ;
  Xv_Cursor help_cursor, main_cursor ;
  
! Display *dpy ;
! Drawable xid_cpw, xid_rcpw ;
! GC gc ;
! Window root ;
! XColor current_col ;
! XFontStruct *bfont, *font, *nfont, *sfont ;
! XGCValues gc_val ;
  
+ unsigned long gc_mask ;
+ int screen ;
+ unsigned long backgnd, foregnd ;
+ unsigned long palette[CALC_COLORSIZE] ;
+ 
  enum menu_type curmenu ;   /* Current menu (if any) being processed. */
  int started ;              /* Set just before window is displayed. */
  
***************
*** 64,75 ****
  short help_cursor_array[16] = {
  #include "help.cursor"
  } ;
- mpr_static(help_cursor_pr, 16, 16, 1, help_cursor_array) ;
  
  unsigned short icon_image[] = {
  #include "calctool.icon"
  } ;
- mpr_static(icon_pr, 64, 64, 1, icon_image) ;
  
  short cicon_image[] = {
  #include "calctool.color.icon"
--- 74,83 ----
***************
*** 90,115 ****
  }
  
  
! clear_canvas(window, color)
! enum can_type window ;
  int color ;
  {
!   int height,width ;
!   Canvas ctype ;
  
!   if (window == KEYCANVAS)
!     {
!       pw = cpw ;
!       ctype = kcanvas ;
!     } 
!   else if (window == REGCANVAS)
!     {
!       pw = rcpw ;
!       ctype = rcanvas ;
      }
!   height = (int) xv_get(ctype, XV_HEIGHT) ;
!   width = (int) xv_get(ctype, XV_WIDTH) ;
!   PW_WRITEBACKGROUND(pw, 0, 0, width, height, PIX_SRC | PIX_COLOR(color)) ;
  }
  
  
--- 98,123 ----
  }
  
  
! clear_canvas(ctype, color)
! enum can_type ctype ;
  int color ;
  {
!   int x, y ;
!   unsigned int width, height, bwidth, depth ;
!   Window root, window ;
  
!        if (ctype == KEYCANVAS) window = xid_cpw ;
!   else if (ctype == REGCANVAS) window = xid_rcpw ;
!   XGetGeometry(dpy, window, &root, &x, &y, &width, &height, &bwidth, &depth) ;
!   if (iscolor) gc_val.foreground = palette[color] ;
!   else
!     { 
!       if (color == WHITE) gc_val.foreground = backgnd ;
!       else gc_val.foreground = foregnd ;
      }
!   gc_val.function = GXcopy ;
!   XChangeGC(dpy, gc, GCForeground | GCFunction, &gc_val) ;
!   XFillRectangle(dpy, window, gc, x, y, width, height) ;
  }
  
  
***************
*** 125,131 ****
  color_area(x, y, width, height, color)
  int x, y, width, height, color ;
  {
!   PW_WRITEBACKGROUND(cpw, x, y, width, height, PIX_SRC | PIX_COLOR(color)) ;
  }
  
  
--- 133,148 ----
  color_area(x, y, width, height, color)
  int x, y, width, height, color ;
  {
!   if (iscolor) gc_val.foreground = palette[color] ;
!   else
!     { 
!       if (color == WHITE) gc_val.foreground = backgnd ;
!       else gc_val.foreground = foregnd ;
!     }
!   gc_val.function = GXcopy ;
!   XChangeGC(dpy, gc, GCForeground | GCFunction, &gc_val) ;
!   XFillRectangle(dpy, xid_cpw, gc, x, y,
!                  (unsigned int) width, (unsigned int) height) ;
  }
  
  
***************
*** 208,214 ****
  drawline(x1, y1, x2, y2)
  int x1, y1, x2, y2 ;
  {
!   (void) pw_vector(cpw, x1, y1, x2, y2, PIX_SET, 0) ;
  }
  
  
--- 225,235 ----
  drawline(x1, y1, x2, y2)
  int x1, y1, x2, y2 ;
  {
!   if (iscolor) gc_val.foreground = palette[BLACK] ;
!   else gc_val.foreground = foregnd ;
!   gc_val.function = GXcopy ;
!   XChangeGC(dpy, gc, GCForeground | GCFunction, &gc_val) ;
!   XDrawLine(dpy, xid_cpw, gc, x1, y1, x2, y2) ;
  }
  
  
***************
*** 219,240 ****
  }
  
  
! drawtext(x, y, window, fontno, color, str)
  enum font_type fontno ;
! enum can_type window ;
  int x, y, color ;
  char *str ;
  {
         if (fontno == SFONT) font = sfont ;
    else if (fontno == NFONT) font = nfont ;
    else if (fontno == BFONT) font = bfont ;
!        if (window == KEYCANVAS) pw = cpw ;
!   else if (window == REGCANVAS) pw = rcpw ;
! 
!   if (color == BLACK)
!     (void) pw_text(pw, x, y, PIX_SRC | PIX_DST, font, str) ;
!   else if (color == WHITE)
!     PW_TTEXT(pw, x, y, PIX_SRC | PIX_COLOR(color), font, str) ;
  }
  
  
--- 240,270 ----
  }
  
  
! drawtext(x, y, ctype, fontno, color, str)
  enum font_type fontno ;
! enum can_type ctype ;
  int x, y, color ;
  char *str ;
  {
+   Drawable window ;
+ 
         if (fontno == SFONT) font = sfont ;
    else if (fontno == NFONT) font = nfont ;
    else if (fontno == BFONT) font = bfont ;
!        if (ctype == KEYCANVAS) window = xid_cpw ;
!   else if (ctype == REGCANVAS) window = xid_rcpw ;
!  
!   if (ctype == KEYCANVAS && y == items[(int) DISPLAYITEM].y) x += 100 ;
!   if (iscolor) gc_val.foreground = palette[color] ;
!   else
!     {
!       if (color == WHITE) gc_val.foreground = backgnd ;
!       else gc_val.foreground = foregnd ;
!     }
!   gc_val.font = font->fid ;
!   gc_val.function = GXcopy ;
!   XChangeGC(dpy, gc, GCFont | GCForeground | GCFunction, &gc_val) ;
!   XDrawString(dpy, window, gc, x, y, str, strlen(str)) ;
  }
  
  
***************
*** 259,264 ****
--- 289,310 ----
  }
  
  
+ XFontStruct *
+ get_font(name)
+ char *name ;
+ {
+   XFontStruct *font ;
+ 
+   if (!(font = XLoadQueryFont(dpy, name)))
+     if (!(font = XLoadQueryFont(dpy, DEFFONT)))
+       {
+         perror("couldn't get the default font.") ;
+         exit(1) ;
+       }
+   return(font) ;
+ }
+ 
+ 
  get_next_event(event)
  Event *event ;
  {
***************
*** 358,380 ****
  }
  
  
! init_fonts()
  {
-   sfont = (Xv_font) xv_find(0,          FONT,
-                             FONT_STYLE, FONT_STYLE_NORMAL,
-                             FONT_SIZE,  10,
-                             0) ;
- 
-   nfont = (Xv_font) xv_find(0,          FONT,
-                             FONT_STYLE, FONT_STYLE_NORMAL,
-                             FONT_SIZE,  12,
-                             0) ;
-   nfont_width = 9 ;
- 
-   bfont = (Xv_font) xv_find(0,          FONT,
-                             FONT_STYLE, FONT_STYLE_NORMAL,
-                             FONT_SIZE,  18,
-                             0) ;
  }
  
  
--- 404,411 ----
  }
  
  
! init_fonts()      /* Null routine; fonts loaded in make_subframes. */
  {
  }
  
  
***************
*** 386,393 ****
  }
  
  
! load_colors()      /* Create and load color map - done in make_subframes. */
  {
  }
  
  
--- 417,448 ----
  }
  
  
! load_colors()      /* Create and load calctool color map. */
  {
+   u_char red[CALC_COLORSIZE], green[CALC_COLORSIZE], blue[CALC_COLORSIZE] ;
+   int i, numcolors ;
+ 
+   iscolor = 0 ;
+   if (DisplayCells(dpy, screen) > 2)
+     {
+       calc_colorsetup(red, green, blue) ;
+       iscolor = 1 ;
+       numcolors = 0 ;
+       for (i = 0; i < CALC_COLORSIZE; i++)
+         {
+           current_col.flags = DoRed | DoGreen | DoBlue ;
+           current_col.red   = (unsigned short) (red[i]   << 8) ;
+           current_col.green = (unsigned short) (green[i] << 8) ;
+           current_col.blue  = (unsigned short) (blue[i]  << 8) ;
+           if (XAllocColor(dpy, DefaultColormap(dpy, screen), &current_col) == True)
+             palette[numcolors++] = current_col.pixel ;
+         }
+       if (numcolors < 2)
+         {
+           FPRINTF(stderr, "%s: cannot allocate colors.\n", progname) ;
+           exit(1) ;
+         }
+     }
  }
  
  
***************
*** 395,402 ****
  int argc ;
  char *argv[] ;
  {
-   int x, y ;
- 
    xv_init(XV_INIT_ARGS, argc, argv, 0) ;
    frame = xv_create(0, FRAME,
                      FRAME_ICON,        calctool_icon,
--- 450,455 ----
***************
*** 425,433 ****
  
  make_icon()
  {
!   calctool_icon = xv_create(0, ICON,
                              XV_WIDTH,   ICONWIDTH,
!                             ICON_IMAGE, &icon_pr,
                              0) ;
  }
  
--- 478,494 ----
  
  make_icon()
  {
!   Server_image sv_image ;
! 
!   sv_image = xv_create(XV_NULL,            SERVER_IMAGE,
!                        SERVER_IMAGE_BITS,  icon_image,
!                        SERVER_IMAGE_DEPTH, 1,
!                        XV_WIDTH,           64,
!                        XV_HEIGHT,          64,
!                        0) ;
!   calctool_icon = xv_create(XV_NULL,    ICON,
                              XV_WIDTH,   ICONWIDTH,
!                             ICON_IMAGE, sv_image,
                              0) ;
  }
  
***************
*** 434,439 ****
--- 495,502 ----
  
  make_items()
  {
+   Server_image help_pr ;
+ 
    main_cursor = xv_get(kcanvas, WIN_CURSOR) ;
  
    if (iscolor)
***************
*** 441,456 ****
        calctool_icon = (Icon) xv_get(frame, FRAME_ICON) ;
        XV_SET(calctool_icon,
               ICON_IMAGE, &cicon_pr,
-              WIN_CMS_NAME, colorname,
               0) ;
        XV_SET(frame, FRAME_ICON, calctool_icon, 0) ;
      }
  
    help_cursor = xv_create(NULL, CURSOR,
                            CURSOR_XHOT,  0,
                            CURSOR_YHOT,  0,
                            CURSOR_OP,    PIX_SRC | PIX_DST,
!                           CURSOR_IMAGE, &help_cursor_pr,
                            0) ;
  }
  
--- 504,523 ----
        calctool_icon = (Icon) xv_get(frame, FRAME_ICON) ;
        XV_SET(calctool_icon,
               ICON_IMAGE, &cicon_pr,
               0) ;
        XV_SET(frame, FRAME_ICON, calctool_icon, 0) ;
      }
  
+   help_pr = xv_create(XV_NULL,           SERVER_IMAGE,
+                       XV_WIDTH,          16,
+                       XV_HEIGHT,         16,
+                       SERVER_IMAGE_BITS, help_cursor_array,
+                       0) ;
    help_cursor = xv_create(NULL, CURSOR,
                            CURSOR_XHOT,  0,
                            CURSOR_YHOT,  0,
                            CURSOR_OP,    PIX_SRC | PIX_DST,
!                           CURSOR_IMAGE, help_pr,
                            0) ;
  }
  
***************
*** 458,475 ****
  make_subframes()
  {
    rcanvas = xv_create(rframe, CANVAS, 0) ;
- 
-   SPRINTF(colorname, "%s%D", CALC_COLOR, getpid()) ;
-   calc_colorsetup(red, green, blue) ;
- 
-   cms_data.type = XV_STATIC_CMS ;
-   cms_data.size = CALC_COLORSIZE ;
-   cms_data.rgb_count = CALC_COLORSIZE ;
-   cms_data.index = 0 ;
-   cms_data.red = red ;
-   cms_data.green = green ;
-   cms_data.blue = blue ;
- 
    kcanvas = xv_create(frame, CANVAS,
                        CANVAS_RETAINED,     FALSE,
                        OPENWIN_AUTO_CLEAR,  FALSE,
--- 525,530 ----
***************
*** 477,484 ****
                        XV_HEIGHT,           THEIGHT + DISPLAY,
                        XV_FONT,             nfont,
                        CANVAS_PAINTWINDOW_ATTRS,
-                           WIN_CMS_NAME, colorname,
-                           WIN_CMS_DATA, &cms_data,
                            WIN_CONSUME_EVENTS,
                              MS_LEFT, MS_MIDDLE, MS_RIGHT,
                              WIN_ASCII_EVENTS, KBD_USE, KBD_DONE,
--- 532,537 ----
***************
*** 494,502 ****
--- 547,578 ----
  
    rcpw = canvas_paint_window(rcanvas) ;
    cpw = canvas_paint_window(kcanvas) ;
+   dpy = (Display *) xv_get(frame, XV_DISPLAY) ;
+   xid_cpw  = (Drawable) xv_get(cpw, XV_XID) ;
+   xid_rcpw = (Drawable) xv_get(rcpw, XV_XID) ;
+ 
+   screen = DefaultScreen(dpy) ;
+   root = RootWindow(dpy, screen) ;
+   foregnd = BlackPixel(dpy, screen) ;
+   backgnd = WhitePixel(dpy, screen) ;
+ 
+   gc_mask = GCForeground | GCBackground | GCGraphicsExposures ;
+   gc_val.foreground = foregnd ;
+   gc_val.background = backgnd ;
+   gc_val.graphics_exposures = False ;
+   gc = XCreateGC(dpy, root, gc_mask, &gc_val) ;
+   XSynchronize(dpy, 1) ;
+ 
+   load_colors() ;                 /* Load the calctool colormap. */
+ 
+   bfont = get_font(BIGFONT) ;
+   nfont = get_font(NORMALFONT) ;
+   nfont_width = 6 ;
+   sfont = get_font(SMALLFONT) ;
  }
  
  
+ /*ARGSUSED*/
  menu_proc(menu, menu_item)
  Menu menu ;
  Menu_item menu_item ;
***************
*** 559,567 ****
  {
    switch (type)
      {
!       case HELPCURSOR : XV_SET(kcanvas, WIN_CURSOR, help_cursor, 0) ;
                          break ;
!       case MAINCURSOR : XV_SET(kcanvas, WIN_CURSOR, main_cursor, 0) ;
      }
  }
  
--- 635,643 ----
  {
    switch (type)
      {
!       case HELPCURSOR : XV_SET(cpw, WIN_CURSOR, help_cursor, 0) ;
                          break ;
!       case MAINCURSOR : XV_SET(cpw, WIN_CURSOR, main_cursor, 0) ;
      }
  }
  

------- CHANGES -------
*** /tmp/da01562	Wed Aug  8 17:03:56 1990
--- CHANGES	Wed Aug  8 14:45:20 1990
***************
*** 226,228 ****
--- 226,233 ----
         With the X11 version, pressing the SHIFT key to access some of the
         keyboard equivalents repeated the last command. It didn't wait for
         the key you're shifting to be pressed.
+ 
+ v2.4 - patchlevel 11. - Posted to comp.sources.bugs (August 1990).
+ 
+     *  From Steve Nahm <sxn at Eng.Sun.COM>
+        The XView version didn't correctly run under Open Windows v2.0(FCS).



More information about the Comp.sources.bugs mailing list