[darwin] Support Ignore mouse events

[darwin] Support applicationSupportsSecureRestorableState
Update video example
This commit is contained in:
Lea Anthony 2023-10-29 20:29:45 +11:00
commit 985c5bf8e2
7 changed files with 24 additions and 19 deletions

View file

@ -4,10 +4,7 @@ go 1.21
toolchain go1.21.0
require (
github.com/wailsapp/go-webview2 v1.0.9
github.com/wailsapp/wails/v3 v3.0.0-alpha.0
)
require github.com/wailsapp/wails/v3 v3.0.0-alpha.0
require (
github.com/Microsoft/go-winio v0.4.16 // indirect
@ -37,6 +34,7 @@ require (
github.com/rivo/uniseg v0.4.4 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/wailsapp/go-webview2 v1.0.9 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
@ -47,5 +45,3 @@ require (
)
replace github.com/wailsapp/wails/v3 => ../..
replace github.com/wailsapp/go-webview2 => D:\GolandProjects\go-webview2

View file

@ -101,6 +101,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/wailsapp/go-webview2 v1.0.9 h1:lrU+q0cf1wgLdR69rN+ZnRtMJNaJRrcQ4ELxoO7/xjs=
github.com/wailsapp/go-webview2 v1.0.9/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=

View file

@ -31,6 +31,9 @@ func main() {
BackgroundColour: application.NewRGB(33, 37, 41),
Mac: application.MacWindow{
DisableShadow: true,
WebviewPreferences: application.MacWebviewPreferences{
FullscreenEnabled: application.Enabled,
},
},
HTML: "<video controls width=\"500\" >\n <source\n src=\"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm\"\n type=\"video/webm\"\n />\n <source\n src=\"https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4\"\n type=\"video/mp4\"\n />\n </video>",
})

View file

@ -5,7 +5,6 @@ import (
"fmt"
"log"
"math/rand"
"os"
"runtime"
"strconv"
"time"
@ -400,16 +399,6 @@ func main() {
_ = w.Print()
})
})
printMenu.Add("Capture PNG").OnClick(func(ctx *application.Context) {
currentWindow(func(w *application.WebviewWindow) {
img, err := w.CapturePNG()
if err != nil {
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
return
}
os.WriteFile("capture.png", img, 0644)
})
})
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
BackgroundColour: application.NewRGB(33, 37, 41),

View file

@ -7,6 +7,7 @@
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property bool shouldTerminateWhenLastWindowClosed;
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app;
@end
#endif

View file

@ -17,7 +17,13 @@ extern bool hasListeners(unsigned int);
processApplicationEvent(EventApplicationDidChangeTheme, NULL);
}
}
- (BOOL)applicationShouldHandleReopen:(NSNotification *)notification
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app
{
return YES;
}
- (BOOL)applicationShouldHandleReopen:(NSNotification *)notification
hasVisibleWindows:(BOOL)flag {
if( hasListeners(EventApplicationShouldHandleReopen) ) {
processApplicationEvent(EventApplicationShouldHandleReopen, @{@"hasVisibleWindows": @(flag)});

View file

@ -649,7 +649,11 @@ static void windowShowMenu(void *window, void *menu, int x, int y) {
[nsMenu popUpMenuPositioningItem:nil atLocation:point inView:webView];
}
// windowIgnoreMouseEvents makes the window ignore mouse events
static void windowIgnoreMouseEvents(void *window, bool ignore) {
WebviewWindow* nsWindow = (WebviewWindow*)window;
[nsWindow setIgnoresMouseEvents:ignore];
}
// Make the given window frameless
static void windowSetFrameless(void *window, bool frameless) {
@ -1112,6 +1116,10 @@ func (w *macosWebviewWindow) run() {
C.webviewSetTransparent(w.nsWindow)
}
if options.IgnoreMouseEvents {
C.windowIgnoreMouseEvents(w.nsWindow, C.bool(true))
}
titleBarOptions := macOptions.TitleBar
if !w.parent.options.Frameless {
C.windowSetTitleBarAppearsTransparent(w.nsWindow, C.bool(titleBarOptions.AppearsTransparent))