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 BOOL m_isDynamicLayoutSet; 181 182 AwtToolkit(); 183 ~AwtToolkit(); 184 185 BOOL Initialize(BOOL localPump); 186 BOOL Dispose(); 187 188 void SetDynamicLayout(BOOL dynamic); 189 BOOL IsDynamicLayoutSet(); 190 BOOL IsDynamicLayoutSupported(); 191 BOOL IsDynamicLayoutActive(); 192 BOOL areExtraMouseButtonsEnabled(); 193 void setExtraMouseButtonsEnabled(BOOL enable); 194 static UINT GetNumberOfButtons(); 195 196 INLINE BOOL localPump() { return m_localPump; } 197 INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag 198 INLINE HWND GetHWnd() { return m_toolkitHWnd; } 199 200 INLINE HMODULE GetModuleHandle() { return m_dllHandle; } 201 INLINE void SetModuleHandle(HMODULE h) { m_dllHandle = h; } 202 203 INLINE static DWORD MainThread() { return GetInstance().m_mainThreadId; } 204 INLINE void VerifyActive() throw (awt_toolkit_shutdown) { 205 if (!m_isActive && m_mainThreadId != ::GetCurrentThreadId()) { 206 throw awt_toolkit_shutdown(); 207 } 208 } 209 INLINE BOOL IsDisposed() { return m_isDisposed; } 210 static UINT GetMouseKeyState(); 211 static void GetKeyboardState(PBYTE keyboardState); 212 213 static ATOM RegisterClass(); 214 static void UnregisterClass(); 215 INLINE LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0) { 372 INLINE void SetVerify(long flag) { m_verifyComponents = (flag != 0); } 373 INLINE void SetBreak(long flag) { m_breakOnError = (flag != 0); } 374 INLINE void SetHeapCheck(long flag); 375 376 static void SetBusy(BOOL busy); 377 378 /* Set and get the default input method Window handler. */ 379 INLINE void SetInputMethodWindow(HWND inputMethodHWnd) { m_inputMethodHWnd = inputMethodHWnd; } 380 INLINE HWND GetInputMethodWindow() { return m_inputMethodHWnd; } 381 382 static VOID CALLBACK PrimaryIdleFunc(); 383 static VOID CALLBACK SecondaryIdleFunc(); 384 static BOOL CALLBACK CommonPeekMessageFunc(MSG& msg); 385 static BOOL activateKeyboardLayout(HKL hkl); 386 387 HANDLE m_waitEvent; 388 DWORD eventNumber; 389 private: 390 HWND CreateToolkitWnd(LPCTSTR name); 391 392 BOOL m_localPump; 393 DWORD m_mainThreadId; 394 HWND m_toolkitHWnd; 395 HWND m_inputMethodHWnd; 396 BOOL m_verbose; 397 BOOL m_isActive; // set to FALSE at beginning of Dispose 398 BOOL m_isDisposed; // set to TRUE at end of Dispose 399 BOOL m_areExtraMouseButtonsEnabled; 400 401 BOOL m_vmSignalled; // set to TRUE if QUERYENDSESSION has successfully 402 // raised SIGTERM 403 404 BOOL m_verifyComponents; 405 BOOL m_breakOnError; 406 407 BOOL m_breakMessageLoop; 408 UINT m_messageLoopResult; 409 410 class AwtComponent* m_lastMouseOver; 411 BOOL m_mouseDown; 412 413 HHOOK m_hGetMessageHook; 414 HHOOK m_hMouseLLHook; 415 UINT_PTR m_timer; 416 417 class AwtCmdIDList* m_cmdIDs; 418 BYTE m_lastKeyboardState[KB_STATE_SIZE]; 419 CriticalSection m_lockKB; 420 | 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 /* 164 * RegisterTouchWindow flag values 165 */ 166 #define TWF_FINETOUCH (0x00000001) 167 #define TWF_WANTPALM (0x00000002) 168 169 #define WM_TOUCH 0x0240 170 171 /* 172 * Touch input handle 173 */ 174 typedef HANDLE HTOUCHINPUT; 175 176 typedef struct tagTOUCHINPUT { 177 LONG x; 178 LONG y; 179 HANDLE hSource; 180 DWORD dwID; 181 DWORD dwFlags; 182 DWORD dwMask; 183 DWORD dwTime; 184 ULONG_PTR dwExtraInfo; 185 DWORD cxContact; 186 DWORD cyContact; 187 } TOUCHINPUT, *PTOUCHINPUT; 188 typedef TOUCHINPUT const * PCTOUCHINPUT; 189 190 /* 191 * Touch input flag values (TOUCHINPUT.dwFlags) 192 */ 193 #define TOUCHEVENTF_MOVE 0x0001 194 #define TOUCHEVENTF_DOWN 0x0002 195 #define TOUCHEVENTF_UP 0x0004 196 #define TOUCHEVENTF_INRANGE 0x0008 197 #define TOUCHEVENTF_PRIMARY 0x0010 198 #define TOUCHEVENTF_NOCOALESCE 0x0020 199 #define TOUCHEVENTF_PEN 0x0040 200 #define TOUCHEVENTF_PALM 0x0080 201 #endif 202 203 /************************************************************************ 204 * AwtToolkit class 205 */ 206 207 class AwtToolkit { 208 public: 209 enum { 210 KB_STATE_SIZE = 256 211 }; 212 213 /* java.awt.Toolkit method ids */ 214 static jmethodID getDefaultToolkitMID; 215 static jmethodID getFontMetricsMID; 216 static jmethodID insetsMID; 217 218 /* sun.awt.windows.WToolkit ids */ 219 static jmethodID windowsSettingChangeMID; 220 static jmethodID displayChangeMID; 221 222 BOOL m_isDynamicLayoutSet; 223 224 AwtToolkit(); 225 ~AwtToolkit(); 226 227 BOOL Initialize(BOOL localPump); 228 BOOL Dispose(); 229 230 void SetDynamicLayout(BOOL dynamic); 231 BOOL IsDynamicLayoutSet(); 232 BOOL IsDynamicLayoutSupported(); 233 BOOL IsDynamicLayoutActive(); 234 BOOL areExtraMouseButtonsEnabled(); 235 void setExtraMouseButtonsEnabled(BOOL enable); 236 static UINT GetNumberOfButtons(); 237 238 bool IsWin8OrLater(); 239 bool IsTouchKeyboardAutoShowEnabled(); 240 bool IsAnyKeyboardAttached(); 241 bool IsTouchKeyboardAutoShowSystemEnabled(); 242 void ShowTouchKeyboard(); 243 void HideTouchKeyboard(); 244 BOOL TIRegisterTouchWindow(HWND hWnd, ULONG ulFlags); 245 BOOL TIGetTouchInputInfo(HTOUCHINPUT hTouchInput, 246 UINT cInputs, PTOUCHINPUT pInputs, int cbSize); 247 BOOL TICloseTouchInputHandle(HTOUCHINPUT hTouchInput); 248 249 INLINE BOOL localPump() { return m_localPump; } 250 INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag 251 INLINE HWND GetHWnd() { return m_toolkitHWnd; } 252 253 INLINE HMODULE GetModuleHandle() { return m_dllHandle; } 254 INLINE void SetModuleHandle(HMODULE h) { m_dllHandle = h; } 255 256 INLINE static DWORD MainThread() { return GetInstance().m_mainThreadId; } 257 INLINE void VerifyActive() throw (awt_toolkit_shutdown) { 258 if (!m_isActive && m_mainThreadId != ::GetCurrentThreadId()) { 259 throw awt_toolkit_shutdown(); 260 } 261 } 262 INLINE BOOL IsDisposed() { return m_isDisposed; } 263 static UINT GetMouseKeyState(); 264 static void GetKeyboardState(PBYTE keyboardState); 265 266 static ATOM RegisterClass(); 267 static void UnregisterClass(); 268 INLINE LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0) { 425 INLINE void SetVerify(long flag) { m_verifyComponents = (flag != 0); } 426 INLINE void SetBreak(long flag) { m_breakOnError = (flag != 0); } 427 INLINE void SetHeapCheck(long flag); 428 429 static void SetBusy(BOOL busy); 430 431 /* Set and get the default input method Window handler. */ 432 INLINE void SetInputMethodWindow(HWND inputMethodHWnd) { m_inputMethodHWnd = inputMethodHWnd; } 433 INLINE HWND GetInputMethodWindow() { return m_inputMethodHWnd; } 434 435 static VOID CALLBACK PrimaryIdleFunc(); 436 static VOID CALLBACK SecondaryIdleFunc(); 437 static BOOL CALLBACK CommonPeekMessageFunc(MSG& msg); 438 static BOOL activateKeyboardLayout(HKL hkl); 439 440 HANDLE m_waitEvent; 441 DWORD eventNumber; 442 private: 443 HWND CreateToolkitWnd(LPCTSTR name); 444 445 void InitTouchKeyboardExeFilePath(); 446 HWND GetTouchKeyboardWindow(); 447 448 BOOL m_localPump; 449 DWORD m_mainThreadId; 450 HWND m_toolkitHWnd; 451 HWND m_inputMethodHWnd; 452 BOOL m_verbose; 453 BOOL m_isActive; // set to FALSE at beginning of Dispose 454 BOOL m_isDisposed; // set to TRUE at end of Dispose 455 BOOL m_areExtraMouseButtonsEnabled; 456 457 typedef BOOL (WINAPI *RegisterTouchWindowFunc)(HWND hWnd, ULONG ulFlags); 458 typedef BOOL (WINAPI *GetTouchInputInfoFunc)(HTOUCHINPUT hTouchInput, 459 UINT cInputs, PTOUCHINPUT pInputs, int cbSize); 460 typedef BOOL (WINAPI *CloseTouchInputHandleFunc)(HTOUCHINPUT hTouchInput); 461 462 BOOL m_isWin8OrLater; 463 BOOL m_touchKbrdAutoShowIsEnabled; 464 TCHAR* m_touchKbrdExeFilePath; 465 RegisterTouchWindowFunc m_pRegisterTouchWindow; 466 GetTouchInputInfoFunc m_pGetTouchInputInfo; 467 CloseTouchInputHandleFunc m_pCloseTouchInputHandle; 468 469 BOOL m_vmSignalled; // set to TRUE if QUERYENDSESSION has successfully 470 // raised SIGTERM 471 472 BOOL m_verifyComponents; 473 BOOL m_breakOnError; 474 475 BOOL m_breakMessageLoop; 476 UINT m_messageLoopResult; 477 478 class AwtComponent* m_lastMouseOver; 479 BOOL m_mouseDown; 480 481 HHOOK m_hGetMessageHook; 482 HHOOK m_hMouseLLHook; 483 UINT_PTR m_timer; 484 485 class AwtCmdIDList* m_cmdIDs; 486 BYTE m_lastKeyboardState[KB_STATE_SIZE]; 487 CriticalSection m_lockKB; 488 |