

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
2 messages in net.java.dev.jna.usersRe: [jna-users] InputOnly window to m...| From | Sent On | Attachments |
|---|---|---|
| Kim Eik | Nov 21, 2007 7:14 pm | |
| Timothy Wall | Nov 21, 2007 9:01 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] InputOnly window to manage read events. | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Nov 21, 2007 9:01:49 pm | |
| List: | net.java.dev.jna.users | |
If you're not sure what you're doing, I'd recommend getting the thing to work in a simple C program first. Then you can worry about mapping into Java.
On Nov 21, 2007, at 10:15 PM, Kim Eik wrote:
I implemented this javacode, and crossed my fingers. But no, i encountered several issues trying to make this work.
1. There is a structure X11.XSetWindowAttributes which cant be passed along the method XCreateWindow as i recieve this error:
Exception in thread "main" java.lang.IllegalArgumentException: The type "boolean" is not supported as a Structure field at com.sun.jna.Structure.getNativeSize(Structure.java:738) at com.sun.jna.Structure.getNativeSize(Structure.java:758) at com.sun.jna.Structure.calculateSize(Structure.java:640) at com.sun.jna.Structure.allocateMemory(Structure.java:173) at com.sun.jna.Structure.<init>(Structure.java:96) at com.sun.jna.Structure.<init>(Structure.java:90) at com.sun.jna.Structure.<init>(Structure.java:86) at com.sun.jna.examples.unix.X11$XSetWindowAttributes.<init> (X11.java:291) at teste2.main(teste2.java:22)
"boolean" should auto-map to native "int", but if it doesn't, you can just use what's appropriate for the native size. "boolean" isn't a C type, and varies depending on the library (sometimes "char", sometimes "int").
So i progressed with creating my own structure, but since im extending com.sun.jna.examples.unix.X11 from my X11 interface it will use the X11.XSetWindowAttributes by default instead of XSetWindowAttributes.
i then just set the arguments required to null and hoped for the best. which didnt turn out well :) it seems i create the window, but i dont recieve any events. and if i try to get window information through XGetWMName i recieve segfaults.
Passing null arguments to a library will more often than not result in a crash. Especially if the argument is used to return a value, as in XGetWMName. Again, I'd recommend getting a simple C program to work first (it's easier to run it under a debugger like "gdb" to see what's wrong).
im fresh out of ideas on where to go now. Can anyone help me?
import java.awt.Dimension; import java.awt.Toolkit;
import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.examples.unix.X11.Display; import com.sun.jna.examples.unix.X11.Window;
public class teste2 extends Thread {
final static X11 INSTANCE = (X11)Native.loadLibrary("/usr/lib/ libX11.so", X11.class); final static Display d = INSTANCE.XOpenDisplay(":0.0");
public static void main(String[] args) throws InterruptedException, InstantiationException, IllegalAccessException {
Window rootWin = INSTANCE.XDefaultRootWindow(d); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); System.out.println(dim.width+"x"+dim.height); Window n = INSTANCE.XCreateWindow(d, rootWin, 0, 0, dim.width, dim.height, 0, 0, 0, null,0,null); System.out.println(INSTANCE.XSelectInput(d, n, new NativeLong (X11.PointerMotionMask))); System.out.println(INSTANCE.XMapWindow(d, n)); INSTANCE.XRaiseWindow(d, n);
System.out.println(n.toNative());
/*XTextProperty t = null; INSTANCE.XGetWMName(d, n, t); System.out.println(t.value);*/
XEvent e = null; while(true){ INSTANCE.XNextEvent(d,e); System.out.println(e); } } }
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/







