Skip to content

Commit

Permalink
Add better macos guard for elementFullscreenEnabled (#3111)
Browse files Browse the repository at this point in the history
* Add better macos guard for elementFullscreenEnabled

* Disable go linters as they constantly error

* Run full check on bugfix branches

* Update to Go 1.20+1.21

* Update github.com/tc-hib/winres to v0.2.1

* Update setup-go to v4

* Try fix for Go 1.20

* Fix go.mod

* Update go sum

* Revert to builds on Go 1.18 + 1.19

* Update Go version to 1.19 for all workflows and modules

The Go version is updated to 1.19 across all GitHub Actions workflows and go.mod files. All builds and tests will now only run on Go 1.19, simplifying our build matrix, and ensuring we're testing on the latest stable Go version.

* Update build-and-test workflow for MacOS version and Go version

The build-and-test workflow has been updated to run tests on 'macos-11' in addition to 'macos-latest'. Furthermore, Go version for the tests has been set to '1.19' only.

* Update actions versions

* Move to go 1.20 and improve caching

* Move to go 1.20 and improve caching

* Add additional guards
  • Loading branch information
leaanthony authored Dec 9, 2023
1 parent c3d57d0 commit 975c55a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 49 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,31 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-11]
go-version: [1.20, 1.21]
go-version: ['1.20']

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install linux dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: ./v2/go.sum

- name: Run tests (mac)
if: matrix.os == 'macos-latest'
if: matrix.os == 'macos-latest' || matrix.os == 'macos-11'
env:
CGO_LDFLAGS: -framework UniformTypeIdentifiers -mmacosx-version-min=10.13
working-directory: ./v2
run: go test -v ./...

- name: Run tests (!mac)
if: matrix.os != 'macos-latest'
if: matrix.os != 'macos-latest' && matrix.os != 'macos-11'
working-directory: ./v2
run: go test -v ./...

Expand All @@ -50,7 +51,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down Expand Up @@ -89,15 +90,16 @@ jobs:
vanilla-ts,
plain,
]
go-version: [1.18, 1.19]
go-version: ['1.20']
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: ./v2/go.sum

- name: Build Wails CLI
run: |
Expand Down
46 changes: 23 additions & 23 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ jobs:
run: |
echo "::warning::Feature branch does not contain any changes to the website."
lint_go:
name: Run Go Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Update go modules
working-directory: ./v2
run: go mod tidy

- name: Run Linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
working-directory: ./v2
args: --timeout=10m0s --config ./.golangci.yml
# lint_go:
# name: Run Go Linters
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Setup Go
# uses: actions/setup-go@v4
# with:
# go-version: "1.21"
#
# - name: Update go modules
# working-directory: ./v2
# run: go mod tidy
#
# - name: Run Linter
# uses: golangci/golangci-lint-action@v3
# with:
# version: v1.54
# working-directory: ./v2
# args: --timeout=10m0s --config ./.golangci.yml

test_go:
name: Run Go Tests
Expand All @@ -56,7 +56,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
go-version: [1.18, 1.19]
go-version: [1.19]

steps:
- name: Checkout code
Expand Down
4 changes: 1 addition & 3 deletions v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/wailsapp/wails/v2

go 1.21

toolchain go1.21.0
go 1.20

