summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2010-11-12 21:06:24 +0000
committerSilenio Quarti <silenio>2010-11-12 21:06:24 +0000
commit43f69591d2861e44e31ebc47702400b2a09fcdc6 (patch)
tree855f8d7edc21c3e282c90cf07631c255a3981a99 /bundles/org.eclipse.swt/Eclipse SWT
parent0aefae2205ecbebdf2518c8c6d05ab0032e5adad (diff)
downloadeclipse.platform.swt-43f69591d2861e44e31ebc47702400b2a09fcdc6.tar.gz
eclipse.platform.swt-43f69591d2861e44e31ebc47702400b2a09fcdc6.tar.xz
eclipse.platform.swt-43f69591d2861e44e31ebc47702400b2a09fcdc6.zip
Bug 285879 - [Widgets] Wrong postion of popup menus for tray icons on linux (ubuntu) causes accidental selection of the first menu item
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java8
3 files changed, 25 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index de2f2e39a6..52ea794eb8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -167,6 +167,7 @@ public class Display extends Device {
/* System Tray */
Tray tray;
+ TrayItem currentTrayItem;
/* Timers */
int [] timerIds;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 796e6a1c7c..af48795516 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -210,13 +210,28 @@ void _setVisible (boolean visible) {
}
}
int /*long*/ address = hasLocation ? display.menuPositionProc: 0;
+ int /*long*/ data = 0;
+ if ((OS.GTK_VERSION >= OS.VERSION (2, 10, 0))) {
+ /*
+ * Popup-menu to the status icon should be aligned to
+ * Tray rather than to cursor position. There is a
+ * possibility (unlikely) that TrayItem might have
+ * been disposed in the listener, for which case
+ * the menu should be shown in the cursor position.
+ */
+ TrayItem item = display.currentTrayItem;
+ if (item != null && !item.isDisposed()) {
+ data = item.handle;
+ address = OS.gtk_status_icon_position_menu_func ();
+ }
+ }
/*
* Bug in GTK. The timestamp passed into gtk_menu_popup is used
* to perform an X pointer grab. It cannot be zero, else the grab
* will fail. The fix is to ensure that the timestamp of the last
* event processed is used.
*/
- OS.gtk_menu_popup (handle, 0, 0, address, 0, 0, display.getLastEventTime ());
+ OS.gtk_menu_popup (handle, 0, 0, address, data, 0, display.getLastEventTime ());
} else {
sendEvent (SWT.Hide);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
index ca2e9be981..3484fef1b5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
@@ -329,7 +329,15 @@ int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
}
int /*long*/ gtk_status_icon_popup_menu (int /*long*/ widget, int /*long*/ button, int /*long*/ activate_time) {
+ /*
+ * GTK provides a MenuPositionFunc for GtkStatusIcon in order
+ * to set the popup-menu aligned to the tray.
+ */
+ Display display = this.display;
+ display.currentTrayItem = this;
sendEvent (SWT.MenuDetect);
+ if (!isDisposed ()) display.runPopups();
+ display.currentTrayItem = null;
return 0;
}