@@ -38,14 +38,16 @@ internal class TrayApplicationContext : ApplicationContext {
3838 private DateTimeOffset lastAutoOptimizationByMemoryUsage = DateTimeOffset . Now ;
3939 private DateTimeOffset lastUpdateCheckTime = DateTimeOffset . Now . AddHours ( - AutoUpdateCheckInterval ) . AddSeconds ( 10 ) ;
4040 private byte optimizationProgressPercentage ;
41+ private DateTime lastClickTime = DateTime . MinValue ;
42+ private readonly int doubleClickThreshold = SystemInformation . DoubleClickTime ;
4143
4244 public TrayApplicationContext ( ) {
4345 imageIcon = Icon . ExtractAssociatedIcon ( Updater . CurrentFileLocation ) ;
4446 notifyIcon = new NotifyIcon ( components ) {
4547 ContextMenuStrip = new ContextMenuStrip ( ) ,
4648 Icon = imageIcon ,
4749 Text = Updater . ApplicationTitle ,
48- Visible = true
50+ Visible = true ,
4951 } ;
5052 //notifyIcon.MouseUp += (s, e) => {
5153 // if (e.Button != MouseButtons.Left) return;
@@ -57,7 +59,18 @@ public TrayApplicationContext() {
5759 if ( notifyIcon . Text != iconText )
5860 notifyIcon . Text = iconText . Length > 63 ? iconText . Substring ( 0 , 63 ) : iconText ;
5961 } ;
60- notifyIcon . DoubleClick += ( s , e ) => {
62+ notifyIcon . MouseDown += ( s , e ) => {
63+ if ( e . Button != MouseButtons . Left )
64+ return ;
65+ var now = DateTime . Now ;
66+ if ( ( now - lastClickTime ) . TotalMilliseconds > doubleClickThreshold ) {
67+ lastClickTime = now ;
68+ return ;
69+ }
70+ //real double-click
71+ lastClickTime = DateTime . MinValue ;
72+ //};
73+ //notifyIcon.DoubleClick += (s, e) => {
6174 switch ( Settings . DoubleClickAction ) {
6275 case Enums . DoubleClickAction . Optimize :
6376 MenuItemOptimizeClick ( s , e ) ;
0 commit comments