141 #define CRITICAL_SECTION_ENTER(cs) { \ 142 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 143 "CS.Wait: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 144 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 145 (cs).Enter(); \ 146 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 147 "CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 148 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 149 } 150 151 #define CRITICAL_SECTION_LEAVE(cs) { \ 152 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 153 "CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 154 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 155 (cs).Leave(); \ 156 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 157 "CS.Left: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 158 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 159 } 160 161 /************************************************************************ 162 * AwtToolkit class 163 */ 164 165 class AwtToolkit { 166 public: 167 enum { 168 KB_STATE_SIZE = 256 169 }; 170 171 /* java.awt.Toolkit method ids */ 172 static jmethodID getDefaultToolkitMID; 173 static jmethodID getFontMetricsMID; 174 static jmethodID insetsMID; 175 176 /* sun.awt.windows.WToolkit ids */ 177 static jmethodID windowsSettingChangeMID; 178 static jmethodID displayChangeMID; 179 180 static jmethodID userSessionMID; 181 static jmethodID systemSleepMID; 182 183 BOOL m_isDynamicLayoutSet; 184 185 AwtToolkit(); 186 ~AwtToolkit(); 187 188 BOOL Initialize(BOOL localPump); 189 BOOL Dispose(); 190 191 void SetDynamicLayout(BOOL dynamic); 192 BOOL IsDynamicLayoutSet(); 193 BOOL IsDynamicLayoutSupported(); 194 BOOL IsDynamicLayoutActive(); 195 BOOL areExtraMouseButtonsEnabled(); 196 void setExtraMouseButtonsEnabled(BOOL enable); 197 static UINT GetNumberOfButtons(); 198 199 INLINE BOOL localPump() { return m_localPump; } 200 INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag 201 INLINE HWND GetHWnd() { return m_toolkitHWnd; } 202 203 INLINE HMODULE GetModuleHandle() { return m_dllHandle; } 204 INLINE void SetModuleHandle(HMODULE h) { m_dllHandle = h; } 205 206 INLINE static DWORD MainThread() { return GetInstance().m_mainThreadId; } 207 INLINE void VerifyActive() throw (awt_toolkit_shutdown) { 208 if (!m_isActive && m_mainThreadId != ::GetCurrentThreadId()) { 209 throw awt_toolkit_shutdown(); 210 } 211 } 212 INLINE BOOL IsDisposed() { return m_isDisposed; } 213 static UINT GetMouseKeyState(); 214 static void GetKeyboardState(PBYTE keyboardState); 215 216 static ATOM RegisterClass(); 217 static void UnregisterClass(); 218 INLINE LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0) { 384 385 static VOID CALLBACK PrimaryIdleFunc(); 386 static VOID CALLBACK SecondaryIdleFunc(); 387 static BOOL CALLBACK CommonPeekMessageFunc(MSG& msg); 388 static BOOL activateKeyboardLayout(HKL hkl); 389 390 HANDLE m_waitEvent; 391 volatile DWORD eventNumber; 392 volatile BOOL isInDoDragDropLoop; 393 private: 394 HWND CreateToolkitWnd(LPCTSTR name); 395 396 BOOL m_localPump; 397 DWORD m_mainThreadId; 398 HWND m_toolkitHWnd; 399 HWND m_inputMethodHWnd; 400 BOOL m_verbose; 401 BOOL m_isActive; // set to FALSE at beginning of Dispose 402 BOOL m_isDisposed; // set to TRUE at end of Dispose 403 BOOL m_areExtraMouseButtonsEnabled; 404 405 BOOL m_vmSignalled; // set to TRUE if QUERYENDSESSION has successfully 406 // raised SIGTERM 407 408 BOOL m_verifyComponents; 409 BOOL m_breakOnError; 410 411 BOOL m_breakMessageLoop; 412 UINT m_messageLoopResult; 413 414 class AwtComponent* m_lastMouseOver; 415 BOOL m_mouseDown; 416 417 HHOOK m_hGetMessageHook; 418 HHOOK m_hMouseLLHook; 419 UINT_PTR m_timer; 420 421 class AwtCmdIDList* m_cmdIDs; 422 BYTE m_lastKeyboardState[KB_STATE_SIZE]; 423 CriticalSection m_lockKB; | 141 #define CRITICAL_SECTION_ENTER(cs) { \ 142 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 143 "CS.Wait: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 144 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 145 (cs).Enter(); \ 146 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 147 "CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 148 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 149 } 150 151 #define CRITICAL_SECTION_LEAVE(cs) { \ 152 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 153 "CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 154 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 155 (cs).Leave(); \ 156 J2dTraceLn4(J2D_TRACE_VERBOSE2, \ 157 "CS.Left: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \ 158 GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \ 159 } 160 161 // Redefine WinAPI values related to touch input, if OS < Windows 7. 162 #if (!defined(WINVER) || ((WINVER) < 0x0601)) 163 typedef UINT32 POINTER_FLAGS; 164 typedef UINT32 TOUCH_FLAGS; 165 typedef UINT32 TOUCH_MASK; 166 167 #define GET_POINTERID_WPARAM(wParam) (LOWORD (wParam)) 168 169 #define WM_POINTERENTER 0x0249 170 #define WM_NCPOINTERDOWN 0x0242 171 #define WM_NCPOINTERUP 0x0243 172 #define WM_NCPOINTERUPDATE 0x0241 173 #define WM_POINTERACTIVATE 0x024B 174 #define WM_POINTERCAPTURECHANGED 0x024C 175 #define WM_POINTERDOWN 0x0246 176 #define WM_POINTERLEAVE 0x024A 177 #define WM_POINTERUP 0x0247 178 #define WM_POINTERUPDATE 0x0245 179 180 typedef enum _POINTER_BUTTON_CHANGE_TYPE { 181 POINTER_CHANGE_NONE , 182 POINTER_CHANGE_FIRSTBUTTON_DOWN , 183 POINTER_CHANGE_FIRSTBUTTON_UP , 184 POINTER_CHANGE_SECONDBUTTON_DOWN , 185 POINTER_CHANGE_SECONDBUTTON_UP , 186 POINTER_CHANGE_THIRDBUTTON_DOWN , 187 POINTER_CHANGE_THIRDBUTTON_UP , 188 POINTER_CHANGE_FOURTHBUTTON_DOWN , 189 POINTER_CHANGE_FOURTHBUTTON_UP , 190 POINTER_CHANGE_FIFTHBUTTON_DOWN , 191 POINTER_CHANGE_FIFTHBUTTON_UP , 192 } POINTER_BUTTON_CHANGE_TYPE; 193 194 typedef enum tagPOINTER_INPUT_TYPE { 195 PT_POINTER = 0x00000001, 196 PT_TOUCH = 0x00000002, 197 PT_PEN = 0x00000003, 198 PT_MOUSE = 0x00000004, 199 PT_TOUCHPAD = 0x00000005 200 } POINTER_INPUT_TYPE; 201 202 typedef struct tagPOINTER_INFO { 203 POINTER_INPUT_TYPE pointerType; 204 UINT32 pointerId; 205 UINT32 frameId; 206 POINTER_FLAGS pointerFlags; 207 HANDLE sourceDevice; 208 HWND hwndTarget; 209 POINT ptPixelLocation; 210 POINT ptHimetricLocation; 211 POINT ptPixelLocationRaw; 212 POINT ptHimetricLocationRaw; 213 DWORD dwTime; 214 UINT32 historyCount; 215 INT32 inputData; 216 DWORD dwKeyStates; 217 UINT64 PerformanceCount; 218 POINTER_BUTTON_CHANGE_TYPE ButtonChangeType; 219 } POINTER_INFO; 220 #endif 221 222 /************************************************************************ 223 * AwtToolkit class 224 */ 225 226 class AwtToolkit { 227 public: 228 enum { 229 KB_STATE_SIZE = 256 230 }; 231 232 /* java.awt.Toolkit method ids */ 233 static jmethodID getDefaultToolkitMID; 234 static jmethodID getFontMetricsMID; 235 static jmethodID insetsMID; 236 237 /* sun.awt.windows.WToolkit ids */ 238 static jmethodID windowsSettingChangeMID; 239 static jmethodID displayChangeMID; 240 241 static jmethodID userSessionMID; 242 static jmethodID systemSleepMID; 243 244 BOOL m_isDynamicLayoutSet; 245 246 AwtToolkit(); 247 ~AwtToolkit(); 248 249 BOOL Initialize(BOOL localPump); 250 BOOL Dispose(); 251 252 void SetDynamicLayout(BOOL dynamic); 253 BOOL IsDynamicLayoutSet(); 254 BOOL IsDynamicLayoutSupported(); 255 BOOL IsDynamicLayoutActive(); 256 BOOL areExtraMouseButtonsEnabled(); 257 void setExtraMouseButtonsEnabled(BOOL enable); 258 static UINT GetNumberOfButtons(); 259 260 BOOL TIGetPointerInfo(UINT32 pointerID, POINTER_INFO *pointerInfo); 261 262 INLINE BOOL localPump() { return m_localPump; } 263 INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag 264 INLINE HWND GetHWnd() { return m_toolkitHWnd; } 265 266 INLINE HMODULE GetModuleHandle() { return m_dllHandle; } 267 INLINE void SetModuleHandle(HMODULE h) { m_dllHandle = h; } 268 269 INLINE static DWORD MainThread() { return GetInstance().m_mainThreadId; } 270 INLINE void VerifyActive() throw (awt_toolkit_shutdown) { 271 if (!m_isActive && m_mainThreadId != ::GetCurrentThreadId()) { 272 throw awt_toolkit_shutdown(); 273 } 274 } 275 INLINE BOOL IsDisposed() { return m_isDisposed; } 276 static UINT GetMouseKeyState(); 277 static void GetKeyboardState(PBYTE keyboardState); 278 279 static ATOM RegisterClass(); 280 static void UnregisterClass(); 281 INLINE LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0) { 447 448 static VOID CALLBACK PrimaryIdleFunc(); 449 static VOID CALLBACK SecondaryIdleFunc(); 450 static BOOL CALLBACK CommonPeekMessageFunc(MSG& msg); 451 static BOOL activateKeyboardLayout(HKL hkl); 452 453 HANDLE m_waitEvent; 454 volatile DWORD eventNumber; 455 volatile BOOL isInDoDragDropLoop; 456 private: 457 HWND CreateToolkitWnd(LPCTSTR name); 458 459 BOOL m_localPump; 460 DWORD m_mainThreadId; 461 HWND m_toolkitHWnd; 462 HWND m_inputMethodHWnd; 463 BOOL m_verbose; 464 BOOL m_isActive; // set to FALSE at beginning of Dispose 465 BOOL m_isDisposed; // set to TRUE at end of Dispose 466 BOOL m_areExtraMouseButtonsEnabled; 467 468 typedef BOOL (WINAPI *GetPointerInfoHandleFunc)(UINT32 pointerID, POINTER_INFO *pointerInfo); 469 470 BOOL m_isWin8OrLater; 471 GetPointerInfoHandleFunc m_pGetPointerInfoHandle; 472 473 BOOL m_vmSignalled; // set to TRUE if QUERYENDSESSION has successfully 474 // raised SIGTERM 475 476 BOOL m_verifyComponents; 477 BOOL m_breakOnError; 478 479 BOOL m_breakMessageLoop; 480 UINT m_messageLoopResult; 481 482 class AwtComponent* m_lastMouseOver; 483 BOOL m_mouseDown; 484 485 HHOOK m_hGetMessageHook; 486 HHOOK m_hMouseLLHook; 487 UINT_PTR m_timer; 488 489 class AwtCmdIDList* m_cmdIDs; 490 BYTE m_lastKeyboardState[KB_STATE_SIZE]; 491 CriticalSection m_lockKB; |