diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2012-11-13 17:03:53 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2012-11-13 17:03:53 +0200 |
commit | 60bac26347164e8c89d783fc2f4b0d7b40af9efc (patch) | |
tree | 44d782caad2e4751caf1ac3edce7a784e20da88e /src/corelib/gdi | |
parent | 85682e5586a60487d8aa65564dc0a77c24f080d4 (diff) | |
download | fpGUI-60bac26347164e8c89d783fc2f4b0d7b40af9efc.tar.xz |
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.
Diffstat (limited to 'src/corelib/gdi')
-rw-r--r-- | src/corelib/gdi/fpg_gdi.pas | 9 |
1 files changed, 9 insertions, 0 deletions
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); |