mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Merged LazApplication int CefApplication (IFDEF)
This commit is contained in:
parent
74f4caf000
commit
eb03146bb2
@ -51,7 +51,7 @@ unit GlobalCefApplication;
|
||||
interface
|
||||
|
||||
uses
|
||||
uCEFApplication, uCEFWorkScheduler, uCEFLazApplication, FileUtil;
|
||||
uCEFApplication, uCEFWorkScheduler, FileUtil;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
@ -75,7 +75,7 @@ begin
|
||||
GlobalCEFWorkScheduler := TCEFWorkScheduler.Create(nil);
|
||||
{$ENDIF}
|
||||
|
||||
GlobalCEFApp := TCefLazApplication.Create;
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.CheckCEFFiles := False;
|
||||
{$IFDEF USE_MULTI_THREAD_LOOP}
|
||||
// On Windows/Linux CEF can use threads for the message-loop
|
||||
|
@ -51,7 +51,7 @@ unit GlobalCefApplication;
|
||||
interface
|
||||
|
||||
uses
|
||||
uCEFApplication, uCEFWorkScheduler, uCEFLazApplication, FileUtil,
|
||||
uCEFApplication, uCEFWorkScheduler, FileUtil,
|
||||
uHelperProcessDom;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
@ -76,7 +76,7 @@ begin
|
||||
GlobalCEFWorkScheduler := TCEFWorkScheduler.Create(nil);
|
||||
{$ENDIF}
|
||||
|
||||
GlobalCEFApp := TCefLazApplication.Create;
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.CheckCEFFiles := False;
|
||||
{$IFDEF USE_MULTI_THREAD_LOOP}
|
||||
// On Windows/Linux CEF can use threads for the message-loop
|
||||
|
@ -51,7 +51,7 @@ unit GlobalCefApplication;
|
||||
interface
|
||||
|
||||
uses
|
||||
uCEFApplication, uCEFWorkScheduler, uCEFLazApplication, FileUtil,
|
||||
uCEFApplication, uCEFWorkScheduler, FileUtil,
|
||||
uHelperProcessDom;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
@ -76,7 +76,7 @@ begin
|
||||
GlobalCEFWorkScheduler := TCEFWorkScheduler.Create(nil);
|
||||
{$ENDIF}
|
||||
|
||||
GlobalCEFApp := TCefLazApplication.Create;
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.CheckCEFFiles := False;
|
||||
{$IFDEF USE_MULTI_THREAD_LOOP}
|
||||
// On Windows/Linux CEF can use threads for the message-loop
|
||||
|
@ -22,7 +22,7 @@
|
||||
<Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/>
|
||||
<License Value="MPL 1.1"/>
|
||||
<Version Major="89" Release="7"/>
|
||||
<Files Count="202">
|
||||
<Files Count="201">
|
||||
<Item1>
|
||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||
<UnitName Value="uCEFAccessibilityHandler"/>
|
||||
@ -841,14 +841,10 @@
|
||||
<UnitName Value="uCEFBrowserWindow"/>
|
||||
</Item200>
|
||||
<Item201>
|
||||
<Filename Value="..\source\uCEFLazApplication.pas"/>
|
||||
<UnitName Value="uCEFLazApplication"/>
|
||||
</Item201>
|
||||
<Item202>
|
||||
<Filename Value="..\source\uCEFOsrBrowserWindow.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="uCEFOsrBrowserWindow"/>
|
||||
</Item202>
|
||||
</Item201>
|
||||
</Files>
|
||||
<CompatibilityMode Value="True"/>
|
||||
<RequiredPkgs Count="5">
|
||||
|
@ -66,8 +66,7 @@ uses
|
||||
uCEFPrintDialogCallback, uCEFPrintHandler, uCEFPrintJobCallback,
|
||||
uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants,
|
||||
uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, uCEFLazarusCocoa,
|
||||
uCEFBrowserWindow, uCEFLazApplication, uCEFOsrBrowserWindow,
|
||||
LazarusPackageIntf;
|
||||
uCEFBrowserWindow, uCEFOsrBrowserWindow, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -60,7 +60,11 @@ uses
|
||||
{$ENDIF}
|
||||
System.Classes, System.UITypes,
|
||||
{$ELSE}
|
||||
{$IFDEF MSWINDOWS}Windows, Forms, ActiveX,{$ENDIF} Classes, Controls, {$IFDEF FPC}dynlibs,{$ENDIF}
|
||||
Forms,
|
||||
{$IFDEF MSWINDOWS}Windows, ActiveX,{$ENDIF} Classes, Controls, {$IFDEF FPC}dynlibs,{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$IFDEF FPC}
|
||||
LCLProc,
|
||||
{$ENDIF}
|
||||
uCEFApplicationCore, uCEFTypes;
|
||||
|
||||
@ -83,6 +87,12 @@ type
|
||||
protected
|
||||
FDestroyApplicationObject : boolean;
|
||||
FDestroyAppWindows : boolean;
|
||||
{$IFDEF FPC}
|
||||
FContextInitializedHandlers: TMethodList;
|
||||
FContextInitializedDone: Boolean;
|
||||
|
||||
procedure CallContextInitializedHandlers(Data: PtrInt);
|
||||
{$ENDIF}
|
||||
|
||||
procedure BeforeInitSubProcess; override;
|
||||
|
||||
@ -93,6 +103,13 @@ type
|
||||
|
||||
property DestroyApplicationObject: boolean read FDestroyApplicationObject write FDestroyApplicationObject;
|
||||
property DestroyAppWindows : boolean read FDestroyAppWindows write FDestroyAppWindows;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure Internal_OnContextInitialized; override; // In UI thread
|
||||
|
||||
Procedure AddContextInitializedHandler(AHandler: TNotifyEvent);
|
||||
Procedure RemoveContextInitializedHandler(AHandler: TNotifyEvent);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
TCEFDirectoryDeleterThread = uCEFApplicationCore.TCEFDirectoryDeleterThread;
|
||||
@ -187,6 +204,10 @@ end;
|
||||
|
||||
constructor TCefApplication.Create;
|
||||
begin
|
||||
{$IFDEF FPC}
|
||||
FContextInitializedHandlers := TMethodList.Create;
|
||||
{$ENDIF}
|
||||
|
||||
inherited Create;
|
||||
if GlobalCEFApp = nil then
|
||||
GlobalCEFApp := Self;
|
||||
@ -200,6 +221,10 @@ begin
|
||||
if GlobalCEFApp = Self then
|
||||
GlobalCEFApp := nil;
|
||||
inherited Destroy;
|
||||
|
||||
{$IFDEF FPC}
|
||||
FContextInitializedHandlers.Free;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TCefApplication.UpdateDeviceScaleFactor;
|
||||
@ -238,6 +263,34 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure TCefApplication.Internal_OnContextInitialized;
|
||||
begin
|
||||
inherited Internal_OnContextInitialized;
|
||||
Application.QueueAsyncCall(@CallContextInitializedHandlers, 0);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.AddContextInitializedHandler(AHandler: TNotifyEvent);
|
||||
begin
|
||||
FContextInitializedHandlers.Add(TMethod(AHandler));
|
||||
if FContextInitializedDone then
|
||||
AHandler(Self);
|
||||
end;
|
||||
|
||||
procedure TCefApplication.RemoveContextInitializedHandler(AHandler: TNotifyEvent);
|
||||
begin
|
||||
FContextInitializedHandlers.Remove(TMethod(AHandler));
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
procedure TCefApplication.CallContextInitializedHandlers(Data: PtrInt);
|
||||
begin
|
||||
FContextInitializedHandlers.CallNotifyEvents(Self);
|
||||
FContextInitializedDone := True;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TCefApplication.BeforeInitSubProcess;
|
||||
{$IFNDEF FPC}
|
||||
{$IFNDEF FMX}
|
||||
|
@ -47,7 +47,7 @@ uses
|
||||
LResources, PropEdits,
|
||||
{$ENDIF}
|
||||
uCEFApplication, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces, uCEFChromium,
|
||||
uCEFLinkedWinControlBase, uCEFLazApplication, uCEFBrowserViewComponent,
|
||||
uCEFLinkedWinControlBase, uCEFBrowserViewComponent,
|
||||
uCEFChromiumEvents, Forms, ExtCtrls, Controls, Classes, sysutils;
|
||||
|
||||
type
|
||||
@ -619,10 +619,7 @@ begin
|
||||
But at least on Linux, we need to wait
|
||||
*)
|
||||
|
||||
if GlobalCEFApp is TCefLazApplication then
|
||||
TCefLazApplication(GlobalCEFApp).AddContextInitializedHandler(@DoCreateBrowserAfterContext)
|
||||
else
|
||||
DoCreateBrowserAfterContext(nil);
|
||||
GlobalCEFApp.AddContextInitializedHandler(@DoCreateBrowserAfterContext);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -1,80 +0,0 @@
|
||||
unit uCEFLazApplication;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
{$ELSE}
|
||||
Forms, LclProc, Classes, SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFTypes, uCEFApplication;
|
||||
|
||||
type
|
||||
|
||||
{ TCefLazApplication }
|
||||
|
||||
TCefLazApplication = class(TCefApplication)
|
||||
protected
|
||||
FContextInitializedHandlers: TMethodList;
|
||||
FContextInitializedDone: Boolean;
|
||||
|
||||
procedure CallContextInitializedHandlers(Data: PtrInt);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure Internal_OnContextInitialized; override; // In UI thread
|
||||
|
||||
Procedure AddContextInitializedHandler(AHandler: TNotifyEvent);
|
||||
Procedure RemoveContextInitializedHandler(AHandler: TNotifyEvent);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TCefLazApplication }
|
||||
|
||||
procedure TCefLazApplication.Internal_OnContextInitialized;
|
||||
begin
|
||||
inherited Internal_OnContextInitialized;
|
||||
Application.QueueAsyncCall(@CallContextInitializedHandlers, 0);
|
||||
//TThread.Queue(@CallContextInitializedHandlers);
|
||||
end;
|
||||
|
||||
procedure TCefLazApplication.CallContextInitializedHandlers(Data: PtrInt);
|
||||
begin
|
||||
FContextInitializedHandlers.CallNotifyEvents(Self);
|
||||
FContextInitializedDone := True;
|
||||
end;
|
||||
|
||||
constructor TCefLazApplication.Create;
|
||||
begin
|
||||
FContextInitializedHandlers := TMethodList.Create;
|
||||
inherited Create;
|
||||
end;
|
||||
|
||||
destructor TCefLazApplication.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
FContextInitializedHandlers.Free;
|
||||
end;
|
||||
|
||||
procedure TCefLazApplication.AddContextInitializedHandler(AHandler: TNotifyEvent);
|
||||
begin
|
||||
FContextInitializedHandlers.Add(TMethod(AHandler));
|
||||
if FContextInitializedDone then
|
||||
AHandler(Self);
|
||||
end;
|
||||
|
||||
procedure TCefLazApplication.RemoveContextInitializedHandler(
|
||||
AHandler: TNotifyEvent);
|
||||
begin
|
||||
FContextInitializedHandlers.Remove(TMethod(AHandler));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -59,7 +59,7 @@ uses
|
||||
LResources, PropEdits,
|
||||
{$ENDIF}
|
||||
uCEFApplication, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces, uCEFChromium,
|
||||
uCEFLinkedWinControlBase, uCEFLazApplication, uCEFBufferPanel,
|
||||
uCEFLinkedWinControlBase, uCEFBufferPanel,
|
||||
uCEFBrowserWindow, uCEFBitmapBitBuffer, uCEFMiscFunctions,
|
||||
uCEFConstants, uCEFChromiumEvents, Forms, ExtCtrls, LCLType, Graphics,
|
||||
Controls, syncobjs, Classes, sysutils, math;
|
||||
@ -605,10 +605,7 @@ procedure TOsrBrowserWindow.CreateHandle;
|
||||
begin
|
||||
inherited CreateHandle;
|
||||
if not (csDesigning in ComponentState) then begin
|
||||
if GlobalCEFApp is TCefLazApplication then
|
||||
TCefLazApplication(GlobalCEFApp).AddContextInitializedHandler(@DoCreateBrowserAfterContext)
|
||||
else
|
||||
DoCreateBrowserAfterContext(nil);
|
||||
GlobalCEFApp.AddContextInitializedHandler(@DoCreateBrowserAfterContext);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user