< prev index next >

jdk/src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeATInstance.cpp

Print this page




 127     strcpy(memoryMappedView, AB_MEMORY_MAPPED_FILE_OK_ANSWER);
 128 
 129 
 130     return 0;
 131 }
 132 
 133 
 134 typedef struct EVENT_STRUCT
 135 {
 136     char *buffer;
 137     int bufsize;
 138     ABHWND64 winAccessBridgeWindow;
 139     ABHWND64 ourAccessBridgeWindow;
 140 }EVENT_STRUCT;
 141 
 142 
 143 #include <process.h>
 144 #define THREAD_PROC unsigned int __stdcall
 145 typedef unsigned int (__stdcall *THREAD_ROUTINE)(LPVOID lpThreadParameter);
 146 
 147 static HANDLE BeginThread(THREAD_ROUTINE thread_func,DWORD *id,DWORD param)
 148 {
 149     HANDLE ret;
 150     ret = (HANDLE) _beginthreadex(NULL,0,thread_func,(void *)param,0,(unsigned int *)id);
 151     if(ret == INVALID_HANDLE_VALUE)
 152         ret = NULL;
 153     return(ret);
 154 }
 155 
 156 DWORD JavaBridgeThreadId = 0;
 157 
 158 static THREAD_PROC JavaBridgeThread(LPVOID param1)
 159 {
 160     MSG msg;
 161     DWORD rc = 0;
 162     while (GetMessage(&msg,        // message structure
 163                       NULL,                  // handle of window receiving the message
 164                       0,                  // lowest message to examine
 165                       0))                 // highest message to examine
 166         {
 167             if(msg.message == WM_USER)
 168                 {
 169                     EVENT_STRUCT *event_struct = (EVENT_STRUCT *)msg.wParam;
 170                     COPYDATASTRUCT toCopy;


 180             if(msg.message == (WM_USER+1))
 181                 PostQuitMessage(0);
 182         }
 183     JavaBridgeThreadId = 0;
 184     return(0);
 185 }
 186 
 187 /*
 188  * Handles one event
 189  */
 190 static void do_event(char *buffer, int bufsize,HWND ourAccessBridgeWindow,HWND winAccessBridgeWindow)
 191 {
 192     EVENT_STRUCT *event_struct = new EVENT_STRUCT;
 193     event_struct->bufsize = bufsize;
 194     event_struct->buffer = new char[bufsize];
 195     memcpy(event_struct->buffer,buffer,bufsize);
 196     event_struct->ourAccessBridgeWindow = ABHandleToLong(ourAccessBridgeWindow);
 197     event_struct->winAccessBridgeWindow = ABHandleToLong(winAccessBridgeWindow);
 198     if(!JavaBridgeThreadId)
 199         {
 200             HANDLE JavaBridgeThreadHandle = BeginThread(JavaBridgeThread,&JavaBridgeThreadId,(DWORD)event_struct);
 201             CloseHandle(JavaBridgeThreadHandle);
 202         }
 203     PostThreadMessage(JavaBridgeThreadId,WM_USER,(WPARAM)event_struct,0);
 204 }
 205 
 206 
 207 /**
 208  * sendJavaEventPackage - uses SendMessage(WM_COPYDATA) to do
 209  *                        IPC messaging with the Java AccessBridge DLL
 210  *                        to propogate events to those ATs that want 'em
 211  *
 212  */
 213 LRESULT
 214 AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eventID) {
 215 
 216     PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() eventID = %X", eventID);
 217     PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() (using PostMessage) eventID = %X", eventID);
 218 
 219     if (eventID & javaEventMask) {
 220         do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow);




 127     strcpy(memoryMappedView, AB_MEMORY_MAPPED_FILE_OK_ANSWER);
 128 
 129 
 130     return 0;
 131 }
 132 
 133 
 134 typedef struct EVENT_STRUCT
 135 {
 136     char *buffer;
 137     int bufsize;
 138     ABHWND64 winAccessBridgeWindow;
 139     ABHWND64 ourAccessBridgeWindow;
 140 }EVENT_STRUCT;
 141 
 142 
 143 #include <process.h>
 144 #define THREAD_PROC unsigned int __stdcall
 145 typedef unsigned int (__stdcall *THREAD_ROUTINE)(LPVOID lpThreadParameter);
 146 
 147 static HANDLE BeginThread(THREAD_ROUTINE thread_func,DWORD *id,LPVOID param)
 148 {
 149     HANDLE ret;
 150     ret = (HANDLE) _beginthreadex(NULL,0,thread_func,param,0,(unsigned int *)id);
 151     if(ret == INVALID_HANDLE_VALUE)
 152         ret = NULL;
 153     return(ret);
 154 }
 155 
 156 DWORD JavaBridgeThreadId = 0;
 157 
 158 static THREAD_PROC JavaBridgeThread(LPVOID param1)
 159 {
 160     MSG msg;
 161     DWORD rc = 0;
 162     while (GetMessage(&msg,        // message structure
 163                       NULL,                  // handle of window receiving the message
 164                       0,                  // lowest message to examine
 165                       0))                 // highest message to examine
 166         {
 167             if(msg.message == WM_USER)
 168                 {
 169                     EVENT_STRUCT *event_struct = (EVENT_STRUCT *)msg.wParam;
 170                     COPYDATASTRUCT toCopy;


 180             if(msg.message == (WM_USER+1))
 181                 PostQuitMessage(0);
 182         }
 183     JavaBridgeThreadId = 0;
 184     return(0);
 185 }
 186 
 187 /*
 188  * Handles one event
 189  */
 190 static void do_event(char *buffer, int bufsize,HWND ourAccessBridgeWindow,HWND winAccessBridgeWindow)
 191 {
 192     EVENT_STRUCT *event_struct = new EVENT_STRUCT;
 193     event_struct->bufsize = bufsize;
 194     event_struct->buffer = new char[bufsize];
 195     memcpy(event_struct->buffer,buffer,bufsize);
 196     event_struct->ourAccessBridgeWindow = ABHandleToLong(ourAccessBridgeWindow);
 197     event_struct->winAccessBridgeWindow = ABHandleToLong(winAccessBridgeWindow);
 198     if(!JavaBridgeThreadId)
 199         {
 200             HANDLE JavaBridgeThreadHandle = BeginThread(JavaBridgeThread,&JavaBridgeThreadId,NULL);
 201             CloseHandle(JavaBridgeThreadHandle);
 202         }
 203     PostThreadMessage(JavaBridgeThreadId,WM_USER,(WPARAM)event_struct,0);
 204 }
 205 
 206 
 207 /**
 208  * sendJavaEventPackage - uses SendMessage(WM_COPYDATA) to do
 209  *                        IPC messaging with the Java AccessBridge DLL
 210  *                        to propogate events to those ATs that want 'em
 211  *
 212  */
 213 LRESULT
 214 AccessBridgeATInstance::sendJavaEventPackage(char *buffer, int bufsize, long eventID) {
 215 
 216     PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() eventID = %X", eventID);
 217     PrintDebugString("AccessBridgeATInstance::sendJavaEventPackage() (using PostMessage) eventID = %X", eventID);
 218 
 219     if (eventID & javaEventMask) {
 220         do_event(buffer,bufsize,ourAccessBridgeWindow,winAccessBridgeWindow);


< prev index next >