Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
09eec8d
Nit.
Berrysoft Dec 3, 2019
27d4a52
Add GetSize & SetSize.
Berrysoft Dec 3, 2019
81fc8a4
Add width and height property.
Berrysoft Dec 3, 2019
8f4d41c
Fix finilizer.
Berrysoft Dec 3, 2019
c049a98
Fix Mac code.
Berrysoft Dec 3, 2019
e593973
Fix Linux code.
Berrysoft Dec 3, 2019
ad87dc1
Fix Mac again.
Berrysoft Dec 3, 2019
7a3cbe9
Fix typo.
Berrysoft Dec 3, 2019
baa3a3d
Fix Mac.
Berrysoft Dec 3, 2019
5b25a01
Use CGSizeMake?
Berrysoft Dec 3, 2019
61d5299
Add GetPosition & SetPosition.
Berrysoft Dec 7, 2019
b04cfef
Add location pinvoke.
Berrysoft Dec 7, 2019
0250361
Fix typo.
Berrysoft Dec 7, 2019
9df1f49
Add GetScreenSize & GetScreenDpi.
Berrysoft Dec 7, 2019
fd636b5
Add dtor & Topmost.
Berrysoft Dec 7, 2019
bd9f56c
Add Topmost prop.
Berrysoft Dec 7, 2019
807cc17
Clean-up: use auto charset for strings.
Berrysoft Dec 7, 2019
93edc2c
Add UTF8String typedef.
Berrysoft Dec 7, 2019
30c73ce
Fix string define on Unix.
Berrysoft Dec 7, 2019
59f8eb0
Add SetResizable.
Berrysoft Dec 8, 2019
0c25fc7
Add size demo.
Berrysoft Dec 8, 2019
8d8d678
Remove function ptr allocations.
Berrysoft Dec 8, 2019
36cbb64
Add FreeHGlobal.
Berrysoft Dec 8, 2019
ea98b3a
Demo: input size and location.
Berrysoft Dec 8, 2019
0b0b526
Add SetIconFile.
Berrysoft Dec 8, 2019
c46b63f
Fix calling convention.
Berrysoft Dec 8, 2019
1aef851
Remove UTF8String define.
Berrysoft Dec 8, 2019
07f5914
Size->WindowProp
Berrysoft Dec 8, 2019
1b523bf
Add icon demo.
Berrysoft Dec 8, 2019
6998bc7
Revert temp change.
Berrysoft Dec 8, 2019
e61f89e
Add ResizedCallback and MovedCallback for Win & Linux.
Berrysoft Dec 8, 2019
efdfaf0
Fix Gtk issue.
Berrysoft Dec 9, 2019
986574b
Use per-monitor API.
Berrysoft Dec 10, 2019
5d48327
Add windowDidResize and windowDidMove for Mac.
Berrysoft Dec 10, 2019
faf35ee
Fix name conflict.
Berrysoft Dec 10, 2019
a76ccd1
Fix for new Edge Dev.
Berrysoft Dec 11, 2019
acdb2a1
Fix invoke block.
Berrysoft Dec 11, 2019
9cb955a
Revert "Fix invoke block."
Berrysoft Dec 11, 2019
5b1b5c4
Fix block in another thread.
Berrysoft Dec 11, 2019
758dba0
Use IReadOnlyList for monitors.
Berrysoft Dec 14, 2019
f26a0dc
Fix warning.
Berrysoft Dec 14, 2019
7c23f3a
Revert "Fix for new Edge Dev."
SteveSandersonMS Dec 23, 2019
46dfaf5
Make Invoke always safe by skipping dispatch when on UI thread
SteveSandersonMS Dec 23, 2019
6512398
Fix threading issues for setting width/position/resizable/topmost
SteveSandersonMS Dec 23, 2019
f9da521
On macOS, fix notifications for move/resize
SteveSandersonMS Dec 23, 2019
c31c396
Fix size and position calculations for macOS
SteveSandersonMS Dec 23, 2019
7263328
Update WebWindow.Mac.mm
SteveSandersonMS Dec 23, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vs/
.vscode/
bin/
obj/
*.user
Expand Down
25 changes: 0 additions & 25 deletions .vscode/c_cpp_properties.json

This file was deleted.

16 changes: 8 additions & 8 deletions src/WebWindow.Blazor/ComponentsDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public static class ComponentsDesktop
internal static string BaseUriAbsolute { get; private set; }
internal static DesktopJSRuntime DesktopJSRuntime { get; private set; }
internal static DesktopRenderer DesktopRenderer { get; private set; }

internal static WebWindow webWindow;
internal static WebWindow WebWindow { get; private set; }

public static void Run<TStartup>(string windowTitle, string hostHtmlPath)
{
Expand All @@ -30,7 +29,7 @@ public static void Run<TStartup>(string windowTitle, string hostHtmlPath)
UnhandledException(exception);
};

