mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 21:33:57 -07:00
Only poll the ZeroTier service when the menu or Network List are visible. Reduces CPU idle prevention by a a LOT
This commit is contained in:
parent
b9a4d138fc
commit
78e5a00a68
3 changed files with 27 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
|||
import Cocoa
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
|
||||
@IBOutlet weak var window: NSWindow!
|
||||
|
||||
|
@ -85,6 +85,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
self.showAbout()
|
||||
}
|
||||
}
|
||||
|
||||
monitor.updateNetworkInfo()
|
||||
}
|
||||
|
||||
func applicationWillTerminate(aNotification: NSNotification) {
|
||||
|
@ -181,6 +183,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
|
||||
func buildMenu() {
|
||||
let menu = NSMenu()
|
||||
menu.delegate = self
|
||||
|
||||
if let s = self.status {
|
||||
menu.addItem(NSMenuItem(title: "Node ID: \(s.address)", action: #selector(AppDelegate.copyNodeID), keyEquivalent: ""))
|
||||
|
@ -230,7 +233,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
menu.addItem(NSMenuItem(title: "Quit ZeroTier One", action: #selector(AppDelegate.quit), keyEquivalent: "q"))
|
||||
|
||||
statusItem.menu = menu
|
||||
|
||||
}
|
||||
|
||||
func toggleNetwork(sender: NSMenuItem) {
|
||||
|
@ -253,5 +255,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
pasteboard.setString(s.address, forType: NSPasteboardTypeString)
|
||||
}
|
||||
}
|
||||
|
||||
func menuWillOpen(menu: NSMenu) {
|
||||
monitor.start()
|
||||
}
|
||||
|
||||
func menuDidClose(menu: NSMenu) {
|
||||
monitor.stop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue