5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 03:40:12 +08:00

[v2 mac] add fullscreen option to preference (#2953)

* [v2 mac] add fullscreen option to preference

* update changelog

* replace space by tabs
This commit is contained in:
Fadi Khadra 2023-10-01 22:05:25 +02:00 committed by GitHub
parent 1c9765096d
commit f6c82dcaba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 0 deletions

View File

@ -58,6 +58,7 @@
struct Preferences { struct Preferences {
bool *tabFocusesLinks; bool *tabFocusesLinks;
bool *textInteractionEnabled; bool *textInteractionEnabled;
bool *fullscreenEnabled;
}; };
- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString *)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight :(bool)fraudulentWebsiteWarningEnabled :(struct Preferences)preferences; - (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString *)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight :(bool)fraudulentWebsiteWarningEnabled :(struct Preferences)preferences;

View File

@ -225,6 +225,12 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
} }
} }
if (@available(macOS 12.3, *)) {
if (preferences.fullscreenEnabled != NULL) {
config.preferences.elementFullscreenEnabled = *preferences.fullscreenEnabled;
}
}
// [config.preferences setValue:[NSNumber numberWithBool:true] forKey:@"developerExtrasEnabled"]; // [config.preferences setValue:[NSNumber numberWithBool:true] forKey:@"developerExtrasEnabled"];
if (@available(macOS 10.15, *)) { if (@available(macOS 10.15, *)) {

View File

@ -95,6 +95,10 @@ func NewWindow(frontendOptions *options.App, debug bool, devtools bool) *Window
if mac.Preferences.TextInteractionEnabled.IsSet() { if mac.Preferences.TextInteractionEnabled.IsSet() {
preferences.textInteractionEnabled = bool2CboolPtr(mac.Preferences.TextInteractionEnabled.Get()) preferences.textInteractionEnabled = bool2CboolPtr(mac.Preferences.TextInteractionEnabled.Get())
} }
if mac.Preferences.FullscreenEnabled.IsSet() {
preferences.fullscreenEnabled = bool2CboolPtr(mac.Preferences.FullscreenEnabled.Get())
}
} }
windowIsTranslucent = bool2Cint(mac.WindowIsTranslucent) windowIsTranslucent = bool2Cint(mac.WindowIsTranslucent)

View File

@ -13,4 +13,7 @@ type Preferences struct {
// A Boolean value that indicates whether to allow people to select or otherwise interact with text. // A Boolean value that indicates whether to allow people to select or otherwise interact with text.
// Set to true by default. // Set to true by default.
TextInteractionEnabled u.Bool TextInteractionEnabled u.Bool
// A Boolean value that indicates whether a web view can display content full screen.
// Set to false by default
FullscreenEnabled u.Bool
} }

View File

@ -812,6 +812,7 @@ You can specify the webview preferences.
type Preferences struct { type Preferences struct {
TabFocusesLinks u.Bool TabFocusesLinks u.Bool
TextInteractionEnabled u.Bool TextInteractionEnabled u.Bool
FullscreenEnabled u.Bool
} }
``` ```
@ -819,6 +820,7 @@ type Preferences struct {
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| TabFocusesLinks | A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/2818595-tabfocuseslinks?language=objc) | | TabFocusesLinks | A Boolean value that indicates whether pressing the tab key changes the focus to links and form controls. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/2818595-tabfocuseslinks?language=objc) |
| TextInteractionEnabled | A Boolean value that indicates whether to allow people to select or otherwise interact with text. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/3727362-textinteractionenabled?language=objc) | | TextInteractionEnabled | A Boolean value that indicates whether to allow people to select or otherwise interact with text. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/3727362-textinteractionenabled?language=objc) |
| FullscreenEnabled | A Boolean value that indicates whether a web view can display content full screen. [Apple Docs](https://developer.apple.com/documentation/webkit/wkpreferences/3917769-elementfullscreenenabled?language=objc) |
Example: Example:
@ -827,6 +829,7 @@ Mac: &mac.Options{
Preferences: &mac.Preferences{ Preferences: &mac.Preferences{
TabFocusesLinks: mac.Enabled, TabFocusesLinks: mac.Enabled,
TextInteractionEnabled: mac.Disabled, TextInteractionEnabled: mac.Disabled,
FullscreenEnabled: mac.Enabled,
} }
} }
``` ```

View File

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for enabling/disabling swipe gestures for Windows WebView2. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2878) - Added support for enabling/disabling swipe gestures for Windows WebView2. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2878)
- When building with `-devtools` flag, CMD/CTRL+SHIFT+F12 can be used to open the devtools. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2915) - When building with `-devtools` flag, CMD/CTRL+SHIFT+F12 can be used to open the devtools. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2915)
- Added support for setting some of the Webview preferences, `textInteractionEnabled` and `tabFocusesLinks` on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2937) - Added support for setting some of the Webview preferences, `textInteractionEnabled` and `tabFocusesLinks` on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2937)
- Added support for enabling/disabling fullscreen of the Webview on Mac. Added by @fkhadra in [PR](https://github.com/wailsapp/wails/pull/2953)
### Changed ### Changed