require (
github.com/Masterminds/semver v1.5.0
Expand Down
6 changes: 0 additions & 6 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tc-hib/winres v0.1.5 h1:2dA5yfjdoEA3UyRaOC92HNMt3jap66pLzoW4MjpC/0M=
github.com/tc-hib/winres v0.1.5/go.mod h1:pe6dOR40VOrGz8PkzreVKNvEKnlE8t4yR8A8naL+t7A=
github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA=
github.com/tc-hib/winres v0.2.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk=
github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
Expand Down Expand Up @@ -257,9 +255,6 @@ golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.10.0 h1:gXjUUtwtx5yOE0VKWq1CH4IJAClq4UGgUA3i+rpON9M=
golang.org/x/image v0.10.0/go.mod h1:jtrku+n79PfroUbvDdeUWMAI+heR786BofxrbiSF+J0=
golang.org/x/image v0.12.0 h1:w13vZbU4o5rKOFFR8y7M+c4A5jXDC0uXTdHYRP8X2DQ=
golang.org/x/image v0.12.0/go.mod h1:Lu90jvHG7GfemOIcldsh9A2hS01ocl6oNO7ype5mEnk=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand Down Expand Up @@ -320,7 +315,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
3 changes: 2 additions & 1 deletion v2/internal/frontend/desktop/darwin/Application.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ void ReleaseContext(void *inctx) {
// Credit: https://stackoverflow.com/q/33319295
void WindowPrint(void *inctx) {

// Check if macOS 11.0 or newer
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (@available(macOS 11.0, *)) {
ON_MAIN_THREAD(
WailsContext *ctx = (__bridge WailsContext*) inctx;
Expand Down Expand Up @@ -424,4 +424,5 @@ void WindowPrint(void *inctx) {
[po runOperationModalForWindow:ctx.mainWindow delegate:ctx.mainWindow.delegate didRunSelector:nil contextInfo:nil];
)
}
#endif
}
25 changes: 19 additions & 6 deletions v2/internal/frontend/desktop/darwin/WailsContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,27 @@ - (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable
config.preferences.tabFocusesLinks = *preferences.tabFocusesLinks;
}

#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110300
if (@available(macOS 11.3, *)) {
if (preferences.textInteractionEnabled != NULL) {
config.preferences.textInteractionEnabled = *preferences.textInteractionEnabled;
}
}
#endif

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

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

#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101500
if (@available(macOS 10.15, *)) {
config.preferences.fraudulentWebsiteWarningEnabled = fraudulentWebsiteWarningEnabled;
}
#endif

WKUserContentController* userContentController = [WKUserContentController new];
[userContentController addScriptMessageHandler:self name:@"external"];
Expand Down Expand Up @@ -431,10 +435,11 @@ - (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelPara

NSOpenPanel *openPanel = [NSOpenPanel openPanel];
openPanel.allowsMultipleSelection = parameters.allowsMultipleSelection;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
if (@available(macOS 10.14, *)) {
openPanel.canChooseDirectories = parameters.allowsDirectories;
}
#endif
[openPanel
beginSheetModalForWindow:webView.window
completionHandler:^(NSInteger result) {
Expand Down Expand Up @@ -558,14 +563,18 @@ -(void) OpenFileDialog :(NSString*)title :(NSString*)defaultFilename :(NSString*
#ifdef USE_NEW_FILTERS
NSMutableArray *contentTypes = [[NSMutableArray new] autorelease];
for (NSString *filter in filterList) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (@available(macOS 11.0, *)) {
UTType *t = [UTType typeWithFilenameExtension:filter];
[contentTypes addObject:t];
}
#endif
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (@available(macOS 11.0, *)) {
[dialog setAllowedContentTypes:contentTypes];
}
#endif
#else
[dialog setAllowedFileTypes:filterList];
#endif
Expand Down Expand Up @@ -638,17 +647,21 @@ -(void) SaveFileDialog :(NSString*)title :(NSString*)defaultFilename :(NSString*
#ifdef USE_NEW_FILTERS
NSMutableArray *contentTypes = [[NSMutableArray new] autorelease];
for (NSString *filter in filterList) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (@available(macOS 11.0, *)) {
UTType *t = [UTType typeWithFilenameExtension:filter];
[contentTypes addObject:t];
}
#endif
}
if( contentTypes.count == 0) {
[dialog setAllowsOtherFileTypes:true];
} else {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (@available(macOS 11.0, *)) {
[dialog setAllowedContentTypes:contentTypes];
}
#endif
}

#else
Expand Down
3 changes: 2 additions & 1 deletion v2/internal/frontend/desktop/darwin/inspector_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern void processMessage(const char *message);
@end
void showInspector(void *inctx) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
ON_MAIN_THREAD(
if (@available(macOS 12.0, *)) {
WailsContext *ctx = (__bridge WailsContext*) inctx;
Expand All @@ -47,7 +48,7 @@ void showInspector(void *inctx) {
NSLog(@"Opening the inspector needs at least MacOS 12");
}
);
#endif
}
void setupF12hotkey() {
Expand Down

0 comments on commit 975c55a

Please sign in to comment.