--- a/XWorkstation.st Fri Jun 14 13:14:41 1996 +0200
+++ b/XWorkstation.st Fri Jun 14 13:19:42 1996 +0200
@@ -61,6 +61,13 @@
#define TWOBYTESTRINGS
/*
+ * this define suppresses XAllocColor/XFreeColor on
+ * TrueColor systems - I am not certain, if this is
+ * always legal to do (it works with XFree servers).
+ */
+#define QUICK_TRUE_COLORS
+
+/*
* shape support works; enabled by -DSHAPE in makefile
* see RoundClock and RoundGlobe examples
*/
@@ -163,21 +170,21 @@
extern int __interruptsBlocked;
# define BEGIN_INTERRUPTSBLOCKED \
{ \
- int needUnblock = 0; \
- extern OBJ __thisContext__; \
- \
- __thisContext__ = __thisContext;\
- if (!__interruptsBlocked) { \
- __BLOCKINTERRUPTS(); \
- needUnblock = 1; \
- }
+ int needUnblock = 0; \
+ extern OBJ __thisContext__; \
+ \
+ __thisContext__ = __thisContext;\
+ if (!__interruptsBlocked) { \
+ __BLOCKINTERRUPTS(); \
+ needUnblock = 1; \
+ }
# define END_INTERRUPTSBLOCKED \
- __thisContext = __thisContext; \
- __thisContext__ = 0; \
- if (needUnblock) { \
- __UNBLOCKINTERRUPTS(); \
- } \
+ __thisContext = __thisContext; \
+ __thisContext__ = 0; \
+ if (needUnblock) { \
+ __UNBLOCKINTERRUPTS(); \
+ } \
}
#endif
@@ -1809,20 +1816,28 @@
Status ok;
if (ISCONNECTED) {
- if (__isString(aString) || __isSymbol(aString)) {
- colorname = (char *)_stringVal(aString);
-
- BEGIN_INTERRUPTSBLOCKED
- ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
- if (ok) {
- ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
- }
- END_INTERRUPTSBLOCKED
- if (! ok) {
- RETURN ( nil );
- }
- RETURN ( __MKSMALLINT(ecolor.pixel) );
- }
+ if (__isString(aString) || __isSymbol(aString)) {
+ colorname = (char *)_stringVal(aString);
+
+ BEGIN_INTERRUPTSBLOCKED
+ ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
+ if (ok) {
+#ifdef QUICK_TRUE_COLORS
+ if (__INST(visualType) == @symbol(TrueColor)) {
+ id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask));
+ id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask));
+ id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask));
+ RETURN ( __MKSMALLINT(id) );
+ }
+#endif
+ ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
+ }
+ END_INTERRUPTSBLOCKED
+ if (! ok) {
+ RETURN ( nil );
+ }
+ RETURN ( __MKSMALLINT(ecolor.pixel) );
+ }
}
%}.
self primitiveFailed.
@@ -1856,7 +1871,6 @@
ecolor.red = __intVal(r);
ecolor.green= __intVal(g);
ecolor.blue = __intVal(b);
-#define QUICK_TRUE_COLORS
#ifdef QUICK_TRUE_COLORS
if (__INST(visualType) == @symbol(TrueColor)) {
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask));
@@ -1887,7 +1901,6 @@
unsigned long color;
int screen = __intVal(__INST(screen));
-#define QUICK_TRUE_COLORS
#ifdef QUICK_TRUE_COLORS
if (__INST(visualType) == @symbol(TrueColor)) {
/* no need to do anything on TrueColor displays ... */
@@ -8040,6 +8053,6 @@
!XWorkstation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.143 1996-06-14 11:14:41 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.144 1996-06-14 11:19:42 cg Exp $'
! !
XWorkstation initialize!