Ejemplo n.º 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();
    }
  }
Ejemplo n.º 2
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();
   }
 }
Ejemplo n.º 3
0
 void childResized() {
   if (xembedLog.isLoggable(PlatformLogger.FINER)) {
     Rectangle bounds = getClientBounds();
     xembedLog.finer("Child resized: " + bounds);
     // It is not required to update embedder's size when client size changes
     // However, since there is no any means to get client size it seems to be the
     // only way to provide it. However, it contradicts with Java layout concept -
     // so it is disabled for now.
     //             Rectangle my_bounds = getBounds();
     //             setBounds(my_bounds.x, my_bounds.y, bounds.width, bounds.height, SET_BOUNDS);
   }
   XToolkit.postEvent(
       XToolkit.targetToAppContext(target),
       new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
 }
Ejemplo n.º 4
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();
   }
 }
Ejemplo n.º 5
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();
  }
Ejemplo n.º 6
0
 public boolean processXEmbedDnDEvent(long ctxt, int eventID) {
   if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
     xembedLog.finest("     Drop target=" + target.getDropTarget());
   }
   if (target.getDropTarget() instanceof XEmbedDropTarget) {
     AppContext appContext = XToolkit.targetToAppContext(getTarget());
     XDropTargetContextPeer peer = XDropTargetContextPeer.getPeer(appContext);
     peer.forwardEventToEmbedded(xembed.handle, ctxt, eventID);
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
 void forwardKeyEvent(KeyEvent e) {
   xembedLog.fine("Try to forward key event");
   byte[] bdata = getBData(e);
   long data = Native.toData(bdata);
   if (data == 0) {
     return;
   }
   try {
     XKeyEvent ke = new XKeyEvent(data);
     ke.set_window(xembed.handle);
     if (xembedLog.isLoggable(PlatformLogger.FINE))
       xembedLog.fine("Forwarding native key event: " + ke);
     XToolkit.awtLock();
     try {
       XlibWrapper.XSendEvent(
           XToolkit.getDisplay(), xembed.handle, false, XConstants.NoEventMask, data);
     } finally {
       XToolkit.awtUnlock();
     }
   } finally {
     XlibWrapper.unsafe.freeMemory(data);
   }
 }
Ejemplo n.º 9
0
    private void init(KeyEvent e) {
      byte[] bdata = getBData(e);
      long data = Native.toData(bdata);
      if (data == 0) {
        return;
      }
      try {
        XToolkit.awtLock();
        try {
          keysym = XWindow.getKeySymForAWTKeyCode(e.getKeyCode());
        } finally {
          XToolkit.awtUnlock();
        }
        XKeyEvent ke = new XKeyEvent(data);

        // We recognize only these masks
        modifiers =
            ke.get_state() & (XConstants.ShiftMask | XConstants.ControlMask | XConstants.LockMask);
        if (xembedLog.isLoggable(PlatformLogger.FINEST))
          xembedLog.finest("Mapped " + e + " to " + this);
      } finally {
        XlibWrapper.unsafe.freeMemory(data);
      }
    }
Ejemplo n.º 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);
   }
 }