home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ImageMagick / magick / PreRvIcccm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  5.7 KB  |  367 lines

  1. #include "magick.h"
  2. #include "image.h"
  3. #include "X.h"
  4.  
  5. #ifdef PRE_R5_ICCCM
  6. /*
  7.   Compatibility routines for pre X11R5 ICCCM.
  8. */
  9. XrmDatabase XrmGetDatabase(display)
  10. Display
  11.   *display;
  12. {
  13.   return(display->db);
  14. }
  15. #endif
  16.  
  17. #ifdef PRE_R4_ICCCM
  18. /*
  19.   Compatibility routines for pre X11R4 ICCCM.
  20. */
  21. XClassHint *XAllocClassHint()
  22. {
  23.   return((XClassHint *) malloc(sizeof(XClassHint)));
  24. }
  25.  
  26. XIconSize *XAllocIconSize()
  27. {
  28.   return((XIconSize *) malloc(sizeof(XIconSize)));
  29. }
  30.  
  31. XSizeHints *XAllocSizeHints()
  32. {
  33.   return((XSizeHints *) malloc(sizeof(XSizeHints)));
  34. }
  35.  
  36. Status XReconfigureWMWindow(display,window,screen_number,value_mask,values)
  37. Display
  38.   *display;
  39.  
  40. Window
  41.   window;
  42.  
  43. int
  44.   screen_number;
  45.  
  46. unsigned int
  47.   value_mask;
  48.  
  49. XWindowChanges
  50.   *values;
  51. {
  52.   return(XConfigureWindow(display,window,value_mask,values));
  53. }
  54.  
  55. XStandardColormap *XAllocStandardColormap()
  56. {
  57.   return((XStandardColormap *) malloc(sizeof(XStandardColormap)));
  58. }
  59.  
  60. XWMHints *XAllocWMHints()
  61. {
  62.   return((XWMHints *) malloc(sizeof(XWMHints)));
  63. }
  64.  
  65. Status XGetGCValues(display,gc,mask,values)
  66. Display
  67.   *display;
  68.  
  69. GC
  70.   gc;
  71.  
  72. unsigned long
  73.   mask;
  74.  
  75. XGCValues
  76.   *values;
  77. {
  78.   return(True);
  79. }
  80.  
  81. Status XGetRGBColormaps(display,window,colormap,count,property)
  82. Display
  83.   *display;
  84.  
  85. Window
  86.   window;
  87.  
  88. XStandardColormap
  89.   **colormap;
  90.  
  91. int
  92.   *count;
  93.  
  94. Atom
  95.   property;
  96. {
  97.   *count=1;
  98.   return(XGetStandardColormap(display,window,colormap,property));
  99. }
  100.  
  101. Status XGetWMColormapWindows(display,window,colormap_windows,number_windows)
  102. Display
  103.   *display;
  104.  
  105. Window
  106.   window,
  107.   **colormap_windows;
  108.  
  109. int
  110.   *number_windows;
  111. {
  112.   Atom
  113.     actual_type,
  114.     *data,
  115.     property;
  116.  
  117.   int
  118.     actual_format,
  119.     status;
  120.  
  121.   unsigned long
  122.     leftover,
  123.     number_items;
  124.  
  125.   property=XInternAtom(display,"WM_COLORMAP_WINDOWS",False);
  126.   if (property == None)
  127.     return(False);
  128.   /*
  129.     Get the window property.
  130.   */
  131.   *data=(Atom) NULL;
  132.   status=XGetWindowProperty(display,window,property,0L,1000000L,False,
  133.     XA_WINDOW,&actual_type,&actual_format,&number_items,&leftover,
  134.     (unsigned char **) &data);
  135.   if (status != Success)
  136.     return(False);
  137.   if ((actual_type != XA_WINDOW) || (actual_format != 32))
  138.     {
  139.       if (data != (Atom *) NULL)
  140.         XFree((char *) data);
  141.       return(False);
  142.     }
  143.   *colormap_windows=(Window *) data;
  144.   *number_windows=(int) number_items;
  145.   return(True);
  146. }
  147.  
  148. Status XGetWMName(display,window,text_property)
  149. Display
  150.   *display;
  151.  
  152. Window
  153.   window;
  154.  
  155. XTextProperty
  156.   *text_property;
  157. {
  158.   char
  159.     *window_name;
  160.  
  161.   if (XFetchName(display,window,&window_name) == 0)
  162.     return(False);
  163.   text_property->value=(unsigned char *) window_name;
  164.   text_property->encoding=XA_STRING;
  165.   text_property->format=8;
  166.   text_property->nitems=strlen(window_name);
  167.   return(True);
  168. }
  169.  
  170. char *XResourceManagerString(display)
  171. Display
  172.   *display;
  173. {
  174.   return display->xdefaults;
  175. }
  176.  
  177. void XrmDestroyDatabase(database)
  178. XrmDatabase
  179.   database;
  180. {
  181. }
  182.  
  183. void XSetWMName(display,window,property)
  184. Display
  185.   *display;
  186.  
  187. Window
  188.   window;
  189.  
  190. XTextProperty
  191.   *property;
  192. {
  193.   XStoreName(display,window,property->value);
  194. }
  195.  
  196. int XStringListToTextProperty(argv,argc,property)
  197. char
  198.   **argv;
  199.  
  200. int
  201.   argc;
  202.  
  203. XTextProperty
  204.   *property;
  205. {
  206.   register int
  207.     i;
  208.  
  209.   register unsigned int
  210.     number_bytes;
  211.  
  212.   XTextProperty
  213.      protocol;
  214.  
  215.   number_bytes=0;
  216.   for (i=0; i < argc; i++)
  217.     number_bytes+=(unsigned int) ((argv[i] ? strlen(argv[i]) : 0)+1);
  218.   protocol.encoding=XA_STRING;
  219.   protocol.format=8;
  220.   protocol.nitems=0;
  221.   if (number_bytes)
  222.     protocol.nitems=number_bytes-1;
  223.   protocol.value=NULL;
  224.   if (number_bytes <= 0)
  225.     {
  226.       protocol.value=(unsigned char *) malloc(sizeof(char));
  227.       if (!protocol.value)
  228.         return(False);
  229.       *protocol.value='\0';
  230.     }
  231.   else
  232.     {
  233.       register char
  234.         *buffer;
  235.  
  236.       buffer=(char *) malloc(number_bytes*sizeof(char));
  237.       if (buffer == (char *) NULL)
  238.         return(False);
  239.       protocol.value=(unsigned char *) buffer;
  240.       for (i=0; i < argc; i++)
  241.       {
  242.         char
  243.           *argument;
  244.  
  245.         argument=argv[i];
  246.         if (!argument)
  247.           *buffer++='\0';
  248.         else
  249.           {
  250.             (void) strcpy(buffer,argument);
  251.             buffer+=(strlen(argument)+1);
  252.           }
  253.       }
  254.     }
  255.   *property=protocol;
  256.   return(True);
  257. }
  258.  
  259. void XSetWMProperties(display,window,window_name,icon_name,argv,argc,
  260.   size_hints,manager_hints,class_hint)
  261. Display
  262.   *display;
  263.  
  264. Window
  265.   window;
  266.  
  267. XTextProperty
  268.   *window_name,
  269.   *icon_name;
  270.  
  271. char
  272.   **argv;
  273.  
  274. int
  275.   argc;
  276.  
  277. XSizeHints
  278.   *size_hints;
  279.  
  280. XWMHints *manager_hints;
  281.  
  282. XClassHint
  283.   *class_hint;
  284. {
  285.   XSetStandardProperties(display,window,window_name->value,icon_name,None,
  286.     argv,argc,size_hints);
  287.   XSetWMHints(display,window,manager_hints);
  288.   XSetClassHint(display,window,class_hint);
  289. }
  290.  
  291. Status XSetWMProtocols(display,window,protocols,count)
  292. Display
  293.   *display;
  294.  
  295. Window
  296.   window;
  297.  
  298. Atom
  299.   *protocols;
  300.  
  301. int
  302.   count;
  303. {
  304.   Atom
  305.     protocols_property;
  306.  
  307.   protocols_property=XInternAtom(display,"WM_PROTOCOLS",False);
  308.   XChangeProperty(display,window,protocols_property,XA_ATOM,32,PropModeReplace,
  309.     (unsigned char *) protocols, count);
  310.   return(True);
  311. }
  312.  
  313. VisualID XVisualIDFromVisual(visual)
  314. Visual
  315.   *visual;
  316. {
  317.   return(visual->visualid);
  318. }
  319.  
  320. Status XWithdrawWindow(display,window,screen)
  321. Display
  322.   *display;
  323.  
  324. Window
  325.   window;
  326.  
  327. int
  328.   screen;
  329. {
  330.   return(XUnmapWindow(display,window));
  331. }
  332.  
  333. int XWMGeometry(display,screen,user_geometry,default_geometry,border_width,
  334.   size_hints,x,y,width,height,gravity)
  335. Display
  336.   *display;
  337.  
  338. int
  339.   screen;
  340.  
  341. char
  342.   *user_geometry,
  343.   *default_geometry;
  344.  
  345. unsigned int
  346.   border_width;
  347.  
  348. XSizeHints
  349.   *size_hints;
  350.  
  351. int
  352.   *x,
  353.   *y,
  354.   *width,
  355.   *height,
  356.   *gravity;
  357. {
  358.   int
  359.     status;
  360.  
  361.   status=XGeometry(display,screen,user_geometry,default_geometry,border_width,
  362.     0,0,0,0,x,y,width,height);
  363.   *gravity=NorthWestGravity;
  364.   return(status);
  365. }
  366. #endif
  367.