diff options
Diffstat (limited to 'bundles')
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; } |