diff --git a/demos/Lazarus_Mac/SubProcess/00-Delete.bat b/demos/Lazarus_Mac/AppHelper/00-Delete.bat
similarity index 100%
rename from demos/Lazarus_Mac/SubProcess/00-Delete.bat
rename to demos/Lazarus_Mac/AppHelper/00-Delete.bat
diff --git a/demos/Lazarus_Mac/SubProcess/cef_subprocess.ico b/demos/Lazarus_Mac/AppHelper/AppHelper.ico
similarity index 100%
rename from demos/Lazarus_Mac/SubProcess/cef_subprocess.ico
rename to demos/Lazarus_Mac/AppHelper/AppHelper.ico
diff --git a/demos/Lazarus_Mac/SubProcess/cef_subprocess.lpi b/demos/Lazarus_Mac/AppHelper/AppHelper.lpi
similarity index 93%
rename from demos/Lazarus_Mac/SubProcess/cef_subprocess.lpi
rename to demos/Lazarus_Mac/AppHelper/AppHelper.lpi
index 55968a1e..7a12e328 100644
--- a/demos/Lazarus_Mac/SubProcess/cef_subprocess.lpi
+++ b/demos/Lazarus_Mac/AppHelper/AppHelper.lpi
@@ -10,7 +10,7 @@
-
+
@@ -40,7 +40,7 @@
-
+
@@ -49,7 +49,7 @@
-
+
diff --git a/demos/Lazarus_Mac/SubProcess/cef_subprocess.lpr b/demos/Lazarus_Mac/AppHelper/AppHelper.lpr
similarity index 91%
rename from demos/Lazarus_Mac/SubProcess/cef_subprocess.lpr
rename to demos/Lazarus_Mac/AppHelper/AppHelper.lpr
index 1da714f8..94707950 100644
--- a/demos/Lazarus_Mac/SubProcess/cef_subprocess.lpr
+++ b/demos/Lazarus_Mac/AppHelper/AppHelper.lpr
@@ -1,4 +1,4 @@
-program cef_subprocess;
+program AppHelper;
(*
* The compiled exe should be copied into
@@ -21,9 +21,8 @@ begin
// The main process and the subprocess *MUST* have the same GlobalCEFApp
// properties and events, specially FrameworkDirPath, ResourcesDirPath,
// LocalesDirPath, cache and UserDataPath paths.
+ GlobalCEFApp.InitLibLocationFromArgs;
-
- GlobalCEFApp.MultiThreadedMessageLoop:=false;
GlobalCEFApp.StartSubProcess;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
diff --git a/demos/Lazarus_Mac/SubProcess/cef_subprocess.res b/demos/Lazarus_Mac/AppHelper/AppHelper.res
similarity index 100%
rename from demos/Lazarus_Mac/SubProcess/cef_subprocess.res
rename to demos/Lazarus_Mac/AppHelper/AppHelper.res
diff --git a/demos/Lazarus_Mac/SubProcess/cef.inc b/demos/Lazarus_Mac/AppHelper/cef.inc
similarity index 100%
rename from demos/Lazarus_Mac/SubProcess/cef.inc
rename to demos/Lazarus_Mac/AppHelper/cef.inc
diff --git a/demos/Lazarus_Mac/AppHelper/create_mac_helper_apps.sh b/demos/Lazarus_Mac/AppHelper/create_mac_helper_apps.sh
new file mode 100755
index 00000000..4050723f
--- /dev/null
+++ b/demos/Lazarus_Mac/AppHelper/create_mac_helper_apps.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+BASEDIR=$(dirname "$0")
+DEST=$1
+SRC=$2
+
+if [ "$SRC" = "" ];
+then
+ SRC=$BASEDIR/../../../bin/AppHelper.app
+fi
+
+if [ "$1" = "" ] || [ ! -e "$DEST" ] || [ ! -e "$SRC" ];
+then
+ echo "Usage"
+ echo " $0 destpath/project.app"
+ echo " $0 destpath/project.app sourcedir/AppHelper.app"
+ echo
+ if [ ! -e "$DEST" ];
+ then
+ echo "Error: Target app bundle not found. (Did you compile AND create the bundle?)"
+ fi
+ if [ ! -e "$SRC" ];
+ then
+ echo "Error: Source (AppHelper) app bundle not found. (Did you compile AND create the bundle?)"
+ fi
+ exit;
+fi
+
+SRCAPP=$(basename "$SRC")
+SRCAPP="${SRCAPP%\.app}"
+DESTAPP=$(basename "$DEST")
+DESTAPP="${DESTAPP%\.app}"
+
+SUB=""
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
+SUB=" (GPU)"
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
+SUB=" (Renderer)"
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
+SUB=" (Plugin)"
+rm -rf "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+cp -r "$SRC" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app"
+mv "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$SRCAPP" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/MacOS/$DESTAPP Helper$SUB"
+sed -i '' "s/$SRCAPP/$DESTAPP Helper$SUB/g" "$DEST/Contents/Frameworks/$DESTAPP Helper$SUB.app/Contents/Info.plist"
+
diff --git a/demos/Lazarus_Mac/SimpleBrowser2/create_mac_helper.sh b/demos/Lazarus_Mac/SimpleBrowser2/create_mac_helper.sh
new file mode 100755
index 00000000..43b6334b
--- /dev/null
+++ b/demos/Lazarus_Mac/SimpleBrowser2/create_mac_helper.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+CDIR=$(pwd)
+cd "$(dirname "$0")"
+
+../AppHelper/create_mac_helper_apps.sh ../../../bin/SimpleBrowser2.app
+
+cd "$CDIR"
diff --git a/source/uCEFApplicationCore.pas b/source/uCEFApplicationCore.pas
index f36072d2..32718257 100644
--- a/source/uCEFApplicationCore.pas
+++ b/source/uCEFApplicationCore.pas
@@ -90,6 +90,11 @@ const
CHROMEELF_DLL = '';
{$ENDIF}
+ // for InitLibLocationFromArgs
+ LIBCEF_PAK = 'cef.pak';
+ LIBCEF_LOCALE_DIR = 'locales';
+ LIBCEF_LOCALE_ENUS = 'en-US.pak';
+
type
TCefApplicationCore = class
protected
@@ -265,6 +270,8 @@ type
function GetLibCefVersion : ustring;
function GetLibCefPath : ustring;
function GetChromeElfPath : ustring;
+ function GetLocalesDirPath: ustring;
+ function GetResourcesDirPath: ustring;
function GetMustCreateResourceBundleHandler : boolean; virtual;
function GetMustCreateBrowserProcessHandler : boolean; virtual;
function GetMustCreateRenderProcessHandler : boolean; virtual;
@@ -359,6 +366,7 @@ type
destructor Destroy; override;
procedure AfterConstruction; override;
procedure AddCustomCommandLine(const aCommandLine : string; const aValue : string = '');
+ procedure InitLibLocationFromArgs;
function StartMainProcess : boolean;
function StartSubProcess : boolean;
@@ -421,8 +429,8 @@ type
property LogFile : ustring read FLogFile write FLogFile;
property LogSeverity : TCefLogSeverity read FLogSeverity write FLogSeverity;
property JavaScriptFlags : ustring read FJavaScriptFlags write FJavaScriptFlags;
- property ResourcesDirPath : ustring read FResourcesDirPath write SetResourcesDirPath;
- property LocalesDirPath : ustring read FLocalesDirPath write SetLocalesDirPath;
+ property ResourcesDirPath : ustring read GetResourcesDirPath write SetResourcesDirPath;
+ property LocalesDirPath : ustring read GetLocalesDirPath write SetLocalesDirPath;
property PackLoadingDisabled : Boolean read FPackLoadingDisabled write FPackLoadingDisabled;
property RemoteDebuggingPort : Integer read FRemoteDebuggingPort write FRemoteDebuggingPort;
property UncaughtExceptionStackSize : Integer read FUncaughtExceptionStackSize write FUncaughtExceptionStackSize;
@@ -859,6 +867,50 @@ begin
if (FCustomCommandLineValues <> nil) then FCustomCommandLineValues.Add(aValue);
end;
+// This function checks if argv contains
+// --framework-dir-path=
+// --main-bundle-path=
+// It sets the corresponding fields in the config
+// This params are passed on Mac.
+// The values can also be calculated, instead of calling this procedure
+var
+ PARAM_FRAME_PATH : string = '--framework-dir-path';
+ PARAM_BUNDLE_PATH : string = '--main-bundle-path';
+procedure TCefApplicationCore.InitLibLocationFromArgs;
+var
+ i, l : Integer;
+ p : PChar;
+ MBPath : ustring;
+begin
+ for i := 0 to argc - 1 do
+ begin
+ p := strscan(argv[i], '=');
+ if p = nil then continue;
+ l := p - argv[i];
+ if (l = Length(PARAM_FRAME_PATH)) and
+ (strlcomp(argv[i], PChar(PARAM_FRAME_PATH), Length(PARAM_FRAME_PATH)) = 0) then
+ begin
+ FrameworkDirPath := PChar(argv[i] + Length(PARAM_FRAME_PATH) + 1);
+ end;
+ if (l = Length(PARAM_BUNDLE_PATH)) and
+ (strlcomp(argv[i], PChar(PARAM_BUNDLE_PATH), Length(PARAM_BUNDLE_PATH)) = 0) then
+ begin
+ MBPath := PChar(argv[i] + Length(PARAM_BUNDLE_PATH) + 1);
+ MainBundlePath := MBPath;
+ end;
+ end;
+ if (MBPath <> '') and (FrameworkDirPath = '') then
+ begin
+ MBPath := IncludeTrailingPathDelimiter(MBPath);
+ {$IFDEF MACOSX}
+ MBPath := MBPath + LIBCEF_PREFIX;
+ {$ENDIF}
+ if FileExists(MBPath + LIBCEF_DLL) then begin
+ FrameworkDirPath := MBPath;
+ end;
+ end;
+end;
+
// This function must only be called by the main executable when the application
// is configured to use a different executable for the subprocesses.
// The process calling ths function must be the browser process.
@@ -968,6 +1020,28 @@ begin
Result := CHROMEELF_DLL;
end;
+function TCefApplicationCore.GetLocalesDirPath: ustring;
+begin
+ Result := FLocalesDirPath;
+ {$IFNDEF MACOSX}
+ if (Result = '') and (FrameworkDirPath <> '') then
+ begin
+ if FileExists(IncludeTrailingPathDelimiter(FrameworkDirPath + LIBCEF_LOCALE_DIR) + LIBCEF_LOCALE_ENUS) then
+ Result := FrameworkDirPath + LIBCEF_LOCALE_DIR;
+ end;
+ {$ENDIF}
+end;
+
+function TCefApplicationCore.GetResourcesDirPath: ustring;
+begin
+ Result := FResourcesDirPath;
+ if (Result = '') and (FrameworkDirPath <> '') then
+ begin
+ if FileExists(IncludeTrailingPathDelimiter(FrameworkDirPath) + LIBCEF_PAK) then
+ Result := FrameworkDirPath;
+ end;
+end;
+
procedure TCefApplicationCore.SetCache(const aValue : ustring);
begin
FCache := CustomAbsolutePath(aValue);
@@ -1583,7 +1657,8 @@ begin
FOnScheduleMessagePumpWork(delayMs);
end;
-function TCefApplicationCore.Internal_GetLocalizedString(stringid: Integer; var stringVal: ustring) : boolean;
+function TCefApplicationCore.Internal_GetLocalizedString(stringId: Integer;
+ var stringVal: ustring): boolean;
begin
Result := False;
@@ -1744,7 +1819,8 @@ begin
FOnGetPDFPaperSize(deviceUnitsPerInch, aResult);
end;
-procedure TCefApplicationCore.AppendSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring);
+procedure TCefApplicationCore.AppendSwitch(var aKeys, aValues: TStringList;
+ const aNewKey: ustring; const aNewValue: ustring);
var
TempKey, TempHyphenatedKey : ustring;
i : integer;
@@ -1848,7 +1924,8 @@ begin
FreeAndNil(TempDisabledValues);
end;
-procedure TCefApplicationCore.ReplaceSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring);
+procedure TCefApplicationCore.ReplaceSwitch(var aKeys, aValues: TStringList;
+ const aNewKey: ustring; const aNewValue: ustring);
var
TempKey, TempHyphenatedKey : ustring;
i : integer;
diff --git a/source/uCEFBufferPanel.pas b/source/uCEFBufferPanel.pas
index aa2ff2d2..c5893688 100644
--- a/source/uCEFBufferPanel.pas
+++ b/source/uCEFBufferPanel.pas
@@ -871,14 +871,15 @@ begin
end;
function TBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean;
-var
{$IFDEF MSWINDOWS}
+var
TempHandle : TCefWindowHandle;
TempDC : HDC;
TempDPI : UINT;
{$ELSE}
{$IFDEF LINUX}
{$IFDEF FPC}
+var
TempForm : TCustomForm;
TempMonitor : TMonitor;
{$ENDIF}
diff --git a/source/uCEFMiscFunctions.pas b/source/uCEFMiscFunctions.pas
index b05c9bcd..a04c53e2 100644
--- a/source/uCEFMiscFunctions.pas
+++ b/source/uCEFMiscFunctions.pas
@@ -2334,7 +2334,7 @@ end;
function ValidCefWindowHandle(aHandle : TCefWindowHandle) : boolean;
begin
- {$IFDEF MACOSX}
+ {$IFDEF MACOS}
Result := (aHandle <> nil);
{$ELSE}
Result := (aHandle <> 0);
@@ -2343,7 +2343,7 @@ end;
procedure InitializeWindowHandle(var aHandle : TCefWindowHandle);
begin
- {$IFDEF MACOSX}
+ {$IFDEF MACOS}
aHandle := nil;
{$ELSE}
aHandle := 0;