webWindow = new WebWindow(windowTitle, options =>
WebWindow = new WebWindow(windowTitle, options =>
{
var contentRootAbsolute = Path.GetDirectoryName(Path.GetFullPath(hostHtmlPath));

Expand All @@ -57,11 +56,11 @@ public static void Run<TStartup>(string windowTitle, string hostHtmlPath)
});

CancellationTokenSource appLifetimeCts = new CancellationTokenSource();
Task.Factory.StartNew(async() =>
Task.Factory.StartNew(async () =>
{
try
{
var ipc = new IPC(webWindow);
var ipc = new IPC(WebWindow);
await RunAsync<TStartup>(ipc, appLifetimeCts.Token);
}
catch (Exception ex)
Expand All @@ -73,8 +72,8 @@ public static void Run<TStartup>(string windowTitle, string hostHtmlPath)

try
{
webWindow.NavigateToUrl(BlazorAppScheme + "://app/");
webWindow.WaitForExit();
WebWindow.NavigateToUrl(BlazorAppScheme + "://app/");
WebWindow.WaitForExit();
}
finally
{
Expand Down Expand Up @@ -110,7 +109,7 @@ private static string BlazorAppScheme

private static void UnhandledException(Exception ex)
{
webWindow.ShowMessage("Error", $"{ex.Message}\n{ex.StackTrace}");
WebWindow.ShowMessage("Error", $"{ex.Message}\n{ex.StackTrace}");
}

private static async Task RunAsync<TStartup>(IPC ipc, CancellationToken appLifetime)
Expand All @@ -124,6 +123,7 @@ private static async Task RunAsync<TStartup>(IPC ipc, CancellationToken appLifet
serviceCollection.AddSingleton<NavigationManager>(DesktopNavigationManager.Instance);
serviceCollection.AddSingleton<IJSRuntime>(DesktopJSRuntime);
serviceCollection.AddSingleton<INavigationInterception, DesktopNavigationInterception>();
serviceCollection.AddSingleton(WebWindow);

var startup = new ConventionBasedStartup(Activator.CreateInstance(typeof(TStartup)));
startup.ConfigureServices(serviceCollection);
Expand Down
2 changes: 1 addition & 1 deletion src/WebWindow.Blazor/IPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public IPC(WebWindow webWindow)
_webWindow.OnWebMessageReceived += HandleScriptNotify;
}

public async Task Send(string eventName, params object[] args)
public void Send(string eventName, params object[] args)
{
try
{
Expand Down
76 changes: 68 additions & 8 deletions src/WebWindow.Native/Exports.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "WebWindow.h"

#ifdef _WIN32
# define EXPORTED __declspec( dllexport )
# define EXPORTED __declspec(dllexport)
#else
# define EXPORTED
#endif
Expand All @@ -25,12 +25,17 @@ extern "C"
}
#endif

EXPORTED WebWindow* WebWindow_ctor(UTF8String title, WebWindow* parent, WebMessageReceivedCallback webMessageReceivedCallback)
EXPORTED WebWindow* WebWindow_ctor(AutoString title, WebWindow* parent, WebMessageReceivedCallback webMessageReceivedCallback)
{
return new WebWindow(title, parent, webMessageReceivedCallback);
}

EXPORTED void WebWindow_SetTitle(WebWindow* instance, UTF8String title)
EXPORTED void WebWindow_dtor(WebWindow* instance)
{
delete instance;
}

EXPORTED void WebWindow_SetTitle(WebWindow* instance, AutoString title)
{
instance->SetTitle(title);
}
Expand All @@ -45,7 +50,7 @@ extern "C"
instance->WaitForExit();
}

EXPORTED void WebWindow_ShowMessage(WebWindow* instance, UTF8String title, UTF8String body, unsigned int type)
EXPORTED void WebWindow_ShowMessage(WebWindow* instance, AutoString title, AutoString body, unsigned int type)
{
instance->ShowMessage(title, body, type);
}
Expand All @@ -55,23 +60,78 @@ extern "C"
instance->Invoke(callback);
}

EXPORTED void WebWindow_NavigateToString(WebWindow* instance, UTF8String content)
EXPORTED void WebWindow_NavigateToString(WebWindow* instance, AutoString content)
{
instance->NavigateToString(content);
}

EXPORTED void WebWindow_NavigateToUrl(WebWindow* instance, UTF8String url)
EXPORTED void WebWindow_NavigateToUrl(WebWindow* instance, AutoString url)
{
instance->NavigateToUrl(url);
}

EXPORTED void WebWindow_SendMessage(WebWindow* instance, UTF8String message)
EXPORTED void WebWindow_SendMessage(WebWindow* instance, AutoString message)
{
instance->SendMessage(message);
}

EXPORTED void WebWindow_AddCustomScheme(WebWindow* instance, UTF8String scheme, WebResourceRequestedCallback requestHandler)
EXPORTED void WebWindow_AddCustomScheme(WebWindow* instance, AutoString scheme, WebResourceRequestedCallback requestHandler)
{
instance->AddCustomScheme(scheme, requestHandler);
}

EXPORTED void WebWindow_SetResizable(WebWindow* instance, int resizable)
{
instance->SetResizable(resizable);
}

EXPORTED void WebWindow_GetSize(WebWindow* instance, int* width, int* height)
{
instance->GetSize(width, height);
}

EXPORTED void WebWindow_SetSize(WebWindow* instance, int width, int height)
{
instance->SetSize(width, height);
}

EXPORTED void WebWindow_SetResizedCallback(WebWindow* instance, ResizedCallback callback)
{
instance->SetResizedCallback(callback);
}

EXPORTED void WebWindow_GetAllMonitors(WebWindow* instance, GetAllMonitorsCallback callback)
{
instance->GetAllMonitors(callback);
}

EXPORTED unsigned int WebWindow_GetScreenDpi(WebWindow* instance)
{
return instance->GetScreenDpi();
}

EXPORTED void WebWindow_GetPosition(WebWindow* instance, int* x, int* y)
{
instance->GetPosition(x, y);
}

EXPORTED void WebWindow_SetPosition(WebWindow* instance, int x, int y)
{
instance->SetPosition(x, y);
}

EXPORTED void WebWindow_SetMovedCallback(WebWindow* instance, MovedCallback callback)
{
instance->SetMovedCallback(callback);
}

EXPORTED void WebWindow_SetTopmost(WebWindow* instance, int topmost)
{
instance->SetTopmost(topmost);
}

EXPORTED void WebWindow_SetIconFile(WebWindow* instance, AutoString filename)
{
instance->SetIconFile(filename);
}
}
Loading