

![]() | 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: |
5 messages in net.java.dev.jna.usersRe: [jna-users] vm crash when receivi...| From | Sent On | Attachments |
|---|---|---|
| Erik Romson | Dec 30, 2007 3:33 am | |
| Timothy Wall | Dec 30, 2007 7:04 am | |
| Erik Romson | Dec 30, 2007 2:13 pm | |
| Timothy Wall | Jan 1, 2008 6:53 pm | |
| Timothy Wall | Jan 3, 2008 12:40 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] vm crash when receiving XEvents from x11 on Linux | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Jan 3, 2008 12:40:35 pm | |
| List: | net.java.dev.jna.users | |
See below for some sample X11 code that tracks events in *all* windows. Note that it uses the "create" event to select for input on newly-created windows.
But when I run it wo actually checking the event, the whole IDE locks up and no events are picked up from other applications. I'm aware of that this is not a JNA question but I'm stuck (and desperate). Am I doing something wrong? I want to pick up all mouse and key events from all applications. How should I do this?
#include <stdio.h> #include <stdlib.h> #include <X11/X.h> #include <X11/Xlib.h>
static void select(Display* dpy, Window w, long mask) { Window* children = NULL; unsigned count = 0; Window root, parent;
printf("Checking window %lx\n", w);
if (!XSelectInput(dpy, w, mask)) { fprintf(stderr, "Can't select input\n"); exit(1); } if (!XQueryTree(dpy, w, &root, &parent, &children, &count)) { fprintf(stderr, "Can't query tree\n"); exit(1); }
while (count-- > 0) { select(dpy, children[count], mask); }
if (children) { XFree(children); } }
int main(int argc, char* argv[]) {
Display* dpy = XOpenDisplay(NULL); Window root = XDefaultRootWindow(dpy); XEvent event; int quit = 0; long mask = KeyPressMask|KeyReleaseMask |PointerMotionMask|ButtonMotionMask |StructureNotifyMask|SubstructureNotifyMask;
const char* TYPE[LASTEvent] = { "0", "1", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify", };
select(dpy, root, mask);
while (!quit) {
XNextEvent(dpy, &event); printf("Event: %s\n", TYPE[event.type]); switch (event.type) { case CreateNotify: select(dpy, event.xany.window, mask); break; case KeyRelease: quit = event.xkey.keycode == 24; break; default: break; } } exit(0); return 0; }







