Skip to content

Commit

Permalink
[v2 mac] add fullscreen option to preference
Browse files Browse the repository at this point in the history
  • Loading branch information
fkhadra committed Sep 29, 2023
1 parent e31ad83 commit b8de068
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions v2/internal/frontend/desktop/darwin/WailsContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
struct Preferences {
bool *tabFocusesLinks;
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;
Expand Down
6 changes: 6 additions & 0 deletions v2/internal/frontend/desktop/darwin/WailsContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ - (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable
config.preferences.textInteractionEnabled = *preferences.textInteractionEnabled;
}
}

if (@available(macOS 12.3, *)) {
if (preferences.fullscreenEnabled != NULL) {
config.preferences.elementFullscreenEnabled = *preferences.fullscreenEnabled;
}
}

// [config.preferences setValue:[NSNumber numberWithBool:true] forKey:@"developerExtrasEnabled"];

Expand Down
4 changes: 4 additions & 0 deletions v2/internal/frontend/desktop/darwin/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func NewWindow(frontendOptions *options.App, debug bool, devtools bool) *Window
if mac.Preferences.TextInteractionEnabled.IsSet() {
preferences.textInteractionEnabled = bool2CboolPtr(mac.Preferences.TextInteractionEnabled.Get())
}

if mac.Preferences.FullscreenEnabled.IsSet() {
preferences.fullscreenEnabled = bool2CboolPtr(mac.Preferences.FullscreenEnabled.Get())
}
}

windowIsTranslucent = bool2Cint(mac.WindowIsTranslucent)
Expand Down
3 changes: 3 additions & 0 deletions v2/pkg/options/mac/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ type Preferences struct {
// A Boolean value that indicates whether to allow people to select or otherwise interact with text.
// Set to true by default.
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
}
3 changes: 3 additions & 0 deletions website/docs/reference/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -812,13 +812,15 @@ You can specify the webview preferences.
type Preferences struct {
TabFocusesLinks u.Bool
TextInteractionEnabled u.Bool
FullscreenEnabled u.Bool
}
```

| Name | Description |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 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) |
| 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:

Expand All @@ -827,6 +829,7 @@ Mac: &mac.Options{
Preferences: &mac.Preferences{
TabFocusesLinks: mac.Enabled,
TextInteractionEnabled: mac.Disabled,
FullscreenEnabled: mac.Enabled,
}
}
```
Expand Down

0 comments on commit b8de068

Please sign in to comment.