mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-07 12:11:50 +08:00
[linux] Add webkit version detection + capabilities
This commit is contained in:
parent
1f16655769
commit
0b48c3456b
@ -6,10 +6,6 @@ type Capabilities struct {
|
|||||||
HasNativeDrag bool
|
HasNativeDrag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCapabilities(version string) Capabilities {
|
|
||||||
return newCapabilities(version)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c Capabilities) AsBytes() []byte {
|
func (c Capabilities) AsBytes() []byte {
|
||||||
// JSON encode
|
// JSON encode
|
||||||
result, err := json.Marshal(c)
|
result, err := json.Marshal(c)
|
||||||
|
@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
package capabilities
|
package capabilities
|
||||||
|
|
||||||
func newCapabilities(_ string) Capabilities {
|
import "github.com/wailsapp/wails/v3/internal/operatingsystem"
|
||||||
|
|
||||||
|
func NewCapabilities() Capabilities {
|
||||||
c := Capabilities{}
|
c := Capabilities{}
|
||||||
c.HasNativeDrag = false
|
|
||||||
|
webkitVersion := operatingsystem.GetWebkitVersion()
|
||||||
|
c.HasNativeDrag = webkitVersion.IsAtLeast(2, 36, 0)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ func (v version) IsAtLeast(input string) bool {
|
|||||||
return result >= 0
|
return result >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCapabilities(webview2version string) Capabilities {
|
func NewCapabilities(version string) Capabilities {
|
||||||
webview2 := version(webview2version)
|
webview2 := version(webview2version)
|
||||||
c := Capabilities{}
|
c := Capabilities{}
|
||||||
c.HasNativeDrag = webview2.IsAtLeast("113.0.0.0")
|
c.HasNativeDrag = webview2.IsAtLeast("113.0.0.0")
|
||||||
|
40
v3/internal/operatingsystem/webkit_linux.go
Normal file
40
v3/internal/operatingsystem/webkit_linux.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package operatingsystem
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0 javascriptcoregtk-4.1
|
||||||
|
#include <webkit2/webkit2.h>
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type WebkitVersion struct {
|
||||||
|
Major uint
|
||||||
|
Minor uint
|
||||||
|
Micro uint
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetWebkitVersion() WebkitVersion {
|
||||||
|
var major, minor, micro C.uint
|
||||||
|
major = C.webkit_get_major_version()
|
||||||
|
minor = C.webkit_get_minor_version()
|
||||||
|
micro = C.webkit_get_micro_version()
|
||||||
|
return WebkitVersion{
|
||||||
|
Major: uint(major),
|
||||||
|
Minor: uint(minor),
|
||||||
|
Micro: uint(micro),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v WebkitVersion) String() string {
|
||||||
|
return fmt.Sprintf("v%d.%d.%d", v.Major, v.Minor, v.Micro)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v WebkitVersion) IsAtLeast(major int, minor int, micro int) bool {
|
||||||
|
if v.Major != uint(major) {
|
||||||
|
return v.Major > uint(major)
|
||||||
|
}
|
||||||
|
if v.Minor != uint(minor) {
|
||||||
|
return v.Minor > uint(minor)
|
||||||
|
}
|
||||||
|
return v.Micro >= uint(micro)
|
||||||
|
}
|
@ -203,5 +203,9 @@ func (a *App) logPlatformInfo() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
a.info("Platform Info:", info.AsLogSlice()...)
|
wkVersion := operatingsystem.GetWebkitVersion()
|
||||||
|
platformInfo := info.AsLogSlice()
|
||||||
|
platformInfo = append(platformInfo, "Webkit2Gtk", wkVersion)
|
||||||
|
|
||||||
|
a.info("Platform Info:", platformInfo...)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package application
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/wailsapp/wails/v3/internal/capabilities"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v3/pkg/events"
|
"github.com/wailsapp/wails/v3/pkg/events"
|
||||||
@ -355,6 +356,9 @@ func (w *linuxWebviewWindow) run() {
|
|||||||
w.on(eventId)
|
w.on(eventId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register the capabilities
|
||||||
|
globalApplication.capabilities = capabilities.NewCapabilities()
|
||||||
|
|
||||||
app := getNativeApplication()
|
app := getNativeApplication()
|
||||||
|
|
||||||
menu := app.getApplicationMenu()
|
menu := app.getApplicationMenu()
|
||||||
|
Loading…
Reference in New Issue
Block a user