Bug 569296 - AbstractNotificationPopup appears at unexpected position
* Do not create a dummy shell for parent. This caused the
implementation of getPrimaryClientArea() to never fall
back to the primary monitor.
* Fine-tune position of the popup by taking the usable client area
of the parent shell into account.
Change-Id: I877ed5357ef2e1cd97eccb6f3454bd60cba18c87
Signed-off-by: Sebastian Ratz <sebastian.ratz@sap.com>
diff --git a/bundles/org.eclipse.jface.notifications/src/org/eclipse/jface/notifications/AbstractNotificationPopup.java b/bundles/org.eclipse.jface.notifications/src/org/eclipse/jface/notifications/AbstractNotificationPopup.java
index 7de7e9a..adc076c 100644
--- a/bundles/org.eclipse.jface.notifications/src/org/eclipse/jface/notifications/AbstractNotificationPopup.java
+++ b/bundles/org.eclipse.jface.notifications/src/org/eclipse/jface/notifications/AbstractNotificationPopup.java
@@ -107,7 +107,7 @@
}
public AbstractNotificationPopup(Display display, int style) {
- super(new Shell(display));
+ super((Shell) null);
setShellStyle(style);
this.display = display;
@@ -387,8 +387,14 @@
}
private Rectangle getPrimaryClientArea() {
- if (getParentShell() != null) {
- return getParentShell().getBounds();
+ Shell parentShell = getParentShell();
+ if (parentShell != null) {
+ // calculate client area in display-relative coordinates
+ // (i.e. without window border / decorations)
+ Rectangle bounds = parentShell.getBounds();
+ Rectangle trim = parentShell.computeTrim(0, 0, 0, 0);
+ return new Rectangle(bounds.x - trim.x, bounds.y - trim.y, bounds.width - trim.width,
+ bounds.height - trim.height);
}
// else display on primary monitor
Monitor primaryMonitor = this.shell.getDisplay().getPrimaryMonitor();