mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Added keyboard support to the FMXExternalPumpBrowser2 demo in Linux thanks to Christoph Schneider
Moved most of the Linux constants, types and functions to new units.
This commit is contained in:
parent
8d5797b01f
commit
77a5766367
@ -125,6 +125,7 @@ object FMXExternalPumpBrowserFrm: TFMXExternalPumpBrowserFrm
|
||||
OnLoadError = chrmosrLoadError
|
||||
OnLoadingStateChange = chrmosrLoadingStateChange
|
||||
OnTooltip = chrmosrTooltip
|
||||
OnCursorChange = chrmosrCursorChange
|
||||
OnBeforePopup = chrmosrBeforePopup
|
||||
OnAfterCreated = chrmosrAfterCreated
|
||||
OnBeforeClose = chrmosrBeforeClose
|
||||
|
@ -49,16 +49,6 @@ uses
|
||||
uCEFInterfaces, uCEFTypes, uCEFConstants, uCEFChromiumCore;
|
||||
|
||||
type
|
||||
PRGBQuad = ^TRGBQuad;
|
||||
tagRGBQUAD = record
|
||||
rgbBlue: Byte;
|
||||
rgbGreen: Byte;
|
||||
rgbRed: Byte;
|
||||
rgbReserved: Byte;
|
||||
end;
|
||||
TRGBQuad = tagRGBQUAD;
|
||||
RGBQUAD = tagRGBQUAD;
|
||||
|
||||
TFMXExternalPumpBrowserFrm = class(TForm)
|
||||
AddressPnl: TPanel;
|
||||
AddressEdt: TEdit;
|
||||
@ -108,12 +98,12 @@ type
|
||||
procedure chrmosrLoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
|
||||
procedure chrmosrLoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring);
|
||||
|
||||
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
procedure AddressEdtEnter(Sender: TObject);
|
||||
|
||||
procedure SnapshotBtnClick(Sender: TObject);
|
||||
procedure SnapshotBtnEnter(Sender: TObject);
|
||||
|
||||
protected
|
||||
FPopUpBitmap : TBitmap;
|
||||
FPopUpRect : TRect;
|
||||
@ -137,6 +127,7 @@ type
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
procedure SendCaptureLostEvent;
|
||||
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
|
||||
procedure SendCEFKeyEvent(const aCefEvent : TCefKeyEvent);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -172,8 +163,40 @@ implementation
|
||||
{$R *.fmx}
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Math, FMX.Platform,
|
||||
uCEFMiscFunctions, uCEFApplication;
|
||||
System.SysUtils, System.Math, FMX.Platform, FMX.Platform.Linux,
|
||||
uCEFMiscFunctions, uCEFApplication, uCEFLinuxTypes, uCEFLinuxConstants,
|
||||
uCEFLinuxFunctions;
|
||||
|
||||
function GTKKeyPress(Widget: PGtkWidget; Event: PGdkEventKey; Data: gPointer) : GBoolean; cdecl;
|
||||
var
|
||||
TempCefEvent : TCefKeyEvent;
|
||||
begin
|
||||
if FMXExternalPumpBrowserFrm.Panel1.IsFocused then
|
||||
begin
|
||||
GdkEventKeyToCEFKeyEvent(Event, TempCefEvent);
|
||||
|
||||
if (Event^._type = GDK_KEY_PRESS) then
|
||||
begin
|
||||
TempCefEvent.kind := KEYEVENT_RAWKEYDOWN;
|
||||
FMXExternalPumpBrowserFrm.SendCEFKeyEvent(TempCefEvent);
|
||||
TempCefEvent.kind := KEYEVENT_CHAR;
|
||||
FMXExternalPumpBrowserFrm.SendCEFKeyEvent(TempCefEvent);
|
||||
end
|
||||
else
|
||||
begin
|
||||
TempCefEvent.kind := KEYEVENT_KEYUP;
|
||||
FMXExternalPumpBrowserFrm.SendCEFKeyEvent(TempCefEvent);
|
||||
end;
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure ConnectKeyPressReleaseEvents(const aWidget : PGtkWidget);
|
||||
begin
|
||||
g_signal_connect(aWidget, 'key-press-event', TGCallback(@GTKKeyPress), nil);
|
||||
g_signal_connect(aWidget, 'key-release-event', TGCallback(@GTKKeyPress), nil);
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.FormActivate(Sender: TObject);
|
||||
var
|
||||
@ -201,13 +224,17 @@ begin
|
||||
end);
|
||||
end
|
||||
else
|
||||
if not(chrmosr.Initialized) then
|
||||
begin
|
||||
// opaque white background color
|
||||
chrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
|
||||
begin
|
||||
ConnectKeyPressReleaseEvents(TLinuxWindowHandle(Handle).NativeHandle);
|
||||
|
||||
if not(chrmosr.CreateBrowser) then Timer1.Enabled := True;
|
||||
end;
|
||||
if not(chrmosr.Initialized) then
|
||||
begin
|
||||
// opaque white background color
|
||||
chrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
|
||||
|
||||
if not(chrmosr.CreateBrowser) then Timer1.Enabled := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
@ -797,6 +824,11 @@ begin
|
||||
if PositionChanged then NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.SendCEFKeyEvent(const aCefEvent : TCefKeyEvent);
|
||||
begin
|
||||
chrmosr.SendKeyEvent(@aCefEvent);
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.NotifyMoveOrResizeStarted;
|
||||
begin
|
||||
if (chrmosr <> nil) then chrmosr.NotifyMoveOrResizeStarted;
|
||||
|
@ -20,9 +20,9 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="187"/>
|
||||
<CursorPos Y="352"/>
|
||||
<FoldState Value=" TJmA1{32 pjZlg1@4 pmOoL1{D1q"/>
|
||||
<TopLine Value="168"/>
|
||||
<CursorPos X="52" Y="196"/>
|
||||
<FoldState Value=" TJmA1{32 pjZlg1@311]B8qW1JF"/>
|
||||
<UsageCount Value="22"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -119,7 +119,7 @@
|
||||
<OtherDefines Count="1">
|
||||
<Define0 Value="UseCThreads"/>
|
||||
</OtherDefines>
|
||||
<JumpHistory Count="5" HistoryIndex="4">
|
||||
<JumpHistory Count="6" HistoryIndex="5">
|
||||
<Position1>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="865" TopLine="829"/>
|
||||
@ -140,6 +140,10 @@
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="222" Column="47" TopLine="210"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="352" TopLine="188"/>
|
||||
</Position6>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
@ -193,7 +193,7 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uCefClient;
|
||||
uCEFMiscFunctions, uCefClient, uCEFLinuxConstants;
|
||||
|
||||
const
|
||||
CEF_UPDATEADDRESS = 1;
|
||||
|
@ -3,11 +3,11 @@
|
||||
<ProjectSession>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="112">
|
||||
<Units Count="113">
|
||||
<Unit0>
|
||||
<Filename Value="OSRExternalPumpBrowser.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<TopLine Value="31"/>
|
||||
<CursorPos X="20" Y="72"/>
|
||||
<UsageCount Value="91"/>
|
||||
@ -21,15 +21,15 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="uOSRExternalPumpBrowser"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="189"/>
|
||||
<CursorPos X="4" Y="199"/>
|
||||
<TopLine Value="177"/>
|
||||
<CursorPos X="21" Y="195"/>
|
||||
<UsageCount Value="91"/>
|
||||
<Bookmarks Count="6">
|
||||
<Item0 Y="704" ID="2"/>
|
||||
<Item1 X="9" Y="602" ID="3"/>
|
||||
<Item2 X="13" Y="315" ID="9"/>
|
||||
<Item3 Y="689" ID="8"/>
|
||||
<Item4 X="41" Y="280" ID="7"/>
|
||||
<Item0 Y="705" ID="2"/>
|
||||
<Item1 X="9" Y="603" ID="3"/>
|
||||
<Item2 X="13" Y="316" ID="9"/>
|
||||
<Item3 Y="690" ID="8"/>
|
||||
<Item4 X="41" Y="281" ID="7"/>
|
||||
<Item5 X="52" Y="187" ID="1"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
@ -94,10 +94,11 @@
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="184"/>
|
||||
<CursorPos X="22" Y="211"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="40"/>
|
||||
<CursorPos X="51" Y="63"/>
|
||||
<UsageCount Value="15"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="/usr/share/lazarus/2.0.10/lcl/interfaces/gtk2/gtk2int.pas"/>
|
||||
@ -145,13 +146,11 @@
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
<Filename Value="../../../source/uCEFApplicationCore.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="340"/>
|
||||
<CursorPos X="40" Y="377"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="604"/>
|
||||
<CursorPos X="71" Y="623"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 X="3" Y="2235" ID="3"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
<Filename Value="../../../source/uCEFApplication.pas"/>
|
||||
@ -826,6 +825,14 @@
|
||||
<CursorPos X="78" Y="45"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit111>
|
||||
<Unit112>
|
||||
<Filename Value="../../../source/uCEFLinuxFunctions.pas"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="62"/>
|
||||
<CursorPos X="19" Y="81"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit112>
|
||||
</Units>
|
||||
<OtherDefines Count="2">
|
||||
<Define0 Value="UseCthreads"/>
|
||||
@ -834,123 +841,123 @@
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="708" TopLine="682"/>
|
||||
<Caret Line="328" Column="58" TopLine="308"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="709" Column="22" TopLine="682"/>
|
||||
<Caret Line="216" Column="77" TopLine="205"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="706" Column="39" TopLine="682"/>
|
||||
<Caret Line="87" Column="22" TopLine="60"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="72" Column="32" TopLine="54"/>
|
||||
<Caret Line="73" Column="13" TopLine="63"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="117" Column="33" TopLine="92"/>
|
||||
<Caret Line="410" Column="3" TopLine="406"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="88" Column="22" TopLine="61"/>
|
||||
<Caret Line="277" Column="73" TopLine="237"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="328" Column="58" TopLine="308"/>
|
||||
<Caret Line="86" Column="24" TopLine="81"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="216" Column="77" TopLine="205"/>
|
||||
<Caret Line="768" TopLine="54"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="87" Column="22" TopLine="60"/>
|
||||
<Caret Line="195" Column="47" TopLine="172"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="73" Column="13" TopLine="63"/>
|
||||
<Caret Line="220" Column="36" TopLine="197"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="410" Column="3" TopLine="406"/>
|
||||
<Caret Line="221" Column="51" TopLine="197"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="277" Column="73" TopLine="237"/>
|
||||
<Caret Line="235" Column="62" TopLine="208"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="86" Column="24" TopLine="81"/>
|
||||
<Caret Line="240" Column="47" TopLine="205"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="768" TopLine="54"/>
|
||||
<Caret Line="331" TopLine="310"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="195" Column="47" TopLine="172"/>
|
||||
<Caret Line="722" TopLine="713"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="220" Column="36" TopLine="197"/>
|
||||
<Caret Line="96" TopLine="74"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="221" Column="51" TopLine="197"/>
|
||||
<Caret Line="95" TopLine="73"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="235" Column="62" TopLine="208"/>
|
||||
<Caret Line="317" Column="82" TopLine="291"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="240" Column="47" TopLine="205"/>
|
||||
<Caret Line="79" Column="15" TopLine="65"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="331" TopLine="310"/>
|
||||
<Caret Line="620" Column="34" TopLine="596"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="722" TopLine="713"/>
|
||||
<Filename Value="OSRExternalPumpBrowser.lpr"/>
|
||||
<Caret Line="72" Column="20" TopLine="31"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="96" TopLine="74"/>
|
||||
<Caret Line="689" TopLine="644"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="95" TopLine="73"/>
|
||||
<Caret Line="687" Column="3" TopLine="644"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="317" Column="82" TopLine="291"/>
|
||||
<Caret Line="231" TopLine="174"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="79" Column="15" TopLine="65"/>
|
||||
<Caret Line="199" Column="4" TopLine="189"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="620" Column="34" TopLine="596"/>
|
||||
<Filename Value="../../../source/uCEFApplicationCore.pas"/>
|
||||
<Caret Line="623" Column="71" TopLine="604"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="OSRExternalPumpBrowser.lpr"/>
|
||||
<Caret Line="72" Column="20" TopLine="31"/>
|
||||
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
|
||||
<Caret Line="70" Column="7" TopLine="39"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="689" TopLine="644"/>
|
||||
<Filename Value="../../../source/uCEFLinuxFunctions.pas"/>
|
||||
<Caret Line="55" Column="19" TopLine="33"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="687" Column="3" TopLine="644"/>
|
||||
<Filename Value="../../../source/uCEFMiscFunctions.pas"/>
|
||||
<Caret Line="74" Column="66" TopLine="39"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="uosrexternalpumpbrowser.pas"/>
|
||||
<Caret Line="231" TopLine="174"/>
|
||||
<Caret Line="191" Column="60" TopLine="189"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
|
@ -191,7 +191,8 @@ implementation
|
||||
|
||||
uses
|
||||
Math, gtk2, glib2, gdk2, gtk2proc, gtk2int,
|
||||
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer, uCEFWorkScheduler;
|
||||
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer, uCEFWorkScheduler,
|
||||
uCEFLinuxFunctions;
|
||||
|
||||
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
|
||||
begin
|
||||
|
@ -20,8 +20,8 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="uSimpleOSRBrowser"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="187"/>
|
||||
<CursorPos X="72" Y="225"/>
|
||||
<TopLine Value="213"/>
|
||||
<CursorPos X="78" Y="229"/>
|
||||
<UsageCount Value="83"/>
|
||||
<Bookmarks Count="2">
|
||||
<Item0 X="49" Y="223" ID="2"/>
|
||||
@ -802,7 +802,7 @@
|
||||
<Define0 Value="UseCthreads"/>
|
||||
<Define1 Value="EnabledGtkThreading"/>
|
||||
</OtherDefines>
|
||||
<JumpHistory Count="20" HistoryIndex="19">
|
||||
<JumpHistory Count="21" HistoryIndex="20">
|
||||
<Position1>
|
||||
<Filename Value="usimpleosrbrowser.pas"/>
|
||||
<Caret Line="56" Column="63" TopLine="51"/>
|
||||
@ -883,6 +883,10 @@
|
||||
<Filename Value="usimpleosrbrowser.pas"/>
|
||||
<Caret Line="85" Column="15" TopLine="68"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="usimpleosrbrowser.pas"/>
|
||||
<Caret Line="225" Column="72" TopLine="187"/>
|
||||
</Position21>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
@ -226,7 +226,7 @@ implementation
|
||||
|
||||
uses
|
||||
Math, gtk2, glib2, gdk2, gtk2proc, gtk2int,
|
||||
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer;
|
||||
uCEFMiscFunctions, uCEFApplication, uCEFBitmapBitBuffer, uCEFLinuxFunctions;
|
||||
|
||||
const
|
||||
CEF_UPDATE_CURSOR = $A0D;
|
||||
|
@ -226,7 +226,10 @@ contains
|
||||
uCEFBitmapBitBuffer in '..\source\uCEFBitmapBitBuffer.pas',
|
||||
uCEFPrintHandler in '..\source\uCEFPrintHandler.pas',
|
||||
uCEFPrintDialogCallback in '..\source\uCEFPrintDialogCallback.pas',
|
||||
uCEFPrintJobCallback in '..\source\uCEFPrintJobCallback.pas';
|
||||
uCEFPrintJobCallback in '..\source\uCEFPrintJobCallback.pas',
|
||||
uCEFLinuxConstants in '..\source\uCEFLinuxConstants.pas',
|
||||
uCEFLinuxTypes in '..\source\uCEFLinuxTypes.pas',
|
||||
uCEFLinuxFunctions in '..\source\uCEFLinuxFunctions.pas';
|
||||
|
||||
end.
|
||||
|
||||
|
@ -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="88" Minor="1" Release="6"/>
|
||||
<Files Count="193">
|
||||
<Files Count="196">
|
||||
<Item1>
|
||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||
<UnitName Value="uCEFAccessibilityHandler"/>
|
||||
@ -811,6 +811,18 @@
|
||||
<Filename Value="..\source\uCEFPrintJobCallback.pas"/>
|
||||
<UnitName Value="uCEFPrintJobCallback"/>
|
||||
</Item193>
|
||||
<Item194>
|
||||
<Filename Value="..\source\uCEFLinuxFunctions.pas"/>
|
||||
<UnitName Value="uCEFLinuxFunctions"/>
|
||||
</Item194>
|
||||
<Item195>
|
||||
<Filename Value="..\source\uCEFLinuxTypes.pas"/>
|
||||
<UnitName Value="uCEFLinuxTypes"/>
|
||||
</Item195>
|
||||
<Item196>
|
||||
<Filename Value="..\source\uCEFLinuxConstants.pas"/>
|
||||
<UnitName Value="uCEFLinuxConstants"/>
|
||||
</Item196>
|
||||
</Files>
|
||||
<RequiredPkgs Count="4">
|
||||
<Item1>
|
||||
|
@ -64,7 +64,7 @@ uses
|
||||
uCEFViewsFrameworkEvents, uCEFAudioHandler, uCEFDevToolsMessageObserver,
|
||||
uCEFMediaSinkDeviceInfoCallback, uCEFJson, uCEFBitmapBitBuffer,
|
||||
uCEFPrintDialogCallback, uCEFPrintHandler, uCEFPrintJobCallback,
|
||||
LazarusPackageIntf;
|
||||
uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -620,7 +620,7 @@ uses
|
||||
Math, {$IFDEF DELPHI14_UP}IOUtils,{$ENDIF} SysUtils,
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF MSWINDOWS}jwatlhelp32, jwapsapi,{$ENDIF}
|
||||
{$IFDEF LINUX}lcltype, Forms, InterfaceBase,{$ENDIF}
|
||||
{$IFDEF LINUX}lcltype, Forms, InterfaceBase, uCEFLinuxFunctions,{$ENDIF}
|
||||
{$ELSE}
|
||||
TlHelp32, {$IFDEF MSWINDOWS}PSAPI,{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
File diff suppressed because it is too large
Load Diff
4045
source/uCEFLinuxConstants.pas
Normal file
4045
source/uCEFLinuxConstants.pas
Normal file
File diff suppressed because it is too large
Load Diff
640
source/uCEFLinuxFunctions.pas
Normal file
640
source/uCEFLinuxFunctions.pas
Normal file
@ -0,0 +1,640 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFLinuxFunctions;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF LINUX}
|
||||
{$IFDEF FPC}
|
||||
ctypes, keysym, xf86keysym, x, xlib,
|
||||
{$IFDEF LCLGTK2}gtk2, glib2, gdk2, gtk2proc, gtk2int, Gtk2Def, gdk2x, Gtk2Extra,{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
uCEFLinuxTypes, uCEFTypes;
|
||||
|
||||
{$IFDEF LINUX}
|
||||
procedure GdkEventKeyToCEFKeyEvent(GdkEvent: PGdkEventKey; var aCEFKeyEvent : TCEFKeyEvent);
|
||||
function KeyboardCodeFromXKeysym(keysym : uint32) : integer;
|
||||
function GetCefStateModifiers(state : uint32) : integer;
|
||||
function GdkEventToWindowsKeyCode(Event: PGdkEventKey) : integer;
|
||||
function GetWindowsKeyCodeWithoutLocation(key_code : integer) : integer;
|
||||
function GetControlCharacter(windows_key_code : integer; shift : boolean) : integer;
|
||||
{$IFDEF FMX}
|
||||
function gdk_keyval_to_unicode(keyval: guint): guint32; cdecl; external 'libgdk-3.so';
|
||||
function g_signal_connect_data(instance: gpointer; detailed_signal: Pgchar; c_handler: TGCallback; data: gpointer; destroy_data: TGClosureNotify; connect_flags: TGConnectFlags): gulong; cdecl; external 'libgobject-2.0.so';
|
||||
function g_signal_connect(instance: gpointer; detailed_signal: Pgchar; c_handler: TGCallback; data: gpointer): gulong; overload;
|
||||
function g_signal_connect(instance: gpointer; const detailed_signal: AnsiString; c_handler: TGCallback; data: gpointer): gulong; overload;
|
||||
{$ENDIF}
|
||||
{$IFDEF FPC}
|
||||
procedure ShowX11Message(const aMessage : string);
|
||||
{$ENDIF}{$ENDIF}
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.SysUtils,
|
||||
{$ELSE}
|
||||
SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFLinuxConstants, uCEFConstants;
|
||||
|
||||
{$IFDEF LINUX}
|
||||
function KeyboardCodeFromXKeysym(keysym : uint32) : integer;
|
||||
begin
|
||||
case keysym of
|
||||
XK_BackSpace:
|
||||
Result := VKEY_BACK;
|
||||
XK_Delete,
|
||||
XK_KP_Delete:
|
||||
Result := VKEY_DELETE;
|
||||
XK_Tab,
|
||||
XK_KP_Tab,
|
||||
XK_ISO_Left_Tab,
|
||||
XK_3270_BackTab:
|
||||
Result := VKEY_TAB;
|
||||
XK_Linefeed,
|
||||
XK_Return,
|
||||
XK_KP_Enter,
|
||||
XK_ISO_Enter:
|
||||
Result := VKEY_Return;
|
||||
XK_Clear,
|
||||
XK_KP_Begin:
|
||||
Result := VKEY_CLEAR;
|
||||
XK_KP_Space,
|
||||
XK_space:
|
||||
Result := VKEY_SPACE;
|
||||
XK_Home,
|
||||
XK_KP_Home:
|
||||
Result := VKEY_HOME;
|
||||
XK_End,
|
||||
XK_KP_End:
|
||||
Result := VKEY_END;
|
||||
XK_Page_Up,
|
||||
XK_KP_Page_Up:
|
||||
Result := VKEY_PRIOR;
|
||||
XK_Page_Down,
|
||||
XK_KP_Page_Down:
|
||||
Result := VKEY_NEXT;
|
||||
XK_Left,
|
||||
XK_KP_Left:
|
||||
Result := VKEY_LEFT;
|
||||
XK_Right,
|
||||
XK_KP_Right:
|
||||
Result := VKEY_RIGHT;
|
||||
XK_Down,
|
||||
XK_KP_Down:
|
||||
Result := VKEY_DOWN;
|
||||
XK_Up,
|
||||
XK_KP_Up:
|
||||
Result := VKEY_UP;
|
||||
XK_Escape:
|
||||
Result := VKEY_ESCAPE;
|
||||
XK_Kana_Lock,
|
||||
XK_Kana_Shift:
|
||||
Result := VKEY_KANA;
|
||||
XK_Hangul:
|
||||
Result := VKEY_HANGUL;
|
||||
XK_Hangul_Hanja:
|
||||
Result := VKEY_HANJA;
|
||||
XK_Kanji:
|
||||
Result := VKEY_KANJI;
|
||||
XK_Henkan:
|
||||
Result := VKEY_CONVERT;
|
||||
XK_Muhenkan:
|
||||
Result := VKEY_NONCONVERT;
|
||||
XK_Zenkaku_Hankaku:
|
||||
Result := VKEY_DBE_DBCSCHAR;
|
||||
XKc_A,
|
||||
XK_a:
|
||||
Result := VKEY_A;
|
||||
XKc_B,
|
||||
XK_b:
|
||||
Result := VKEY_B;
|
||||
XKc_C,
|
||||
XK_c:
|
||||
Result := VKEY_C;
|
||||
XKc_D,
|
||||
XK_d:
|
||||
Result := VKEY_D;
|
||||
XKc_E,
|
||||
XK_e:
|
||||
Result := VKEY_E;
|
||||
XKc_F,
|
||||
XK_f:
|
||||
Result := VKEY_F;
|
||||
XKc_G,
|
||||
XK_g:
|
||||
Result := VKEY_G;
|
||||
XKc_H,
|
||||
XK_h:
|
||||
Result := VKEY_H;
|
||||
XKc_I,
|
||||
XK_i:
|
||||
Result := VKEY_I;
|
||||
XKc_J,
|
||||
XK_j:
|
||||
Result := VKEY_J;
|
||||
XKc_K,
|
||||
XK_k:
|
||||
Result := VKEY_K;
|
||||
XKc_L,
|
||||
XK_l:
|
||||
Result := VKEY_L;
|
||||
XKc_M,
|
||||
XK_m:
|
||||
Result := VKEY_M;
|
||||
XKc_N,
|
||||
XK_n:
|
||||
Result := VKEY_N;
|
||||
XKc_O,
|
||||
XK_o:
|
||||
Result := VKEY_O;
|
||||
XKc_P,
|
||||
XK_p:
|
||||
Result := VKEY_P;
|
||||
XKc_Q,
|
||||
XK_q:
|
||||
Result := VKEY_Q;
|
||||
XKc_R,
|
||||
XK_r:
|
||||
Result := VKEY_R;
|
||||
XKc_S,
|
||||
XK_s:
|
||||
Result := VKEY_S;
|
||||
XKc_T,
|
||||
XK_t:
|
||||
Result := VKEY_T;
|
||||
XKc_U,
|
||||
XK_u:
|
||||
Result := VKEY_U;
|
||||
XKc_V,
|
||||
XK_v:
|
||||
Result := VKEY_V;
|
||||
XKc_W,
|
||||
XK_w:
|
||||
Result := VKEY_W;
|
||||
XKc_X,
|
||||
XK_x:
|
||||
Result := VKEY_X;
|
||||
XKc_Y,
|
||||
XK_y:
|
||||
Result := VKEY_Y;
|
||||
XKc_Z,
|
||||
XK_z:
|
||||
Result := VKEY_Z;
|
||||
XK_0,
|
||||
XK_1,
|
||||
XK_2,
|
||||
XK_3,
|
||||
XK_4,
|
||||
XK_5,
|
||||
XK_6,
|
||||
XK_7,
|
||||
XK_8,
|
||||
XK_9:
|
||||
Result := VKEY_0 + (keysym - XK_0);
|
||||
XK_parenright:
|
||||
Result := VKEY_0;
|
||||
XK_exclam:
|
||||
Result := VKEY_1;
|
||||
XK_at:
|
||||
Result := VKEY_2;
|
||||
XK_numbersign:
|
||||
Result := VKEY_3;
|
||||
XK_dollar:
|
||||
Result := VKEY_4;
|
||||
XK_percent:
|
||||
Result := VKEY_5;
|
||||
XK_asciicircum:
|
||||
Result := VKEY_6;
|
||||
XK_ampersand:
|
||||
Result := VKEY_7;
|
||||
XK_asterisk:
|
||||
Result := VKEY_8;
|
||||
XK_parenleft:
|
||||
Result := VKEY_9;
|
||||
XK_KP_0,
|
||||
XK_KP_1,
|
||||
XK_KP_2,
|
||||
XK_KP_3,
|
||||
XK_KP_4,
|
||||
XK_KP_5,
|
||||
XK_KP_6,
|
||||
XK_KP_7,
|
||||
XK_KP_8,
|
||||
XK_KP_9:
|
||||
Result := VKEY_NUMPAD0 + (keysym - XK_KP_0);
|
||||
XK_multiply,
|
||||
XK_KP_Multiply:
|
||||
Result := VKEY_MULTIPLY;
|
||||
XK_KP_Add:
|
||||
Result := VKEY_ADD;
|
||||
XK_KP_Separator:
|
||||
Result := VKEY_SEPARATOR;
|
||||
XK_KP_Subtract:
|
||||
Result := VKEY_SUBTRACT;
|
||||
XK_KP_Decimal:
|
||||
Result := VKEY_DECIMAL;
|
||||
XK_KP_Divide:
|
||||
Result := VKEY_DIVIDE;
|
||||
XK_KP_Equal,
|
||||
XK_equal,
|
||||
XK_plus:
|
||||
Result := VKEY_OEM_PLUS;
|
||||
XK_comma,
|
||||
XK_less:
|
||||
Result := VKEY_OEM_COMMA;
|
||||
XK_minus,
|
||||
XK_underscore:
|
||||
Result := VKEY_OEM_MINUS;
|
||||
XK_greater,
|
||||
XK_period:
|
||||
Result := VKEY_OEM_PERIOD;
|
||||
XK_colon,
|
||||
XK_semicolon:
|
||||
Result := VKEY_OEM_1;
|
||||
XK_question,
|
||||
XK_slash:
|
||||
Result := VKEY_OEM_2;
|
||||
XK_asciitilde,
|
||||
XK_quoteleft:
|
||||
Result := VKEY_OEM_3;
|
||||
XK_bracketleft,
|
||||
XK_braceleft:
|
||||
Result := VKEY_OEM_4;
|
||||
XK_backslash,
|
||||
XK_bar:
|
||||
Result := VKEY_OEM_5;
|
||||
XK_bracketright,
|
||||
XK_braceright:
|
||||
Result := VKEY_OEM_6;
|
||||
XK_quoteright,
|
||||
XK_quotedbl:
|
||||
Result := VKEY_OEM_7;
|
||||
XK_ISO_Level5_Shift:
|
||||
Result := VKEY_OEM_8;
|
||||
XK_Shift_L,
|
||||
XK_Shift_R:
|
||||
Result := VKEY_SHIFT;
|
||||
XK_Control_L,
|
||||
XK_Control_R:
|
||||
Result := VKEY_CONTROL;
|
||||
XK_Meta_L,
|
||||
XK_Meta_R,
|
||||
XK_Alt_L,
|
||||
XK_Alt_R:
|
||||
Result := VKEY_MENU;
|
||||
XK_ISO_Level3_Shift:
|
||||
Result := VKEY_ALTGR;
|
||||
XK_Multi_key:
|
||||
Result := VKEY_COMPOSE;
|
||||
XK_Pause:
|
||||
Result := VKEY_PAUSE;
|
||||
XK_Caps_Lock:
|
||||
Result := VKEY_CAPITAL;
|
||||
XK_Num_Lock:
|
||||
Result := VKEY_NUMLOCK;
|
||||
XK_Scroll_Lock:
|
||||
Result := VKEY_SCROLL;
|
||||
XK_Select:
|
||||
Result := VKEY_SELECT;
|
||||
XK_Print:
|
||||
Result := VKEY_PRINT;
|
||||
XK_Execute:
|
||||
Result := VKEY_EXECUTE;
|
||||
XK_Insert,
|
||||
XK_KP_Insert:
|
||||
Result := VKEY_INSERT;
|
||||
XK_Help:
|
||||
Result := VKEY_HELP;
|
||||
XK_Super_L:
|
||||
Result := VKEY_LWIN;
|
||||
XK_Super_R:
|
||||
Result := VKEY_RWIN;
|
||||
XK_Menu:
|
||||
Result := VKEY_APPS;
|
||||
XK_F1,
|
||||
XK_F2,
|
||||
XK_F3,
|
||||
XK_F4,
|
||||
XK_F5,
|
||||
XK_F6,
|
||||
XK_F7,
|
||||
XK_F8,
|
||||
XK_F9,
|
||||
XK_F10,
|
||||
XK_F11,
|
||||
XK_F12,
|
||||
XK_F13,
|
||||
XK_F14,
|
||||
XK_F15,
|
||||
XK_F16,
|
||||
XK_F17,
|
||||
XK_F18,
|
||||
XK_F19,
|
||||
XK_F20,
|
||||
XK_F21,
|
||||
XK_F22,
|
||||
XK_F23,
|
||||
XK_F24:
|
||||
Result := VKEY_F1 + (keysym - XK_F1);
|
||||
XK_KP_F1,
|
||||
XK_KP_F2,
|
||||
XK_KP_F3,
|
||||
XK_KP_F4:
|
||||
Result := VKEY_F1 + (keysym - XK_KP_F1);
|
||||
XK_guillemotleft,
|
||||
XK_guillemotright,
|
||||
XK_degree,
|
||||
XK_ugrave,
|
||||
XKc_Ugrave,
|
||||
XK_brokenbar:
|
||||
Result := VKEY_OEM_102;
|
||||
XF86XK_Tools:
|
||||
Result := VKEY_F13;
|
||||
XF86XK_Launch5:
|
||||
Result := VKEY_F14;
|
||||
XF86XK_Launch6:
|
||||
Result := VKEY_F15;
|
||||
XF86XK_Launch7:
|
||||
Result := VKEY_F16;
|
||||
XF86XK_Launch8:
|
||||
Result := VKEY_F17;
|
||||
XF86XK_Launch9:
|
||||
Result := VKEY_F18;
|
||||
XF86XK_Refresh,
|
||||
XF86XK_History,
|
||||
XF86XK_OpenURL,
|
||||
XF86XK_AddFavorite,
|
||||
XF86XK_Go,
|
||||
XF86XK_ZoomIn,
|
||||
XF86XK_ZoomOut:
|
||||
Result := VKEY_UNKNOWN;
|
||||
XF86XK_Back:
|
||||
Result := VKEY_BROWSER_BACK;
|
||||
XF86XK_Forward:
|
||||
Result := VKEY_BROWSER_FORWARD;
|
||||
XF86XK_Reload:
|
||||
Result := VKEY_BROWSER_REFRESH;
|
||||
XF86XK_Stop:
|
||||
Result := VKEY_BROWSER_STOP;
|
||||
XF86XK_Search:
|
||||
Result := VKEY_BROWSER_SEARCH;
|
||||
XF86XK_Favorites:
|
||||
Result := VKEY_BROWSER_FAVORITES;
|
||||
XF86XK_HomePage:
|
||||
Result := VKEY_BROWSER_HOME;
|
||||
XF86XK_AudioMute:
|
||||
Result := VKEY_VOLUME_MUTE;
|
||||
XF86XK_AudioLowerVolume:
|
||||
Result := VKEY_VOLUME_DOWN;
|
||||
XF86XK_AudioRaiseVolume:
|
||||
Result := VKEY_VOLUME_UP;
|
||||
XF86XK_AudioNext:
|
||||
Result := VKEY_MEDIA_NEXT_TRACK;
|
||||
XF86XK_AudioPrev:
|
||||
Result := VKEY_MEDIA_PREV_TRACK;
|
||||
XF86XK_AudioStop:
|
||||
Result := VKEY_MEDIA_STOP;
|
||||
XF86XK_AudioPlay:
|
||||
Result := VKEY_MEDIA_PLAY_PAUSE;
|
||||
XF86XK_Mail:
|
||||
Result := VKEY_MEDIA_LAUNCH_MAIL;
|
||||
XF86XK_LaunchA:
|
||||
Result := VKEY_MEDIA_LAUNCH_APP1;
|
||||
XF86XK_LaunchB,
|
||||
XF86XK_Calculator:
|
||||
Result := VKEY_MEDIA_LAUNCH_APP2;
|
||||
XF86XK_WLAN:
|
||||
Result := VKEY_WLAN;
|
||||
XF86XK_PowerOff:
|
||||
Result := VKEY_POWER;
|
||||
XF86XK_MonBrightnessDown:
|
||||
Result := VKEY_BRIGHTNESS_DOWN;
|
||||
XF86XK_MonBrightnessUp:
|
||||
Result := VKEY_BRIGHTNESS_UP;
|
||||
XF86XK_KbdBrightnessDown:
|
||||
Result := VKEY_KBD_BRIGHTNESS_DOWN;
|
||||
XF86XK_KbdBrightnessUp:
|
||||
Result := VKEY_KBD_BRIGHTNESS_UP;
|
||||
else Result := VKEY_UNKNOWN;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetCefStateModifiers(state : uint32) : integer;
|
||||
begin
|
||||
Result := EVENTFLAG_NONE;
|
||||
|
||||
if ((state and GDK_SHIFT_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_SHIFT_DOWN;
|
||||
|
||||
if ((state and GDK_LOCK_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_CAPS_LOCK_ON;
|
||||
|
||||
if ((state and GDK_CONTROL_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_CONTROL_DOWN;
|
||||
|
||||
if ((state and GDK_MOD1_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_ALT_DOWN;
|
||||
|
||||
if ((state and GDK_BUTTON1_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_LEFT_MOUSE_BUTTON;
|
||||
|
||||
if ((state and GDK_BUTTON2_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_MIDDLE_MOUSE_BUTTON;
|
||||
|
||||
if ((state and GDK_BUTTON3_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_RIGHT_MOUSE_BUTTON;
|
||||
end;
|
||||
|
||||
function GdkEventToWindowsKeyCode(event: PGdkEventKey) : integer;
|
||||
var
|
||||
windows_key_code, keyval : integer;
|
||||
begin
|
||||
windows_key_code := KeyboardCodeFromXKeysym(event^.keyval);
|
||||
if (windows_key_code <> 0) then
|
||||
begin
|
||||
Result := windows_key_code;
|
||||
exit;
|
||||
end;
|
||||
|
||||
if (event^.hardware_keycode < length(kHardwareCodeToGDKKeyval)) then
|
||||
begin
|
||||
keyval := kHardwareCodeToGDKKeyval[event^.hardware_keycode];
|
||||
if (keyval <> 0) then
|
||||
begin
|
||||
Result := KeyboardCodeFromXKeysym(keyval);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
Result := KeyboardCodeFromXKeysym(event^.keyval);
|
||||
end;
|
||||
|
||||
function GetWindowsKeyCodeWithoutLocation(key_code : integer) : integer;
|
||||
begin
|
||||
case key_code of
|
||||
VKEY_LCONTROL, VKEY_RCONTROL : Result := VKEY_CONTROL;
|
||||
VKEY_LSHIFT, VKEY_RSHIFT : Result := VKEY_SHIFT;
|
||||
VKEY_LMENU, VKEY_RMENU : Result := VKEY_MENU;
|
||||
else Result := key_code;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetControlCharacter(windows_key_code : integer; shift : boolean) : integer;
|
||||
begin
|
||||
if (windows_key_code >= VKEY_A) and (windows_key_code <= VKEY_Z) then
|
||||
Result := windows_key_code - VKEY_A + 1
|
||||
else
|
||||
if shift then
|
||||
case windows_key_code of
|
||||
VKEY_2 : Result := 0;
|
||||
VKEY_6 : Result := $1E;
|
||||
VKEY_OEM_MINUS : Result := $1F;
|
||||
else Result := 0;
|
||||
end
|
||||
else
|
||||
case windows_key_code of
|
||||
VKEY_OEM_4 : Result := $1B;
|
||||
VKEY_OEM_5 : Result := $1C;
|
||||
VKEY_OEM_6 : Result := $1D;
|
||||
VKEY_RETURN : Result := $0A;
|
||||
else Result := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure GdkEventKeyToCEFKeyEvent(GdkEvent: PGdkEventKey; var aCEFKeyEvent : TCEFKeyEvent);
|
||||
var
|
||||
windows_key_code : integer;
|
||||
begin
|
||||
windows_key_code := GdkEventToWindowsKeyCode(GdkEvent);
|
||||
aCEFKeyEvent.windows_key_code := GetWindowsKeyCodeWithoutLocation(windows_key_code);
|
||||
aCEFKeyEvent.native_key_code := GdkEvent^.hardware_keycode;
|
||||
aCEFKeyEvent.modifiers := GetCefStateModifiers(GdkEvent^.state);
|
||||
aCEFKeyEvent.focus_on_editable_field := 0;
|
||||
|
||||
if (GdkEvent^.keyval >= GDK_KP_Space) and (GdkEvent^.keyval <= GDK_KP_9) then
|
||||
aCEFKeyEvent.modifiers := aCEFKeyEvent.modifiers or EVENTFLAG_IS_KEY_PAD;
|
||||
|
||||
aCEFKeyEvent.is_system_key := ord((aCEFKeyEvent.modifiers and EVENTFLAG_ALT_DOWN) <> 0);
|
||||
|
||||
if (windows_key_code = VKEY_RETURN) then
|
||||
aCEFKeyEvent.unmodified_character := #13
|
||||
else
|
||||
aCEFKeyEvent.unmodified_character := WideChar(gdk_keyval_to_unicode(GdkEvent^.keyval));
|
||||
|
||||
if ((aCEFKeyEvent.modifiers and EVENTFLAG_CONTROL_DOWN) <> 0) then
|
||||
aCEFKeyEvent.character := WideChar(GetControlCharacter(windows_key_code, ((aCEFKeyEvent.modifiers and EVENTFLAG_SHIFT_DOWN) <> 0)))
|
||||
else
|
||||
aCEFKeyEvent.character := aCEFKeyEvent.unmodified_character;
|
||||
end;
|
||||
|
||||
{$IFDEF FMX}
|
||||
function g_signal_connect(instance: gpointer; detailed_signal: Pgchar; c_handler: TGCallback; data: gpointer): gulong;
|
||||
begin
|
||||
Result := g_signal_connect_data(instance, detailed_signal, c_handler, data, nil, TGConnectFlags(0));
|
||||
end;
|
||||
|
||||
function g_signal_connect(instance: gpointer; const detailed_signal: AnsiString; c_handler: TGCallback; data: gpointer): gulong;
|
||||
begin
|
||||
Result := g_signal_connect(instance, @detailed_signal[1], c_handler, data);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
// This function is almost an identical copy of "ModalShowX11Window" available
|
||||
// at https://wiki.lazarus.freepascal.org/X11
|
||||
procedure ShowX11Message(const aMessage : string);
|
||||
var
|
||||
TempDisplay : PDisplay;
|
||||
TempWindow : TWindow;
|
||||
TempEvent : TXEvent;
|
||||
TempMessage : PChar;
|
||||
TempScreen : cint;
|
||||
begin
|
||||
TempMessage := PChar(trim(copy(aMessage, 1, pred(pos(#13, aMessage)))));
|
||||
TempDisplay := XOpenDisplay(nil);
|
||||
|
||||
if (TempDisplay = nil) then
|
||||
begin
|
||||
WriteLn(aMessage);
|
||||
exit;
|
||||
end;
|
||||
|
||||
TempScreen := DefaultScreen(TempDisplay);
|
||||
TempWindow := XCreateSimpleWindow(TempDisplay,
|
||||
RootWindow(TempDisplay, TempScreen),
|
||||
10, 10, 200, 100, 1,
|
||||
BlackPixel(TempDisplay, TempScreen),
|
||||
WhitePixel(TempDisplay, TempScreen));
|
||||
|
||||
XSelectInput(TempDisplay, TempWindow, ExposureMask or KeyPressMask);
|
||||
|
||||
XMapWindow(TempDisplay, TempWindow);
|
||||
|
||||
while (True) do
|
||||
begin
|
||||
XNextEvent(TempDisplay, @TempEvent);
|
||||
|
||||
if (TempEvent._type = Expose) then
|
||||
XDrawString(TempDisplay,
|
||||
TempWindow,
|
||||
DefaultGC(TempDisplay, TempScreen),
|
||||
40, 50,
|
||||
TempMessage,
|
||||
strlen(TempMessage));
|
||||
|
||||
if (TempEvent._type = KeyPress) then Break;
|
||||
end;
|
||||
|
||||
XCloseDisplay(TempDisplay);
|
||||
end;
|
||||
{$ENDIF}{$ENDIF}
|
||||
|
||||
end.
|
130
source/uCEFLinuxTypes.pas
Normal file
130
source/uCEFLinuxTypes.pas
Normal file
@ -0,0 +1,130 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFLinuxTypes;
|
||||
|
||||
interface
|
||||
|
||||
{$IFDEF LINUX}
|
||||
{$IFDEF FMX}
|
||||
type
|
||||
// https://developer.gnome.org/glib/stable/glib-Basic-Types.htm
|
||||
gboolean = longbool;
|
||||
gpointer = pointer;
|
||||
gconstpointer = pointer;
|
||||
gchar = ansichar;
|
||||
guchar = byte;
|
||||
gint = integer;
|
||||
guint = cardinal;
|
||||
gshort = smallint;
|
||||
gushort = word;
|
||||
gulong = uint64;
|
||||
glong = int64;
|
||||
gint8 = shortint;
|
||||
guint8 = byte;
|
||||
gint16 = int16;
|
||||
guint16 = uint16;
|
||||
gint32 = int32;
|
||||
guint32 = uint32;
|
||||
gint64 = int64;
|
||||
guint64 = uint64;
|
||||
gfloat = single;
|
||||
gdouble = double;
|
||||
gsize = NativeUInt;
|
||||
gssize = NativeInt;
|
||||
goffset = gint64;
|
||||
gintptr = NativeInt;
|
||||
guintptr = NativeUInt;
|
||||
Pgchar = ^gchar;
|
||||
PGData = pointer;
|
||||
PGClosure = pointer;
|
||||
TGConnectFlags = integer;
|
||||
GType = gulong;
|
||||
PGtkWidget = pointer;
|
||||
TGdkEventType = int32;
|
||||
PGdkEventKey = ^TGdkEventKey;
|
||||
|
||||
PGTypeClass = ^TGTypeClass;
|
||||
TGTypeClass = record
|
||||
g_type : GType;
|
||||
end;
|
||||
|
||||
TGTypeInstance = record
|
||||
g_class : PGTypeClass;
|
||||
end;
|
||||
|
||||
TGObject = record
|
||||
g_type_instance : TGTypeInstance;
|
||||
ref_count : guint;
|
||||
qdata : PGData;
|
||||
end;
|
||||
|
||||
TGdkDrawable = record
|
||||
parent_instance : TGObject;
|
||||
end;
|
||||
|
||||
PGdkWindow = ^TGdkWindow;
|
||||
TGdkWindow = TGdkDrawable;
|
||||
TGdkEventKey = record
|
||||
_type : TGdkEventType;
|
||||
window : PGdkWindow;
|
||||
send_event : gint8;
|
||||
time : guint32;
|
||||
state : guint;
|
||||
keyval : guint;
|
||||
length : gint;
|
||||
_string : Pgchar;
|
||||
hardware_keycode : guint16;
|
||||
group : guint8;
|
||||
end;
|
||||
|
||||
TGCallBackProcedure = procedure;
|
||||
TGCallback = procedure (para1: TGCallBackProcedure); cdecl;
|
||||
TGClosureNotify = procedure(data: gpointer; closure: PGClosure); cdecl;
|
||||
|
||||
TRGBQuad = record
|
||||
rgbBlue : Byte;
|
||||
rgbGreen : Byte;
|
||||
rgbRed : Byte;
|
||||
rgbReserved : Byte;
|
||||
end;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
@ -79,31 +79,6 @@ const
|
||||
NTDLL = 'ntdll.dll';
|
||||
User32DLL = 'User32.dll';
|
||||
|
||||
type
|
||||
TOSVersionInfoEx = record
|
||||
dwOSVersionInfoSize: DWORD;
|
||||
dwMajorVersion: DWORD;
|
||||
dwMinorVersion: DWORD;
|
||||
dwBuildNumber: DWORD;
|
||||
dwPlatformId: DWORD;
|
||||
szCSDVersion: array[0..127] of WideChar;
|
||||
wServicePackMajor: WORD;
|
||||
wServicePackMinor: WORD;
|
||||
wSuiteMask: WORD;
|
||||
wProductType: BYTE;
|
||||
wReserved:BYTE;
|
||||
end;
|
||||
{$IFDEF DELPHI14_UP}
|
||||
TDigitizerStatus = record
|
||||
IntegratedTouch : boolean;
|
||||
ExternalTouch : boolean;
|
||||
IntegratedPen : boolean;
|
||||
ExternalPen : boolean;
|
||||
MultiInput : boolean;
|
||||
Ready : boolean;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function CefColorGetA(color: TCefColor): Byte;
|
||||
function CefColorGetR(color: TCefColor): byte;
|
||||
function CefColorGetG(color: TCefColor): Byte;
|
||||
@ -189,7 +164,7 @@ function PathIsURLUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL
|
||||
|
||||
{$IFNDEF DELPHI12_UP}
|
||||
const
|
||||
GWLP_WNDPROC = GWL_WNDPROC;
|
||||
GWLP_WNDPROC = GWL_WNDPROC;
|
||||
GWLP_HWNDPARENT = GWL_HWNDPARENT;
|
||||
{$IFDEF WIN64}
|
||||
function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: int64): int64; stdcall; external user32 name 'SetWindowLongPtrW';
|
||||
@ -312,17 +287,6 @@ function CefGetDataURI(aData : pointer; aSize : integer; const aMimeType : ustri
|
||||
function ValidCefWindowHandle(aHandle : TCefWindowHandle) : boolean;
|
||||
procedure InitializeWindowHandle(var aHandle : TCefWindowHandle);
|
||||
|
||||
{$IFDEF LINUX}{$IFDEF FPC}{$IFDEF LCLGTK2}
|
||||
procedure GdkEventKeyToCEFKeyEvent(GdkEvent: PGdkEventKey; var aCEFKeyEvent : TCEFKeyEvent);
|
||||
function KeyboardCodeFromXKeysym(keysym : cuint) : integer;
|
||||
function GetCefStateModifiers(state : cuint) : integer;
|
||||
function GdkEventToWindowsKeyCode(Event: PGdkEventKey) : integer;
|
||||
function GetWindowsKeyCodeWithoutLocation(key_code : integer) : integer;
|
||||
function GetControlCharacter(windows_key_code : integer; shift : boolean) : integer;
|
||||
{$ENDIF}
|
||||
procedure ShowX11Message(const aMessage : string);
|
||||
{$ENDIF}{$ENDIF}
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -2358,545 +2322,4 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{$IFDEF LINUX}{$IFDEF FPC}{$IFDEF LCLGTK2}
|
||||
function KeyboardCodeFromXKeysym(keysym : cuint) : integer;
|
||||
begin
|
||||
case keysym of
|
||||
XK_BackSpace:
|
||||
Result := VKEY_BACK;
|
||||
XK_Delete,
|
||||
XK_KP_Delete:
|
||||
Result := VKEY_DELETE;
|
||||
XK_Tab,
|
||||
XK_KP_Tab,
|
||||
XK_ISO_Left_Tab,
|
||||
XK_3270_BackTab:
|
||||
Result := VKEY_TAB;
|
||||
XK_Linefeed,
|
||||
XK_Return,
|
||||
XK_KP_Enter,
|
||||
XK_ISO_Enter:
|
||||
Result := VKEY_Return;
|
||||
XK_Clear,
|
||||
XK_KP_Begin:
|
||||
Result := VKEY_CLEAR;
|
||||
XK_KP_Space,
|
||||
XK_space:
|
||||
Result := VKEY_SPACE;
|
||||
XK_Home,
|
||||
XK_KP_Home:
|
||||
Result := VKEY_HOME;
|
||||
XK_End,
|
||||
XK_KP_End:
|
||||
Result := VKEY_END;
|
||||
XK_Page_Up,
|
||||
XK_KP_Page_Up:
|
||||
Result := VKEY_PRIOR;
|
||||
XK_Page_Down,
|
||||
XK_KP_Page_Down:
|
||||
Result := VKEY_NEXT;
|
||||
XK_Left,
|
||||
XK_KP_Left:
|
||||
Result := VKEY_LEFT;
|
||||
XK_Right,
|
||||
XK_KP_Right:
|
||||
Result := VKEY_RIGHT;
|
||||
XK_Down,
|
||||
XK_KP_Down:
|
||||
Result := VKEY_DOWN;
|
||||
XK_Up,
|
||||
XK_KP_Up:
|
||||
Result := VKEY_UP;
|
||||
XK_Escape:
|
||||
Result := VKEY_ESCAPE;
|
||||
XK_Kana_Lock,
|
||||
XK_Kana_Shift:
|
||||
Result := VKEY_KANA;
|
||||
XK_Hangul:
|
||||
Result := VKEY_HANGUL;
|
||||
XK_Hangul_Hanja:
|
||||
Result := VKEY_HANJA;
|
||||
XK_Kanji:
|
||||
Result := VKEY_KANJI;
|
||||
XK_Henkan:
|
||||
Result := VKEY_CONVERT;
|
||||
XK_Muhenkan:
|
||||
Result := VKEY_NONCONVERT;
|
||||
XK_Zenkaku_Hankaku:
|
||||
Result := VKEY_DBE_DBCSCHAR;
|
||||
XKc_A,
|
||||
XK_a:
|
||||
Result := VKEY_A;
|
||||
XKc_B,
|
||||
XK_b:
|
||||
Result := VKEY_B;
|
||||
XKc_C,
|
||||
XK_c:
|
||||
Result := VKEY_C;
|
||||
XKc_D,
|
||||
XK_d:
|
||||
Result := VKEY_D;
|
||||
XKc_E,
|
||||
XK_e:
|
||||
Result := VKEY_E;
|
||||
XKc_F,
|
||||
XK_f:
|
||||
Result := VKEY_F;
|
||||
XKc_G,
|
||||
XK_g:
|
||||
Result := VKEY_G;
|
||||
XKc_H,
|
||||
XK_h:
|
||||
Result := VKEY_H;
|
||||
XKc_I,
|
||||
XK_i:
|
||||
Result := VKEY_I;
|
||||
XKc_J,
|
||||
XK_j:
|
||||
Result := VKEY_J;
|
||||
XKc_K,
|
||||
XK_k:
|
||||
Result := VKEY_K;
|
||||
XKc_L,
|
||||
XK_l:
|
||||
Result := VKEY_L;
|
||||
XKc_M,
|
||||
XK_m:
|
||||
Result := VKEY_M;
|
||||
XKc_N,
|
||||
XK_n:
|
||||
Result := VKEY_N;
|
||||
XKc_O,
|
||||
XK_o:
|
||||
Result := VKEY_O;
|
||||
XKc_P,
|
||||
XK_p:
|
||||
Result := VKEY_P;
|
||||
XKc_Q,
|
||||
XK_q:
|
||||
Result := VKEY_Q;
|
||||
XKc_R,
|
||||
XK_r:
|
||||
Result := VKEY_R;
|
||||
XKc_S,
|
||||
XK_s:
|
||||
Result := VKEY_S;
|
||||
XKc_T,
|
||||
XK_t:
|
||||
Result := VKEY_T;
|
||||
XKc_U,
|
||||
XK_u:
|
||||
Result := VKEY_U;
|
||||
XKc_V,
|
||||
XK_v:
|
||||
Result := VKEY_V;
|
||||
XKc_W,
|
||||
XK_w:
|
||||
Result := VKEY_W;
|
||||
XKc_X,
|
||||
XK_x:
|
||||
Result := VKEY_X;
|
||||
XKc_Y,
|
||||
XK_y:
|
||||
Result := VKEY_Y;
|
||||
XKc_Z,
|
||||
XK_z:
|
||||
Result := VKEY_Z;
|
||||
XK_0,
|
||||
XK_1,
|
||||
XK_2,
|
||||
XK_3,
|
||||
XK_4,
|
||||
XK_5,
|
||||
XK_6,
|
||||
XK_7,
|
||||
XK_8,
|
||||
XK_9:
|
||||
Result := VKEY_0 + (keysym - XK_0);
|
||||
XK_parenright:
|
||||
Result := VKEY_0;
|
||||
XK_exclam:
|
||||
Result := VKEY_1;
|
||||
XK_at:
|
||||
Result := VKEY_2;
|
||||
XK_numbersign:
|
||||
Result := VKEY_3;
|
||||
XK_dollar:
|
||||
Result := VKEY_4;
|
||||
XK_percent:
|
||||
Result := VKEY_5;
|
||||
XK_asciicircum:
|
||||
Result := VKEY_6;
|
||||
XK_ampersand:
|
||||
Result := VKEY_7;
|
||||
XK_asterisk:
|
||||
Result := VKEY_8;
|
||||
XK_parenleft:
|
||||
Result := VKEY_9;
|
||||
XK_KP_0,
|
||||
XK_KP_1,
|
||||
XK_KP_2,
|
||||
XK_KP_3,
|
||||
XK_KP_4,
|
||||
XK_KP_5,
|
||||
XK_KP_6,
|
||||
XK_KP_7,
|
||||
XK_KP_8,
|
||||
XK_KP_9:
|
||||
Result := VKEY_NUMPAD0 + (keysym - XK_KP_0);
|
||||
XK_multiply,
|
||||
XK_KP_Multiply:
|
||||
Result := VKEY_MULTIPLY;
|
||||
XK_KP_Add:
|
||||
Result := VKEY_ADD;
|
||||
XK_KP_Separator:
|
||||
Result := VKEY_SEPARATOR;
|
||||
XK_KP_Subtract:
|
||||
Result := VKEY_SUBTRACT;
|
||||
XK_KP_Decimal:
|
||||
Result := VKEY_DECIMAL;
|
||||
XK_KP_Divide:
|
||||
Result := VKEY_DIVIDE;
|
||||
XK_KP_Equal,
|
||||
XK_equal,
|
||||
XK_plus:
|
||||
Result := VKEY_OEM_PLUS;
|
||||
XK_comma,
|
||||
XK_less:
|
||||
Result := VKEY_OEM_COMMA;
|
||||
XK_minus,
|
||||
XK_underscore:
|
||||
Result := VKEY_OEM_MINUS;
|
||||
XK_greater,
|
||||
XK_period:
|
||||
Result := VKEY_OEM_PERIOD;
|
||||
XK_colon,
|
||||
XK_semicolon:
|
||||
Result := VKEY_OEM_1;
|
||||
XK_question,
|
||||
XK_slash:
|
||||
Result := VKEY_OEM_2;
|
||||
XK_asciitilde,
|
||||
XK_quoteleft:
|
||||
Result := VKEY_OEM_3;
|
||||
XK_bracketleft,
|
||||
XK_braceleft:
|
||||
Result := VKEY_OEM_4;
|
||||
XK_backslash,
|
||||
XK_bar:
|
||||
Result := VKEY_OEM_5;
|
||||
XK_bracketright,
|
||||
XK_braceright:
|
||||
Result := VKEY_OEM_6;
|
||||
XK_quoteright,
|
||||
XK_quotedbl:
|
||||
Result := VKEY_OEM_7;
|
||||
XK_ISO_Level5_Shift:
|
||||
Result := VKEY_OEM_8;
|
||||
XK_Shift_L,
|
||||
XK_Shift_R:
|
||||
Result := VKEY_SHIFT;
|
||||
XK_Control_L,
|
||||
XK_Control_R:
|
||||
Result := VKEY_CONTROL;
|
||||
XK_Meta_L,
|
||||
XK_Meta_R,
|
||||
XK_Alt_L,
|
||||
XK_Alt_R:
|
||||
Result := VKEY_MENU;
|
||||
XK_ISO_Level3_Shift:
|
||||
Result := VKEY_ALTGR;
|
||||
XK_Multi_key:
|
||||
Result := VKEY_COMPOSE;
|
||||
XK_Pause:
|
||||
Result := VKEY_PAUSE;
|
||||
XK_Caps_Lock:
|
||||
Result := VKEY_CAPITAL;
|
||||
XK_Num_Lock:
|
||||
Result := VKEY_NUMLOCK;
|
||||
XK_Scroll_Lock:
|
||||
Result := VKEY_SCROLL;
|
||||
XK_Select:
|
||||
Result := VKEY_SELECT;
|
||||
XK_Print:
|
||||
Result := VKEY_PRINT;
|
||||
XK_Execute:
|
||||
Result := VKEY_EXECUTE;
|
||||
XK_Insert,
|
||||
XK_KP_Insert:
|
||||
Result := VKEY_INSERT;
|
||||
XK_Help:
|
||||
Result := VKEY_HELP;
|
||||
XK_Super_L:
|
||||
Result := VKEY_LWIN;
|
||||
XK_Super_R:
|
||||
Result := VKEY_RWIN;
|
||||
XK_Menu:
|
||||
Result := VKEY_APPS;
|
||||
XK_F1,
|
||||
XK_F2,
|
||||
XK_F3,
|
||||
XK_F4,
|
||||
XK_F5,
|
||||
XK_F6,
|
||||
XK_F7,
|
||||
XK_F8,
|
||||
XK_F9,
|
||||
XK_F10,
|
||||
XK_F11,
|
||||
XK_F12,
|
||||
XK_F13,
|
||||
XK_F14,
|
||||
XK_F15,
|
||||
XK_F16,
|
||||
XK_F17,
|
||||
XK_F18,
|
||||
XK_F19,
|
||||
XK_F20,
|
||||
XK_F21,
|
||||
XK_F22,
|
||||
XK_F23,
|
||||
XK_F24:
|
||||
Result := VKEY_F1 + (keysym - XK_F1);
|
||||
XK_KP_F1,
|
||||
XK_KP_F2,
|
||||
XK_KP_F3,
|
||||
XK_KP_F4:
|
||||
Result := VKEY_F1 + (keysym - XK_KP_F1);
|
||||
XK_guillemotleft,
|
||||
XK_guillemotright,
|
||||
XK_degree,
|
||||
XK_ugrave,
|
||||
XKc_Ugrave,
|
||||
XK_brokenbar:
|
||||
Result := VKEY_OEM_102;
|
||||
XF86XK_Tools:
|
||||
Result := VKEY_F13;
|
||||
XF86XK_Launch5:
|
||||
Result := VKEY_F14;
|
||||
XF86XK_Launch6:
|
||||
Result := VKEY_F15;
|
||||
XF86XK_Launch7:
|
||||
Result := VKEY_F16;
|
||||
XF86XK_Launch8:
|
||||
Result := VKEY_F17;
|
||||
XF86XK_Launch9:
|
||||
Result := VKEY_F18;
|
||||
XF86XK_Refresh,
|
||||
XF86XK_History,
|
||||
XF86XK_OpenURL,
|
||||
XF86XK_AddFavorite,
|
||||
XF86XK_Go,
|
||||
XF86XK_ZoomIn,
|
||||
XF86XK_ZoomOut:
|
||||
Result := VKEY_UNKNOWN;
|
||||
XF86XK_Back:
|
||||
Result := VKEY_BROWSER_BACK;
|
||||
XF86XK_Forward:
|
||||
Result := VKEY_BROWSER_FORWARD;
|
||||
XF86XK_Reload:
|
||||
Result := VKEY_BROWSER_REFRESH;
|
||||
XF86XK_Stop:
|
||||
Result := VKEY_BROWSER_STOP;
|
||||
XF86XK_Search:
|
||||
Result := VKEY_BROWSER_SEARCH;
|
||||
XF86XK_Favorites:
|
||||
Result := VKEY_BROWSER_FAVORITES;
|
||||
XF86XK_HomePage:
|
||||
Result := VKEY_BROWSER_HOME;
|
||||
XF86XK_AudioMute:
|
||||
Result := VKEY_VOLUME_MUTE;
|
||||
XF86XK_AudioLowerVolume:
|
||||
Result := VKEY_VOLUME_DOWN;
|
||||
XF86XK_AudioRaiseVolume:
|
||||
Result := VKEY_VOLUME_UP;
|
||||
XF86XK_AudioNext:
|
||||
Result := VKEY_MEDIA_NEXT_TRACK;
|
||||
XF86XK_AudioPrev:
|
||||
Result := VKEY_MEDIA_PREV_TRACK;
|
||||
XF86XK_AudioStop:
|
||||
Result := VKEY_MEDIA_STOP;
|
||||
XF86XK_AudioPlay:
|
||||
Result := VKEY_MEDIA_PLAY_PAUSE;
|
||||
XF86XK_Mail:
|
||||
Result := VKEY_MEDIA_LAUNCH_MAIL;
|
||||
XF86XK_LaunchA:
|
||||
Result := VKEY_MEDIA_LAUNCH_APP1;
|
||||
XF86XK_LaunchB,
|
||||
XF86XK_Calculator:
|
||||
Result := VKEY_MEDIA_LAUNCH_APP2;
|
||||
XF86XK_WLAN:
|
||||
Result := VKEY_WLAN;
|
||||
XF86XK_PowerOff:
|
||||
Result := VKEY_POWER;
|
||||
XF86XK_MonBrightnessDown:
|
||||
Result := VKEY_BRIGHTNESS_DOWN;
|
||||
XF86XK_MonBrightnessUp:
|
||||
Result := VKEY_BRIGHTNESS_UP;
|
||||
XF86XK_KbdBrightnessDown:
|
||||
Result := VKEY_KBD_BRIGHTNESS_DOWN;
|
||||
XF86XK_KbdBrightnessUp:
|
||||
Result := VKEY_KBD_BRIGHTNESS_UP;
|
||||
else Result := VKEY_UNKNOWN;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetCefStateModifiers(state : cuint) : integer;
|
||||
begin
|
||||
Result := EVENTFLAG_NONE;
|
||||
|
||||
if ((state and GDK_SHIFT_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_SHIFT_DOWN;
|
||||
|
||||
if ((state and GDK_LOCK_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_CAPS_LOCK_ON;
|
||||
|
||||
if ((state and GDK_CONTROL_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_CONTROL_DOWN;
|
||||
|
||||
if ((state and GDK_MOD1_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_ALT_DOWN;
|
||||
|
||||
if ((state and GDK_BUTTON1_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_LEFT_MOUSE_BUTTON;
|
||||
|
||||
if ((state and GDK_BUTTON2_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_MIDDLE_MOUSE_BUTTON;
|
||||
|
||||
if ((state and GDK_BUTTON3_MASK) <> 0) then
|
||||
Result := Result or EVENTFLAG_RIGHT_MOUSE_BUTTON;
|
||||
end;
|
||||
|
||||
function GdkEventToWindowsKeyCode(event: PGdkEventKey) : integer;
|
||||
var
|
||||
windows_key_code, keyval : integer;
|
||||
begin
|
||||
windows_key_code := KeyboardCodeFromXKeysym(event^.keyval);
|
||||
if (windows_key_code <> 0) then
|
||||
begin
|
||||
Result := windows_key_code;
|
||||
exit;
|
||||
end;
|
||||
|
||||
if (event^.hardware_keycode < length(kHardwareCodeToGDKKeyval)) then
|
||||
begin
|
||||
keyval := kHardwareCodeToGDKKeyval[event^.hardware_keycode];
|
||||
if (keyval <> 0) then
|
||||
begin
|
||||
Result := KeyboardCodeFromXKeysym(keyval);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
Result := KeyboardCodeFromXKeysym(event^.keyval);
|
||||
end;
|
||||
|
||||
function GetWindowsKeyCodeWithoutLocation(key_code : integer) : integer;
|
||||
begin
|
||||
case key_code of
|
||||
VKEY_LCONTROL, VKEY_RCONTROL : Result := VKEY_CONTROL;
|
||||
VKEY_LSHIFT, VKEY_RSHIFT : Result := VKEY_SHIFT;
|
||||
VKEY_LMENU, VKEY_RMENU : Result := VKEY_MENU;
|
||||
else Result := key_code;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetControlCharacter(windows_key_code : integer; shift : boolean) : integer;
|
||||
begin
|
||||
if (windows_key_code >= VKEY_A) and (windows_key_code <= VKEY_Z) then
|
||||
Result := windows_key_code - VKEY_A + 1
|
||||
else
|
||||
if shift then
|
||||
case windows_key_code of
|
||||
VKEY_2 : Result := 0;
|
||||
VKEY_6 : Result := $1E;
|
||||
VKEY_OEM_MINUS : Result := $1F;
|
||||
else Result := 0;
|
||||
end
|
||||
else
|
||||
case windows_key_code of
|
||||
VKEY_OEM_4 : Result := $1B;
|
||||
VKEY_OEM_5 : Result := $1C;
|
||||
VKEY_OEM_6 : Result := $1D;
|
||||
VKEY_RETURN : Result := $0A;
|
||||
else Result := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure GdkEventKeyToCEFKeyEvent(GdkEvent: PGdkEventKey; var aCEFKeyEvent : TCEFKeyEvent);
|
||||
var
|
||||
windows_key_code : integer;
|
||||
begin
|
||||
windows_key_code := GdkEventToWindowsKeyCode(GdkEvent);
|
||||
aCEFKeyEvent.windows_key_code := GetWindowsKeyCodeWithoutLocation(windows_key_code);
|
||||
aCEFKeyEvent.native_key_code := GdkEvent^.hardware_keycode;
|
||||
aCEFKeyEvent.modifiers := GetCefStateModifiers(GdkEvent^.state);
|
||||
aCEFKeyEvent.focus_on_editable_field := 0;
|
||||
|
||||
if (GdkEvent^.keyval >= GDK_KP_Space) and (GdkEvent^.keyval <= GDK_KP_9) then
|
||||
aCEFKeyEvent.modifiers := aCEFKeyEvent.modifiers or EVENTFLAG_IS_KEY_PAD;
|
||||
|
||||
aCEFKeyEvent.is_system_key := ord((aCEFKeyEvent.modifiers and EVENTFLAG_ALT_DOWN) <> 0);
|
||||
|
||||
if (windows_key_code = VKEY_RETURN) then
|
||||
aCEFKeyEvent.unmodified_character := #13
|
||||
else
|
||||
aCEFKeyEvent.unmodified_character := WideChar(gdk_keyval_to_unicode(GdkEvent^.keyval));
|
||||
|
||||
if ((aCEFKeyEvent.modifiers and EVENTFLAG_CONTROL_DOWN) <> 0) then
|
||||
aCEFKeyEvent.character := WideChar(GetControlCharacter(windows_key_code, ((aCEFKeyEvent.modifiers and EVENTFLAG_SHIFT_DOWN) <> 0)))
|
||||
else
|
||||
aCEFKeyEvent.character := aCEFKeyEvent.unmodified_character;
|
||||
end;
|
||||
|
||||
// This function is almost an identical copy of "ModalShowX11Window" available
|
||||
// at https://wiki.lazarus.freepascal.org/X11
|
||||
procedure ShowX11Message(const aMessage : string);
|
||||
var
|
||||
TempDisplay : PDisplay;
|
||||
TempWindow : TWindow;
|
||||
TempEvent : TXEvent;
|
||||
TempMessage : PChar;
|
||||
TempScreen : cint;
|
||||
begin
|
||||
TempMessage := PChar(trim(copy(aMessage, 1, pred(pos(#13, aMessage)))));
|
||||
TempDisplay := XOpenDisplay(nil);
|
||||
|
||||
if (TempDisplay = nil) then
|
||||
begin
|
||||
WriteLn(aMessage);
|
||||
exit;
|
||||
end;
|
||||
|
||||
TempScreen := DefaultScreen(TempDisplay);
|
||||
TempWindow := XCreateSimpleWindow(TempDisplay,
|
||||
RootWindow(TempDisplay, TempScreen),
|
||||
10, 10, 200, 100, 1,
|
||||
BlackPixel(TempDisplay, TempScreen),
|
||||
WhitePixel(TempDisplay, TempScreen));
|
||||
|
||||
XSelectInput(TempDisplay, TempWindow, ExposureMask or KeyPressMask);
|
||||
|
||||
XMapWindow(TempDisplay, TempWindow);
|
||||
|
||||
while (True) do
|
||||
begin
|
||||
XNextEvent(TempDisplay, @TempEvent);
|
||||
|
||||
if (TempEvent._type = Expose) then
|
||||
XDrawString(TempDisplay,
|
||||
TempWindow,
|
||||
DefaultGC(TempDisplay, TempScreen),
|
||||
40, 50,
|
||||
TempMessage,
|
||||
strlen(TempMessage));
|
||||
|
||||
if (TempEvent._type = KeyPress) then Break;
|
||||
end;
|
||||
|
||||
XCloseDisplay(TempDisplay);
|
||||
end;
|
||||
|
||||
{$ENDIF}{$ENDIF}{$ENDIF}
|
||||
|
||||
end.
|
||||
|
@ -366,6 +366,31 @@ type
|
||||
ullAvailVirtual : uint64;
|
||||
ullAvailExtendedVirtual : uint64;
|
||||
end;
|
||||
|
||||
TOSVersionInfoEx = record
|
||||
dwOSVersionInfoSize: DWORD;
|
||||
dwMajorVersion: DWORD;
|
||||
dwMinorVersion: DWORD;
|
||||
dwBuildNumber: DWORD;
|
||||
dwPlatformId: DWORD;
|
||||
szCSDVersion: array[0..127] of WideChar;
|
||||
wServicePackMajor: WORD;
|
||||
wServicePackMinor: WORD;
|
||||
wSuiteMask: WORD;
|
||||
wProductType: BYTE;
|
||||
wReserved:BYTE;
|
||||
end;
|
||||
|
||||
{$IFDEF DELPHI14_UP}
|
||||
TDigitizerStatus = record
|
||||
IntegratedTouch : boolean;
|
||||
ExternalTouch : boolean;
|
||||
IntegratedPen : boolean;
|
||||
ExternalPen : boolean;
|
||||
MultiInput : boolean;
|
||||
Ready : boolean;
|
||||
end;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
PPSingle = ^PSingle;
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 242,
|
||||
"InternalVersion" : 243,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "88.1.6.0"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user