Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: App-specific ApplicationData on Skia #12314

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c7c1e45
chore: Start breaking down WPF Skia host to separate app hosting and …
MartinZikmund May 18, 2023
9cbb72a
chore: Move additional hosting properties to IWpfXamlRootHost
MartinZikmund May 18, 2023
f1e60f5
chore: Adjustments to extensions and renderers
MartinZikmund May 18, 2023
235a26c
chore: Samples app WPF changes
MartinZikmund May 18, 2023
cf5e504
chore: Launch adjustments
MartinZikmund May 18, 2023
49fb5dd
chore: Start adjusting Window.Current references
MartinZikmund May 18, 2023
8690479
fix: Show window content only when both Activate and Content are set
MartinZikmund May 19, 2023
91f95c7
chore: Initial Window-hosted root support
MartinZikmund May 19, 2023
555a130
chore: Start adjusting GTK app lifecycle
MartinZikmund May 24, 2023
2d56bbd
chore: UnoGtkWindow, avoid using MainWindow in UnoWpfWindow
MartinZikmund May 24, 2023
7552148
chore: GTK rendering/host split, resturcturing runtime projects
MartinZikmund Jun 2, 2023
94c3759
chore: Adjusting GTK window logic
MartinZikmund Jun 3, 2023
4331d4a
chore: Adjusting renderers, temporary adjustments
MartinZikmund Jun 4, 2023
902a12e
chore: Adjust WPF Window native overlay lifetime
MartinZikmund Jun 4, 2023
36407cc
chore: XamlRoot adjustments, internals
MartinZikmund Jun 4, 2023
7632e77
chore: Separate WPF window host and window itself
MartinZikmund Jun 4, 2023
1dca1aa
chore: Fix rendering issue on WPF OpenGL
MartinZikmund Jun 5, 2023
b0c601b
chore: Refactor WPF renderer infrastructure
MartinZikmund Jun 5, 2023
7fb07b0
chore: Move render invalidation to application level, finalize WPF re…
MartinZikmund Jun 5, 2023
ee46dc3
chore: Shared overlay invalidation, restore WPF input
MartinZikmund Jun 5, 2023
caae49c
chore: Window reference changes
MartinZikmund Jun 6, 2023
1d09c5d
chore: Moving Window-related logic to window classes
MartinZikmund Jun 6, 2023
6b1a34e
chore: Adjust namespaces
MartinZikmund Jun 6, 2023
f058f8e
chore: Adjust render surface initialization, GTK compiles
MartinZikmund Jun 7, 2023
1582d8e
chore: Adjusting ApplicationView and resizing
MartinZikmund Jun 7, 2023
b5cce77
chore: Adjust formatting
MartinZikmund Jun 8, 2023
96bc6af
chore: Adjust WASM activation
MartinZikmund Jun 8, 2023
6bc3d3a
chore: Adjust naming
MartinZikmund Jun 8, 2023
4498874
refactor: Share XamlRootMap implementation across target
MartinZikmund Jun 8, 2023
7081e33
chore: Formatting, naming
MartinZikmund Jun 9, 2023
f51a439
chore: Adjust namings
MartinZikmund Jun 9, 2023
bc3953d
chore: Adjustments to WPF extensions, refactoring of XamlRootMap
MartinZikmund Jun 9, 2023
4ca9e2f
chore: Adjust window startup
MartinZikmund Jun 9, 2023
b72e2bf
chore: Set default window size
MartinZikmund Jun 9, 2023
75bfd99
chore: Adjust the Identity of Samples app
MartinZikmund May 15, 2023
2a9b9e6
feat: Support PackageId on Skia and WASM
MartinZikmund May 15, 2023
b807adc
feat: App-specific ApplicationData folders and settings
MartinZikmund May 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/SamplesApp/SamplesApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public App()
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

#if __SKIA__
ApplicationView.PreferredLaunchViewSize = new Windows.Foundation.Size(1024, 768);
#endif

ConfigureFeatureFlags();

