mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Support GPU acceleration settings on Windows & Linux (#2266)
* support GPU acceleration settings Window & Linux * fix linux empty option crash * fix change linux gpu policy switch case * add PR to changelog
This commit is contained in:
@@ -7,13 +7,13 @@ import (
|
||||
|
||||
// Default options for creating the App
|
||||
var Default = &App{
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
Logger: logger.NewDefaultLogger(),
|
||||
LogLevel: logger.INFO,
|
||||
LogLevelProduction: logger.ERROR,
|
||||
CSSDragProperty: "--wails-draggable",
|
||||
CSSDragValue: "drag",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
Logger: logger.NewDefaultLogger(),
|
||||
LogLevel: logger.INFO,
|
||||
LogLevelProduction: logger.ERROR,
|
||||
CSSDragProperty: "--wails-draggable",
|
||||
CSSDragValue: "drag",
|
||||
}
|
||||
|
||||
var defaultMacMenu = menu.NewMenuFromItems(
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
package linux
|
||||
|
||||
// WebviewGpuPolicy values used for determining the webview's hardware acceleration policy.
|
||||
type WebviewGpuPolicy int
|
||||
|
||||
const (
|
||||
// WebviewGpuPolicyAlways Hardware acceleration is always enabled.
|
||||
WebviewGpuPolicyAlways WebviewGpuPolicy = iota
|
||||
// WebviewGpuPolicyOnDemand Hardware acceleration is enabled/disabled as request by web contents.
|
||||
WebviewGpuPolicyOnDemand
|
||||
// WebviewGpuPolicyNever Hardware acceleration is always disabled.
|
||||
WebviewGpuPolicyNever
|
||||
)
|
||||
|
||||
// Options specific to Linux builds
|
||||
type Options struct {
|
||||
Icon []byte
|
||||
// Icon Sets up the icon representing the window. This icon is used when the window is minimized
|
||||
// (also known as iconified).
|
||||
Icon []byte
|
||||
|
||||
// WindowIsTranslucent sets the window's background to transparent when enabled.
|
||||
WindowIsTranslucent bool
|
||||
|
||||
// User messages that can be customised
|
||||
// Messages are messages that can be customised
|
||||
Messages *Messages
|
||||
|
||||
// WebviewGpuPolicy used for determining the hardware acceleration policy for the webview.
|
||||
// - WebviewGpuPolicyAlways
|
||||
// - WebviewGpuPolicyOnDemand
|
||||
// - WebviewGpuPolicyNever
|
||||
WebviewGpuPolicy WebviewGpuPolicy
|
||||
}
|
||||
|
||||
type Messages struct {
|
||||
|
||||
@@ -2,6 +2,7 @@ package options
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/linux"
|
||||
"html"
|
||||
"io/fs"
|
||||
"log"
|
||||
@@ -9,7 +10,6 @@ import (
|
||||
"runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/linux"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/mac"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||
|
||||
|
||||
@@ -96,8 +96,12 @@ type Options struct {
|
||||
|
||||
// OnSuspend is called when Windows enters low power mode
|
||||
OnSuspend func()
|
||||
|
||||
// OnResume is called when Windows resumes from low power mode
|
||||
OnResume func()
|
||||
|
||||
// WebviewGpuIsDisabled is used to enable / disable GPU acceleration for the webview
|
||||
WebviewGpuIsDisabled bool
|
||||
}
|
||||
|
||||
func DefaultMessages() *Messages {
|
||||
|
||||
Reference in New Issue
Block a user