aboutsummaryrefslogtreecommitdiffstats
path: root/systray_windows.go
diff options
context:
space:
mode:
authorjoesis2017-06-20 11:15:46 +0800
committerjoesis2017-06-20 11:51:19 +0800
commit6c75433ef1a85cae3919dcf1e3fb29e0b8fd03f7 (patch)
tree2534f1a3b79397d2e523eaaed5832a90714e54f5 /systray_windows.go
parent0068f6ae40ea39bfd683043e8452024097fff0e4 (diff)
downloadsystray-6c75433ef1a85cae3919dcf1e3fb29e0b8fd03f7.tar.bz2
add systray_on_exit callback
Diffstat (limited to 'systray_windows.go')
-rw-r--r--systray_windows.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/systray_windows.go b/systray_windows.go
index 7630c82..664af0c 100644
--- a/systray_windows.go
+++ b/systray_windows.go
@@ -5,19 +5,18 @@ import (
"io/ioutil"
"os"
"path/filepath"
- "syscall"
"runtime"
+ "syscall"
"unsafe"
"github.com/getlantern/filepersist"
)
var (
- iconFiles = make([]*os.File, 0)
- dllDir = filepath.Join(os.Getenv("APPDATA"), "systray")
+ iconFiles = make([]*os.File, 0)
+ dllDir = filepath.Join(os.Getenv("APPDATA"), "systray")
dllFileName = "systray" + runtime.GOARCH + ".dll"
- dllFile = filepath.Join(dllDir, dllFileName)
-
+ dllFile = filepath.Join(dllDir, dllFileName)
mod = syscall.NewLazyDLL(dllFile)
_nativeLoop = mod.NewProc("nativeLoop")
@@ -32,23 +31,24 @@ func init() {
// Write DLL to file
b, err := Asset(dllFileName)
if err != nil {
- panic(fmt.Errorf("Unable to read " + dllFileName + ": %v", err))
+ panic(fmt.Errorf("Unable to read "+dllFileName+": %v", err))
}
err = os.MkdirAll(dllDir, 0755)
if err != nil {
- panic(fmt.Errorf("Unable to create directory %v to hold " + dllFileName + ": %v", dllDir, err))
+ panic(fmt.Errorf("Unable to create directory %v to hold "+dllFileName+": %v", dllDir, err))
}
err = filepersist.Save(dllFile, b, 0644)
if err != nil {
- panic(fmt.Errorf("Unable to save " + dllFileName + " to %v: %v", dllFile, err))
+ panic(fmt.Errorf("Unable to save "+dllFileName+" to %v: %v", dllFile, err))
}
}
func nativeLoop() {
_nativeLoop.Call(
syscall.NewCallbackCDecl(systray_ready),
+ syscall.NewCallbackCDecl(systray_on_exit),
syscall.NewCallbackCDecl(systray_menu_item_selected))
}
@@ -151,6 +151,11 @@ func systray_ready(ignore uintptr) uintptr {
return 0
}
+func systray_on_exit(ignore uintptr) uintptr {
+ systrayExit()
+ return 0
+}
+
func systray_menu_item_selected(id uintptr) uintptr {
systrayMenuItemSelected(int32(id))
return 0