< prev index next >

jdk/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp

Print this page




 150      *
 151      * replaced with code to send output to debug file
 152      *
 153      */
 154     void AppendToCallInfo(char *s) {
 155 
 156         /*
 157           _CrtDbgReport(_CRT_WARN, (const char *) NULL, NULL, (const char *) NULL,
 158           (const char *) "WinAccessBridge: %s", s);
 159         */
 160 
 161         char buf[1024];
 162         sprintf(buf, "WinAccessBridge: %s", s);
 163         OutputDebugString(buf);
 164     }
 165 
 166     /**
 167      * Our window proc
 168      *
 169      */
 170     BOOL CALLBACK AccessBridgeDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) {
 171         COPYDATASTRUCT *sentToUs;
 172         char *package;
 173 
 174         switch (message) {
 175         case WM_INITDIALOG:
 176             PrintDebugString("AccessBridgeDialogProc -> Initializing");
 177             break;
 178 
 179             // call from Java with data for us to deliver
 180         case WM_COPYDATA:
 181             if (theDialogWindow == (HWND) wParam) {
 182                 PrintDebugString("AccessBridgeDialogProc -> Got WM_COPYDATA from Java Bridge DLL");
 183             } else {
 184                 PrintDebugString("AccessBridgeDialogProc -> Got WM_COPYDATA from HWND %p", wParam);
 185                 sentToUs = (COPYDATASTRUCT *) lParam;
 186                 package = (char *) sentToUs->lpData;
 187                 theWindowsAccessBridge->preProcessPackage(package, sentToUs->cbData);
 188             }
 189             break;
 190 


 843 
 844     if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) {
 845         return FALSE;
 846     }
 847 
 848     // quick check to see if 'window' is top-level; if not, it's not interesting...
 849     // [[[FIXME]]] is this for sure an OK optimization?
 850     hwnd = getTopLevelHWND(window);
 851     if (hwnd == (HWND) NULL) {
 852         return FALSE;
 853     }
 854 
 855     PrintDebugString("In WinAccessBridge::isJavaWindow");
 856 
 857 
 858 
 859     char buffer[sizeof(PackageType) + sizeof(IsJavaWindowPackage)];
 860     PackageType *type = (PackageType *) buffer;
 861     IsJavaWindowPackage *pkg = (IsJavaWindowPackage *) (buffer + sizeof(PackageType));
 862     *type = cIsJavaWindowPackage;
 863     pkg->window = (jint) window;
 864 
 865     PrintDebugString("WinAccessBridge::isJavaWindow(%p)", window);
 866 
 867     isVMInstanceChainInUse = true;
 868     AccessBridgeJavaVMInstance *current = javaVMs;
 869     while (current != (AccessBridgeJavaVMInstance *) 0) {
 870         if (sendMemoryPackage(buffer, sizeof(buffer), current->javaAccessBridgeWindow) == TRUE) {
 871             if (pkg->rResult != 0) {
 872                 isVMInstanceChainInUse = false;
 873                 return TRUE;
 874             }
 875         }
 876         current = current->nextJVMInstance;
 877     }
 878     isVMInstanceChainInUse = false;
 879     return FALSE;
 880 
 881 
 882     /*
 883       char classname[256];


 948     return FALSE;
 949 }
 950 
 951 /**
 952  * FromHWND - returns the AccessibleContext jobject for the HWND
 953  *
 954  * Note: this routine can return null, even if the HWND is a Java Window,
 955  * because the Java Window may not be accessible.
 956  *
 957  */
 958 BOOL
 959 WinAccessBridge::getAccessibleContextFromHWND(HWND window, long *vmID, JOBJECT64 *AccessibleContext) {
 960     if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) {
 961         return FALSE;
 962     }
 963 
 964     char buffer[sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage)];
 965     PackageType *type = (PackageType *) buffer;
 966     GetAccessibleContextFromHWNDPackage *pkg = (GetAccessibleContextFromHWNDPackage *) (buffer + sizeof(PackageType));
 967     *type = cGetAccessibleContextFromHWNDPackage;
 968     pkg->window = (jint) window;
 969 
 970     PrintDebugString("WinAccessBridge::getAccessibleContextFromHWND(%p, )", window);
 971 
 972     DEBUG_CODE(pkg->rVMID = (long ) 0x01010101);
 973     DEBUG_CODE(pkg->rAccessibleContext = (JOBJECT64) 0x01010101);
 974 
 975     isVMInstanceChainInUse = true;
 976     AccessBridgeJavaVMInstance *current = javaVMs;
 977     while (current != (AccessBridgeJavaVMInstance *) 0) {
 978 
 979         if (sendMemoryPackage(buffer, sizeof(buffer), current->javaAccessBridgeWindow) == TRUE) {
 980             if (pkg->rAccessibleContext != 0) {
 981                 *vmID = pkg->rVMID;
 982                 *AccessibleContext = (JOBJECT64)pkg->rAccessibleContext;
 983                 PrintDebugString("    current->vmID = %X", current->vmID);
 984                 PrintDebugString("    pkg->rVMID = %X", pkg->rVMID);
 985 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
 986                 PrintDebugString("    pkg->rAccessibleContext = %p", pkg->rAccessibleContext);
 987 #else // JOBJECT64 is jlong (64 bit)
 988                 PrintDebugString("    pkg->rAccessibleContext = %016I64X", pkg->rAccessibleContext);


1110  * so that the AccessBridge can hide expected changes in how this functions
1111  * between JDK 1.1.x w/AccessibilityUtility classes, and JDK 1.2, when some
1112  * of this functionality may be built into the platform
1113  *
1114  */
1115 BOOL
1116 WinAccessBridge::getAccessibleContextWithFocus(HWND window, long *vmID, JOBJECT64 *AccessibleContext) {
1117 
1118     if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) {
1119         return FALSE;
1120     }
1121     char buffer[sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage)];
1122     PackageType *type = (PackageType *) buffer;
1123     GetAccessibleContextWithFocusPackage *pkg = (GetAccessibleContextWithFocusPackage *) (buffer + sizeof(PackageType));
1124     *type = cGetAccessibleContextWithFocusPackage;
1125 
1126     PrintDebugString("WinAccessBridge::getAccessibleContextWithFocus(%p, %X, )", window, vmID);
1127     // find vmID, etc. from HWND; ask that VM for the AC w/Focus
1128         HWND pkgVMID = (HWND)ABLongToHandle( pkg->rVMID ) ;
1129     if (getAccessibleContextFromHWND(window, (long *)&(pkgVMID), &(pkg->rAccessibleContext)) == TRUE) {
1130         HWND destABWindow = javaVMs->findAccessBridgeWindow((long)pkgVMID);     // ineffecient [[[FIXME]]]
1131         if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) {
1132             *vmID = pkg->rVMID;
1133             *AccessibleContext = pkg->rAccessibleContext;
1134             return TRUE;
1135         }
1136     }
1137 
1138     return FALSE;
1139 }
1140 
1141 /**
1142  * getAccessibleContextInfo - fills a struct with a bunch of information
1143  * contained in the Java Accessibility API
1144  *
1145  *
1146  * Note: if the AccessibleContext parameter is bogus, this call will blow up
1147  */
1148 BOOL
1149 WinAccessBridge::getAccessibleContextInfo(long vmID,
1150                                           JOBJECT64 accessibleContext,




 150      *
 151      * replaced with code to send output to debug file
 152      *
 153      */
 154     void AppendToCallInfo(char *s) {
 155 
 156         /*
 157           _CrtDbgReport(_CRT_WARN, (const char *) NULL, NULL, (const char *) NULL,
 158           (const char *) "WinAccessBridge: %s", s);
 159         */
 160 
 161         char buf[1024];
 162         sprintf(buf, "WinAccessBridge: %s", s);
 163         OutputDebugString(buf);
 164     }
 165 
 166     /**
 167      * Our window proc
 168      *
 169      */
 170     INT_PTR CALLBACK AccessBridgeDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
 171         COPYDATASTRUCT *sentToUs;
 172         char *package;
 173 
 174         switch (message) {
 175         case WM_INITDIALOG:
 176             PrintDebugString("AccessBridgeDialogProc -> Initializing");
 177             break;
 178 
 179             // call from Java with data for us to deliver
 180         case WM_COPYDATA:
 181             if (theDialogWindow == (HWND) wParam) {
 182                 PrintDebugString("AccessBridgeDialogProc -> Got WM_COPYDATA from Java Bridge DLL");
 183             } else {
 184                 PrintDebugString("AccessBridgeDialogProc -> Got WM_COPYDATA from HWND %p", wParam);
 185                 sentToUs = (COPYDATASTRUCT *) lParam;
 186                 package = (char *) sentToUs->lpData;
 187                 theWindowsAccessBridge->preProcessPackage(package, sentToUs->cbData);
 188             }
 189             break;
 190 


 843 
 844     if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) {
 845         return FALSE;
 846     }
 847 
 848     // quick check to see if 'window' is top-level; if not, it's not interesting...
 849     // [[[FIXME]]] is this for sure an OK optimization?
 850     hwnd = getTopLevelHWND(window);
 851     if (hwnd == (HWND) NULL) {
 852         return FALSE;
 853     }
 854 
 855     PrintDebugString("In WinAccessBridge::isJavaWindow");
 856 
 857 
 858 
 859     char buffer[sizeof(PackageType) + sizeof(IsJavaWindowPackage)];
 860     PackageType *type = (PackageType *) buffer;
 861     IsJavaWindowPackage *pkg = (IsJavaWindowPackage *) (buffer + sizeof(PackageType));
 862     *type = cIsJavaWindowPackage;
 863     pkg->window = (jint)(uintptr_t) window;
 864 
 865     PrintDebugString("WinAccessBridge::isJavaWindow(%p)", window);
 866 
 867     isVMInstanceChainInUse = true;
 868     AccessBridgeJavaVMInstance *current = javaVMs;
 869     while (current != (AccessBridgeJavaVMInstance *) 0) {
 870         if (sendMemoryPackage(buffer, sizeof(buffer), current->javaAccessBridgeWindow) == TRUE) {
 871             if (pkg->rResult != 0) {
 872                 isVMInstanceChainInUse = false;
 873                 return TRUE;
 874             }
 875         }
 876         current = current->nextJVMInstance;
 877     }
 878     isVMInstanceChainInUse = false;
 879     return FALSE;
 880 
 881 
 882     /*
 883       char classname[256];


 948     return FALSE;
 949 }
 950 
 951 /**
 952  * FromHWND - returns the AccessibleContext jobject for the HWND
 953  *
 954  * Note: this routine can return null, even if the HWND is a Java Window,
 955  * because the Java Window may not be accessible.
 956  *
 957  */
 958 BOOL
 959 WinAccessBridge::getAccessibleContextFromHWND(HWND window, long *vmID, JOBJECT64 *AccessibleContext) {
 960     if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) {
 961         return FALSE;
 962     }
 963 
 964     char buffer[sizeof(PackageType) + sizeof(GetAccessibleContextFromHWNDPackage)];
 965     PackageType *type = (PackageType *) buffer;
 966     GetAccessibleContextFromHWNDPackage *pkg = (GetAccessibleContextFromHWNDPackage *) (buffer + sizeof(PackageType));
 967     *type = cGetAccessibleContextFromHWNDPackage;
 968     pkg->window = (jint)(uintptr_t) window;
 969 
 970     PrintDebugString("WinAccessBridge::getAccessibleContextFromHWND(%p, )", window);
 971 
 972     DEBUG_CODE(pkg->rVMID = (long ) 0x01010101);
 973     DEBUG_CODE(pkg->rAccessibleContext = (JOBJECT64) 0x01010101);
 974 
 975     isVMInstanceChainInUse = true;
 976     AccessBridgeJavaVMInstance *current = javaVMs;
 977     while (current != (AccessBridgeJavaVMInstance *) 0) {
 978 
 979         if (sendMemoryPackage(buffer, sizeof(buffer), current->javaAccessBridgeWindow) == TRUE) {
 980             if (pkg->rAccessibleContext != 0) {
 981                 *vmID = pkg->rVMID;
 982                 *AccessibleContext = (JOBJECT64)pkg->rAccessibleContext;
 983                 PrintDebugString("    current->vmID = %X", current->vmID);
 984                 PrintDebugString("    pkg->rVMID = %X", pkg->rVMID);
 985 #ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer)
 986                 PrintDebugString("    pkg->rAccessibleContext = %p", pkg->rAccessibleContext);
 987 #else // JOBJECT64 is jlong (64 bit)
 988                 PrintDebugString("    pkg->rAccessibleContext = %016I64X", pkg->rAccessibleContext);


1110  * so that the AccessBridge can hide expected changes in how this functions
1111  * between JDK 1.1.x w/AccessibilityUtility classes, and JDK 1.2, when some
1112  * of this functionality may be built into the platform
1113  *
1114  */
1115 BOOL
1116 WinAccessBridge::getAccessibleContextWithFocus(HWND window, long *vmID, JOBJECT64 *AccessibleContext) {
1117 
1118     if ((AccessBridgeJavaVMInstance *) 0 == javaVMs) {
1119         return FALSE;
1120     }
1121     char buffer[sizeof(PackageType) + sizeof(GetAccessibleContextWithFocusPackage)];
1122     PackageType *type = (PackageType *) buffer;
1123     GetAccessibleContextWithFocusPackage *pkg = (GetAccessibleContextWithFocusPackage *) (buffer + sizeof(PackageType));
1124     *type = cGetAccessibleContextWithFocusPackage;
1125 
1126     PrintDebugString("WinAccessBridge::getAccessibleContextWithFocus(%p, %X, )", window, vmID);
1127     // find vmID, etc. from HWND; ask that VM for the AC w/Focus
1128         HWND pkgVMID = (HWND)ABLongToHandle( pkg->rVMID ) ;
1129     if (getAccessibleContextFromHWND(window, (long *)&(pkgVMID), &(pkg->rAccessibleContext)) == TRUE) {
1130         HWND destABWindow = javaVMs->findAccessBridgeWindow((long)(uintptr_t)pkgVMID);     // ineffecient [[[FIXME]]]
1131         if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) {
1132             *vmID = pkg->rVMID;
1133             *AccessibleContext = pkg->rAccessibleContext;
1134             return TRUE;
1135         }
1136     }
1137 
1138     return FALSE;
1139 }
1140 
1141 /**
1142  * getAccessibleContextInfo - fills a struct with a bunch of information
1143  * contained in the Java Accessibility API
1144  *
1145  *
1146  * Note: if the AccessibleContext parameter is bogus, this call will blow up
1147  */
1148 BOOL
1149 WinAccessBridge::getAccessibleContextInfo(long vmID,
1150                                           JOBJECT64 accessibleContext,


< prev index next >