home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume7 / xcmap / patch1 next >
Encoding:
Internet Message Format  |  1990-06-12  |  6.8 KB

  1. Path: uunet!nems!ark1!uakari.primate.wisc.edu!samsung!cs.utexas.edu!sun-barr!newstop!sun!icky.Sony.COM
  2. From: dce@icky.Sony.COM (David Elliott)
  3. Newsgroups: comp.sources.x
  4. Subject: v07i091: xcmap, Patch1, Part01/01
  5. Message-ID: <137108@sun.Eng.Sun.COM>
  6. Date: 12 Jun 90 06:34:32 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 245
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: David Elliott <dce@icky.Sony.COM>
  12. Posting-number: Volume 7, Issue 91
  13. Archive-name: xcmap/patch1
  14. Patch-To: xcmap: Volume XXX, Issue XXX
  15.  
  16.  
  17. I have tried to contact the author of xcmap with no success.  I would
  18. like to see these patches go out, and I would even gladly take over
  19. maintenance of the program if the author doesn't want to continue.
  20.  
  21. This is a set of patches to cause the icon for xcmap to be a 48x48
  22. view-only copy of the colormap window.  I find this to be particularly
  23. useful since I just need to see the colormap more often than I need to
  24. query the color cells.
  25.  
  26. This also adds a -iconic flag, but no icon geometry checking (hmm,
  27. maybe it should be rewritten as an Xt program...)
  28.  
  29. *** xcmap.c.orig    Tue Nov  7 10:08:18 1989
  30. --- xcmap.c    Mon May 21 11:09:19 1990
  31. ***************
  32. *** 29,35 ****
  33.   Display       *theDisp;
  34.   int           theScreen, dispcells;
  35.   Colormap      theCmap;
  36. ! Window        rootW, mainW;
  37.   GC            theGC;
  38.   unsigned long fcol,bcol;
  39.   Font          mfont;
  40. --- 29,35 ----
  41.   Display       *theDisp;
  42.   int           theScreen, dispcells;
  43.   Colormap      theCmap;
  44. ! Window        rootW, mainW, iconW;
  45.   GC            theGC;
  46.   unsigned long fcol,bcol;
  47.   Font          mfont;
  48. ***************
  49. *** 41,46 ****
  50. --- 41,47 ----
  51.   int            WIDE,HIGH,cWIDE,cHIGH,nxcells,nycells, pvalup;
  52.   XColor         defs[256];
  53.   char          *cmd, tmpstr[128];
  54. + int            initState = NormalState;
  55.   
  56.   
  57.   
  58. ***************
  59. *** 86,91 ****
  60. --- 87,98 ----
  61.               continue;
  62.               }
  63.   
  64. +         if (!strncmp(argv[i],"-i",2)) {        /* iconic */
  65. +             i++;
  66. +             initState = IconicState;
  67. +             continue;
  68. +             }
  69.           Syntax(cmd);
  70.       }
  71.   
  72. ***************
  73. *** 132,141 ****
  74. --- 139,150 ----
  75.       XSetBackground(theDisp,theGC,bcol);
  76.   
  77.       CreateMainWindow(cmd,geom,argc,argv);
  78. +     CreateIconWindow();
  79.       Resize(WIDE,HIGH);
  80.   
  81.       XSelectInput(theDisp, mainW, ExposureMask | KeyPressMask 
  82.                                  | StructureNotifyMask | ButtonPressMask);
  83. +     XSelectInput(theDisp, iconW, ExposureMask);
  84.       XMapWindow(theDisp,mainW);
  85.   
  86.       /**************** Main loop *****************/
  87. ***************
  88. *** 159,165 ****
  89. --- 168,177 ----
  90.               if (exp_event->window==mainW) 
  91.                   DrawWindow(exp_event->x,exp_event->y,
  92.                              exp_event->width, exp_event->height);
  93. +         if (exp_event->window==iconW)
  94. +                 DrawIcon();
  95.               }
  96. +         
  97.               break;
  98.   
  99.           case ButtonPress: {
  100. ***************
  101. *** 186,201 ****
  102.               if (conf_event->window == mainW && 
  103.                    (conf_event->width != WIDE || conf_event->height != HIGH))
  104.                   Resize(conf_event->width, conf_event->height);
  105. !             }
  106.               break;
  107.           case CirculateNotify:
  108.           case MapNotify:
  109.           case DestroyNotify:
  110.           case GravityNotify:
  111.           case ReparentNotify:
  112. !         case UnmapNotify:       break;
  113.   
  114.           default:
  115.               printf("event type=%ld\n",event->type); 
  116. --- 198,212 ----
  117.               if (conf_event->window == mainW && 
  118.                    (conf_event->width != WIDE || conf_event->height != HIGH))
  119.                   Resize(conf_event->width, conf_event->height);
  120. !         }
  121.               break;
  122.           case CirculateNotify:
  123.           case MapNotify:
  124.           case DestroyNotify:
  125.           case GravityNotify:
  126.           case ReparentNotify:
  127. !         case UnmapNotify:
  128. !         break;
  129.   
  130.           default:
  131.               printf("event type=%ld\n",event->type); 
  132. ***************
  133. *** 208,214 ****
  134.   /***********************************/
  135.   Syntax()
  136.   {
  137. !     printf("Usage: %s filename [=geometry | -geometry geom] [ [-display] display]\n",cmd);
  138.       exit(1);
  139.   }
  140.   
  141. --- 219,225 ----
  142.   /***********************************/
  143.   Syntax()
  144.   {
  145. !     printf("Usage: %s filename [-iconic] [=geometry | -geometry geom] [ [-display] display]\n",cmd);
  146.       exit(1);
  147.   }
  148.   
  149. ***************
  150. *** 237,242 ****
  151. --- 248,254 ----
  152.       XSetWindowAttributes xswa;
  153.       unsigned int xswamask;
  154.       XSizeHints hints;
  155. +     XClassHint classHints;
  156.       int i,x,y,w,h;
  157.   
  158.       WIDE = HIGH = 256;            /* default window size */
  159. ***************
  160. *** 247,253 ****
  161. --- 259,267 ----
  162.       if (i&HeightValue) HIGH = h;
  163.   
  164.       if (i&XValue || i&YValue) hints.flags = USPosition;  
  165. + #ifdef notdef
  166.                            else hints.flags = PPosition;
  167. + #endif
  168.   
  169.       hints.flags |= USSize;
  170.   
  171. ***************
  172. *** 273,283 ****
  173.       mainW = XCreateWindow(theDisp,rootW,x,y,WIDE,HIGH,2,0,CopyFromParent,
  174.                             CopyFromParent, xswamask, &xswa);
  175.   
  176.       XSetStandardProperties(theDisp,mainW,"xcmap","xcmap",None,
  177.                               argv,argc,&hints);
  178.   
  179. !     if (!mainW) FatalError("Can't open main window");
  180.   
  181.   }
  182.   
  183.   
  184. --- 287,302 ----
  185.       mainW = XCreateWindow(theDisp,rootW,x,y,WIDE,HIGH,2,0,CopyFromParent,
  186.                             CopyFromParent, xswamask, &xswa);
  187.   
  188. +     if (!mainW) FatalError("Can't open main window");
  189.       XSetStandardProperties(theDisp,mainW,"xcmap","xcmap",None,
  190.                               argv,argc,&hints);
  191.   
  192. !     classHints.res_name = "xcmap";
  193. !     classHints.res_class = "XCmap";
  194.   
  195. +     XSetClassHint(theDisp, mainW, &classHints);
  196.   }
  197.   
  198.   
  199. ***************
  200. *** 378,380 ****
  201. --- 397,435 ----
  202.           }
  203.   }
  204.   
  205. + /***********************************/
  206. + #define IWIDTH    48
  207. + #define    IHEIGHT    48
  208. + CreateIconWindow()
  209. + {
  210. +     XWMHints xwmh;
  211. +     iconW = XCreateSimpleWindow(theDisp, rootW, 0, 0, IWIDTH, IHEIGHT, 1,
  212. +         fcol, bcol);
  213. +     xwmh.flags = IconWindowHint | StateHint;
  214. +     xwmh.icon_window = iconW;
  215. +     xwmh.initial_state = initState;
  216. +     XSetWMHints(theDisp, mainW, &xwmh);
  217. + }
  218. + /***********************************/
  219. + DrawIcon()
  220. + {
  221. +     int i,j,x1,y1,x2,y2;
  222. +     int cwide, chigh;
  223. +     cwide = (IWIDTH + nxcells - 1) / nxcells;
  224. +     chigh = (IHEIGHT + nycells - 1) / nycells;
  225. +     x2 = ((IWIDTH) + cwide - 1) / cwide;
  226. +     y2 = ((IHEIGHT) + chigh - 1) / chigh;
  227. +     for (i=0; i<y2; i++) {
  228. +         for (j=0; j<x2; j++) {
  229. +             XSetForeground(theDisp,theGC,(unsigned long) (i*nycells+j) );
  230. +             XFillRectangle(theDisp,iconW,theGC,j*cwide,i*chigh,cwide,chigh);
  231. +             }
  232. +         }
  233. + }
  234.  
  235. ...David Elliott
  236. ...dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
  237. ...(408)944-4073
  238.  
  239.  
  240. dan
  241. ----------------------------------------------------
  242. O'Reilly && Associates   argv@sun.com / argv@ora.com
  243. Opinions expressed reflect those of the author only.
  244.