Exemple #1
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();
    }
  }
Exemple #2
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);
   }
 }
Exemple #3
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);
   }
 }
Exemple #4
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);
      }
    }