diff --git a/v2/cmd/wails/internal/commands/build/build.go b/v2/cmd/wails/internal/commands/build/build.go index a8c458a92..cb095494f 100644 --- a/v2/cmd/wails/internal/commands/build/build.go +++ b/v2/cmd/wails/internal/commands/build/build.go @@ -97,7 +97,8 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { "darwin/universal", //"linux/amd64", //"linux/arm-7", - //"windows/amd64", + "windows", + "windows/amd64", }) if !validPlatformArch.Contains(platform) { return fmt.Errorf("platform %s is not supported", platform) diff --git a/v2/go.mod b/v2/go.mod index f6d8ce84d..87457ccf3 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -10,7 +10,7 @@ require ( github.com/imdario/mergo v0.3.11 github.com/jackmordaunt/icns v1.0.0 github.com/leaanthony/clir v1.0.4 - github.com/leaanthony/debme v1.1.1 + github.com/leaanthony/debme v1.1.2 github.com/leaanthony/go-ansi-parser v1.0.1 github.com/leaanthony/gosod v1.0.1 github.com/leaanthony/slicer v1.5.0 diff --git a/v2/go.sum b/v2/go.sum index c1db157f5..e4b2e6c3b 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -41,8 +41,9 @@ github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eT github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/leaanthony/clir v1.0.4 h1:Dov2y9zWJmZr7CjaCe86lKa4b5CSxskGAt2yBkoDyiU= github.com/leaanthony/clir v1.0.4/go.mod h1:k/RBkdkFl18xkkACMCLt09bhiZnrGORoxmomeMvDpE0= -github.com/leaanthony/debme v1.1.1 h1:2CQjJkfrjr4b2VgpDmkq2aghem5R2bNbg1Yg5cKQGBQ= github.com/leaanthony/debme v1.1.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA= +github.com/leaanthony/debme v1.1.2 h1:dGeQuj0+xPIlDQzGIjmAU52+yRg85u5pWaaqrdLBjD0= +github.com/leaanthony/debme v1.1.2/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA= github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQOk2DgKxGG4= github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM= github.com/leaanthony/gosod v1.0.1 h1:F+4c3DmEBfigi7oAswCV2RpQ+k4DcNbhuCZUGdBHacQ= diff --git a/v2/internal/ffenestri/LICENCES.md b/v2/internal/ffenestri/LICENCES.md index 1b1bdf148..1c02ffa9c 100644 --- a/v2/internal/ffenestri/LICENCES.md +++ b/v2/internal/ffenestri/LICENCES.md @@ -1,5 +1,11 @@ # 3rd Party Licenses +## Webview +Whilst not using the library directly, there is certainly some code that is inspired by or used from the webview library. + +Homepage: https://github.com/webview/webview +License: https://github.com/webview/webview/blob/master/LICENSE + ## vec Homepage: https://github.com/rxi/vec License: https://github.com/rxi/vec/blob/master/LICENSE diff --git a/v2/internal/ffenestri/ffenestri_windows.c b/v2/internal/ffenestri/ffenestri_windows.c index b72e52a10..b6e9bdf37 100644 --- a/v2/internal/ffenestri/ffenestri_windows.c +++ b/v2/internal/ffenestri/ffenestri_windows.c @@ -1,14 +1,100 @@ +// Some code may be inspired by or directly used from Webview. +#include "ffenestri_windows.h" -typedef struct { -} Application; +struct Application{ + // Window specific + HWND window; + const char *title; + int width; + int height; + int resizable; + int devtools; + int fullscreen; + int startHidden; + int logLevel; + int hideWindowOnClose; + int minWidth; + int minHeight; + int maxWidth; + int maxHeight; +}; struct Application *NewApplication(const char *title, int width, int height, int resizable, int devtools, int fullscreen, int startHidden, int logLevel, int hideWindowOnClose) { + + // Create application + struct Application *result = malloc(sizeof(struct Application)); + + result->title = title; + result->width = width; + result->height = height; + result->resizable = resizable; + result->devtools = devtools; + result->fullscreen = fullscreen; + result->startHidden = startHidden; + result->logLevel = logLevel; + result->hideWindowOnClose = hideWindowOnClose; + + return result; } + void SetMinWindowSize(struct Application* app, int minWidth, int minHeight) { + app->minWidth = minWidth; + app->minHeight = minHeight; } + void SetMaxWindowSize(struct Application* app, int maxWidth, int maxHeight) { + app->maxWidth = maxWidth; + app->maxHeight = maxHeight; } + +LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + + switch(msg) { + + case WM_DESTROY: + + PostQuitMessage(0); + break; + } + + return DefWindowProcW(hwnd, msg, wParam, lParam); +} + void Run(struct Application* app, int argc, char **argv) { + + WNDCLASSEX wc; + HINSTANCE hInstance = GetModuleHandle(NULL); + ZeroMemory(&wc, sizeof(WNDCLASSEX)); + wc.cbSize = sizeof(WNDCLASSEX); + wc.hInstance = hInstance; + wc.lpszClassName = "ffenestri"; + wc.lpfnWndProc = WndProc; + + // TODO: Trim title to 256 chars + // https://stackoverflow.com/a/20458904 + wchar_t wchTitle[256]; + MultiByteToWideChar(CP_ACP, 0, app->title, -1, wchTitle, 256); + + RegisterClassEx(&wc); + app->window = CreateWindow("ffenestri", wchTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, + CW_USEDEFAULT, app->width, app->height, NULL, NULL, + GetModuleHandle(NULL), NULL); + + MSG msg; + ShowWindow(app->window, SW_SHOWNORMAL); + UpdateWindow(app->window); + BOOL res; + while ((res = GetMessage(&msg, NULL, 0, 0)) != -1) { + if (msg.hwnd) { + TranslateMessage(&msg); + DispatchMessage(&msg); + continue; + } + if (msg.message == WM_APP) { + } else if (msg.message == WM_QUIT) { + return; + } + } } void DestroyApplication(struct Application* app) { } diff --git a/v2/internal/ffenestri/ffenestri_windows.go b/v2/internal/ffenestri/ffenestri_windows.go index 3edf2482e..1fc896b86 100644 --- a/v2/internal/ffenestri/ffenestri_windows.go +++ b/v2/internal/ffenestri/ffenestri_windows.go @@ -2,6 +2,8 @@ package ffenestri /* +#cgo windows,amd64 LDFLAGS: -L./windows/x64 -lwebview -lWebView2Loader + #include "ffenestri.h" #include "ffenestri_windows.h" diff --git a/v2/internal/ffenestri/ffenestri_windows.h b/v2/internal/ffenestri/ffenestri_windows.h index 9360f629c..e6831a479 100644 --- a/v2/internal/ffenestri/ffenestri_windows.h +++ b/v2/internal/ffenestri/ffenestri_windows.h @@ -1,5 +1,7 @@ -#ifndef _FFENESTRI_WINDOWS_ -#define _FFENESTRI_WINDOWS_ +#ifndef _FFENESTRI_WINDOWS_H +#define _FFENESTRI_WINDOWS_H + +#include #endif \ No newline at end of file