mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 17:39:58 +08:00

* 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
79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
//go:build darwin && (dev || debug || devtools)
|
|
|
|
package darwin
|
|
|
|
// We are using private APIs here, make sure this is only included in a dev/debug build and not in a production build.
|
|
// Otherwise the binary might get rejected by the AppReview-Team when pushing it to the AppStore.
|
|
|
|
/*
|
|
#cgo CFLAGS: -x objective-c
|
|
#cgo LDFLAGS: -framework Foundation -framework Cocoa -framework WebKit
|
|
#import <Foundation/Foundation.h>
|
|
#import "WailsContext.h"
|
|
|
|
extern void processMessage(const char *message);
|
|
|
|
@interface _WKInspector : NSObject
|
|
- (void)show;
|
|
- (void)detach;
|
|
@end
|
|
|
|
@interface WKWebView ()
|
|
- (_WKInspector *)_inspector;
|
|
@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;
|
|
|
|
@try {
|
|
[ctx.webview._inspector show];
|
|
} @catch (NSException *exception) {
|
|
NSLog(@"Opening the inspector failed: %@", exception.reason);
|
|
return;
|
|
}
|
|
|
|
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
|
|
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
|
|
// Detach must be deferred a little bit and is ignored directly after a show.
|
|
@try {
|
|
[ctx.webview._inspector detach];
|
|
} @catch (NSException *exception) {
|
|
NSLog(@"Detaching the inspector failed: %@", exception.reason);
|
|
}
|
|
});
|
|
} else {
|
|
NSLog(@"Opening the inspector needs at least MacOS 12");
|
|
}
|
|
);
|
|
#endif
|
|
}
|
|
|
|
void setupF12hotkey() {
|
|
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown handler:^NSEvent * _Nullable(NSEvent * _Nonnull event) {
|
|
if (event.keyCode == 111 &&
|
|
event.modifierFlags & NSEventModifierFlagFunction &&
|
|
event.modifierFlags & NSEventModifierFlagCommand &&
|
|
event.modifierFlags & NSEventModifierFlagShift) {
|
|
processMessage("wails:openInspector");
|
|
return nil;
|
|
}
|
|
return event;
|
|
}];
|
|
}
|
|
*/
|
|
import "C"
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
func init() {
|
|
C.setupF12hotkey()
|
|
}
|
|
|
|
func showInspector(context unsafe.Pointer) {
|
|
C.showInspector(context)
|
|
}
|