summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2012-11-13 17:03:53 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2012-11-13 17:03:53 +0200
commit60bac26347164e8c89d783fc2f4b0d7b40af9efc (patch)
tree44d782caad2e4751caf1ac3edce7a784e20da88e
parent85682e5586a60487d8aa65564dc0a77c24f080d4 (diff)
downloadfpGUI-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.
-rw-r--r--src/corelib/gdi/fpg_gdi.pas9
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);