1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/*
* tkUnixXId.c --
*
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkUnixInt.h"
/*
*----------------------------------------------------------------------
*
* Tk_FreeXId --
*
* This function is called to indicate that an X resource identifier is
* now free.
*
* Results:
* None.
*
* Side effects:
* The identifier is added to the stack of free identifiers for its
* display, so that it can be re-used.
*
*----------------------------------------------------------------------
*/
void
Tk_FreeXId(
Display *display, /* Display for which xid was allocated. */
XID xid) /* Identifier that is no longer in use. */
{
/*
* This does nothing, because the XC-MISC extension takes care of
* freeing XIDs for us. It has been a standard X11 extension for
* about 15 years as of 2008. Keith Packard and another X.org
* developer suggested that we remove the previous code that used:
* #define XLIB_ILLEGAL_ACCESS.
*/
}
/*
*----------------------------------------------------------------------
*
* Tk_GetPixmap --
*
* Same as the XCreatePixmap function except that it manages resource
* identifiers better.
*
* Results:
* Returns a new pixmap.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
Pixmap
Tk_GetPixmap(
Display *display, /* Display for new pixmap. */
Drawable d, /* Drawable where pixmap will be used. */
int width, int height, /* Dimensions of pixmap. */
int depth) /* Bits per pixel for pixmap. */
{
return XCreatePixmap(display, d, (unsigned) width, (unsigned) height,
(unsigned) depth);
}
/*
*----------------------------------------------------------------------
*
* Tk_FreePixmap --
*
* Same as the XFreePixmap function except that it also marks the
* resource identifier as free.
*
* Results:
* None.
*
* Side effects:
* The pixmap is freed in the X server and its resource identifier is
* saved for re-use.
*
*----------------------------------------------------------------------
*/
void
Tk_FreePixmap(
Display *display, /* Display for which pixmap was allocated. */
Pixmap pixmap) /* Identifier for pixmap. */
{
XFreePixmap(display, pixmap);
}
/*
*----------------------------------------------------------------------
*
* TkpScanWindowId --
*
* Given a string, produce the corresponding Window Id.
*
* Results:
* The return value is normally TCL_OK; in this case *idPtr will be set
* to the Window value equivalent to string. If string is improperly
* formed then TCL_ERROR is returned and an error message will be left in
* the interp's result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
TkpScanWindowId(
Tcl_Interp *interp,
const char *string,
Window *idPtr)
{
int code;
Tcl_Obj obj;
obj.refCount = 1;
obj.bytes = (char *) string; /* DANGER?! */
obj.length = strlen(string);
obj.typePtr = NULL;
code = Tcl_GetLongFromObj(interp, &obj, (long *)idPtr);
if (obj.refCount > 1) {
Tcl_Panic("invalid sharing of Tcl_Obj on C stack");
}
if (obj.typePtr && obj.typePtr->freeIntRepProc) {
obj.typePtr->freeIntRepProc(&obj);
}
return code;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
|