diff options
author | Damian Minkov <damencho@jitsi.org> | 2014-02-11 11:59:59 +0200 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2014-02-11 16:42:50 +0200 |
commit | d8c4a1e1f20674982a94bd827ec20ed7536ecb2d (patch) | |
tree | 9c1da0846ca72e07b2e3fcb76b40d7c188f27553 | |
parent | fa49941803ef121160b316d132eae3263be6139a (diff) | |
download | jitsi-d8c4a1e1f20674982a94bd827ec20ed7536ecb2d.zip jitsi-d8c4a1e1f20674982a94bd827ec20ed7536ecb2d.tar.gz jitsi-d8c4a1e1f20674982a94bd827ec20ed7536ecb2d.tar.bz2 |
Avoids showing contactlist tooltips if we are no longer focused on our window.
-rw-r--r-- | src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java b/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java index f1fbaab..e3ff3a2 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java @@ -20,6 +20,7 @@ import net.java.sip.communicator.util.*; * The tooltip shown over a contact in the contact list. * * @author Yana Stamcheva + * @author Damian Minkov */ public class ExtendedTooltip extends JToolTip @@ -193,7 +194,7 @@ public class ExtendedTooltip public void addLine(JLabel[] labels) { Dimension lineSize = null; - JPanel labelPanel = null; + JPanel labelPanel; if (labels.length > 0) { @@ -204,19 +205,19 @@ public class ExtendedTooltip else return; - if (labelPanel != null) - for (JLabel label : labels) - { - labelPanel.add(label); - if (lineSize == null) - lineSize = calculateLabelSize(label); - else - lineSize = new Dimension( - lineSize.width + calculateLabelSize(label).width, - lineSize.height); - } + for (JLabel label : labels) + { + labelPanel.add(label); + if (lineSize == null) + lineSize = calculateLabelSize(label); + else + lineSize = new Dimension( + lineSize.width + calculateLabelSize(label).width, + lineSize.height); + } - recalculateTooltipSize(lineSize.width, lineSize.height); + if (lineSize != null) + recalculateTooltipSize(lineSize.width, lineSize.height); } /** @@ -311,14 +312,13 @@ public class ExtendedTooltip /** * Not used. - * @param e + * @param e window event */ @Override public void windowGainedFocus(WindowEvent e) {} /** - * Not used. - * @param event + * @param event ancestor event, something has become visible. */ @Override public void ancestorAdded(AncestorEvent event) @@ -332,12 +332,33 @@ public class ExtendedTooltip { parentWindow.addWindowFocusListener(this); } + else + { + // well, no parent window, this is the case when we hovered over a + // contact and tooltip started creating and we switched to another + // window or another window stole our focus, we will hide the + // tooltip in order to avoid showing it over non jitsi window + // seems only a problem when using java 1.6 (under macosx), + // not reproducible with 1.7. + Window popupWindow + = SwingUtilities.getWindowAncestor( + ExtendedTooltip.this); + + if ((popupWindow != null) + // The popup window should normally be a JWindow, so we + // check here explicitly if for some reason we didn't + // get something else. + && (popupWindow instanceof JWindow)) + { + popupWindow.setVisible(false); + } + } } /** * When the tooltip window is disposed elements are removed from it * and this is the time to clear resources. - * @param event + * @param event the component has become not visible */ @Override public void ancestorRemoved(AncestorEvent event) @@ -353,7 +374,7 @@ public class ExtendedTooltip /** * Not used. - * @param event + * @param event ancestor event. */ @Override public void ancestorMoved(AncestorEvent event) @@ -368,8 +389,8 @@ public class ExtendedTooltip /** * Creates the UI. - * @param c - * @return + * @param c component + * @return ui shared instance. */ public static ComponentUI createUI(JComponent c) { @@ -429,7 +450,7 @@ public class ExtendedTooltip if (icon != null) imageHeight = icon.getIconHeight(); - int height = 0; + int height; if (tooltip.isListViewEnabled) { height = imageHeight > tooltip.textHeight |