

![]() | 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: |
3 messages in net.java.dev.jna.usersRe: [jna-users] Issue using X11.Butto...| From | Sent On | Attachments |
|---|---|---|
| Kim Eik | Nov 20, 2007 11:55 pm | |
| Timothy Wall | Nov 21, 2007 9:35 am | |
| Timothy Wall | Nov 21, 2007 1:29 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] Issue using X11.ButtonPressMask with both linux libX11.so in jar and system library. | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Nov 21, 2007 9:35:54 am | |
| List: | net.java.dev.jna.users | |
I'd suggest you google for the X11 error in question to see if you can narrow down the parameter causing the problem.
XEvent is a union; the only type that will be auto-initialized is the "type" field. If you define it as a Union, you'll need to set the type before reading it. You can get away with only defining a few of the union fields, but make sure the structure is big enough to hold the biggest structure field.
XEvent extends Union { public int type; public XButtonEvent xbutton; ... }
XEvent event; XNextEvent(d, event); event.setType(XButtonEvent.class); event.read(); // java fields are now properly initialized
On Nov 21, 2007, at 2:56 AM, Kim Eik wrote:
Every other mask i have tried have worked, but not X11.ButtonPressMask, and X11.ButtonReleaseMask isnt reporting mousereleases at all.
im making a code snippet that listens globally for all mouse and key events. and i have everything working except mouseclicks, and mousewheel. and also, my datastructure XEvent doesnt seem to store any data, most of the fields are blank or set to zero.
INSTANCE.XSelectInput(d, new Window(i), new NativeLong (X11.PointerMotionMask|X11.KeyPressMask|X11.KeyReleaseMask| X11.ButtonPressMask));
getting the error: X Error of failed request: BadAccess (attempt to access private resource denied) Major opcode of failed request: 2 (X_ChangeWindowAttributes) Serial number of failed request: 46 Current serial number in output stream: 47
im guessing this is a bug?
here's some more dirty, dirty code...
import com.sun.jna.*; import com.sun.jna.examples.unix.X11.*; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference;
public class teste 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 haeha(Window root){ WindowByReference parent_return = new WindowByReference(); WindowByReference root_return = new WindowByReference(); PointerByReference children_return = new PointerByReference(); IntByReference nchildren_return = new IntByReference(); if(INSTANCE.XQueryTree(d, root, root_return, parent_return, children_return, nchildren_return) != 0){ if(nchildren_return.getValue() != 0) for(int i : children_return.getValue().getIntArray(0, nchildren_return.getValue())){ haeha(new Window(i)); //System.out.println(i); //XWindowAttributes attr = new XWindowAttributes(); //INSTANCE.XGetWindowAttributes(d, new Window(i), attr); //XTextProperty txt = new XTextProperty(); //INSTANCE.XGetWMName(d,new Window(i),txt); //System.out.println(txt.value); INSTANCE.XSelectInput(d, new Window(i), new NativeLong (X11.PointerMotionMask|X11.KeyPressMask|X11.KeyReleaseMask| X11.ButtonPressMask)); } } }
public static void main(String[] args) throws InterruptedException, InstantiationException, IllegalAccessException {
//Native.setProtected(true);
Window rootWin = INSTANCE.XRootWindow(d, 0); //INSTANCE.XSelectInput(d, rootWin, new NativeLong(KeyPressMask| PointerMotionMask|KeyReleaseMask)); XWindowAttributes rattr = new XWindowAttributes(); INSTANCE.XGetWindowAttributes(d, rootWin, rattr); System.out.println(rattr.width+"x"+rattr.height); /////////////////////////////////// haeha(rootWin); while(true){ sleep(1); //if(INSTANCE.XEventsQueued(d, 0)>0){ XEvent e = new XEvent(); INSTANCE.XNextEvent(d,e); System.out.println(e.type); //} } } }
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/







