diff --git a/v3/pkg/application/dialogs_darwin.go b/v3/pkg/application/dialogs_darwin.go index dd46a5542..06a999451 100644 --- a/v3/pkg/application/dialogs_darwin.go +++ b/v3/pkg/application/dialogs_darwin.go @@ -70,13 +70,24 @@ static void* createAlert(int alertType, char* title, char *message, void *icon, static int dialogRunModal(void *dialog, void *parent) { NSAlert *alert = (__bridge NSAlert *)dialog; - long response; - if( parent != NULL ) { - NSWindow *window = (__bridge NSWindow *)parent; - response = [alert runModalSheetForWindow:window]; - } else { + __block long response; + //if( parent != NULL ) { + // NSWindow *window = (__bridge NSWindow *)parent; + // response = [alert runModalSheetForWindow:window]; + //} else { + // response = [alert runModal]; + //} + + // If the parent is NULL, we are running a modal dialog, otherwise attach the alert to the parent + if( parent == NULL ) { response = [alert runModal]; + } else { + NSWindow *window = (__bridge NSWindow *)parent; + [alert beginSheetModalForWindow:window completionHandler:^(NSModalResponse returnCode) { + response = returnCode; + }]; } + int result; if( response == NSAlertFirstButtonReturn ) { @@ -350,9 +361,10 @@ func (m *macosDialog) show() { iconLength = C.int(len(globalApplication.options.Icon)) } } + var parent unsafe.Pointer if m.dialog.window != nil { // get NSWindow from window - nsWindow = m.dialog.window.impl.(*macosWebviewWindow).nsWindow + parent = m.dialog.window.impl.(*macosWebviewWindow).nsWindow } alertType, ok := alertTypeMap[m.dialog.DialogType] @@ -360,7 +372,7 @@ func (m *macosDialog) show() { alertType = C.NSAlertStyleInformational } - m.nsDialog = C.createAlert(alertType, title, message, iconData, iconLength, nsWindow) + m.nsDialog = C.createAlert(alertType, title, message, iconData, iconLength) // Reverse the Buttons so that the default is on the right reversedButtons := make([]*Button, len(m.dialog.Buttons)) @@ -372,7 +384,7 @@ func (m *macosDialog) show() { count++ } - buttonPressed := int(C.dialogRunModal(m.nsDialog, nsWindow)) + buttonPressed := int(C.dialogRunModal(m.nsDialog, parent)) if len(m.dialog.Buttons) > buttonPressed { button := reversedButtons[buttonPressed] if button.Callback != nil { diff --git a/v3/pkg/application/systemtray_darwin.go b/v3/pkg/application/systemtray_darwin.go index fdf125a90..5e68e312c 100644 --- a/v3/pkg/application/systemtray_darwin.go +++ b/v3/pkg/application/systemtray_darwin.go @@ -130,6 +130,10 @@ func (s *macosSystemTray) setIcon(icon []byte) { }) } +func (s *macosSystemTray) setDarkModeIcon(icon []byte) { + s.setIcon(icon) +} + func (s *macosSystemTray) setTemplateIcon(icon []byte) { s.icon = icon s.isTemplateIcon = true diff --git a/v3/pkg/application/webview_window_darwin.go b/v3/pkg/application/webview_window_darwin.go index 7a073ec77..95ebd0a69 100644 --- a/v3/pkg/application/webview_window_darwin.go +++ b/v3/pkg/application/webview_window_darwin.go @@ -685,6 +685,10 @@ void setWindowEnabled(void *window, bool enabled) { [nsWindow setIgnoresMouseEvents:!enabled]; } +void windowSetEnabled(void *window, bool enabled) { + // TODO: Implement +} + */ import "C" import ( @@ -702,6 +706,10 @@ type macosWebviewWindow struct { parent *WebviewWindow } +func (w *macosWebviewWindow) setAbsolutePosition(x int, y int) { + C.windowSetAbsolutePosition(w.nsWindow, C.int(x), C.int(y)) +} + func (w *macosWebviewWindow) print() error { C.windowPrint(w.nsWindow) return nil @@ -959,9 +967,6 @@ func (w *macosWebviewWindow) setRelativePosition(x, y int) { C.windowSetRelativePosition(w.nsWindow, C.int(x), C.int(y)) } -func (w *macosWebviewWindow) setRelativePosition(x, y int) { - C.windowSetAbsolutePosition(w.nsWindow, C.int(x), C.int(y)) -} func (w *macosWebviewWindow) width() int { var width C.int var wg sync.WaitGroup