Beispiel #1
0
  /** Returns the supported cursor size */
  static Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {

    // Fix for bug 4212593 The Toolkit.createCustomCursor does not
    //                     check absence of the image of cursor
    // We use XQueryBestCursor which accepts unsigned ints to obtain
    // the largest cursor size that could be dislpayed
    // Dimension d = new Dimension(Math.abs(preferredWidth), Math.abs(preferredHeight));
    Dimension d;

    XToolkit.awtLock();
    try {
      long display = XToolkit.getDisplay();
      long root_window = XlibWrapper.RootWindow(display, XlibWrapper.DefaultScreen(display));

      XlibWrapper.XQueryBestCursor(
          display,
          root_window,
          Math.abs(preferredWidth),
          Math.abs(preferredHeight),
          XlibWrapper.larg1,
          XlibWrapper.larg2);
      d =
          new Dimension(
              XlibWrapper.unsafe.getInt(XlibWrapper.larg1),
              XlibWrapper.unsafe.getInt(XlibWrapper.larg2));
    } finally {
      XToolkit.awtUnlock();
    }
    return d;
  }