From: Lars Op den Kamp Date: Fri, 13 Dec 2013 14:35:13 +0000 (+0100) Subject: guard against the screensaver failing to be activated. don't disconnect from libCEC... X-Git-Tag: upstream/2.2.0~1^2~3^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e9698d4a08bc15ff64f6f5ee8e0ae19f2cdb139f;p=deb_libcec.git guard against the screensaver failing to be activated. don't disconnect from libCEC when away mode is activated, but just send standby. bugzid: 1375 --- diff --git a/src/LibCecTray/ui/CECTray.cs b/src/LibCecTray/ui/CECTray.cs index 3f7c094..0b8d17c 100644 --- a/src/LibCecTray/ui/CECTray.cs +++ b/src/LibCecTray/ui/CECTray.cs @@ -59,6 +59,8 @@ namespace LibCECTray.ui _sstimer.Tick += ScreensaverActiveCheck; _sstimer.Enabled = false; + _lastScreensaverActivated = DateTime.Now; + VisibleChanged += delegate { if (!Visible) @@ -114,8 +116,14 @@ namespace LibCECTray.ui // there's no event for screensaver exit if (!_sstimer.Enabled) { - _sstimer.Enabled = true; - Controller.CECActions.SendStandby(CecLogicalAddress.Broadcast); + // guard against screensaver failing, and resulting in power up and down spam to the tv + TimeSpan diff = DateTime.Now - _lastScreensaverActivated; + if (diff.TotalSeconds > 60) + { + _sstimer.Enabled = true; + _lastScreensaverActivated = DateTime.Now; + Controller.CECActions.SendStandby(CecLogicalAddress.Broadcast); + } } } else if (msg.Msg == WM_POWERBROADCAST) @@ -144,7 +152,7 @@ namespace LibCECTray.ui //OnWake(); //return; case 1: - OnSleep(); + Controller.CECActions.SendStandby(CecLogicalAddress.Broadcast); return; default: break; @@ -616,6 +624,7 @@ namespace LibCECTray.ui } private System.Windows.Forms.Timer _sstimer = new System.Windows.Forms.Timer(); + private DateTime _lastScreensaverActivated; #endregion private void AddNewApplicationToolStripMenuItemClick(object sender, EventArgs e)