Search code examples
javajava-native-interfaceawtx11jniwrapper

JAWT_LOCK_ERROR when trying to acquire lock from JAWT_DrawingSurface


Introduction

I'm using JNIWrapper, and the JAWT subcomponent of that library.

I'm trying to acquire the lock on a JAWT_DrawingSurface with the following code:

JAWT_DrawingSurface *ds = NULL;
ds = awt.GetDrawingSurface(env, comp);
dsLocked = !(ds->Lock(ds) & JAWT_LOCK_ERROR)

But I keep getting dsLocked to be false.

Details

comp is sent to this JNIWrapper code from Java by the following:

Component panel = new VideoViewport().getDisplay();
panel.setBounds(150,150,150,150);
System.out.println("Handle: " + core.utils.X11.X11Utils.getDrawable(panel));

There's not much done to panel either by running VideoViewport() or by getDisplay(), and I don't know what details would be relevant.

Question

What sort of things would cause acquiring the lock on the surface to fail?


Solution

  • The Component must be added to a frame and made visible.

    When I added the Component to a AWT Frame object and made it visible before the getDrawable(panel) call, it worked and I was able to acquire the lock on the surface.