JDK-4373821 : Need a method that tells if a component is unobscured
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.1,1.4.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_95,windows_nt
  • CPU: generic,x86
  • Submitted: 2000-09-25
  • Updated: 2001-01-17
  • Resolved: 2000-12-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Duplicate :  
Description
In order to resovle RFE 4285812 we need a method that will tell us if a 
viewport is unobscured (unclipped).  I have written prototye code that performs
this function udner X11 and Windows (see suggested fix).  We need it integrated
into AWT and made available to Swing.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin merlin-beta FIXED IN: merlin merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

SUGGESTED FIX Protype native code: ============================ X11. This code determines if a window is on the top of the Window stack. If it is, we know the window cannot be obscured and so we return true, otherwise we "fail safe" and return false. Note that this is not as good an algorithym as the clipping baseed one used in the sugegsted windows code (below), but is "good enough" for now. ------------------------------- JNIEXPORT jboolean JNICALL Java_OnTop_isOnTop (JNIEnv *env, jclass ontopClass, jobject frame) { JAWT awt; JAWT_DrawingSurface* ds; JAWT_DrawingSurfaceInfo* dsi; JAWT_X11DrawingSurfaceInfo* dsi_x11; jboolean result; jint lock; // X variables Display *display; Window w; Window root_return; Window parent_return; Window dummy; Window *children_return; Window current_window; unsigned int nchildren_return; unsigned char cresult; unsigned int done = FALSE; // Get the AWT awt.version = JAWT_VERSION_1_3; result = JAWT_GetAWT(env, &awt); assert(result != JNI_FALSE); // Get the drawing surface ds = awt.GetDrawingSurface(env, frame); assert(ds != NULL); // Lock the drawing surface lock = ds->Lock(ds); assert((lock & JAWT_LOCK_ERROR) == 0); // Get the drawing surface info dsi = ds->GetDrawingSurfaceInfo(ds); // Get the platform-specific drawing info dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo; // Test For OnTop current_window = dsi_x11->drawable; while (!done){ // get parent if( XQueryTree(dsi_x11->display, current_window, &root_return, &parent_return, &children_return, &nchildren_return)==0) { // Free the drawing surface info ds->FreeDrawingSurfaceInfo(dsi); // Unlock the drawing surface ds->Unlock(ds); // Free the drawing surface awt.FreeDrawingSurface(ds); jclass execClass = env->FindClass("OntopException"); if (execClass != NULL){ env->ThrowNew(execClass,"Could not get parent window."); } env->DeleteLocalRef(execClass); } // get parent's children if( XQueryTree(dsi_x11->display, parent_return, &root_return, &dummy, &children_return, &nchildren_return) == 0) { // failure // Free the drawing surface info ds->FreeDrawingSurfaceInfo(dsi); // Unlock the drawing surface ds->Unlock(ds); // Free the drawing surface awt.FreeDrawingSurface(ds); jclass execClass = env->FindClass("OntopException"); if (execClass != NULL){ env->ThrowNew(execClass,"Could not get sibling windows."); } env->DeleteLocalRef(execClass); } cresult = (current_window == children_return[nchildren_return-1]); if (!cresult) done= TRUE; if (parent_return == root_return) done=TRUE; current_window = parent_return; } // Free the drawing surface info ds->FreeDrawingSurfaceInfo(dsi); // Unlock the drawing surface ds->Unlock(ds); // Free the drawing surface awt.FreeDrawingSurface(ds); return (jboolean)cresult; } ======================================================================== Win32 Code. This code works by getting the bounding rectangle of the current clip region and comparing it with the client area rectangle. If they are the same then the window is not beign clipped and is unobscured. If they are differnt then some clipping is going on and the Window is at least partially obscured. Note that obscurement of the non-client area (the area of the window controlled and rendered by windows-- the title bar) still returns an unobscured (true) result. This is as it should be. -------------------------------------- JNIEXPORT jboolean JNICALL Java_OnTop_isOnTop (JNIEnv *env, jclass myclass, jobject canvas){ JAWT awt; JAWT_DrawingSurface* ds; JAWT_DrawingSurfaceInfo* dsi; JAWT_Win32DrawingSurfaceInfo* dsi_win; jboolean result; jint lock; // Get the AWT awt.version = JAWT_VERSION_1_3; result = JAWT_GetAWT(env, &awt); assert(result != JNI_FALSE); // Get the drawing surface ds = awt.GetDrawingSurface(env, canvas); assert(ds != NULL); // Lock the drawing surface lock = ds->Lock(ds); assert((lock & JAWT_LOCK_ERROR) == 0); // Get the drawing surface info dsi = ds->GetDrawingSurfaceInfo(ds); // Get the platform-specific drawing info dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; // On top code goes here HDC hdc = dsi_win->hdc; RECT clipbox; int callresult = GetClipBox(hdc,&clipbox); printf("Call result =%d\n",&callresult); if (callresult == NULLREGION) { result = (jboolean)TRUE; } else if (callresult == SIMPLEREGION) { RECT windowRect; if (GetClientRect(dsi_win->hwnd,&windowRect)==0) { result = (jboolean)FALSE; } result = (jboolean)((clipbox.bottom==windowRect.bottom) && (clipbox.left == windowRect.left) && (clipbox.right == windowRect.right) && (clipbox.top == windowRect.top)); } else if (callresult == COMPLEXREGION ) { result = (jboolean)FALSE; } assert(callresult != ERROR); // End On Top code // Free the drawing surface info ds->FreeDrawingSurfaceInfo(dsi); // Unlock the drawing surface ds->Unlock(ds); // Free the drawing surface awt.FreeDrawingSurface(ds); return result; }
11-06-2004

EVALUATION Committing to merlin. michael.martak@Eng 2000-10-04 Note: the description references the wrong bugid. The correct one is 4285182. eric.hawkes@eng 2000-10-14 The X11 solution does not work; only the Win32 solution is valid. Scott is checking into whether it is harmless to perform the optimization anyway. michael.martak@Eng 2000-11-21 I've added the methods isObscured() and canDetermineObscurity() to ComponentPeer in merlin. The former determines whether a component is obscured and the latter determines whether or not isObscured() can be relied upon. michael.martak@Eng 2000-12-15
15-12-2000