Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2016-03-07 14:20:56 +0000
committerNiraj Modi2016-03-18 13:13:44 +0000
commit4c34b178b62d14c343371b5ef81bc901a3612f5b (patch)
tree490e28398e8b35e1f434c64c9f8692f25415c573
parentc05f6dcca43adfd173bda1b25904a1047f961586 (diff)
downloadeclipse.platform.swt-R3_8_maintenance.tar.gz
eclipse.platform.swt-R3_8_maintenance.tar.xz
eclipse.platform.swt-R3_8_maintenance.zip
Bug 488739 - [Windows 10] Tray item icon is duplicated in someR3_8_maintenance
conditions Change-Id: Ideb9c573ee6d7cc96cbe7d4cb278e900be656582 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java
index 969b2595b9..ebc0294691 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TrayItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -78,7 +78,7 @@ public TrayItem (Tray parent, int style) {
super (parent, style);
this.parent = parent;
parent.createItem (this, parent.getItemCount ());
- createWidget ();
+ createUpdateWidget (true);
}
/**
@@ -145,14 +145,27 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-void createWidget () {
+void createUpdateWidget (boolean newIcon) {
NOTIFYICONDATA iconData = OS.IsUnicode ? (NOTIFYICONDATA) new NOTIFYICONDATAW () : new NOTIFYICONDATAA ();
iconData.cbSize = NOTIFYICONDATA.sizeof;
- iconData.uID = id = display.nextTrayId++;
+ /*
+ * As per MSDN article iconData.uID is unique for every TrayItem
+ * instance(https://msdn.microsoft.com/en-us/library/windows/desktop/
+ * bb762159%28v=vs.85%29.aspx) and this uID value should be specified
+ * during TrayItem instance creation & should be cached and used in
+ * subsequent calls to Shell_NotifyIcon to perform later actions on the
+ * TrayItem instance refer Win10 bug 488739.
+ */
+ iconData.uID = id = (newIcon ? display.nextTrayId++ : id);
iconData.hWnd = display.hwndMessage;
iconData.uFlags = OS.NIF_MESSAGE;
iconData.uCallbackMessage = Display.SWT_TRAYICONMSG;
- OS.Shell_NotifyIcon (OS.NIM_ADD, iconData);
+ /*
+ * OS.NIM_ADD message should be called only once in a TrayItem instance
+ * life-cycle i.e. in the TrayItem instance creation step only, else
+ * will lead to multiple TrayIcons entries on Win10 refer bug 488739.
+ */
+ OS.Shell_NotifyIcon ((newIcon ? OS.NIM_ADD : OS.NIM_MODIFY), iconData);
}
void destroyWidget () {
@@ -320,7 +333,7 @@ int /*long*/ messageProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /
}
void recreate () {
- createWidget ();
+ createUpdateWidget (false);
if (!visible) setVisible (false);
if (text.length () != 0) setText (text);
if (image != null) setImage (image);
@@ -559,7 +572,7 @@ public void setVisible (boolean visible) {
if (visible) {
iconData.uFlags = OS.NIF_MESSAGE;
iconData.uCallbackMessage = Display.SWT_TRAYICONMSG;
- OS.Shell_NotifyIcon (OS.NIM_ADD, iconData);
+ OS.Shell_NotifyIcon (OS.NIM_MODIFY, iconData);
setImage (image);
setToolTipText (toolTipText);
} else {

Back to the top