View Full Version : hooks in linux

20th October 2007, 22:15
is there something like windows hooks in linux?
can i use grabMouse for this, or do other apps dont get mouse events than anymore?

20th October 2007, 22:24
What are you trying to do?

21st October 2007, 12:00
hm this doen't work very fine....
im doing this:

Display *display = QX11Info::display();
Window grab_window = oWidget->winId();
Bool owner_events = true;
unsigned int event_mask = ButtonPressMask | PointerMotionMask;
int pointer_mode = GrabModeAsync, keyboard_mode = GrabModeAsync;
Window confine_to = QX11Info::appRootWindow();
Cursor cursor = 0;
Time time = CurrentTime;
XGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor, time);
is it wrong?
i call it in a thread.

21st October 2007, 12:21
But what are you trying to achieve? I don't think you have to use the native API here, because Qt handles that. I think the only question is if you really want to grab the pointer.

21st October 2007, 12:59
YEs i really want to grab, but how i do it under windows!
My widget shall get all mouse events, before all other applications get the events.
When the mouse somewhere at the screen was moved, i want to know.
But without freezing the pointer for other widgets. isn't this possible on linux?

21st October 2007, 15:19
If you grab the mouse, no other window (regardless of the application) than the grabbing one will get the event. It's a way to steal events, not to monitor them. Thus my question - what is your goal? Maybe it's enough to reimplement x11Event() and handle some specific event there...

21st October 2007, 22:08
if x11Event is global (for the whole desktop, not only for my app) this is what i need.

i show you what i want to do. This app doesn't act as i want it. i need to know all global mouse events to make it work right.

22nd October 2007, 00:56
There surely has to be a way to intercept pending mouse events on X. You might check out KDE sources (specificaly applications like Karm) to see how to do it. You are entering desktop manager specific things here...

22nd October 2007, 18:34
There are ways to listen to global events on both Windows and X11. I've done it, but it has been years and I don't remember now what the details are.

22nd October 2007, 20:57
this is what i need! please find out or give me a hint. which librarys did you use under linux? xlib?

22nd October 2007, 21:23
Here is something to start with: http://lists.freedesktop.org/pipermail/xorg/2007-January/020908.html