From bdb9f5ac19d7fb22aa8d317fc307a505e765d277 Mon Sep 17 00:00:00 2001 From: Josef Zeman <47715641+josefzemanp@users.noreply.github.com> Date: Mon, 16 Feb 2026 20:30:03 +0100 Subject: [PATCH 1/2] feat(darwin): Add native double-click to maximize on custom titlebar --- .../frontend/desktop/darwin/WailsContext.m | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.m b/v2/internal/frontend/desktop/darwin/WailsContext.m index 7c9660d54..5610e4390 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.m +++ b/v2/internal/frontend/desktop/darwin/WailsContext.m @@ -256,6 +256,30 @@ typedef void (^schemeTaskCaller)(id); 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,18 @@ typedef void (^schemeTaskCaller)(id); NSString *m = message.body; + if ( [m isEqualToString:@"titlebar-doubleclick"] ) { + [self ToggleMaximise]; + 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; } From 60a067e6a842c002f4ff03c2b8ed0dac45186c25 Mon Sep 17 00:00:00 2001 From: Josef Zeman <47715641+josefzemanp@users.noreply.github.com> Date: Mon, 16 Feb 2026 20:58:18 +0100 Subject: [PATCH 2/2] fix(darwin): respect fullscreen and macOS titlebar double-click preference --- v2/internal/frontend/desktop/darwin/WailsContext.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.m b/v2/internal/frontend/desktop/darwin/WailsContext.m index 5610e4390..6517039b6 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.m +++ b/v2/internal/frontend/desktop/darwin/WailsContext.m @@ -519,7 +519,19 @@ typedef void (^schemeTaskCaller)(id); NSString *m = message.body; if ( [m isEqualToString:@"titlebar-doubleclick"] ) { - [self ToggleMaximise]; + 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; }