XWorkstation.st
changeset 3412 91fe6c42822d
parent 3333 b886c19185da
child 3414 6c69b65a867b
equal deleted inserted replaced
3411:143ba0c7d373 3412:91fe6c42822d
   853     Window child_ret;
   853     Window child_ret;
   854 
   854 
   855     if (ISCONNECTED
   855     if (ISCONNECTED
   856      && __isExternalAddress(windowId)
   856      && __isExternalAddress(windowId)
   857      && __isPoint(aPoint)) {
   857      && __isPoint(aPoint)) {
   858 	Display *dpy = myDpy;
   858         Display *dpy = myDpy;
   859 
   859 
   860 	xp = _point_X(aPoint);
   860         xp = _point_X(aPoint);
   861 	yp = _point_Y(aPoint);
   861         yp = _point_Y(aPoint);
   862 	if (__bothSmallInteger(xp, yp)) {
   862         if (__bothSmallInteger(xp, yp)) {
   863 
   863 
   864 	    ENTER_XLIB();
   864             ENTER_XLIB();
   865 	    XTranslateCoordinates(dpy,
   865             XTranslateCoordinates(dpy,
   866 				  RootWindow(dpy, screen),
   866                                   RootWindow(dpy, screen),
   867 				  __WindowVal(windowId),
   867                                   __WindowVal(windowId),
   868 				  __intVal(xp), __intVal(yp), 
   868                                   __intVal(xp), __intVal(yp), 
   869 				  &xpos, &ypos, &child_ret);
   869                                   &xpos, &ypos, &child_ret);
   870 	    LEAVE_XLIB();
   870             LEAVE_XLIB();
   871 
   871 
   872 	    if (child_ret) {
   872             if (child_ret) {
   873 		RETURN ( __MKEXTERNALADDRESS(child_ret) );
   873                 RETURN ( __MKEXTERNALADDRESS(child_ret) );
   874 	    }
   874             }
   875 	    RETURN ( nil );
   875             RETURN ( nil );
   876 	}
   876         }
   877     }
   877     }
   878 %}.
   878 %}.
   879     windowId notNil ifTrue:[
   879     windowId notNil ifTrue:[
   880 	aPoint isPoint ifTrue:[
   880         aPoint isPoint ifTrue:[
   881 	    ^ self viewIdFromPoint:aPoint asPoint truncated in:windowId
   881             ^ self viewIdFromPoint:aPoint asPoint truncated in:windowId
   882 	]
   882         ]
   883     ].
   883     ].
   884 
   884 
   885     ^ nil
   885     ^ nil
       
   886 
       
   887     "
       
   888       Display viewIdFromPoint:100@100 in:Display realRootWindowId
       
   889     "
   886 !
   890 !
   887 
   891 
   888 virtualExtent
   892 virtualExtent
   889     "return the virtual extent of the display (in pixels).
   893     "return the virtual extent of the display (in pixels).
   890      On most systems, this is the same as the physical width;
   894      On most systems, this is the same as the physical width;
  2407      since some window managers install a virtual root window on top
  2411      since some window managers install a virtual root window on top
  2408      of the real one. If this is the case, that views id is returned here."
  2412      of the real one. If this is the case, that views id is returned here."
  2409 
  2413 
  2410 %{
  2414 %{
  2411     int screen = __intVal(__INST(screen));
  2415     int screen = __intVal(__INST(screen));
  2412     Window rootWin, vRootWin;
  2416     Window rootWin, vRootWin = 0;
  2413     OBJ id;
  2417     OBJ id;
  2414 
  2418 
  2415     if (__INST(virtualRootId) != nil) {
  2419     if (__INST(virtualRootId) != nil) {
  2416 	RETURN (__INST(virtualRootId));
  2420         RETURN (__INST(virtualRootId));
  2417     }
  2421     }
  2418 
  2422 
  2419     if (ISCONNECTED) {
  2423     if (ISCONNECTED) {
  2420 	Display *dpy = myDpy;
  2424         Display *dpy = myDpy;
  2421 
  2425 
  2422 	vRootWin = rootWin = RootWindow(dpy, screen);
  2426         rootWin = RootWindow(dpy, screen);
  2423 #ifndef IRIS
  2427 #ifndef IRIS
  2424 
  2428 
  2425 	/*
  2429         /*
  2426 	 * on IRIS, this creates a badwindow error - why ?
  2430          * on IRIS, this creates a badwindow error - why ?
  2427 	 * children contains a funny window (000034)
  2431          * children contains a funny window (000034)
  2428 	 */
  2432          */
  2429 
  2433 
  2430 	/*
  2434         /*
  2431 	 * care for virtual root windows (tvtwm & friends)
  2435          * care for virtual root windows (tvtwm & friends)
  2432 	 */
  2436          */
  2433 	{
  2437         {
  2434 	    Atom vRootAtom = None;
  2438             Atom vRootAtom, kwinAtom;
  2435 	    int i;
  2439             int i;
  2436 	    Window rootReturn, parentReturn;
  2440             Window rootReturn, parentReturn;
  2437 	    Window* children = (Window *)0;
  2441             Window* children = (Window *)0;
  2438 	    unsigned int numChildren;
  2442             unsigned int numChildren;
  2439 
  2443             int ignoreVRoot = 0;
  2440 	    if (XQueryTree(dpy, rootWin, 
  2444 
  2441 			   &rootReturn, &parentReturn, 
  2445             /*
  2442 			   &children, &numChildren)) {
  2446              * Take care of KDE 2.1.
  2443 		vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True );
  2447              * they define _SWM_ROOT but this is not the parent of
  2444 		if (vRootAtom != None) {
  2448              * the application windows.
  2445 		    for (i=0; i < numChildren; i++) {
  2449              * Instead it is used for background painting
  2446 			Atom actual_type;
  2450              */
  2447 			int actual_format;
  2451 
  2448 			unsigned long nitems, bytesafter;
  2452             kwinAtom = XInternAtom(dpy, "KWIN_RUNNING", True);
  2449 			Window* newRoot = (Window*) 0;
  2453             if (kwinAtom != None) {
  2450 
  2454                 Atom actual_type;
  2451 			if (children[i]) {
  2455                 int actual_format;
  2452 			    if (XGetWindowProperty(dpy, children[i], vRootAtom, 
  2456                 unsigned long nitems, bytesafter;
  2453 						   0L, 1L, False, XA_WINDOW,
  2457                 unsigned char *retVal = 0;
  2454 						   &actual_type, &actual_format, 
  2458 
  2455 						   &nitems, &bytesafter,
  2459                 ignoreVRoot = XGetWindowProperty(dpy, rootWin, kwinAtom, 
  2456 						   (unsigned char**) &newRoot
  2460                                        0L, 1L, False, kwinAtom,
  2457 						  ) == Success && newRoot) {
  2461                                        &actual_type, &actual_format, 
  2458 				vRootWin = *newRoot;
  2462                                        &nitems, &bytesafter, &retVal) == Success 
  2459 				XFree(newRoot); /* XXX */
  2463                               && actual_type != 0;
  2460 				break;
  2464                 XFree(retVal);
  2461 			    }
  2465             }
  2462 			}
  2466 
  2463 		    }
  2467             if (!ignoreVRoot) {
  2464 		}
  2468                 vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True);
  2465 		if (children) XFree( children );
  2469                 if (vRootAtom != None) {
  2466 	    }
  2470                     if (XQueryTree(dpy, rootWin, 
  2467 	}
  2471                                        &rootReturn, &parentReturn, 
  2468 
  2472                                        &children, &numChildren)) {
       
  2473                         for (i=0; i < numChildren; i++) {
       
  2474                             Atom actual_type;
       
  2475                             int actual_format;
       
  2476                             unsigned long nitems, bytesafter;
       
  2477                             Window* newRoot = (Window*) 0;
       
  2478 
       
  2479                             if (children[i]) {
       
  2480                                 if (XGetWindowProperty(dpy, children[i], vRootAtom, 
       
  2481                                                        0L, 1L, False, XA_WINDOW,
       
  2482                                                        &actual_type, &actual_format, 
       
  2483                                                        &nitems, &bytesafter,
       
  2484                                                        (unsigned char**) &newRoot
       
  2485                                                       ) == Success && newRoot) {
       
  2486                                     vRootWin = *newRoot;
       
  2487                                     XFree(newRoot); /* XXX */
       
  2488                                     break; 
       
  2489                                 }
       
  2490                             }
       
  2491                         }
       
  2492                         if (children) XFree( children );
       
  2493                     }
       
  2494                 }
       
  2495              }
       
  2496         }
  2469 #endif
  2497 #endif
  2470     }
  2498     }
  2471 
  2499 
  2472     /* cannot happen */
       
  2473     if (! vRootWin) {
  2500     if (! vRootWin) {
  2474 	vRootWin = rootWin;
  2501         vRootWin = rootWin;
  2475 	if (! rootWin) {
  2502         if (! vRootWin) {
  2476 	    RETURN ( nil );
  2503             RETURN ( nil );
  2477 	}
  2504         }
  2478     }
  2505     }
  2479     __INST(rootId) = id = __MKEXTERNALADDRESS(rootWin); __STORE(self, id);
  2506     __INST(rootId) = id = __MKEXTERNALADDRESS(rootWin); __STORE(self, id);
  2480     __INST(virtualRootId) = id = __MKEXTERNALADDRESS(vRootWin); __STORE(self, id);
  2507     __INST(virtualRootId) = id = __MKEXTERNALADDRESS(vRootWin); __STORE(self, id);
  2481     RETURN ( id );
  2508     RETURN ( id );
  2482 %}
  2509 %}
       
  2510 
       
  2511     "
       
  2512       Display rootWindowId
       
  2513     "
  2483 ! !
  2514 ! !
  2484 
  2515 
  2485 !XWorkstation methodsFor:'color stuff'!
  2516 !XWorkstation methodsFor:'color stuff'!
  2486 
  2517 
  2487 colorCell
  2518 colorCell
  5776     (self decomposeEventBuffer:eventBuffer into:arr) ifTrue:[
  5807     (self decomposeEventBuffer:eventBuffer into:arr) ifTrue:[
  5777         (self dispatchLastEvent:arr) ifFalse:[
  5808         (self dispatchLastEvent:arr) ifFalse:[
  5778             "if not implemented in new dispatch, fall back to old dispatch"
  5809             "if not implemented in new dispatch, fall back to old dispatch"
  5779             self dispatchLastEvent
  5810             self dispatchLastEvent
  5780         ].
  5811         ].
  5781     ].!
  5812     ].
       
  5813 !
  5782 
  5814 
  5783 setEventMask:aMask in:aWindowId
  5815 setEventMask:aMask in:aWindowId
  5784     "tell X that we are only interested in events from aMask, which
  5816     "tell X that we are only interested in events from aMask, which
  5785      is the bitwise or of the eventMask bits (see 'eventMaskFor:')"
  5817      is the bitwise or of the eventMask bits (see 'eventMaskFor:')"
  5786 
  5818 
 11741 ! !
 11773 ! !
 11742 
 11774 
 11743 !XWorkstation class methodsFor:'documentation'!
 11775 !XWorkstation class methodsFor:'documentation'!
 11744 
 11776 
 11745 version
 11777 version
 11746     ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.382 2000-10-23 12:33:56 stefan Exp $'
 11778     ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.383 2001-04-03 16:22:33 stefan Exp $'
 11747 ! !
 11779 ! !
 11748 XWorkstation initialize!
 11780 XWorkstation initialize!