From 60bac26347164e8c89d783fc2f4b0d7b40af9efc Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Tue, 13 Nov 2012 17:03:53 +0200 Subject: Implements WakeMainThread for Windows. Multi-threaded apps under Windows requires the main thread to be woken up periodically. We now simply hook into the Classes.WakeMainThread function which is automatically called by TThread.Synchronize. I did the same testing under X11, but it doesn't seem needed there. If we do find a case for this under X11, it is easy to implement. --- src/corelib/gdi/fpg_gdi.pas | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/corelib/gdi') diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas index fec0c511..196e467a 100644 --- a/src/corelib/gdi/fpg_gdi.pas +++ b/src/corelib/gdi/fpg_gdi.pas @@ -207,6 +207,7 @@ type TfpgGDIApplication = class(TfpgApplicationBase) private FDrag: TfpgGDIDrag; + procedure DoWakeMainThread(Sender: TObject); procedure SetDrag(const AValue: TfpgGDIDrag); property Drag: TfpgGDIDrag read FDrag write SetDrag; protected @@ -1233,6 +1234,12 @@ begin Result.Sort; end; +procedure TfpgGDIApplication.DoWakeMainThread(Sender: TObject); +begin + // WakeMainThread is called during TThread.Synchronize. + Windows.PostMessage(TfpgGDIWindow(MainForm).WinHandle, WM_NULL, 0, 0); +end; + procedure TfpgGDIApplication.SetDrag(const AValue: TfpgGDIDrag); begin if Assigned(FDrag) then @@ -1313,10 +1320,12 @@ begin FIsInitialized := True; wapplication := TfpgApplication(self); + WakeMainThread := @DoWakeMainThread; end; destructor TfpgGDIApplication.Destroy; begin + WakeMainThread := nil; if Assigned(FDrag) then FDrag.Free; UnhookWindowsHookEx(ActivationHook); -- cgit v1.2.3-70-g09d2