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) { 376 INLINE void SetBreak(long flag) { m_breakOnError = (flag != 0); } 377 INLINE void SetHeapCheck(long flag); 378 379 static void SetBusy(BOOL busy); 380 381 /* Set and get the default input method Window handler. */ 382 INLINE void SetInputMethodWindow(HWND inputMethodHWnd) { m_inputMethodHWnd = inputMethodHWnd; } 383 INLINE HWND GetInputMethodWindow() { return m_inputMethodHWnd; } 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; 424 | 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 static jmethodID userSessionMID; 223 static jmethodID systemSleepMID; 224 225 BOOL m_isDynamicLayoutSet; 226 227 AwtToolkit(); 228 ~AwtToolkit(); 229 230 BOOL Initialize(BOOL localPump); 231 BOOL Dispose(); 232 233 void SetDynamicLayout(BOOL dynamic); 234 BOOL IsDynamicLayoutSet(); 235 BOOL IsDynamicLayoutSupported(); 236 BOOL IsDynamicLayoutActive(); 237 BOOL areExtraMouseButtonsEnabled(); 238 void setExtraMouseButtonsEnabled(BOOL enable); 239 static UINT GetNumberOfButtons(); 240 241 bool IsWin8OrLater(); 242 bool IsTouchKeyboardAutoShowEnabled(); 243 bool IsAnyKeyboardAttached(); 244 bool IsTouchKeyboardAutoShowSystemEnabled(); 245 void ShowTouchKeyboard(); 246 void HideTouchKeyboard(); 247 BOOL TIRegisterTouchWindow(HWND hWnd, ULONG ulFlags); 248 BOOL TIGetTouchInputInfo(HTOUCHINPUT hTouchInput, 249 UINT cInputs, PTOUCHINPUT pInputs, int cbSize); 250 BOOL TICloseTouchInputHandle(HTOUCHINPUT hTouchInput); 251 252 INLINE BOOL localPump() { return m_localPump; } 253 INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag 254 INLINE HWND GetHWnd() { return m_toolkitHWnd; } 255 256 INLINE HMODULE GetModuleHandle() { return m_dllHandle; } 257 INLINE void SetModuleHandle(HMODULE h) { m_dllHandle = h; } 258 259 INLINE static DWORD MainThread() { return GetInstance().m_mainThreadId; } 260 INLINE void VerifyActive() throw (awt_toolkit_shutdown) { 261 if (!m_isActive && m_mainThreadId != ::GetCurrentThreadId()) { 262 throw awt_toolkit_shutdown(); 263 } 264 } 265 INLINE BOOL IsDisposed() { return m_isDisposed; } 266 static UINT GetMouseKeyState(); 267 static void GetKeyboardState(PBYTE keyboardState); 268 269 static ATOM RegisterClass(); 270 static void UnregisterClass(); 271 INLINE LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0) { 429 INLINE void SetBreak(long flag) { m_breakOnError = (flag != 0); } 430 INLINE void SetHeapCheck(long flag); 431 432 static void SetBusy(BOOL busy); 433 434 /* Set and get the default input method Window handler. */ 435 INLINE void SetInputMethodWindow(HWND inputMethodHWnd) { m_inputMethodHWnd = inputMethodHWnd; } 436 INLINE HWND GetInputMethodWindow() { return m_inputMethodHWnd; } 437 438 static VOID CALLBACK PrimaryIdleFunc(); 439 static VOID CALLBACK SecondaryIdleFunc(); 440 static BOOL CALLBACK CommonPeekMessageFunc(MSG& msg); 441 static BOOL activateKeyboardLayout(HKL hkl); 442 443 HANDLE m_waitEvent; 444 volatile DWORD eventNumber; 445 volatile BOOL isInDoDragDropLoop; 446 private: 447 HWND CreateToolkitWnd(LPCTSTR name); 448 449 void InitTouchKeyboardExeFilePath(); 450 HWND GetTouchKeyboardWindow(); 451 452 BOOL m_localPump; 453 DWORD m_mainThreadId; 454 HWND m_toolkitHWnd; 455 HWND m_inputMethodHWnd; 456 BOOL m_verbose; 457 BOOL m_isActive; // set to FALSE at beginning of Dispose 458 BOOL m_isDisposed; // set to TRUE at end of Dispose 459 BOOL m_areExtraMouseButtonsEnabled; 460 461 typedef BOOL (WINAPI *RegisterTouchWindowFunc)(HWND hWnd, ULONG ulFlags); 462 typedef BOOL (WINAPI *GetTouchInputInfoFunc)(HTOUCHINPUT hTouchInput, 463 UINT cInputs, PTOUCHINPUT pInputs, int cbSize); 464 typedef BOOL (WINAPI *CloseTouchInputHandleFunc)(HTOUCHINPUT hTouchInput); 465 466 BOOL m_isWin8OrLater; 467 BOOL m_touchKbrdAutoShowIsEnabled; 468 TCHAR* m_touchKbrdExeFilePath; 469 RegisterTouchWindowFunc m_pRegisterTouchWindow; 470 GetTouchInputInfoFunc m_pGetTouchInputInfo; 471 CloseTouchInputHandleFunc m_pCloseTouchInputHandle; 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; 492 |