diff -r 667adc797288 -r 111e4f4993be XWorkstation.st --- a/XWorkstation.st Thu Aug 27 13:08:05 1998 +0200 +++ b/XWorkstation.st Thu Aug 27 13:56:09 1998 +0200 @@ -7329,6 +7329,11 @@ |dpyName index arguments| + displayId notNil ifTrue:[ + "/ already connected - you bad guy try to trick me manually ? + ^ self + ]. + dpyName := aDisplayName. dpyName isNil ifTrue:[ "look for a '-display xxx' argument" @@ -7339,58 +7344,18 @@ ] ] ]. -%{ - int scr; - Display *dpy; - Visual *visual; - XVisualInfo viproto; - XVisualInfo *vip; /* retured info */ - int maxRGBDepth; - int rgbRedMask, rgbGreenMask, rgbBlueMask; - int rgbVisualID; - int nvi, i; - char *type, *nm; - int dummy; - OBJ dpyID; - - if (__INST(displayId) != nil) { - /* - * already connected - you bad guy try to - * trick me manually ? - */ - RETURN ( self ); - } - - BEGIN_INTERRUPTSBLOCKED - - if (__isString(dpyName)) - nm = (char *) __stringVal(dpyName); - else { - dpyName = __MKSTRING((char *)getenv("DISPLAY")); - nm = NULL; - } - dpy = XOpenDisplay(nm); - - if (dpy) { - static int firstCall = 1; - - __INST(displayId) = dpyID = __MKEXTERNALADDRESS(dpy); __STORE(self, dpyID); - -#ifdef SUPERDEBUG - XSynchronize(dpy, 1); -#endif - - if (firstCall) { - firstCall = 0; - XSetErrorHandler(__XErrorHandler__); - XSetIOErrorHandler(__XIOErrorHandler__); - } - } - - END_INTERRUPTSBLOCKED -%}. + + self openConnectionTo:dpyName. + displayId isNil ifTrue:[ - 'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. + "/ could not connect. + + ((OperatingSystem platformName == #win32) + and:[WinWorkstation notNil]) ifTrue:[ + 'XWorkstation [info]: using local windows display.' infoPrintCR. + ] ifFalse:[ + 'XWorkstation [warning]: cannot connect to Display.' errorPrintCR. + ]. ^ nil ]. @@ -7740,6 +7705,50 @@ ]. ! +openConnectionTo:dpyName + "open a connection to some display; + set my displayId if ok; leaves it as nil of not ok" + +%{ + Display *dpy; + int i; + char *nm; + + if (__INST(displayId) != nil) { + /* + * already connected - you bad guy try to + * trick me manually ? + */ + RETURN ( self ); + } + + BEGIN_INTERRUPTSBLOCKED + + if (__isString(dpyName)) + nm = (char *) __stringVal(dpyName); + else { + dpyName = __MKSTRING((char *)getenv("DISPLAY")); + nm = NULL; + } + dpy = XOpenDisplay(nm); + + if (dpy) { + static int firstCall = 1; + OBJ dpyID; + + __INST(displayId) = dpyID = __MKEXTERNALADDRESS(dpy); __STORE(self, dpyID); + + if (firstCall) { + firstCall = 0; + XSetErrorHandler(__XErrorHandler__); + XSetIOErrorHandler(__XIOErrorHandler__); + } + } + + END_INTERRUPTSBLOCKED +%} +! + reinitialize virtualRootId := rootId := nil. super reinitialize. @@ -9956,6 +9965,6 @@ !XWorkstation class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.289 1998-08-24 13:23:11 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.290 1998-08-27 11:56:09 cg Exp $' ! ! XWorkstation initialize!