This commit is contained in:
Josef Zeman 2026-03-08 00:00:34 +01:00 committed by GitHub
commit 1369c2011a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -256,6 +256,30 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
config.userContentController = userContentController;
self.userContentController = userContentController;
WKUserScript *doubleClickScript = [[WKUserScript alloc]
initWithSource:@"document.addEventListener('dblclick', function(e) { \
let el = e.target; \
while (el) { \
if (el.hasAttribute && el.hasAttribute('data-wails-drag')) { \
window.webkit.messageHandlers.external.postMessage('titlebar-doubleclick'); \
e.preventDefault(); \
return; \
} \
const style = window.getComputedStyle(el); \
if (style.getPropertyValue('-webkit-app-region') === 'drag' || \
style.getPropertyValue('--wails-draggable') === 'drag') { \
window.webkit.messageHandlers.external.postMessage('titlebar-doubleclick'); \
e.preventDefault(); \
return; \
} \
el = el.parentElement; \
} \
}, true);"
injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
forMainFrameOnly:false];
[userContentController addUserScript:doubleClickScript];
[doubleClickScript release];
if (self.devtoolsEnabled) {
[config.preferences setValue:@YES forKey:@"developerExtrasEnabled"];
}
@ -494,13 +518,30 @@ typedef void (^schemeTaskCaller)(id<WKURLSchemeTask>);
NSString *m = message.body;
if ( [m isEqualToString:@"titlebar-doubleclick"] ) {
if ( [self IsFullScreen] ) {
return;
}
NSString *action = [[NSUserDefaults standardUserDefaults]
stringForKey:@"AppleActionOnDoubleClick"];
if (action == nil || [action isEqualToString:@"Maximize"]) {
[self ToggleMaximise];
} else if ([action isEqualToString:@"Minimize"]) {
[self Minimise];
}
return;
}
// Check for drag
if ( [m isEqualToString:@"drag"] ) {
if( [self IsFullScreen] ) {
return;
}
if( self.mouseEvent != nil ) {
[self.mainWindow performWindowDragWithEvent:self.mouseEvent];
[self.mainWindow performWindowDragWithEvent:self.mouseEvent];
}
return;
}