AssertIssue1790ApplicationSettingsUsable();
Expand Down
3 changes: 1 addition & 2 deletions src/SamplesApp/SamplesApp.Skia.WPF/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Application x:Class="SamplesApp.WPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SamplesApp.WPF"
StartupUri="MainWindow.xaml">
xmlns:local="clr-namespace:SamplesApp.WPF">
<Application.Resources>

</Application.Resources>
Expand Down
14 changes: 6 additions & 8 deletions src/SamplesApp/SamplesApp.Skia.WPF/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Uno.UI.Skia;

namespace SamplesApp.WPF
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
public partial class App : System.Windows.Application
{
public App()
{
SamplesApp.App.ConfigureFilters();

var host = new WpfHost(Dispatcher, () => new SamplesApp.App());

host.Run();
}
}
}
10 changes: 0 additions & 10 deletions src/SamplesApp/SamplesApp.Skia.WPF/MainWindow.xaml

This file was deleted.

32 changes: 0 additions & 32 deletions src/SamplesApp/SamplesApp.Skia.WPF/MainWindow.xaml.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/SamplesApp/SamplesApp.UWP/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
IgnorableNamespaces="uap mp rescap uap2">

<Identity
Name="6c25beb3-e332-48d3-b4de-20a0b71935cd"
Publisher="CN=Uno"
Name="SamplesApp"
Publisher="CN=Uno Platform"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="1897f84c-689e-44d3-a8b7-c521a62818ae" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>SamplesApp</DisplayName>
<PublisherDisplayName>SamplesApp</PublisherDisplayName>
<PublisherDisplayName>Uno Platform</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

Expand Down
24 changes: 13 additions & 11 deletions src/Uno.UI.Composition/Composition/Compositor.skia.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#nullable enable

using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Numerics;
using SkiaSharp;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;

namespace Windows.UI.Composition
Expand Down Expand Up @@ -41,9 +42,8 @@ public void Dispose()
}
}

internal ContainerVisual? RootVisual { get; set; }

internal float CurrentOpacity => _currentOpacity;

internal SKColorFilter? CurrentOpacityColorFilter
{
get
Expand All @@ -65,17 +65,19 @@ internal SKColorFilter? CurrentOpacityColorFilter
}
}

internal void Render(SKSurface surface)
internal void RenderRootVisual(SKSurface surface, ContainerVisual rootVisual)
{
if (rootVisual is null)
{
throw new ArgumentNullException(nameof(rootVisual));
}

_isDirty = false;

if (RootVisual != null)
var children = rootVisual.GetChildrenInRenderOrder();
for (var i = 0; i < children.Count; i++)
{
var children = RootVisual.GetChildrenInRenderOrder();
for (var i = 0; i < children.Count; i++)
{
RenderVisual(surface, children[i]);
}
RenderVisual(surface, children[i]);
}
}

