Robert Holt said:
Is there any way to get the X11 window id of a window opened through
Swing?
If you're prepared to to go native, you can use JAWT:
MyX11Utils.java:
class MyX11Utils {
public static native long windowID(Component comp);
}
MyX11Utils.c
#include <jawt.h>
#include <jawt_md.h>
Java_MyX11Utils_windowID(JNIEnv* env, jclass cls, jobject comp) {
JAWT awt;
JAWT_DrawingSurface* ds = NULL;
int dsLocked = false;
JAWT_DrawingSurfaceInfo* dsi = NULL;
JAWT_X11DrawingSurfaceInfo* x = NULL;
jlong windowID = -1; /* or some appropriate error value */
awt.version = JAWT_VERSION_1_4;
if (!JAWT_GetAWT(env, &awt)) { goto done; }
ds = awt.GetDrawingSurface(env, comp);
if (!ds) { goto done; }
dsLocked = !(ds->Lock(ds) & JAWT_LOCK_ERROR);
if (!dsLocked) { goto done; }
dsi = ds->GetDrawingSurfaceInfo(ds);
if (!dsi) { goto done; }
x = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
/* get the window id. Don't know x11, but is it something like
windowID = (jlong)x->visualID;
or using it Drawable or Display properties? */
done:
/* resource cleanup */
if (dsi) { ds->FreeDrawingSurfaceInfo(dsi); }
if (dsLocked) { ds->Unlock(ds); }
if (ds) { awt.FreeDrawingSurface(ds); }
return windowID;
}
HTH
John