mirror of
https://github.com/netbirdio/systray.git
synced 2026-05-22 17:08:41 -07:00
On windows, call on_exit at WM_QUERYENDSESSION
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4
-9
@@ -2,7 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/getlantern/systray"
|
||||
"github.com/getlantern/systray/example/icon"
|
||||
@@ -10,16 +11,10 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
file, err := os.Create("out.txt")
|
||||
if err != nil {
|
||||
fmt.Println("Couldn't create out.txt")
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
onExit := func() {
|
||||
fmt.Println("Starting onExit")
|
||||
file.Write([]byte("On Exit...\n"))
|
||||
file.Sync()
|
||||
now := time.Now()
|
||||
ioutil.WriteFile(fmt.Sprintf(`on_exit_%d.txt`, now.UnixNano()), []byte(now.String()), 0644)
|
||||
fmt.Println("Finished onExit")
|
||||
}
|
||||
// Should be called at the very beginning of main().
|
||||
|
||||
@@ -68,8 +68,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case WM_ENDSESSION:
|
||||
printf("Session ended\n");
|
||||
case WM_QUERYENDSESSION:
|
||||
printf("Session ending\n");
|
||||
// We call on_exit here so that the program has a chance to do cleanup
|
||||
// before the final session ending sequence occurs.
|
||||
systray_on_exit(0/*ignored*/);
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
break;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user