Expand Down Expand Up @@ -167,7 +169,7 @@ partial void InvalidateRenderPartial()
if (!_isDirty)
{
_isDirty = true;
CoreWindow.QueueInvalidateRender();
CoreApplication.QueueInvalidateRender();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class ClipboardExtensions : IClipboardExtension

public ClipboardExtensions(object owner)
{
_clipboard = Clipboard.GetDefault(GtkHost.Window.Display);
_clipboard = Clipboard.GetDefault(GtkHost.Current!.MainWindow.Display);
}

public void Clear() => _clipboard.Clear();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#nullable enable
using Windows.Foundation;
using Windows.UI.ViewManagement;

namespace Uno.UI.Runtime.Skia
{
internal class GtkApplicationViewExtension : IApplicationViewExtension
{
private readonly ApplicationView _owner;

public GtkApplicationViewExtension(object owner)
{
_owner = (ApplicationView)owner;
}

public void ExitFullScreenMode()
{
GtkHost.Current!.MainWindow!.Unfullscreen();
}

public bool TryEnterFullScreenMode()
{
GtkHost.Current!.MainWindow!.Fullscreen();
return true;
}

public bool TryResizeView(Size size)
{
GtkHost.Current!.MainWindow!.Resize((int)size.Width, (int)size.Height);
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Gdk;
using Gtk;
using Uno.Extensions;
using Uno.Foundation.Extensibility;
using Uno.UI.Runtime.Skia;
using Uno.UI.Runtime.Skia.GTK.Extensions;
using Windows.ApplicationModel;
using Windows.Devices.Input;
using Windows.Foundation;
using Windows.System;
using Windows.UI.Composition;
using Windows.UI.Core;
using Windows.UI.Input;
using Uno.Foundation.Logging;

namespace Uno.UI.Runtime.Skia
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
#nullable enable
//#define TRACE_NATIVE_POINTER_EVENTS

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using Gdk;
using Gtk;
using Uno.Extensions;
using Uno.UI.Runtime.Skia.GTK.Extensions;
using Windows.Devices.Input;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Input;
using Uno.Foundation.Logging;
using static Windows.UI.Input.PointerUpdateKind;
using Device = Gtk.Device;
using Exception = System.Exception;
using Windows.UI.Xaml;
using Uno.UI.Xaml.Core;
using Windows.Foundation;
using Uno.UI.XamlHost.Skia.Gtk.Hosting;
using Atk;
using Uno.UI.Hosting;
using Uno.UI.Runtime.Skia.GTK.Hosting;
using Uno.UI.Runtime.Skia.GTK;

namespace Uno.UI.Runtime.Skia
{
Expand All @@ -39,14 +25,8 @@ public GtkCoreWindowExtension(object owner)

partial void InitializeKeyboard();

internal static Fixed? FindNativeOverlayLayer(Gtk.Window window)
{
var overlay = (Overlay)((EventBox)window.Child).Child;
return overlay.Children.OfType<Fixed>().FirstOrDefault();
}

internal static Fixed? GetOverlayLayer(XamlRoot xamlRoot) =>
XamlRootMap.GetHostForRoot(xamlRoot)?.NativeOverlayLayer;
GtkManager.XamlRootMap.GetHostForRoot(xamlRoot)?.NativeOverlayLayer;

public bool IsNativeElement(object content)
=> content is Widget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,32 @@ namespace Uno.UI.Runtime.Skia;
internal class GtkDisplayInformationExtension : IDisplayInformationExtension
{
private readonly DisplayInformation _displayInformation;
private readonly Window _window;
private readonly DpiHelper _dpiHelper;

private float? _dpi;

public GtkDisplayInformationExtension(object owner, Gtk.Window window)
public GtkDisplayInformationExtension(object owner)
{
_displayInformation = (DisplayInformation)owner;
_window = window;
_dpiHelper = new DpiHelper(_window);
GtkHost.Current!.MainWindowShown += GtkDisplayInformationExtension_MainWindowShown;
_dpiHelper = new DpiHelper();
}

private void GtkDisplayInformationExtension_MainWindowShown(object? sender, EventArgs e)
{
_dpiHelper.DpiChanged += OnDpiChanged;
}

private Gtk.Window GetWindow() => GtkHost.Current!.MainWindow!;

public DisplayOrientations CurrentOrientation => DisplayOrientations.Landscape;

public uint ScreenHeightInRawPixels => (uint)_window.Display.GetMonitorAtWindow(_window.Window).Workarea.Height;
public uint ScreenHeightInRawPixels => (uint)GetWindow().Display.GetMonitorAtWindow(GetWindow().Window).Workarea.Height;

public uint ScreenWidthInRawPixels => (uint)_window.Display.GetMonitorAtWindow(_window.Window).Workarea.Width;
public uint ScreenWidthInRawPixels => (uint)GetWindow().Display.GetMonitorAtWindow(GetWindow().Window).Workarea.Width;

public float LogicalDpi
=> _dpi ??= _window.Display.GetMonitorAtWindow(_window.Window).ScaleFactor * DisplayInformation.BaseDpi;
=> _dpi ??= GetWindow().Display.GetMonitorAtWindow(GetWindow().Window).ScaleFactor * DisplayInformation.BaseDpi;

public double RawPixelsPerViewPixel => LogicalDpi / DisplayInformation.BaseDpi;

Expand All @@ -40,7 +45,7 @@ public float LogicalDpi

private void OnDpiChanged(object? sender, EventArgs args)
{
_dpi = _window.Display.GetMonitorAtWindow(_window.Window).ScaleFactor * DisplayInformation.BaseDpi;
_dpi = GetWindow().Display.GetMonitorAtWindow(GetWindow().Window).ScaleFactor * DisplayInformation.BaseDpi;
_displayInformation.NotifyDpiChanged();
}
}
47 changes: 47 additions & 0 deletions src/Uno.UI.Runtime.Skia.Gtk/Extensions/GtkExtensionsRegistrar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Uno.ApplicationModel.DataTransfer;
using Uno.Extensions.ApplicationModel.Core;
using Uno.Extensions.Storage.Pickers;
using Uno.Extensions.System;
using Uno.Extensions.UI.Core.Preview;
using Uno.Foundation.Extensibility;
using Uno.Helpers.Theming;
using Uno.UI.Core.Preview;
using Uno.UI.Runtime.Skia.GTK.Extensions.ApplicationModel.DataTransfer;
using Uno.UI.Runtime.Skia.GTK.Extensions.Helpers.Theming;
using Uno.UI.Runtime.Skia.GTK.Extensions.System;
using Uno.UI.Runtime.Skia.GTK.Extensions.UI.Xaml.Controls;
using Uno.UI.Runtime.Skia.GTK.System.Profile;
using Uno.UI.Xaml.Controls.Extensions;
using Windows.Storage.Pickers;
using Windows.System.Profile.Internal;
using Windows.UI.Xaml.Controls;
#pragma warning disable CS0649
namespace Uno.UI.Runtime.Skia.GTK.Extensions;

internal static class GtkExtensionsRegistrar
{
private static bool _registered;

internal static void Register()
{
if (_registered)
{
return;
}

ApiExtensibility.Register(typeof(Uno.ApplicationModel.Core.ICoreApplicationExtension), o => new CoreApplicationExtension(o));
ApiExtensibility.Register(typeof(Windows.UI.Core.IUnoCorePointerInputSource), o => new GtkCorePointerInputSource());
ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkCoreWindowExtension(o));
ApiExtensibility.Register(typeof(Windows.UI.ViewManagement.IApplicationViewExtension), o => new GtkApplicationViewExtension(o));
ApiExtensibility.Register(typeof(ISystemThemeHelperExtension), o => new GtkSystemThemeHelperExtension(o));
ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => new GtkDisplayInformationExtension(o));
ApiExtensibility.Register<TextBoxView>(typeof(IOverlayTextBoxViewExtension), o => new TextBoxViewExtension(o));
ApiExtensibility.Register(typeof(ILauncherExtension), o => new LauncherExtension(o));
ApiExtensibility.Register<FileOpenPicker>(typeof(IFileOpenPickerExtension), o => new FileOpenPickerExtension(o));
ApiExtensibility.Register<FolderPicker>(typeof(IFolderPickerExtension), o => new FolderPickerExtension(o));
ApiExtensibility.Register(typeof(IClipboardExtension), o => new ClipboardExtensions(o));
ApiExtensibility.Register<FileSavePicker>(typeof(IFileSavePickerExtension), o => new FileSavePickerExtension(o));
ApiExtensibility.Register(typeof(IAnalyticsInfoExtension), o => new AnalyticsInfoExtension());
ApiExtensibility.Register(typeof(ISystemNavigationManagerPreviewExtension), o => new SystemNavigationManagerPreviewExtension());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private async Task<StorageFile[]> OpenPickerAsync(bool multiple)

using FileChooserDialog dialog = new FileChooserDialog(
"Open",
GtkHost.Window,
GtkHost.Current!.MainWindow,
FileChooserAction.Open,
"Cancel", ResponseType.Cancel,
commitText, ResponseType.Accept);
Expand Down
Loading