concurrent focus request races fixed - impacts RunnerLayoutUi - auto-focus of detache...
[fedora-idea.git] / platform-api / src / com / intellij / openapi / ui / popup / util / PopupUtil.java
blob845f2c86c1731819877c626f332553d93c056579
1 package com.intellij.openapi.ui.popup.util;
3 import com.intellij.openapi.ui.popup.JBPopup;
4 import org.jetbrains.annotations.Nullable;
6 import javax.swing.*;
7 import java.awt.*;
9 public class PopupUtil {
11 private PopupUtil() {
14 @Nullable
15 public static Component getOwner(@Nullable Component c) {
16 if (c == null) return null;
18 final Window wnd = SwingUtilities.getWindowAncestor(c);
19 if (wnd instanceof JWindow) {
20 final JRootPane root = ((JWindow)wnd).getRootPane();
21 final JBPopup popup = (JBPopup)root.getClientProperty(JBPopup.KEY);
22 if (popup == null) return c;
24 final Component owner = popup.getOwner();
25 if (owner == null) return c;
27 return getOwner(owner);
29 else {
30 return c;