You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-08-14 21:42:50 +02:00
Added TBufferPanel.UpdateDeviceScaleFactor
Fixed issue #339 : SimpleOSRBrowser crashes when the mouse is moved over the browser using CEF 88
This commit is contained in:
@@ -74,6 +74,7 @@ type
|
|||||||
FTransparent : boolean;
|
FTransparent : boolean;
|
||||||
FOnPaintParentBkg : TNotifyEvent;
|
FOnPaintParentBkg : TNotifyEvent;
|
||||||
FForcedDeviceScaleFactor : single;
|
FForcedDeviceScaleFactor : single;
|
||||||
|
FDeviceScaleFactor : single;
|
||||||
FCopyOriginalBuffer : boolean;
|
FCopyOriginalBuffer : boolean;
|
||||||
FMustInitBuffer : boolean;
|
FMustInitBuffer : boolean;
|
||||||
FBuffer : TBitmap;
|
FBuffer : TBitmap;
|
||||||
@@ -147,6 +148,7 @@ type
|
|||||||
function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;
|
function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;
|
||||||
function UpdateOrigBufferDimensions(aWidth, aHeight : integer) : boolean;
|
function UpdateOrigBufferDimensions(aWidth, aHeight : integer) : boolean;
|
||||||
function UpdateOrigPopupBufferDimensions(aWidth, aHeight : integer) : boolean;
|
function UpdateOrigPopupBufferDimensions(aWidth, aHeight : integer) : boolean;
|
||||||
|
procedure UpdateDeviceScaleFactor;
|
||||||
function BufferIsResized(aUseMutex : boolean = True) : boolean;
|
function BufferIsResized(aUseMutex : boolean = True) : boolean;
|
||||||
procedure CreateIMEHandler;
|
procedure CreateIMEHandler;
|
||||||
procedure ChangeCompositionRange(const selection_range : TCefRange; const character_bounds : TCefRectDynArray);
|
procedure ChangeCompositionRange(const selection_range : TCefRange; const character_bounds : TCefRectDynArray);
|
||||||
@@ -313,6 +315,7 @@ begin
|
|||||||
FOrigBuffer := nil;
|
FOrigBuffer := nil;
|
||||||
FOrigPopupBuffer := nil;
|
FOrigPopupBuffer := nil;
|
||||||
FOrigPopupScanlineSize := 0;
|
FOrigPopupScanlineSize := 0;
|
||||||
|
FDeviceScaleFactor := 0;
|
||||||
|
|
||||||
if (GlobalCEFApp <> nil) and (GlobalCEFApp.ForcedDeviceScaleFactor <> 0) then
|
if (GlobalCEFApp <> nil) and (GlobalCEFApp.ForcedDeviceScaleFactor <> 0) then
|
||||||
FForcedDeviceScaleFactor := GlobalCEFApp.ForcedDeviceScaleFactor
|
FForcedDeviceScaleFactor := GlobalCEFApp.ForcedDeviceScaleFactor
|
||||||
@@ -353,6 +356,7 @@ begin
|
|||||||
inherited AfterConstruction;
|
inherited AfterConstruction;
|
||||||
|
|
||||||
CreateSyncObj;
|
CreateSyncObj;
|
||||||
|
UpdateDeviceScaleFactor;
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
{$IFNDEF FPC}
|
{$IFNDEF FPC}
|
||||||
@@ -874,6 +878,14 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBufferPanel.UpdateDeviceScaleFactor;
|
||||||
|
var
|
||||||
|
TempScale : single;
|
||||||
|
begin
|
||||||
|
if GetRealScreenScale(TempScale) then
|
||||||
|
FDeviceScaleFactor := TempScale;
|
||||||
|
end;
|
||||||
|
|
||||||
function TBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean;
|
function TBufferPanel.GetRealScreenScale(var aResultScale : single) : boolean;
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
var
|
var
|
||||||
@@ -909,11 +921,10 @@ begin
|
|||||||
ReleaseDC(TempHandle, TempDC);
|
ReleaseDC(TempHandle, TempDC);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
{$ENDIF}
|
||||||
|
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
if (MainThreadID = GetCurrentThreadId()) then
|
|
||||||
begin
|
|
||||||
TempForm := GetParentForm(self, True);
|
TempForm := GetParentForm(self, True);
|
||||||
|
|
||||||
if (TempForm <> nil) then
|
if (TempForm <> nil) then
|
||||||
@@ -926,21 +937,27 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
{$ELSE}
|
||||||
|
// TODO: Get the screen scale in FMXLinux
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$IFDEF MACOSX}
|
||||||
|
{$IFDEF FPC}
|
||||||
|
// TODO: Get the screen scale in Lazarus/FPC
|
||||||
|
{$ELSE}
|
||||||
|
// TODO: Get the screen scale in FMX
|
||||||
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBufferPanel.GetScreenScale : single;
|
function TBufferPanel.GetScreenScale : single;
|
||||||
var
|
|
||||||
TempScale : single;
|
|
||||||
begin
|
begin
|
||||||
if (FForcedDeviceScaleFactor <> 0) then
|
if (FForcedDeviceScaleFactor <> 0) then
|
||||||
Result := FForcedDeviceScaleFactor
|
Result := FForcedDeviceScaleFactor
|
||||||
else
|
else
|
||||||
if GetRealScreenScale(TempScale) then
|
if (FDeviceScaleFactor <> 0) then
|
||||||
Result := TempScale
|
Result := FDeviceScaleFactor
|
||||||
else
|
else
|
||||||
if (GlobalCEFApp <> nil) then
|
if (GlobalCEFApp <> nil) then
|
||||||
Result := GlobalCEFApp.DeviceScaleFactor
|
Result := GlobalCEFApp.DeviceScaleFactor
|
||||||
|
Reference in New Issue
Block a user