From e21112145116ed6a282b8815e6a05ee2ea8f31bb Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Mon, 27 Jan 2020 18:11:38 +0000 Subject: [PATCH] Fixes (windows). --- msg_windows.go | 8 ++------ notify_windows.go | 7 +++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/msg_windows.go b/msg_windows.go index ffeb83e..1f148e0 100644 --- a/msg_windows.go +++ b/msg_windows.go @@ -13,7 +13,7 @@ var ( func message(kind messageKind, text string, options []Option) (bool, error) { opts := applyOptions(options) - var flags, caption uintptr + var flags uintptr switch { case kind == questionKind && opts.extraButton != "": @@ -41,10 +41,6 @@ func message(kind messageKind, text string, options []Option) (bool, error) { } } - if opts.title != "" { - caption = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(opts.title))) - } - if opts.okLabel != "" || opts.cancelLabel != "" || opts.extraButton != "" { runtime.LockOSThread() defer runtime.UnlockOSThread() @@ -58,7 +54,7 @@ func message(kind messageKind, text string, options []Option) (bool, error) { n, _, err := messageBox.Call(0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))), - caption, flags) + uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(opts.title))), flags) if n == 0 { return false, err diff --git a/notify_windows.go b/notify_windows.go index 4d84382..4cd2a81 100644 --- a/notify_windows.go +++ b/notify_windows.go @@ -1,6 +1,7 @@ package zenity import ( + "runtime" "syscall" "unsafe" ) @@ -33,8 +34,14 @@ func notify(text string, options []Option) error { args.InfoFlags |= 0x3 // NIIF_ERROR } + runtime.LockOSThread() + defer runtime.UnlockOSThread() + n, _, err := shellNotifyIcon.Call(0 /* NIM_ADD */, uintptr(unsafe.Pointer(&args))) if n == 0 { + if errno, ok := err.(syscall.Errno); ok && errno == 0 { + _, err = Info(text, Title(opts.title), Icon(opts.icon)) + } return err }