Java Code Examples for com.intellij.openapi.util.SystemInfo#isXWindow()

The following examples show how to use com.intellij.openapi.util.SystemInfo#isXWindow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdeFrameDecorator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@ReviewAfterMigrationToJRE(9)
public static IdeFrameDecorator decorate(@Nonnull IdeFrameEx frame) {
  // we can't use internal api for fullscreen
  if (SystemInfo.isJavaVersionAtLeast(9)) {
    return new AWTFrameDecorator(frame);
  }

  if (SystemInfo.isMac) {
    return new MacMainFrameDecorator(frame, false);
  }
  else if (SystemInfo.isWindows) {
    return new AWTFrameDecorator(frame);
  }
  else if (SystemInfo.isXWindow) {
    if (X11UiUtil.isFullScreenSupported()) {
      return new EWMHFrameDecorator(frame);
    }
  }

  return null;
}
 
Example 2
Source File: PasteFromX11Action.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  Editor editor = e.getData(CommonDataKeys.EDITOR);
  if (editor == null || !SystemInfo.isXWindow) {
    presentation.setEnabled(false);
  }
  else {
    boolean rightPlace = true;
    final InputEvent inputEvent = e.getInputEvent();
    if (inputEvent instanceof MouseEvent) {
      rightPlace = false;
      final MouseEvent me = (MouseEvent)inputEvent;
      if (editor.getMouseEventArea(me) == EditorMouseEventArea.EDITING_AREA) {
        final Component component = SwingUtilities.getDeepestComponentAt(me.getComponent(), me.getX(), me.getY());
        rightPlace = !(component instanceof JScrollBar);
      }
    }
    presentation.setEnabled(rightPlace);
  }
}
 
Example 3
Source File: ClipboardSynchronizer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public ClipboardSynchronizer(Application application) {
  if (application.isHeadlessEnvironment() && application.isUnitTestMode()) {
    myClipboardHandler = new HeadlessClipboardHandler();
  }
  else if (Patches.SLOW_GETTING_CLIPBOARD_CONTENTS && SystemInfo.isMac) {
    myClipboardHandler = new MacClipboardHandler();
  }
  else if (Patches.SLOW_GETTING_CLIPBOARD_CONTENTS && SystemInfo.isXWindow) {
    myClipboardHandler = new XWinClipboardHandler();
  }
  else {
    myClipboardHandler = new ClipboardHandler();
  }
  myClipboardHandler.init();
}
 
Example 4
Source File: DesktopApplicationStarter.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void patchSystem(boolean headless) {
  System.setProperty("sun.awt.noerasebackground", "true");

  IdeEventQueue.getInstance(); // replace system event queue

  if (headless) return;

  if (Patches.SUN_BUG_ID_6209673) {
    RepaintManager.setCurrentManager(new IdeRepaintManager());
  }

  if (SystemInfo.isXWindow) {
    String wmName = X11UiUtil.getWmName();
    LOG.info("WM detected: " + wmName);
    if (wmName != null) {
      X11UiUtil.patchDetectedWm(wmName);
    }
  }

  IconLoader.activate();
}
 
