WinWorkstation.st
branchjv
changeset 7743 fa3c8eb0bc1d
parent 7716 3dba89415c91
child 7994 42a7e4c6503d
equal deleted inserted replaced
7742:b5a20c01d46f 7743:fa3c8eb0bc1d
  6672 %}
  6672 %}
  6673 !
  6673 !
  6674 
  6674 
  6675 displayName
  6675 displayName
  6676     "return the display-connections display name.
  6676     "return the display-connections display name.
  6677      For Windows, a dummy name is returned"
  6677      For Windows, a name of window station is returned"
  6678 
  6678     | err |
  6679     ^ 'local'
  6679 
       
  6680 %{
       
  6681     if (__isExternalAddress(__INST(displayId))) {
       
  6682         HANDLE station = (HANDLE)__externalAddressVal(__INST(displayId));
       
  6683         char   stationName[256];
       
  6684         DWORD  stationNameLen = 0;        
       
  6685 
       
  6686         stationName[255] = '\0';
       
  6687         if ( GetUserObjectInformation ( station, UOI_NAME, stationName, 255, &stationNameLen)) {
       
  6688             RETURN( __MKSTRING(stationName));
       
  6689         }
       
  6690     }
       
  6691 %}.
       
  6692     self primitiveFailed: err
  6680 !
  6693 !
  6681 
  6694 
  6682 focusFollowsMouse:aBoolean
  6695 focusFollowsMouse:aBoolean
  6683     "set/clear the focusFollowsMouse behavior.
  6696     "set/clear the focusFollowsMouse behavior.
  6684      If on, the view under the mouse gets the keyboard input
  6697      If on, the view under the mouse gets the keyboard input
 15312     DPRINTF(("multiClickTime = %d\n", multiClickTime));
 15325     DPRINTF(("multiClickTime = %d\n", multiClickTime));
 15313     __INST(multiClickTimeDelta) = __MKSMALLINT(multiClickTime);
 15326     __INST(multiClickTimeDelta) = __MKSMALLINT(multiClickTime);
 15314 %}
 15327 %}
 15315 !
 15328 !
 15316 
 15329 
 15317 primInitializeFor:aDisplayName
 15330 primInitializeFor:stationNameOrNil
 15318     "initialize the receiver for a connection to a display;
 15331     "Initialize the receiver for a connection to given window station. 
 15319      the argument, aDisplayName may be nil (for the default display)
 15332      It the argument `stationNameOrNil` is nil, then it connects
 15320      or the name of the display server as hostname:number
 15333      to process default window station. 
 15321      (not yet under WIN32)"
 15334 
 15322 
 15335      Return an external address for window station handle or nil if
 15323 %{  /* NOCONTEXT */
 15336      requested window station is not an interactive one (i.e, one
 15324 
 15337      cannot initialize Win32Workstation on non-interactive window 
 15325     RETURN ( __MKSMALLINT(1) );
 15338      station).
       
 15339 
       
 15340      See https://msdn.microsoft.com/en-us/library/windows/desktop/ms687096(v=vs.85).aspx
       
 15341      "
       
 15342 
       
 15343      | errcode |
       
 15344 
       
 15345 %{
       
 15346     HWINSTA station;
       
 15347     if (stationNameOrNil == nil) {
       
 15348         station = GetProcessWindowStation();
       
 15349         if (station == NULL) {
       
 15350             errcode = __MKINT( GetLastError() );
       
 15351             goto err;
       
 15352         }
       
 15353         /*
       
 15354          * Check we're connected to "WinSta0" station, only this
       
 15355          * one is interactive one.
       
 15356          */
       
 15357         char stationName[8];
       
 15358         int  stationNameLen;
       
 15359         if ( GetUserObjectInformation ( station, UOI_NAME, stationName, 9, &stationNameLen) ) {
       
 15360             if (strncmp(stationName, "WinSta0", 8) == 0) {
       
 15361                 RETURN ( __MKEXTERNALADDRESS ( station ) );        
       
 15362             }         
       
 15363         }    
       
 15364         RETURN ( nil );
       
 15365 
       
 15366     } else if (__isStringLike( stationNameOrNil)) {
       
 15367         if (strncmp(__stringVal(stationNameOrNil), "WinSta0", 8) == 0) {
       
 15368             /* 
       
 15369              * We're explicitly asked to connect to "WinSta0" station. 
       
 15370              * This could be hand for example when Smalltalk is running as
       
 15371              * a service on non-interactive session and want to open 
       
 15372              * a window to inform user. Maybe, maybe not. Anyway, do our best
       
 15373              * here.
       
 15374              */
       
 15375             station = OpenWindowStation("WinSta0", TRUE, NULL);
       
 15376             if (station == NULL) {
       
 15377                 errcode = __MKINT( GetLastError() );
       
 15378                 goto err;
       
 15379             }
       
 15380             if ( ! SetProcessWindowStation(station) ) {
       
 15381                 errcode = __MKINT( GetLastError() );
       
 15382                 goto err;            
       
 15383             }
       
 15384             RETURN ( __MKEXTERNALADDRESS ( station ) );        
       
 15385         }
       
 15386         RETURN ( nil );
       
 15387     }
       
 15388     err:;
 15326 %}.
 15389 %}.
       
 15390     self primitiveFailed: errcode
       
 15391 
 15327 !
 15392 !
 15328 
 15393 
 15329 reinitialize
 15394 reinitialize
 15330     rootWin := rootDC := nil.
 15395     rootWin := rootDC := nil.
 15331     super reinitialize.
 15396     super reinitialize.