Пример #1
0
  Rectangle getClientBounds() {
    XToolkit.awtLock();
    try {
      XWindowAttributes wattr = new XWindowAttributes();
      try {
        XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
        int status =
            XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), xembed.handle, wattr.pData);

        XToolkit.RESTORE_XERROR_HANDLER();

        if (status == 0
            || (XToolkit.saved_error != null
                && XToolkit.saved_error.get_error_code() != XConstants.Success)) {
          return null;
        }

        return new Rectangle(wattr.get_x(), wattr.get_y(), wattr.get_width(), wattr.get_height());
      } finally {
        wattr.dispose();
      }
    } finally {
      XToolkit.awtUnlock();
    }
  }
Пример #2
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;
  }
 // don't use getLocationOnScreen() inherited from XDecoratedPeer
 public Point getLocationOnScreen() {
   XToolkit.awtLock();
   try {
     return toGlobal(0, 0);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #4
0
 static long getScreenOfWindow(long window) {
   XToolkit.awtLock();
   try {
     return XlibWrapper.getScreenOfWindow(XToolkit.getDisplay(), window);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #5
0
 public static long xGetInputFocus() {
   XToolkit.awtLock();
   try {
     return XlibWrapper.XGetInputFocus(XToolkit.getDisplay());
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #6
0
 long getScreenNumber() {
   XToolkit.awtLock();
   try {
     return XlibWrapper.XScreenNumberOfScreen(getScreen());
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #7
0
 public void toFront() {
   XToolkit.awtLock();
   try {
     XlibWrapper.XRaiseWindow(XToolkit.getDisplay(), getWindow());
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #8
0
 /** Helper function to set W */
 public final void setWMHints(XWMHints hints) {
   XToolkit.awtLock();
   try {
     XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #9
0
 void flush() {
   XToolkit.awtLock();
   try {
     XlibWrapper.XFlush(XToolkit.getDisplay());
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #10
0
 boolean processXEmbedInfo() {
   long xembed_info_data = Native.allocateLongArray(2);
   try {
     if (!XEmbedInfo.getAtomData(handle, xembed_info_data, 2)) {
       // No more XEMBED_INFO? This is not XEmbed client!
       // Unfortunately this is the initial state of the most clients
       // FIXME: add 5-state processing
       // childDestroyed();
       xembedLog.finer("Unable to get XEMBED_INFO atom data");
       return false;
     }
     version = Native.getCard32(xembed_info_data, 0);
     flags = Native.getCard32(xembed_info_data, 1);
     boolean new_mapped = (flags & XEMBED_MAPPED) != 0;
     boolean currently_mapped = XlibUtil.getWindowMapState(handle) != XConstants.IsUnmapped;
     if (new_mapped != currently_mapped) {
       if (xembedLog.isLoggable(PlatformLogger.FINER))
         xembedLog.fine(
             "Mapping state of the client has changed, old state: "
                 + currently_mapped
                 + ", new state: "
                 + new_mapped);
       if (new_mapped) {
         XToolkit.awtLock();
         try {
           XlibWrapper.XMapWindow(XToolkit.getDisplay(), handle);
         } finally {
           XToolkit.awtUnlock();
         }
       } else {
         XToolkit.awtLock();
         try {
           XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), handle);
         } finally {
           XToolkit.awtUnlock();
         }
       }
     } else {
       xembedLog.finer("Mapping state didn't change, mapped: " + currently_mapped);
     }
     return true;
   } finally {
     XlibWrapper.unsafe.freeMemory(xembed_info_data);
   }
 }
Пример #11
0
  protected void createCursor(
      byte[] xorMask,
      byte[] andMask,
      int width,
      int height,
      int fcolor,
      int bcolor,
      int xHotSpot,
      int yHotSpot) {
    XToolkit.awtLock();
    try {
      long display = XToolkit.getDisplay();
      long root_window = XlibWrapper.RootWindow(display, XlibWrapper.DefaultScreen(display));

      long colormap = XToolkit.getDefaultXColormap();
      XColor fore_color = new XColor();

      fore_color.set_flags((byte) (XlibWrapper.DoRed | XlibWrapper.DoGreen | XlibWrapper.DoBlue));
      fore_color.set_red((short) (((fcolor >> 16) & 0x000000ff) << 8));
      fore_color.set_green((short) (((fcolor >> 8) & 0x000000ff) << 8));
      fore_color.set_blue((short) (((fcolor >> 0) & 0x000000ff) << 8));

      XlibWrapper.XAllocColor(display, colormap, fore_color.pData);

      XColor back_color = new XColor();
      back_color.set_flags((byte) (XlibWrapper.DoRed | XlibWrapper.DoGreen | XlibWrapper.DoBlue));

      back_color.set_red((short) (((bcolor >> 16) & 0x000000ff) << 8));
      back_color.set_green((short) (((bcolor >> 8) & 0x000000ff) << 8));
      back_color.set_blue((short) (((bcolor >> 0) & 0x000000ff) << 8));

      XlibWrapper.XAllocColor(display, colormap, back_color.pData);

      long nativeXorMask = Native.toData(xorMask);
      long source =
          XlibWrapper.XCreateBitmapFromData(display, root_window, nativeXorMask, width, height);

      long nativeAndMask = Native.toData(andMask);
      long mask =
          XlibWrapper.XCreateBitmapFromData(display, root_window, nativeAndMask, width, height);

      long cursor =
          XlibWrapper.XCreatePixmapCursor(
              display, source, mask, fore_color.pData, back_color.pData, xHotSpot, yHotSpot);

      XlibWrapper.unsafe.freeMemory(nativeXorMask);
      XlibWrapper.unsafe.freeMemory(nativeAndMask);
      XlibWrapper.XFreePixmap(display, source);
      XlibWrapper.XFreePixmap(display, mask);
      back_color.dispose();
      fore_color.dispose();

      XGlobalCursorManager.setPData(this, cursor);
    } finally {
      XToolkit.awtUnlock();
    }
  }
Пример #12
0
 public void setShellSize(Rectangle rec) {
   if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting shell size on " + this + " to " + rec);
   XToolkit.awtLock();
   try {
     updateSizeHints(rec.x, rec.y, rec.width, rec.height);
     XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #13
0
 public void xRequestFocus() {
   XToolkit.awtLock();
   try {
     if (focusLog.isLoggable(Level.FINER))
       focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()));
     XlibWrapper.XSetInputFocus(XToolkit.getDisplay(), getWindow());
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #14
0
 void endDispatching() {
   xembedLog.fine("End dispatching for " + Long.toHexString(xembed.handle));
   XToolkit.awtLock();
   try {
     XDropTargetRegistry.getRegistry().unregisterXEmbedClient(getWindow(), xembed.handle);
     // We can't deselect input since someone else might be interested in it
     XToolkit.removeEventDispatcher(xembed.handle, xembed);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #15
0
 protected void initClientLeader() {
   XToolkit.awtLock();
   try {
     if (wm_client_leader == null) {
       wm_client_leader = XAtom.get("WM_CLIENT_LEADER");
     }
     wm_client_leader.setWindowProperty(this, getXAWTRootWindow());
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #16
0
 void setWMClass(String[] cl) {
   if (cl.length != 2) {
     throw new IllegalArgumentException("WM_CLASS_NAME consists of exactly two strings");
   }
   XToolkit.awtLock();
   try {
     XAtom xa = XAtom.get(XAtom.XA_WM_CLASS);
     xa.setProperty8(getWindow(), cl[0] + '\0' + cl[1]);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #17
0
  protected void handleCorrectInsets(Insets correctWM) {
    XToolkit.awtLock();
    try {
      /*
       * Ok, now see if we need adjust window size because
       * initial insets were wrong (most likely they were).
       */
      Insets correction = difference(correctWM, currentInsets);
      if (insLog.isLoggable(Level.FINEST)) {
        insLog.log(Level.FINEST, "Corrention {0}", new Object[] {String.valueOf(correction)});
      }
      if (!isNull(correction)) {
        /*
         * Actual insets account for menubar/warning label,
         * so we can't assign directly but must adjust them.
         */
        add(currentInsets, correction);
        applyGuessedInsets();

        // Fix for 6318109: PIT: Min Size is not honored properly when a
        // smaller size is specified in setSize(), XToolkit
        // update minimum size hints
        updateMinSizeHints();

        /*
         * If this window has been sized by a pack() we need
         * to keep the interior geometry intact.  Since pack()
         * computed width and height with wrong insets, we
         * must adjust the target dimensions appropriately.
         */
      }
      if (insLog.isLoggable(Level.FINER)) insLog.finer("Dimensions before reparent: " + dimensions);

      dimensions.setInsets(getRealInsets());
      insets_corrected = true;

      if (isMaximized()) {
        return;
      }

      if ((getHints().get_flags() & (USPosition | PPosition)) != 0) {
        reshape(dimensions, SET_BOUNDS, false);
      } else {
        reshape(dimensions, SET_SIZE, false);
      }
    } finally {
      XToolkit.awtUnlock();
    }
  }
Пример #18
0
 Point toLocal(int x, int y) {
   long root;
   XToolkit.awtLock();
   try {
     root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber());
   } finally {
     XToolkit.awtUnlock();
   }
   Point p = toOtherWindow(root, getContentWindow(), x, y);
   if (p != null) {
     return p;
   } else {
     return new Point(x, y);
   }
 }
Пример #19
0
 void updateWMName() {
   String name = getWMName();
   XToolkit.awtLock();
   try {
     if (name == null) {
       name = " ";
     }
     XAtom nameAtom = XAtom.get(XAtom.XA_WM_NAME);
     nameAtom.setProperty(getWindow(), name);
     XAtom netNameAtom = XAtom.get("_NET_WM_NAME");
     netNameAtom.setPropertyUTF8(getWindow(), name);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #20
0
 public void xSetVisible(boolean visible) {
   if (log.isLoggable(Level.FINE)) log.fine("Setting visible on " + this + " to " + visible);
   XToolkit.awtLock();
   try {
     this.visible = visible;
     if (visible) {
       XlibWrapper.XMapWindow(XToolkit.getDisplay(), getWindow());
     } else {
       XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), getWindow());
     }
     XlibWrapper.XFlush(XToolkit.getDisplay());
   } finally {
     XToolkit.awtUnlock();
   }
 }
  public void synthesizeFocusInOut(boolean doFocus) {
    XFocusChangeEvent xev = new XFocusChangeEvent();

    XToolkit.awtLock();
    try {
      xev.set_type(doFocus ? FocusIn : FocusOut);
      xev.set_window(getFocusProxy().getWindow());
      xev.set_mode(NotifyNormal);
      XlibWrapper.XSendEvent(
          XToolkit.getDisplay(), getFocusProxy().getWindow(), false, NoEventMask, xev.pData);
    } finally {
      XToolkit.awtUnlock();
      xev.dispose();
    }
  }
Пример #22
0
 void updateWMName() {
   super.updateWMName();
   String name = getWMName();
   XToolkit.awtLock();
   try {
     if (name == null || name.trim().equals("")) {
       name = "Java";
     }
     XAtom iconNameAtom = XAtom.get(XAtom.XA_WM_ICON_NAME);
     iconNameAtom.setProperty(getWindow(), name);
     XAtom netIconNameAtom = XAtom.get("_NET_WM_ICON_NAME");
     netIconNameAtom.setPropertyUTF8(getWindow(), name);
   } finally {
     XToolkit.awtUnlock();
   }
 }
 void postInit(XCreateWindowParams params) {
   super.postInit(params);
   if (embedder != null) {
     // install X11 event dispatcher
     embedder.setClient(this);
     // reparent to XEmbed server
     embedder.install();
   } else if (getParentWindowHandle() != 0) {
     XToolkit.awtLock();
     try {
       XlibWrapper.XReparentWindow(
           XToolkit.getDisplay(), getWindow(), getParentWindowHandle(), 0, 0);
     } finally {
       XToolkit.awtUnlock();
     }
   }
 }
Пример #24
0
 public Dimension getMinimumSize() {
   if (isXEmbedActive()) {
     XToolkit.awtLock();
     try {
       long p_hints = XlibWrapper.XAllocSizeHints();
       XSizeHints hints = new XSizeHints(p_hints);
       XlibWrapper.XGetWMNormalHints(
           XToolkit.getDisplay(), xembed.handle, p_hints, XlibWrapper.larg1);
       Dimension res = new Dimension(hints.get_min_width(), hints.get_min_height());
       XlibWrapper.XFree(p_hints);
       return res;
     } finally {
       XToolkit.awtUnlock();
     }
   } else {
     return super.getMinimumSize();
   }
 }
Пример #25
0
 public Point getLocationOnScreen() {
   XToolkit.awtLock();
   try {
     if (configure_seen) {
       return toGlobal(0, 0);
     } else {
       Point location = target.getLocation();
       if (insLog.isLoggable(Level.FINE))
         insLog.log(
             Level.FINE,
             "getLocationOnScreen {0} not reparented: {1} ",
             new Object[] {String.valueOf(this), String.valueOf(location)});
       return location;
     }
   } finally {
     XToolkit.awtUnlock();
   }
 }
  public Rectangle getBoundsPrivate() {
    int x = 0, y = 0;
    int w = 0, h = 0;
    XWindowAttributes attr = new XWindowAttributes();

    XToolkit.awtLock();
    try {
      XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), getWindow(), attr.pData);
      x = attr.get_x();
      y = attr.get_y();
      w = attr.get_width();
      h = attr.get_height();
    } finally {
      XToolkit.awtUnlock();
    }
    attr.dispose();

    return new Rectangle(x, y, w, h);
  }
Пример #27
0
  void initDispatching() {
    if (xembedLog.isLoggable(PlatformLogger.FINE))
      xembedLog.fine("Init embedding for " + Long.toHexString(xembed.handle));
    XToolkit.awtLock();
    try {
      XToolkit.addEventDispatcher(xembed.handle, xembed);
      XlibWrapper.XSelectInput(
          XToolkit.getDisplay(),
          xembed.handle,
          XConstants.StructureNotifyMask | XConstants.PropertyChangeMask);

      XDropTargetRegistry.getRegistry().registerXEmbedClient(getWindow(), xembed.handle);
    } finally {
      XToolkit.awtUnlock();
    }
    xembed.processXEmbedInfo();

    notifyChildEmbedded();
  }
Пример #28
0
 public void xSetBounds(int x, int y, int width, int height) {
   if (getWindow() == 0) {
     insLog.warning("Attempt to resize uncreated window");
     throw new IllegalStateException("Attempt to resize uncreated window");
   }
   insLog.fine(
       "Setting bounds on " + this + " to (" + x + ", " + y + "), " + width + "x" + height);
   if (width <= 0) {
     width = 1;
   }
   if (height <= 0) {
     height = 1;
   }
   XToolkit.awtLock();
   try {
     XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getWindow(), x, y, width, height);
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #29
0
 static void ungrabInput() {
   XToolkit.awtLock();
   try {
     XBaseWindow grabWindow = XAwtState.getGrabWindow();
     if (grabLog.isLoggable(Level.FINE)) {
       grabLog.log(Level.FINE, "UnGrab input on {0}", new Object[] {String.valueOf(grabWindow)});
     }
     if (grabWindow != null) {
       grabWindow.ungrabInputImpl();
       XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime);
       XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), CurrentTime);
       XAwtState.setGrabWindow(null);
       // we need to call XFlush() here to force ungrab
       // see 6384219 for details
       XlibWrapper.XFlush(XToolkit.getDisplay());
     }
   } finally {
     XToolkit.awtUnlock();
   }
 }
Пример #30
0
 void detachChild() {
   if (xembedLog.isLoggable(PlatformLogger.FINE))
     xembedLog.fine("Detaching child " + Long.toHexString(xembed.handle));
   /**
    * XEmbed specification: "The embedder can unmap the client and reparent the client window to
    * the root window. If the client receives an ReparentNotify event, it should check the parent
    * field of the XReparentEvent structure. If this is the root window of the window's screen,
    * then the protocol is finished and there is no further interaction. If it is a window other
    * than the root window, then the protocol continues with the new parent acting as the embedder
    * window."
    */
   XToolkit.awtLock();
   try {
     XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), xembed.handle);
     XlibWrapper.XReparentWindow(
         XToolkit.getDisplay(), xembed.handle, XToolkit.getDefaultRootWindow(), 0, 0);
   } finally {
     XToolkit.awtUnlock();
   }
   endDispatching();
   xembed.handle = 0;
 }