Example 5
Source File: IntellijWithPluginClasspathHelper.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static void addRequiredVmParams(
    JavaParameters params, Sdk ideaJdk, ImmutableSet<File> javaAgents) {
  String canonicalSandbox = IdeaJdkHelper.getSandboxHome(ideaJdk);
  ParametersList vm = params.getVMParametersList();

  String libPath = ideaJdk.getHomePath() + File.separator + "lib";
  vm.add("-Xbootclasspath/a:" + libPath + File.separator + "boot.jar");
  
  vm.defineProperty("idea.config.path", canonicalSandbox + File.separator + "config");
  vm.defineProperty("idea.system.path", canonicalSandbox + File.separator + "system");
  vm.defineProperty("idea.plugins.path", canonicalSandbox + File.separator + "plugins");
  vm.defineProperty("idea.classpath.index.enabled", "false");

  if (SystemInfo.isMac) {
    vm.defineProperty("idea.smooth.progress", "false");
    vm.defineProperty("apple.laf.useScreenMenuBar", "true");
  }

  if (SystemInfo.isXWindow) {
    if (!vm.hasProperty("sun.awt.disablegrab")) {
      vm.defineProperty(
          "sun.awt.disablegrab", "true"); // See http://devnet.jetbrains.net/docs/DOC-1142
    }
  }
  for (File javaAgent : javaAgents) {
    vm.add("-javaagent:" + javaAgent.getAbsolutePath());
  }

  params.setWorkingDirectory(ideaJdk.getHomePath() + File.separator + "bin" + File.separator);
  params.setJdk(ideaJdk);

  addIntellijLibraries(params, ideaJdk);

  params.setMainClass("com.intellij.idea.Main");
}
 
Example 6
Source File: FontPreferences.java    From consulo with Apache License 2.0 5 votes vote down vote up
static String getDefaultFontName() {
  if (SystemInfo.isWindows) return WINDOWS_DEFAULT_FONT_FAMILY;
  if (SystemInfo.isMacOSSnowLeopard) return MAC_OS_DEFAULT_FONT_FAMILY;
  if (SystemInfo.isXWindow && !GraphicsEnvironment.isHeadless() && !ApplicationManager.getApplication().isCommandLine()) {
    for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
      if (LINUX_DEFAULT_FONT_FAMILY.equals(font.getName())) {
        return font.getFontName();
      }
    }
  }
  return FALLBACK_FONT_FAMILY;
}
 
Example 7
Source File: DefaultKeymapImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void readExternal(Element keymapElement, Keymap[] existingKeymaps) throws InvalidDataException {
  super.readExternal(keymapElement, existingKeymaps);

  if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(getName()) && !SystemInfo.isXWindow) {
    addShortcut(IdeActions.ACTION_GOTO_DECLARATION, new MouseShortcut(MouseEvent.BUTTON2, 0, 1));
  }
}
 
Example 8
Source File: DefaultKeymap.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public String getDefaultKeymapName() {
  if (SystemInfo.isMac) {
    return KeymapManager.MAC_OS_X_KEYMAP;
  }
  else if (SystemInfo.isXWindow) {
    return KeymapManager.X_WINDOW_KEYMAP;
  }
  else {
    return KeymapManager.DEFAULT_IDEA_KEYMAP;
  }
}
 
Example 9
Source File: SystemNotificationsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Notifier getPlatformNotifier() {
  try {
    if (SystemInfo.isMac) {
      if (SystemInfo.isMacOSMountainLion && SystemProperties.getBooleanProperty("ide.mac.mountain.lion.notifications.enabled", true)) {
        return MountainLionNotifications.getInstance();
      }
      else {
        return GrowlNotifications.getInstance();
      }
    }
    else if (SystemInfo.isXWindow) {
      return LibNotifyWrapper.getInstance();
    }
    else if (SystemInfo.isWin10OrNewer) {
      return SystemTrayNotifications.getWin10Instance();
    }
  }
  catch (Throwable t) {
    Logger logger = Logger.getInstance(SystemNotifications.class);
    if (logger.isDebugEnabled()) {
      logger.debug(t);
    }
    else {
      logger.info(t.getMessage());
    }
  }

  return null;
}
 
Example 10
Source File: LafManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void afterLoadState() {
  if (myCurrentLaf != null) {
    final UIManager.LookAndFeelInfo laf = findLaf(myCurrentLaf.getClassName());
    if (laf != null) {
      setCurrentLookAndFeel(laf, false);
    }
  }

  updateUI();

  if (SystemInfo.isXWindow) {
    myThemeChangeListener = new PropertyChangeListener() {
      @Override
      public void propertyChange(final PropertyChangeEvent evt) {
        //noinspection SSBasedInspection
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            fixGtkPopupStyle();
            patchOptionPaneIcons(UIManager.getLookAndFeelDefaults());
          }
        });
      }
    };
    Toolkit.getDefaultToolkit().addPropertyChangeListener(GNOME_THEME_PROPERTY_NAME, myThemeChangeListener);
  }

  // refresh UI on localize change
  LocalizeManager.getInstance().addListener((oldLocale, newLocale) -> updateUI(), this);
}
 
