diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java index 7aa22daa4b4f..96b5818f59f3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeFrameImpl.java @@ -52,7 +52,6 @@ import com.intellij.openapi.wm.impl.status.*; import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame; import com.intellij.ui.*; import com.intellij.util.ui.UIUtil; -import org.java.ayatana.ApplicationMenu; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -99,10 +98,10 @@ public class IdeFrameImpl extends JFrame implements IdeFrameEx, DataProvider { setBackground(UIUtil.getPanelBackground()); AppUIUtil.updateWindowIcon(this); final Dimension size = ScreenUtil.getMainScreenBounds().getSize(); - + size.width = Math.min(1400, size.width - 20); size.height= Math.min(1000, size.height - 40); - + setSize(size); setLocationRelativeTo(null); @@ -125,25 +124,22 @@ public class IdeFrameImpl extends JFrame implements IdeFrameEx, DataProvider { MouseGestureManager.getInstance().add(this); myFrameDecorator = IdeFrameDecorator.decorate(this); + addWindowStateListener(new WindowAdapter() { @Override public void windowStateChanged(WindowEvent e) { updateBorder(); } }); + Toolkit.getDefaultToolkit().addPropertyChangeListener("win.xpstyle.themeActive", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { updateBorder(); } }); - if (xdgCurrentDesktop != null && xdgCurrentDesktop.contains("Unity") && Registry.is("linux.native.menu")) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - ApplicationMenu.tryInstall(IdeFrameImpl.this); - } - }); - } + + IdeMenuBar.installAppMenuIfNeeded(this); } private void updateBorder() { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java index 9caef019e72b..2f02707c4918 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeMenuBar.java @@ -30,6 +30,8 @@ import com.intellij.openapi.actionSystem.impl.WeakTimerListener; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.ex.IdeFrameEx; import com.intellij.openapi.wm.impl.status.ClockPanel; import com.intellij.ui.Gray; @@ -37,6 +39,7 @@ import com.intellij.ui.ScreenUtil; import com.intellij.ui.border.CustomLineBorder; import com.intellij.util.ui.Animator; import com.intellij.util.ui.UIUtil; +import org.java.ayatana.ApplicationMenu; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -556,4 +559,15 @@ public class IdeMenuBar extends JMenuBar implements IdeEventQueue.EventDispatche super.mouseClicked(e); } } + + public static void installAppMenuIfNeeded(@NotNull final JFrame frame) { + if (SystemInfo.isLinux && Registry.is("linux.native.menu") && "Unity".equals(System.getenv("XDG_CURRENT_DESKTOP"))) { + //noinspection SSBasedInspection + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ApplicationMenu.tryInstall(frame); + } + }); + } + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java index c56e3b7a9e64..4764ce38ea58 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeFrame.java @@ -32,17 +32,16 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.ProjectManagerAdapter; import com.intellij.openapi.util.DimensionService; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.*; import com.intellij.openapi.wm.impl.IdeFrameImpl; import com.intellij.openapi.wm.impl.IdeGlassPaneImpl; +import com.intellij.openapi.wm.impl.IdeMenuBar; import com.intellij.openapi.wm.impl.WindowManagerImpl; import com.intellij.openapi.wm.impl.status.IdeStatusBarImpl; import com.intellij.ui.AppUIUtil; import com.intellij.ui.BalloonLayout; import com.intellij.ui.BalloonLayoutImpl; import com.intellij.util.ui.UIUtil; -import org.java.ayatana.ApplicationMenu; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -156,11 +155,8 @@ public class WelcomeFrame extends JFrame implements IdeFrame { public static void showNow() { if (ourInstance == null) { - IdeFrame frame = EP.getExtensions().length == 0 - ? new WelcomeFrame() : EP.getExtensions()[0].createFrame(); - if (SystemInfo.isLinux) { - ApplicationMenu.tryInstall(((JFrame)frame)); - } + IdeFrame frame = EP.getExtensions().length == 0 ? new WelcomeFrame() : EP.getExtensions()[0].createFrame(); + IdeMenuBar.installAppMenuIfNeeded((JFrame)frame); ((JFrame)frame).setVisible(true); ourInstance = frame; }