3 messages in net.java.dev.jna.usersRe: [jna-users] Issue using X11.Butto...
FromSent OnAttachments
Kim EikNov 20, 2007 11:55 pm 
Timothy WallNov 21, 2007 9:35 am 
Timothy WallNov 21, 2007 1:29 pm 
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] 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 1:29:34 pm
List:net.java.dev.jna.users

I think the standard way to track *all* input events under X is to create an Input-only window that covers the root window. I don't think the various subwindows are going to be very happy to have their input masks changed out from under them (security restrictions against this may be what's causing the error you see).

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); //} } } }