Example 11
Source File: X11UiUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
private static Xlib getInstance() {
  Class<? extends Toolkit> toolkitClass = Toolkit.getDefaultToolkit().getClass();
  if (!SystemInfo.isXWindow || !"sun.awt.X11.XToolkit".equals(toolkitClass.getName())) {
    return null;
  }

  try {
    Xlib x11 = new Xlib();

    // reflect on Xlib method wrappers and important structures
    Class<?> XlibWrapper = Class.forName("sun.awt.X11.XlibWrapper");
    x11.unsafe = AtomicFieldUpdater.getUnsafe();
    x11.XGetWindowProperty = method(XlibWrapper, "XGetWindowProperty", 12);
    x11.XFree = method(XlibWrapper, "XFree", 1);
    x11.RootWindow = method(XlibWrapper, "RootWindow", 2);
    x11.XSendEvent = method(XlibWrapper, "XSendEvent", 5);
    Class<?> XBaseWindow = Class.forName("sun.awt.X11.XBaseWindow");
    x11.getWindow = method(XBaseWindow, "getWindow");
    x11.getScreenNumber = method(XBaseWindow, "getScreenNumber");
    x11.display = (Long)method(toolkitClass, "getDisplay").invoke(null);
    x11.awtLock = method(toolkitClass, "awtLock");
    x11.awtUnlock = method(toolkitClass, "awtUnlock");

    // intern atoms
    Class<?> XAtom = Class.forName("sun.awt.X11.XAtom");
    Method get = method(XAtom, "get", String.class);
    Field atom = field(XAtom, "atom");
    x11.UTF8_STRING = (Long)atom.get(get.invoke(null, "UTF8_STRING"));
    x11.NET_SUPPORTING_WM_CHECK = (Long)atom.get(get.invoke(null, "_NET_SUPPORTING_WM_CHECK"));
    x11.NET_WM_NAME = (Long)atom.get(get.invoke(null, "_NET_WM_NAME"));
    x11.NET_WM_ALLOWED_ACTIONS = (Long)atom.get(get.invoke(null, "_NET_WM_ALLOWED_ACTIONS"));
    x11.NET_WM_STATE = (Long)atom.get(get.invoke(null, "_NET_WM_STATE"));
    x11.NET_WM_ACTION_FULLSCREEN = (Long)atom.get(get.invoke(null, "_NET_WM_ACTION_FULLSCREEN"));
    x11.NET_WM_STATE_FULLSCREEN = (Long)atom.get(get.invoke(null, "_NET_WM_STATE_FULLSCREEN"));

    // check for _NET protocol support
    Long netWmWindow = x11.getNetWmWindow();
    if (netWmWindow == null) {
      LOG.info("_NET protocol is not supported");
      return null;
    }

    return x11;
  }
  catch (Throwable t) {
    LOG.info("cannot initialize", t);
  }

  return null;
}
 
Example 12
Source File: DesktopWindowManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isFullScreenSupportedInCurrentOS() {
  return SystemInfo.isMacOSLion || SystemInfo.isWindows || SystemInfo.isXWindow && X11UiUtil.isFullScreenSupported();
}
 
Example 13
Source File: Patches.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * XToolkit.getScreenInsets() may be very slow.
 * See https://bugs.openjdk.java.net/browse/JDK-8170937.
 */
public static boolean isJdkBugId8004103() {
  return SystemInfo.isXWindow && !GraphicsEnvironment.isHeadless();
}