2 messages in net.java.dev.jna.usersRe: [jna-users] get the pointer for a...
FromSent OnAttachments
Diego Conde PérezAug 8, 2007 9:05 am 
Timothy WallAug 8, 2007 9:36 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] get the pointer for a CanvasActions...
From:Timothy Wall (twal@dev.java.net)
Date:Aug 8, 2007 9:36:29 am
List:net.java.dev.jna.users

On Aug 8, 2007, at 12:05 PM, Diego Conde Pérez wrote:

Hi,

First of all, good work!!! This library is incredible, I've been dreaming for something similar for years.

I've been trying to use the libvlc (http://www.videolan.org) throught jna, and it worked perfectly (divX inside a JFrame seems to be a dream). The problem is that the only way that I can tell the libvlc where it has to display the multimedia content is with a drawable (Drawable on X11, CGrafPort on MacOSX, HWND on Win32). Now, there is a method com.sun.jna.Native.getWindowPointer that works well for JFrames, but if I want to put the video inside a Canvas and I can't (well, actually I can but with JNI, and I use jna to avoid this).

The solution seems to be simple, in the com.sun.jna.Native class create the couterparts of getWindowPointer and getWindowHandle0, in this case getCanvasPointer and getCanvasHandle0 (maybe a generic getComponentPointer). I'm not completely sure, but I think that the implementation of getCanvasHandle0 can be identical to getWindowHandle0 because awt.GetDrawingSurface(env, w) can receive a canvas instead of a window.

I think that this functionality can be really useful to embed native display (I think that Gecko has a similar method).

Thanks again for this great job.

You're correct, getCanvasHandle would be no different than getWindowHandle. The initial implementation was window-oriented and hadn't been tested with any other AWT (heavyweight) components. You might need some additional information (such as component offset from native origin) if you pass in a lightweight (Swing) component, though. Or just throw IllegalArgumentException on lightweights.

Feel free to submit an issue to add this to the next release, and if you're inclined, some example and test code as well.

Thanks for the feedback, T.