/[dtapublic]/projs/ets/trunk/src/c_tk_base_7_5_w_mods/xutil.c
ViewVC logotype

Diff of /projs/ets/trunk/src/c_tk_base_7_5_w_mods/xutil.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 70 by dashley, Sat Nov 5 10:54:17 2016 UTC revision 71 by dashley, Sat Nov 5 11:07:06 2016 UTC
# Line 1  Line 1 
1  /* $Header$ */  /* $Header$ */
2    
3  /*  /*
4   * xutil.c --   * xutil.c --
5   *   *
6   *      This function contains generic X emulation routines.   *      This function contains generic X emulation routines.
7   *   *
8   * Copyright (c) 1995-1996 Sun Microsystems, Inc.   * Copyright (c) 1995-1996 Sun Microsystems, Inc.
9   *   *
10   * See the file "license.terms" for information on usage and redistribution   * See the file "license.terms" for information on usage and redistribution
11   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12   *   *
13   * RCS: @(#) $Id: xutil.c,v 1.1.1.1 2001/06/13 05:16:00 dtashley Exp $   * RCS: @(#) $Id: xutil.c,v 1.1.1.1 2001/06/13 05:16:00 dtashley Exp $
14   */   */
15    
16  #include <stdlib.h>  #include <stdlib.h>
17  #include "tk.h"  #include "tk.h"
18    
19  #ifdef MAC_TCL  #ifdef MAC_TCL
20  #       include <Xutil.h>  #       include <Xutil.h>
21  #       include <Xatom.h>  #       include <Xatom.h>
22  #else  #else
23  #       include "Xutil.h"  #       include "Xutil.h"
24  #       include "Xatom.h"  #       include "Xatom.h"
25  #endif  #endif
26    
27  /*  /*
28   *----------------------------------------------------------------------   *----------------------------------------------------------------------
29   *   *
30   * XInternAtom --   * XInternAtom --
31   *   *
32   *      This procedure simulates the XInternAtom function by calling   *      This procedure simulates the XInternAtom function by calling
33   *      Tk_Uid to get a unique id for every atom.  This is only a   *      Tk_Uid to get a unique id for every atom.  This is only a
34   *      partial implementation, since it doesn't work across   *      partial implementation, since it doesn't work across
35   *      applications.   *      applications.
36   *   *
37   * Results:   * Results:
38   *      A new Atom.   *      A new Atom.
39   *   *
40   * Side effects:   * Side effects:
41   *      None.   *      None.
42   *   *
43   *----------------------------------------------------------------------   *----------------------------------------------------------------------
44   */   */
45    
46  Atom  Atom
47  XInternAtom(display, atom_name, only_if_exists)  XInternAtom(display, atom_name, only_if_exists)
48      Display* display;      Display* display;
49      _Xconst char* atom_name;      _Xconst char* atom_name;
50      Bool only_if_exists;      Bool only_if_exists;
51  {  {
52      static Atom atom = XA_LAST_PREDEFINED;      static Atom atom = XA_LAST_PREDEFINED;
53            
54      display->request++;      display->request++;
55      return ++atom;      return ++atom;
56  }  }
57    
58  /*  /*
59   *----------------------------------------------------------------------   *----------------------------------------------------------------------
60   *   *
61   * XGetVisualInfo --   * XGetVisualInfo --
62   *   *
63   *      Returns information about the specified visual.   *      Returns information about the specified visual.
64   *   *
65   * Results:   * Results:
66   *      Returns a newly allocated XVisualInfo structure.   *      Returns a newly allocated XVisualInfo structure.
67   *   *
68   * Side effects:   * Side effects:
69   *      Allocates storage.   *      Allocates storage.
70   *   *
71   *----------------------------------------------------------------------   *----------------------------------------------------------------------
72   */   */
73    
74  XVisualInfo *  XVisualInfo *
75  XGetVisualInfo(display, vinfo_mask, vinfo_template, nitems_return)  XGetVisualInfo(display, vinfo_mask, vinfo_template, nitems_return)
76      Display* display;      Display* display;
77      long vinfo_mask;      long vinfo_mask;
78      XVisualInfo* vinfo_template;      XVisualInfo* vinfo_template;
79      int* nitems_return;      int* nitems_return;
80  {  {
81      XVisualInfo *info = (XVisualInfo *)ckalloc(sizeof(XVisualInfo));      XVisualInfo *info = (XVisualInfo *)ckalloc(sizeof(XVisualInfo));
82      info->visual = DefaultVisual(display, 0);      info->visual = DefaultVisual(display, 0);
83      info->visualid = info->visual->visualid;      info->visualid = info->visual->visualid;
84      info->screen = 0;      info->screen = 0;
85      info->depth = info->visual->bits_per_rgb;      info->depth = info->visual->bits_per_rgb;
86      info->class = info->visual->class;      info->class = info->visual->class;
87      info->colormap_size = info->visual->map_entries;      info->colormap_size = info->visual->map_entries;
88      info->bits_per_rgb = info->visual->bits_per_rgb;      info->bits_per_rgb = info->visual->bits_per_rgb;
89      info->red_mask = info->visual->red_mask;      info->red_mask = info->visual->red_mask;
90      info->green_mask = info->visual->green_mask;      info->green_mask = info->visual->green_mask;
91      info->blue_mask = info->visual->blue_mask;      info->blue_mask = info->visual->blue_mask;
92            
93      if (((vinfo_mask & VisualIDMask)      if (((vinfo_mask & VisualIDMask)
94              && (vinfo_template->visualid != info->visualid))              && (vinfo_template->visualid != info->visualid))
95              || ((vinfo_mask & VisualScreenMask)              || ((vinfo_mask & VisualScreenMask)
96                      && (vinfo_template->screen != info->screen))                      && (vinfo_template->screen != info->screen))
97              || ((vinfo_mask & VisualDepthMask)              || ((vinfo_mask & VisualDepthMask)
98                      && (vinfo_template->depth != info->depth))                      && (vinfo_template->depth != info->depth))
99              || ((vinfo_mask & VisualClassMask)              || ((vinfo_mask & VisualClassMask)
100                      && (vinfo_template->class != info->class))                      && (vinfo_template->class != info->class))
101              || ((vinfo_mask & VisualColormapSizeMask)              || ((vinfo_mask & VisualColormapSizeMask)
102                      && (vinfo_template->colormap_size != info->colormap_size))                      && (vinfo_template->colormap_size != info->colormap_size))
103              || ((vinfo_mask & VisualBitsPerRGBMask)              || ((vinfo_mask & VisualBitsPerRGBMask)
104                      && (vinfo_template->bits_per_rgb != info->bits_per_rgb))                      && (vinfo_template->bits_per_rgb != info->bits_per_rgb))
105              || ((vinfo_mask & VisualRedMaskMask)              || ((vinfo_mask & VisualRedMaskMask)
106                      && (vinfo_template->red_mask != info->red_mask))                      && (vinfo_template->red_mask != info->red_mask))
107              || ((vinfo_mask & VisualGreenMaskMask)              || ((vinfo_mask & VisualGreenMaskMask)
108                      && (vinfo_template->green_mask != info->green_mask))                      && (vinfo_template->green_mask != info->green_mask))
109              || ((vinfo_mask & VisualBlueMaskMask)              || ((vinfo_mask & VisualBlueMaskMask)
110                      && (vinfo_template->blue_mask != info->blue_mask))                      && (vinfo_template->blue_mask != info->blue_mask))
111          ) {          ) {
112          ckfree((char *) info);          ckfree((char *) info);
113          return NULL;          return NULL;
114      }      }
115    
116      *nitems_return = 1;      *nitems_return = 1;
117      return info;      return info;
118  }  }
119    
120  /* End of xutil.c */  /* End of xutil.c */

Legend:
Removed from v.70  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25