diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9960ac0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +[*.cs] + +# IDE0056: Use index operator +csharp_style_prefer_index_operator = false:none + +# IDE0055: Fix formatting +dotnet_diagnostic.IDE0055.severity = none + +# Default severity for analyzer diagnostics with category 'Style' +dotnet_analyzer_diagnostic.category-Style.severity = none diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..15098a7 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,51 @@ +name: build & test +on: + push: + branches: + - master + pull_request: + branches: + - master + - development +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 +jobs: + build-windows: + name: build release and debug for windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.300 + - name: build debug + run: | + dotnet build src/Exomia.CEF --configuration Debug --force --nologo -p:Platform=AnyCPU + dotnet build src/Exomia.CEF --configuration Debug --force --nologo -p:Platform=x86 + dotnet build src/Exomia.CEF --configuration Debug --force --nologo -p:Platform=x64 + - name: build release + run: | + dotnet build src/Exomia.CEF --configuration Release --force --nologo -p:Platform=AnyCPU + dotnet build src/Exomia.CEF --configuration Release --force --nologo -p:Platform=x86 + dotnet build src/Exomia.CEF --configuration Release --force --nologo -p:Platform=x64 + test-windows: + name: test release and debug for windows + needs: [build-windows] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.300 + - name: test debug + run: | + dotnet test tests/L0/Exomia.CEF.Tests --configuration Debug --nologo -p:Platform=AnyCPU + dotnet test tests/L0/Exomia.CEF.Tests --configuration Debug --nologo -p:Platform=x86 + dotnet test tests/L0/Exomia.CEF.Tests --configuration Debug --nologo -p:Platform=x64 + - name: test release + run: | + dotnet test tests/L0/Exomia.CEF.Tests --configuration Release --nologo -p:Platform=AnyCPU + dotnet test tests/L0/Exomia.CEF.Tests --configuration Release --nologo -p:Platform=x86 + dotnet test tests/L0/Exomia.CEF.Tests --configuration Release --nologo -p:Platform=x64 \ No newline at end of file diff --git a/.github/workflows/build_test_and_publish.yml b/.github/workflows/build_test_and_publish.yml new file mode 100644 index 0000000..52b3f81 --- /dev/null +++ b/.github/workflows/build_test_and_publish.yml @@ -0,0 +1,92 @@ +name: build, test & publish +on: + release: + types: [published] +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 +jobs: + build-windows: + name: build release and debug for windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.300 + - name: build debug + run: | + dotnet build src/Exomia.CEF --configuration Debug --force --nologo -p:Platform=AnyCPU + dotnet build src/Exomia.CEF --configuration Debug --force --nologo -p:Platform=x86 + dotnet build src/Exomia.CEF --configuration Debug --force --nologo -p:Platform=x64 + - name: build release + run: | + dotnet build src/Exomia.CEF --configuration Release --force --nologo -p:Platform=AnyCPU + dotnet build src/Exomia.CEF --configuration Release --force --nologo -p:Platform=x86 + dotnet build src/Exomia.CEF --configuration Release --force --nologo -p:Platform=x64 + test-windows: + name: test release and debug for windows + needs: [build-windows] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.300 + - name: test debug + run: | + dotnet test tests/L0/Exomia.CEF.Tests --configuration Debug --nologo -p:Platform=AnyCPU + dotnet test tests/L0/Exomia.CEF.Tests --configuration Debug --nologo -p:Platform=x86 + dotnet test tests/L0/Exomia.CEF.Tests --configuration Debug --nologo -p:Platform=x64 + - name: test release + run: | + dotnet test tests/L0/Exomia.CEF.Tests --configuration Release --nologo -p:Platform=AnyCPU + dotnet test tests/L0/Exomia.CEF.Tests --configuration Release --nologo -p:Platform=x86 + dotnet test tests/L0/Exomia.CEF.Tests --configuration Release --nologo -p:Platform=x64 + publish-github-windows: + name: publish debug for windows on github + needs: [test-windows] + if: ${{ github.event_name == 'release' }} + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: extract tag version + run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_ENV + shell: bash + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.301 + - name: publish ${{ github.repository }} [v${{ env.TAG_VERSION }}] + run: | + dotnet pack --configuration Debug --verbosity m --force --nologo -p:Platform=AnyCPU -p:Version=$TAG_VERSION + dotnet pack --configuration Debug --verbosity m --force --nologo -p:Platform=x86 -p:Version=$TAG_VERSION + dotnet pack --configuration Debug --verbosity m --force --nologo -p:Platform=x64 -p:Version=$TAG_VERSION + for f in ./*.nupkg + do + STATUSCODE=$(curl -sSX PUT --retry 3 -o /dev/null -w "%{http_code}" -u "${{ github.repository_owner }}:${{ github.token }}" -F package=@$f https://nuget.pkg.github.com/${{ github.repository_owner }}/) + echo "[$STATUSCODE:https://nuget.pkg.github.com/${{ github.repository_owner }}/] $f" + if [ "${STATUSCODE}" != 200 ] && [ "${STATUSCODE}" != 409 ]; then exit 1; fi + done + shell: bash + working-directory: src/Exomia.CEF + publish-nuget-windows: + name: publish release for windows on nuget + needs: [test-windows, publish-github-windows] + if: ${{ github.event_name == 'release' }} + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: extract tag version + run: echo "TAG_VERSION=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_ENV + shell: bash + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.301 + - name: publish ${{ github.repository }} [v${{ env.TAG_VERSION }}] + run: | + dotnet pack src/Exomia.CEF --configuration Release --verbosity m --force --nologo -p:Platform=AnyCPU -p:Version=$TAG_VERSION + dotnet pack src/Exomia.CEF --configuration Release --verbosity m --force --nologo -p:Platform=x86 -p:Version=$TAG_VERSION + dotnet pack src/Exomia.CEF --configuration Release --verbosity m --force --nologo -p:Platform=x64 -p:Version=$TAG_VERSION + dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.EXOMIA_NUGET_API_KEY_PUSH }} --skip-duplicate + shell: bash diff --git a/Exomia.CEF.sln b/Exomia.CEF.sln index 7fe7f98..1edcb50 100644 --- a/Exomia.CEF.sln +++ b/Exomia.CEF.sln @@ -5,6 +5,15 @@ VisualStudioVersion = 16.0.29709.97 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exomia.CEF", "src\Exomia.CEF\Exomia.CEF.csproj", "{25D9B629-E538-498F-BE33-75D5883164B5}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4DE02C23-CFFF-409D-BA15-B24656DC6712}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Exomia.CEF.Tests", "tests\L0\Exomia.CEF.Tests\Exomia.CEF.Tests.csproj", "{A176B9CC-B4CD-40A3-A733-CDA82076BC0F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BE69773-34D1-456B-9DFE-63B7910C66C8}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,10 +24,17 @@ Global {25D9B629-E538-498F-BE33-75D5883164B5}.Debug|Any CPU.Build.0 = Debug|Any CPU {25D9B629-E538-498F-BE33-75D5883164B5}.Release|Any CPU.ActiveCfg = Release|Any CPU {25D9B629-E538-498F-BE33-75D5883164B5}.Release|Any CPU.Build.0 = Release|Any CPU + {A176B9CC-B4CD-40A3-A733-CDA82076BC0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A176B9CC-B4CD-40A3-A733-CDA82076BC0F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A176B9CC-B4CD-40A3-A733-CDA82076BC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A176B9CC-B4CD-40A3-A733-CDA82076BC0F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A176B9CC-B4CD-40A3-A733-CDA82076BC0F} = {4DE02C23-CFFF-409D-BA15-B24656DC6712} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {014C1820-0280-4D67-8236-9214FCB90B4D} EndGlobalSection diff --git a/LICENSE b/LICENSE index 52d89ff..d1336a4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2018-2019, exomia +Copyright (c) 2018-2021, exomia All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..e0d843a Binary files /dev/null and b/icon.png differ diff --git a/src/Exomia.CEF/CefWrapper.cs b/src/Exomia.CEF/CefWrapper.cs index a67bad8..c247954 100644 --- a/src/Exomia.CEF/CefWrapper.cs +++ b/src/Exomia.CEF/CefWrapper.cs @@ -34,7 +34,7 @@ static CefWrapper() AppDomain.CurrentDomain.AssemblyResolve += (s, args) => { string archSpecificPath = Path.Combine( - AppDomain.CurrentDomain.SetupInformation.ApplicationBase, + AppDomain.CurrentDomain.BaseDirectory, Environment.Is64BitProcess ? "x64" : "x86", args.Name.Split(new[] { ',' }, 2)[0] + ".dll"); return File.Exists(archSpecificPath) ? Assembly.LoadFile(archSpecificPath) @@ -50,7 +50,6 @@ private CefWrapper(Action? overrideCefSettings) { if (!Cef.IsInitialized) { - CefSharpSettings.LegacyJavascriptBindingEnabled = false; CefSharpSettings.ConcurrentTaskExecution = true; CefSharpSettings.ShutdownOnExit = true; CefSharpSettings.SubprocessExitIfParentProcessClosed = true; diff --git a/src/Exomia.CEF/Exomia.CEF.csproj b/src/Exomia.CEF/Exomia.CEF.csproj index e6ca764..eaf7c9d 100644 --- a/src/Exomia.CEF/Exomia.CEF.csproj +++ b/src/Exomia.CEF/Exomia.CEF.csproj @@ -1,46 +1,55 @@ - net471;net472;net48 - exomia + net48 + AnyCPU;x64;x86 + 8.0 + true + + true + enable + true + TRACE;$(Platform) + true + + + + exomia + exomia;saika01 a wrapper around cef for use in the exomia framework to build an ui Copyright © $([System.DateTime]::Now.Year) exomia - 1.1.0.0 + + + https://github.com/exomia/cef true false exomia cef ui framework https://github.com/exomia/cef - AnyCPU;x64;x86 - latest - true git - true . - true - - enable LICENSE https://avatars0.githubusercontent.com/u/37782223 icon.png - true + true + true + + + + true + false + Exomia.CEF.snk - full + portable true - false - NU1605 - DEBUG;TRACE;x86 - DEBUG;TRACE;$(Platform) + true + $(DefineConstants);DEBUG none false - false - NU1605 - TRACE;x86 - TRACE;$(Platform) @@ -53,23 +62,41 @@ $(MSBuildProjectName).$(Platform) + + 1701;1702;IDE0063;IDE0079 + NU1605 + false + + + - + - + - - none - + + - + - + - + + + + true + true + snupkg + True + True + + + + + \ No newline at end of file diff --git a/src/Exomia.CEF/Exomia.CEF.snk b/src/Exomia.CEF/Exomia.CEF.snk new file mode 100644 index 0000000..63df525 Binary files /dev/null and b/src/Exomia.CEF/Exomia.CEF.snk differ diff --git a/src/Exomia.CEF/ExomiaWebBrowser.cs b/src/Exomia.CEF/ExomiaWebBrowser.cs index 1054a26..0b88910 100644 --- a/src/Exomia.CEF/ExomiaWebBrowser.cs +++ b/src/Exomia.CEF/ExomiaWebBrowser.cs @@ -122,6 +122,9 @@ private ExomiaWebBrowser(string name, string baseUrl = "about:blank", bool debug throw new Exception( $"{nameof(CefWrapper)} must be created before the {nameof(ExomiaWebBrowser)} is available!"); } + + JavascriptObjectRepository.Settings.LegacyBindingEnabled = false; + _name = name; _graphicsDevice = null!; @@ -132,18 +135,23 @@ private ExomiaWebBrowser(string name, string baseUrl = "about:blank", bool debug if (debug) { + // ReSharper disable once HeapView.ClosureAllocation ConsoleMessage += (sender, args) => { - Console.WriteLine("[{0}:{1}] [{2}] {3}", args.Level, args.Line, args.Source, args.Message); + // ReSharper disable once HeapView.BoxingAllocation + // ReSharper disable once HeapView.ObjectAllocation + Console.WriteLine("[{0}:{1}] [{2}] {3}", args.Level.ToString(), args.Line.ToString(), args.Source, args.Message); }; JavascriptObjectRepository.ObjectBoundInJavascript += (sender, e) => { Console.WriteLine( - $"Object '{e.ObjectName}' was bound successfully. (cached: {e.IsCached}; alreadyBound: {e.AlreadyBound})"); + $"Object '{e.ObjectName}' was bound successfully. (cached: {e.IsCached.ToString()}; alreadyBound: {e.AlreadyBound.ToString()})"); }; } _uiInputWrapper = new UiInputWrapper(GetBrowser().GetHost()); + // ReSharper disable once HeapView.ClosureAllocation + // ReSharper disable once HeapView.DelegateAllocation JavascriptObjectRepository.ResolveObject += (sender, e) => { if (e.ObjectName == null) { return; } @@ -270,10 +278,12 @@ T IExomiaWebBrowser.AddUiCallback(string name, T item) disposable.Dispose(); } JavascriptObjectRepository.UnRegister(name); + // ReSharper disable once HeapView.PossibleBoxingAllocation _namedServices[name] = item; } else { + // ReSharper disable once HeapView.PossibleBoxingAllocation _namedServices.Add(name, item); } return item; @@ -284,6 +294,8 @@ T IExomiaWebBrowser.AddUiCallback(string name, T item) void IInitializable.Initialize(IServiceRegistry registry) { _graphicsDevice = registry.GetService(); + // ReSharper disable once HeapView.DelegateAllocation + // ReSharper disable once HeapView.ClosureAllocation _graphicsDevice.ResizeFinished += v => { GetBrowser().GetHost().NotifyMoveOrResizeStarted(); @@ -291,23 +303,26 @@ void IInitializable.Initialize(IServiceRegistry registry) GetBrowser().GetHost().WasResized(); }; Size = new Size((int)_graphicsDevice.Viewport.Width, (int)_graphicsDevice.Viewport.Height); - + while (!IsBrowserInitialized) { + // ReSharper disable once HeapView.ClosureAllocation ManualResetEventSlim mre = new ManualResetEventSlim(IsBrowserInitialized); void OnBrowserInitialized(object sender, EventArgs e) { mre.Set(); } - + // ReSharper disable once HeapView.DelegateAllocation BrowserInitialized += OnBrowserInitialized; mre.Wait(2000); + // ReSharper disable once HeapView.DelegateAllocation BrowserInitialized -= OnBrowserInitialized; } + // ReSharper disable once HeapView.DelegateAllocation Paint += OnPaint; } @@ -332,10 +347,12 @@ protected override void Dispose(bool disposing) { if (disposing) { + // ReSharper disable once HeapView.DelegateAllocation Paint -= OnPaint; static void DisposeDictionary(IDictionary dictionary) { + // ReSharper disable once HeapView.ObjectAllocation.Possible foreach (object v in dictionary.Values) { if (v is IDisposable disposable) @@ -365,6 +382,7 @@ static void DisposeDictionary(IDictionary dictionary) /// Event information to send to registered event handlers. private void OnPaint(object sender, OnPaintEventArgs e) { + // ReSharper disable once HeapView.ObjectAllocation using Texture2D tex = new Texture2D( _graphicsDevice.Device, new Texture2DDescription @@ -382,7 +400,9 @@ private void OnPaint(object sender, OnPaintEventArgs e) }, new DataRectangle(e.BufferHandle, e.Width * 4)); Interlocked.Exchange( ref _texture, + // ReSharper disable once HeapView.ObjectAllocation.Evident new Texture( + // ReSharper disable once HeapView.ObjectAllocation.Evident new ShaderResourceView1(_graphicsDevice.Device, tex), e.Width, e.Height)) ?.Dispose(); } diff --git a/src/Exomia.CEF/Interaction/UiInputWrapper.cs b/src/Exomia.CEF/Interaction/UiInputWrapper.cs index 0d76399..a1208ab 100644 --- a/src/Exomia.CEF/Interaction/UiInputWrapper.cs +++ b/src/Exomia.CEF/Interaction/UiInputWrapper.cs @@ -9,9 +9,9 @@ #endregion using System.Threading; -using System.Windows.Forms; using CefSharp; using Exomia.Framework.Input; +using Exomia.Framework.Win32; using MouseButtons = Exomia.Framework.Input.MouseButtons; namespace Exomia.CEF.Interaction @@ -157,89 +157,89 @@ public void RemoveFlag(int flag) Interlocked.Exchange(ref _state, state & ~flag); } - private bool KeyDown(int keyValue, KeyModifier modifiers) + private EventAction KeyDown(int keyValue, KeyModifier modifiers) { - return (_state & KEY_DOWN_FLAG) == KEY_DOWN_FLAG; + return (_state & KEY_DOWN_FLAG) == KEY_DOWN_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool KeyPress(char key) + private EventAction KeyPress(char key) { - return (_state & KEY_PRESS_FLAG) == KEY_PRESS_FLAG; + return (_state & KEY_PRESS_FLAG) == KEY_PRESS_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool KeyUp(int keyValue, KeyModifier modifiers) + private EventAction KeyUp(int keyValue, KeyModifier modifiers) { - return (_state & KEY_UP_FLAG) == KEY_UP_FLAG; + return (_state & KEY_UP_FLAG) == KEY_UP_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool RawKeyEvent(in Message message) + private EventAction RawKeyEvent(in Message message) { - _host.SendKeyEvent(message.Msg, (int)message.WParam.ToInt64(), (int)message.LParam.ToInt64()); - return (_state & KEY_EVENT_FLAG) == KEY_EVENT_FLAG; + _host.SendKeyEvent((int)message.msg, (int)message.wParam.ToInt64(), (int)message.lParam.ToInt64()); + return (_state & KEY_EVENT_FLAG) == KEY_EVENT_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool MouseDown(int x, int y, MouseButtons buttons, int clicks, int wheelDelta) + private EventAction MouseDown(in MouseEventArgs args) { - if ((buttons & MouseButtons.Left) == MouseButtons.Left) + if ((args.Buttons & MouseButtons.Left) == MouseButtons.Left) { - _host.SendMouseClickEvent(x, y, MouseButtonType.Left, false, clicks, CefEventFlags.LeftMouseButton); + _host.SendMouseClickEvent(args.X, args.Y, MouseButtonType.Left, false, args.Clicks, CefEventFlags.LeftMouseButton); } - if ((buttons & MouseButtons.Middle) == MouseButtons.Middle) + if ((args.Buttons & MouseButtons.Middle) == MouseButtons.Middle) { - _host.SendMouseClickEvent(x, y, MouseButtonType.Middle, false, clicks, CefEventFlags.MiddleMouseButton); + _host.SendMouseClickEvent(args.X, args.Y, MouseButtonType.Middle, false, args.Clicks, CefEventFlags.MiddleMouseButton); } - if ((buttons & MouseButtons.Right) == MouseButtons.Right) + if ((args.Buttons & MouseButtons.Right) == MouseButtons.Right) { - _host.SendMouseClickEvent(x, y, MouseButtonType.Right, false, clicks, CefEventFlags.RightMouseButton); + _host.SendMouseClickEvent(args.X, args.Y, MouseButtonType.Right, false, args.Clicks, CefEventFlags.RightMouseButton); } - return (_state & MOUSE_DOWN_FLAG) == MOUSE_DOWN_FLAG; + return (_state & MOUSE_DOWN_FLAG) == MOUSE_DOWN_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool MouseUp(int x, int y, MouseButtons buttons, int clicks, int wheelDelta) + private EventAction MouseUp(in MouseEventArgs args) { - if ((buttons & MouseButtons.Left) == MouseButtons.Left) + if ((args.Buttons & MouseButtons.Left) == MouseButtons.Left) { - _host.SendMouseClickEvent(x, y, MouseButtonType.Left, true, clicks, CefEventFlags.LeftMouseButton); + _host.SendMouseClickEvent(args.X, args.Y, MouseButtonType.Left, true, args.Clicks, CefEventFlags.LeftMouseButton); } - if ((buttons & MouseButtons.Middle) == MouseButtons.Middle) + if ((args.Buttons & MouseButtons.Middle) == MouseButtons.Middle) { - _host.SendMouseClickEvent(x, y, MouseButtonType.Middle, true, clicks, CefEventFlags.MiddleMouseButton); + _host.SendMouseClickEvent(args.X, args.Y, MouseButtonType.Middle, true, args.Clicks, CefEventFlags.MiddleMouseButton); } - if ((buttons & MouseButtons.Right) == MouseButtons.Right) + if ((args.Buttons & MouseButtons.Right) == MouseButtons.Right) { - _host.SendMouseClickEvent(x, y, MouseButtonType.Right, true, clicks, CefEventFlags.RightMouseButton); + _host.SendMouseClickEvent(args.X, args.Y, MouseButtonType.Right, true, args.Clicks, CefEventFlags.RightMouseButton); } - return (_state & MOUSE_UP_FLAG) == MOUSE_UP_FLAG; + return (_state & MOUSE_UP_FLAG) == MOUSE_UP_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool MouseClick(int x, int y, MouseButtons buttons, int clicks, int wheelDelta) + private EventAction MouseClick(in MouseEventArgs args) { - return (_state & MOUSE_CLICK_FLAG) == MOUSE_CLICK_FLAG; + return (_state & MOUSE_CLICK_FLAG) == MOUSE_CLICK_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool MouseMove(int x, int y, MouseButtons buttons, int clicks, int wheelDelta) + private EventAction MouseMove(in MouseEventArgs args) { CefEventFlags cefEventFlags = CefEventFlags.None; - if ((buttons & MouseButtons.Left) == MouseButtons.Left) + if ((args.Buttons & MouseButtons.Left) == MouseButtons.Left) { cefEventFlags |= CefEventFlags.LeftMouseButton; } - if ((buttons & MouseButtons.Middle) == MouseButtons.Middle) + if ((args.Buttons & MouseButtons.Middle) == MouseButtons.Middle) { cefEventFlags |= CefEventFlags.MiddleMouseButton; } - if ((buttons & MouseButtons.Right) == MouseButtons.Right) + if ((args.Buttons & MouseButtons.Right) == MouseButtons.Right) { cefEventFlags |= CefEventFlags.RightMouseButton; } - _host.SendMouseMoveEvent(x, y, false, cefEventFlags); - return (_state & MOUSE_MOVE_FLAG) == MOUSE_MOVE_FLAG; + _host.SendMouseMoveEvent(args.X, args.Y, false, cefEventFlags); + return (_state & MOUSE_MOVE_FLAG) == MOUSE_MOVE_FLAG ? EventAction.StopPropagation : EventAction.Continue; } - private bool MouseWheel(int x, int y, MouseButtons buttons, int clicks, int wheelDelta) + private EventAction MouseWheel(in MouseEventArgs args) { - _host.SendMouseWheelEvent(x, y, 0, wheelDelta, CefEventFlags.None); - return (_state & MOUSE_WHEEL_FLAG) == MOUSE_WHEEL_FLAG; + _host.SendMouseWheelEvent(args.X, args.Y, 0, args.WheelDelta, CefEventFlags.None); + return (_state & MOUSE_WHEEL_FLAG) == MOUSE_WHEEL_FLAG ? EventAction.StopPropagation : EventAction.Continue; } } } \ No newline at end of file diff --git a/tests/L0/Exomia.CEF.Tests/Exomia.CEF.Tests.csproj b/tests/L0/Exomia.CEF.Tests/Exomia.CEF.Tests.csproj new file mode 100644 index 0000000..1732411 --- /dev/null +++ b/tests/L0/Exomia.CEF.Tests/Exomia.CEF.Tests.csproj @@ -0,0 +1,20 @@ + + + + net48 + + false + + + + + + + + + + + + + +