watcherRunning = true;
new Thread() {
@Override
public void run() {
try {
final X11 x11 = X11.INSTANCE;
final Display display = x11.XOpenDisplay(null);
Window window = new Window(nativeHandle);
x11.XSelectInput(display, window,
new NativeLong(X11.ExposureMask |
X11.VisibilityChangeMask |
X11.StructureNotifyMask |
X11.FocusChangeMask |
//X11.PointerMotionMask |
X11.EnterWindowMask |
X11.LeaveWindowMask));
while (watcherRunning) {
final XEvent xEvent = new XEvent();
x11.XNextEvent(display, xEvent);
if (watcherRunning && !isDisposed()) {
getDisplay().asyncExec(new Runnable() {
public void run() {
if (watcherRunning && !isDisposed()) {
final Event swtEvent = new Event();
XCrossingEvent ce;
switch (xEvent.type) {
// case X11.MotionNotify:
// XMotionEvent e = (XMotionEvent)xEvent.readField("xmotion");
// swtEvent.x = e.x;
// swtEvent.y = e.y;
// notifyListeners(SWT.MouseMove, swtEvent);
// break;
case X11.EnterNotify:
ce = (XCrossingEvent)xEvent.readField("xcrossing");
swtEvent.x = ce.x;
swtEvent.y = ce.y;
notifyListeners(SWT.MouseEnter, swtEvent);
break;
case X11.LeaveNotify:
ce = (XCrossingEvent)xEvent.readField("xcrossing");
swtEvent.x = ce.x;
swtEvent.y = ce.y;
notifyListeners(SWT.MouseExit, swtEvent);
break;
default:
overlay.expose();
}
}
}
});
}
}
x11.XCloseDisplay(display);
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();