mirror of
https://github.com/taigrr/wails.git
synced 2026-04-17 04:05:12 -07:00
Compare commits
5 Commits
v2.0.0-alp
...
v2.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a1a4d75ad | ||
|
|
b552c16539 | ||
|
|
d574d53fca | ||
|
|
2b69ac8391 | ||
|
|
e7cb40d5ee |
@@ -1,3 +1,3 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
var version = "v2.0.0-alpha.72"
|
var version = "v2.0.0-alpha.73"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ require (
|
|||||||
github.com/leaanthony/go-ansi-parser v1.0.1
|
github.com/leaanthony/go-ansi-parser v1.0.1
|
||||||
github.com/leaanthony/go-common-file-dialog v1.0.3
|
github.com/leaanthony/go-common-file-dialog v1.0.3
|
||||||
github.com/leaanthony/gosod v1.0.1
|
github.com/leaanthony/gosod v1.0.1
|
||||||
|
github.com/leaanthony/idgen v1.0.0
|
||||||
github.com/leaanthony/slicer v1.5.0
|
github.com/leaanthony/slicer v1.5.0
|
||||||
github.com/leaanthony/webview2runtime v1.1.0
|
github.com/leaanthony/webview2runtime v1.1.0
|
||||||
github.com/leaanthony/winicon v0.0.0-20200606125418-4419cea822a0
|
github.com/leaanthony/winicon v0.0.0-20200606125418-4419cea822a0
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ github.com/leaanthony/go-common-file-dialog v1.0.3 h1:O0uGjKnWtdEADGrkg+TyAAbZyl
|
|||||||
github.com/leaanthony/go-common-file-dialog v1.0.3/go.mod h1:TGhEc9eSJgRsupZ+iH1ZgAOnEo9zp05cRH2j08RPrF0=
|
github.com/leaanthony/go-common-file-dialog v1.0.3/go.mod h1:TGhEc9eSJgRsupZ+iH1ZgAOnEo9zp05cRH2j08RPrF0=
|
||||||
github.com/leaanthony/gosod v1.0.1 h1:F+4c3DmEBfigi7oAswCV2RpQ+k4DcNbhuCZUGdBHacQ=
|
github.com/leaanthony/gosod v1.0.1 h1:F+4c3DmEBfigi7oAswCV2RpQ+k4DcNbhuCZUGdBHacQ=
|
||||||
github.com/leaanthony/gosod v1.0.1/go.mod h1:W8RyeSFBXu7RpIxPGEJfW4moSyGGEjlJMLV25wEbAdU=
|
github.com/leaanthony/gosod v1.0.1/go.mod h1:W8RyeSFBXu7RpIxPGEJfW4moSyGGEjlJMLV25wEbAdU=
|
||||||
|
github.com/leaanthony/idgen v1.0.0 h1:IZreR+JGEzFV4yeVuBZA25gM0keUoFy+RDUldncQ+Jw=
|
||||||
|
github.com/leaanthony/idgen v1.0.0/go.mod h1:4nBZnt8ml/f/ic/EVQuLxuj817RccT2fyrUaZFxrcVA=
|
||||||
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
|
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
|
||||||
github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
||||||
github.com/leaanthony/webview2runtime v1.1.0 h1:N0pv55ift8XtqozIp4PNOtRCJ/Qdd/qzx80lUpalS4c=
|
github.com/leaanthony/webview2runtime v1.1.0 h1:N0pv55ift8XtqozIp4PNOtRCJ/Qdd/qzx80lUpalS4c=
|
||||||
|
|||||||
@@ -9,11 +9,18 @@ import (
|
|||||||
|
|
||||||
func (a *App) PreflightChecks(options *options.App) error {
|
func (a *App) PreflightChecks(options *options.App) error {
|
||||||
|
|
||||||
|
_ = options
|
||||||
|
|
||||||
// Process the webview2 runtime situation. We can pass a strategy in via the `webview2` flag for `wails build`.
|
// Process the webview2 runtime situation. We can pass a strategy in via the `webview2` flag for `wails build`.
|
||||||
// This will determine how wv2runtime.Process will handle a lack of valid runtime.
|
// This will determine how wv2runtime.Process will handle a lack of valid runtime.
|
||||||
err := wv2runtime.Process()
|
installedVersion, err := wv2runtime.Process()
|
||||||
|
if installedVersion != nil {
|
||||||
|
a.logger.Debug("WebView2 Runtime installed: Name: '%s' Version:'%s' Location:'%s'. Minimum version required: %s.",
|
||||||
|
installedVersion.Name, installedVersion.Version, installedVersion.Location, wv2runtime.MinimumRuntimeVersion)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,7 +328,6 @@ void completed(struct Application* app) {
|
|||||||
messageFromWindowCallback(readyMessage.c_str());
|
messageFromWindowCallback(readyMessage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
bool initWebView2(struct Application *app, int debugEnabled, messageCallback cb) {
|
bool initWebView2(struct Application *app, int debugEnabled, messageCallback cb) {
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/leaanthony/webview2runtime"
|
"github.com/leaanthony/webview2runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
const minimumRuntimeVersion string = "91.0.864.48"
|
const MinimumRuntimeVersion string = "91.0.864.48"
|
||||||
|
|
||||||
type installationStatus int
|
type installationStatus int
|
||||||
|
|
||||||
@@ -14,21 +14,21 @@ const (
|
|||||||
installed
|
installed
|
||||||
)
|
)
|
||||||
|
|
||||||
func Process() error {
|
func Process() (*webview2runtime.Info, error) {
|
||||||
installStatus := needsInstalling
|
installStatus := needsInstalling
|
||||||
installedVersion := webview2runtime.GetInstalledVersion()
|
installedVersion := webview2runtime.GetInstalledVersion()
|
||||||
if installedVersion != nil {
|
if installedVersion != nil {
|
||||||
installStatus = installed
|
installStatus = installed
|
||||||
updateRequired, err := installedVersion.IsOlderThan(minimumRuntimeVersion)
|
updateRequired, err := installedVersion.IsOlderThan(MinimumRuntimeVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = webview2runtime.Error(err.Error(), "Error")
|
_ = webview2runtime.Error(err.Error(), "Error")
|
||||||
return err
|
return installedVersion, err
|
||||||
}
|
}
|
||||||
// Installed and does not require updating
|
// Installed and does not require updating
|
||||||
if !updateRequired {
|
if !updateRequired {
|
||||||
return nil
|
return installedVersion, nil
|
||||||
}
|
}
|
||||||
installStatus = needsUpdating
|
|
||||||
}
|
}
|
||||||
return doInstallationStrategy(installStatus)
|
return installedVersion, doInstallationStrategy(installStatus)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func (c *CheckboxCache) addToCheckboxCache(menu *menumanager.ProcessedMenu, item
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CheckboxCache) removeMenuFromChechboxCache(menu *menumanager.ProcessedMenu) {
|
func (c *CheckboxCache) removeMenuFromCheckboxCache(menu *menumanager.ProcessedMenu) {
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
delete(c.cache, menu)
|
delete(c.cache, menu)
|
||||||
c.mutex.Unlock()
|
c.mutex.Unlock()
|
||||||
|
|||||||
@@ -153,8 +153,11 @@ func (m *Menu) processRadioGroups() error {
|
|||||||
|
|
||||||
func (m *Menu) Destroy() error {
|
func (m *Menu) Destroy() error {
|
||||||
|
|
||||||
|
// Release the MenuIDs
|
||||||
|
releaseMenuIDsForProcessedMenu(m.wailsMenu.Menu)
|
||||||
|
|
||||||
// Unload this menu's checkboxes from the cache
|
// Unload this menu's checkboxes from the cache
|
||||||
globalCheckboxCache.removeMenuFromChechboxCache(m.wailsMenu.Menu)
|
globalCheckboxCache.removeMenuFromCheckboxCache(m.wailsMenu.Menu)
|
||||||
|
|
||||||
// Unload this menu's radio groups from the cache
|
// Unload this menu's radio groups from the cache
|
||||||
globalRadioGroupCache.removeMenuFromRadioBoxCache(m.wailsMenu.Menu)
|
globalRadioGroupCache.removeMenuFromRadioBoxCache(m.wailsMenu.Menu)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package ffenestri
|
package ffenestri
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/leaanthony/idgen"
|
||||||
"github.com/wailsapp/wails/v2/internal/menumanager"
|
"github.com/wailsapp/wails/v2/internal/menumanager"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@@ -30,18 +31,28 @@ type menuCacheEntry struct {
|
|||||||
processedMenu *menumanager.ProcessedMenu
|
processedMenu *menumanager.ProcessedMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
// windowsMenuIDCounter keeps track of the unique windows menu IDs
|
var idGenerator = idgen.New()
|
||||||
var windowsMenuIDCounter uint32
|
|
||||||
|
|
||||||
var menuCache = map[win32MenuItemID]*menuCacheEntry{}
|
var menuCache = map[win32MenuItemID]*menuCacheEntry{}
|
||||||
var menuCacheLock sync.RWMutex
|
var menuCacheLock sync.RWMutex
|
||||||
var wailsMenuIDtoWin32IDMap = map[wailsMenuItemID]win32MenuItemID{}
|
var wailsMenuIDtoWin32IDMap = map[wailsMenuItemID]win32MenuItemID{}
|
||||||
|
|
||||||
|
// This releases the menuIDs back to the id generator
|
||||||
|
var winIDsOwnedByProcessedMenu = map[*menumanager.ProcessedMenu][]win32MenuItemID{}
|
||||||
|
|
||||||
|
func releaseMenuIDsForProcessedMenu(processedMenu *menumanager.ProcessedMenu) {
|
||||||
|
for _, menuID := range winIDsOwnedByProcessedMenu[processedMenu] {
|
||||||
|
idGenerator.ReleaseID(uint(menuID))
|
||||||
|
}
|
||||||
|
delete(winIDsOwnedByProcessedMenu, processedMenu)
|
||||||
|
}
|
||||||
|
|
||||||
func addMenuCacheEntry(parent win32Menu, typ menuType, wailsMenuItem *menumanager.ProcessedMenuItem, processedMenu *menumanager.ProcessedMenu) win32MenuItemID {
|
func addMenuCacheEntry(parent win32Menu, typ menuType, wailsMenuItem *menumanager.ProcessedMenuItem, processedMenu *menumanager.ProcessedMenu) win32MenuItemID {
|
||||||
menuCacheLock.Lock()
|
menuCacheLock.Lock()
|
||||||
defer menuCacheLock.Unlock()
|
defer menuCacheLock.Unlock()
|
||||||
menuID := win32MenuItemID(windowsMenuIDCounter)
|
id, err := idGenerator.NewID()
|
||||||
windowsMenuIDCounter++
|
checkFatal(err)
|
||||||
|
menuID := win32MenuItemID(id)
|
||||||
menuCache[menuID] = &menuCacheEntry{
|
menuCache[menuID] = &menuCacheEntry{
|
||||||
parent: parent,
|
parent: parent,
|
||||||
menuType: typ,
|
menuType: typ,
|
||||||
@@ -50,6 +61,8 @@ func addMenuCacheEntry(parent win32Menu, typ menuType, wailsMenuItem *menumanage
|
|||||||
}
|
}
|
||||||
// save the mapping
|
// save the mapping
|
||||||
wailsMenuIDtoWin32IDMap[wailsMenuItemID(wailsMenuItem.ID)] = menuID
|
wailsMenuIDtoWin32IDMap[wailsMenuItemID(wailsMenuItem.ID)] = menuID
|
||||||
|
// keep track of menuids owned by this menu (so we can release the ids)
|
||||||
|
winIDsOwnedByProcessedMenu[processedMenu] = append(winIDsOwnedByProcessedMenu[processedMenu], menuID)
|
||||||
return menuID
|
return menuID
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ class wv2ComHandler
|
|||||||
: public ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler,
|
: public ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler,
|
||||||
public ICoreWebView2CreateCoreWebView2ControllerCompletedHandler,
|
public ICoreWebView2CreateCoreWebView2ControllerCompletedHandler,
|
||||||
public ICoreWebView2WebMessageReceivedEventHandler,
|
public ICoreWebView2WebMessageReceivedEventHandler,
|
||||||
public ICoreWebView2PermissionRequestedEventHandler
|
public ICoreWebView2PermissionRequestedEventHandler,
|
||||||
|
public ICoreWebView2AcceleratorKeyPressedEventHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
struct Application *app;
|
struct Application *app;
|
||||||
@@ -44,6 +45,7 @@ class wv2ComHandler
|
|||||||
ICoreWebView2 *webview;
|
ICoreWebView2 *webview;
|
||||||
::EventRegistrationToken token;
|
::EventRegistrationToken token;
|
||||||
controller->get_CoreWebView2(&webview);
|
controller->get_CoreWebView2(&webview);
|
||||||
|
controller->add_AcceleratorKeyPressed(this, &token);
|
||||||
webview->add_WebMessageReceived(this, &token);
|
webview->add_WebMessageReceived(this, &token);
|
||||||
webview->add_PermissionRequested(this, &token);
|
webview->add_PermissionRequested(this, &token);
|
||||||
|
|
||||||
@@ -51,6 +53,39 @@ class wv2ComHandler
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is our keyboard callback method
|
||||||
|
HRESULT STDMETHODCALLTYPE Invoke(ICoreWebView2Controller *controller, ICoreWebView2AcceleratorKeyPressedEventArgs * args) {
|
||||||
|
COREWEBVIEW2_KEY_EVENT_KIND kind;
|
||||||
|
args->get_KeyEventKind(&kind);
|
||||||
|
if (kind == COREWEBVIEW2_KEY_EVENT_KIND_KEY_DOWN ||
|
||||||
|
kind == COREWEBVIEW2_KEY_EVENT_KIND_SYSTEM_KEY_DOWN)
|
||||||
|
{
|
||||||
|
// UINT key;
|
||||||
|
// args->get_VirtualKey(&key);
|
||||||
|
// printf("Got key: %d\n", key);
|
||||||
|
args->put_Handled(TRUE);
|
||||||
|
// Check if the key is one we want to handle.
|
||||||
|
// if (std::function<void()> action =
|
||||||
|
// m_appWindow->GetAcceleratorKeyFunction(key))
|
||||||
|
// {
|
||||||
|
// // Keep the browser from handling this key, whether it's autorepeated or
|
||||||
|
// // not.
|
||||||
|
// CHECK_FAILURE(args->put_Handled(TRUE));
|
||||||
|
//
|
||||||
|
// // Filter out autorepeated keys.
|
||||||
|
// COREWEBVIEW2_PHYSICAL_KEY_STATUS status;
|
||||||
|
// CHECK_FAILURE(args->get_PhysicalKeyStatus(&status));
|
||||||
|
// if (!status.WasKeyDown)
|
||||||
|
// {
|
||||||
|
// // Perform the action asynchronously to avoid blocking the
|
||||||
|
// // browser process's event queue.
|
||||||
|
// m_appWindow->RunAsync(action);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// This is called when JS posts a message back to webkit
|
// This is called when JS posts a message back to webkit
|
||||||
HRESULT STDMETHODCALLTYPE Invoke(
|
HRESULT STDMETHODCALLTYPE Invoke(
|
||||||
ICoreWebView2 *sender, ICoreWebView2WebMessageReceivedEventArgs *args) {
|
ICoreWebView2 *sender, ICoreWebView2WebMessageReceivedEventArgs *args) {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||||
<assemblyIdentity type="win32" name="MyApplication" version="1.0.0.0" processorArchitecture="amd64"/>
|
<assemblyIdentity type="win32" name="MyApplication" version="1.0.0.0" processorArchitecture="amd64"/>
|
||||||
|
<dependency>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
||||||
|
</dependentAssembly>
|
||||||
|
</dependency>
|
||||||
<asmv3:application>
|
<asmv3:application>
|
||||||
<asmv3:windowsSettings>
|
<asmv3:windowsSettings>
|
||||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
|
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user