On Tue, 28 Oct 2003 13:13:06 +0100 Robert Woerle <[EMAIL PROTECTED]> babbled:
> Carsten Haitzler (The Rasterman) schrieb:
>
> >On Tue, 28 Oct 2003 12:19:49 +0100 (MET) "Gerhard Gruber" <[EMAIL PROTECTED]>
> >babbled:
> >
> >
> >
> >>I'm not sure if this is the proper forum for asking such a question, but I
> >>found nothing so far on the web and so I hope to get some answers at the
> >core>of X. If this is not the correct forum I would really appreciate it if
> >you>could point me to where I can ask this question.
> >>
> >>I'm developing an application which needs to filter all mouse events even
> >>when it's window is not active. So I tried to grab the pointer and redirect
> >it>to my app. This works, but the problem I have is that of course X doesn't
> >>work as long as my app is active because it gets all events and the other
> >apps>none. I was looking into the Xlib reference manuals if there is some way
> >to>forward or return the XEvent to X again so it can be processed the normal
> >way.>In Windows I do this with a hook function which allows me to specify
> >that an>event is either passed on, or will be discarded after my hookfunction
> >>returns. I wonder if there is a similar mechanism for X. I was looking into
> >>GDK, as this would be my prefered way of doing it, but I would settle for a
> >>Xlib solution as well if there is no other way.
> >>So what I need is either a way to simply filter events and block them on
> >>request (prefered) or grab all the input and forward it to the original
> >owner>if I'm not interested in it.
> >>
> >>
> >
> >basically there is no choice. you can't do this. you need to POLL for the
> >mouse position in a timer to do what you want. you dont have the choice of
> >swallowing or allowing a mouse move event (outside your window).
> >
> I dont think you will need to "poll " ...
> you just wait for them to come and then go on .
>
> you say you already manage to grab them , so then you only need to
> decide to sent them back or not.
> I the XLib function XSendEvent is capable to re-generate the
> uninteressting event`s and sent them
> back to where it should belong ... just make sure that you also
> investigate all the other things of the event so that you can aftwards
> generate a proper new one ..
this has issues all of its own. first. other peoples windows need to get the
correct event at the correct location and time - which now won't be right as
windows may have been destroyed, created, shown and hidden, moved and resized,
raised and lowered, shape mask changed etc. in the meantime. remember you need
to keep the list of shape rectangles of the window to determine if the mous is
inside or outside of it - this may change and you now have to poll every window
you think might possibly contain the mouse for its shape mask and rectangles.
you need to determine which window the mouse would be in and its offset in order
to re-construct the event to send. your chances of getting this correct are
getting slimmer by the second, ESPECIALLY since X is an synchronous environment,
by the time you query for things, it all may have changed server-side. you could
grab the server during every query... but now we're talking REALLY stupid code.
also since you have the mouse grabbed to your window (unless you use a big
input-only window on top of everything... another can of worms on its own), this
also makes 1. menus not work cause other apps/toolkits will want to grab mice to
menu windows etc. for this, 2. "mouse bindings" of the wm wont work (alt +left
mouse anywhere in the window wont move it). 3. to make a vague attempt to keep
in sync you'll need to monitor the entire x window tree ALL the time... NOT fun
or efficient. Also other apps might even ignore mouse move events with the
"send_event" flag set to 1. what you have there is a partially working system
that will only work for some things - and will need a LOT of code which will
never be accurate or correct anyway.
i can probably find more holes to poke in it all - but suffice to say however
you look at it you'll NEVER get it right. your only choice to find out what the
mouse is doing outside windows you're listening for events on is to poll. you
cannot intercept and optionally not send an event.
this is actually one of x's downfalls which should be fixed. the ability to
"monitor" events globally/in general without having to specifically select on
them on target windows. then add the ability to allow/disallow them to go to the
next guy listening (first in first served ala the wm?).
> what you then did is to make your own "hook - function" like you where
> used to in windows ..
>
> - i think
>
> >
> >so you need to poll in a timer. you can then just query the mouse position on
> >the screen and do what you need to. this does mean a round trip per query and
> >wont make for the nicest app on the planet.
> >
> >although i can think of an evil hack to avoid polling... very evil. so evil i
> >wont mention it.
> >
> >
> >
> >>Can this be done with X and/or GDK/GTK? If I know how to do it in X I could
> >>probably figure out how to do it in GDK/GTK as well, but I've been searching
> >>the web for several days now and I couldn't find anything helpfull. There
> >>seem to be many workarounds for similar problems but none that works for me,
> >>though.
> >>
> i believe this special "hook part " is best done in pure Xlib ... maybe
> aftwards you can generate GTK - events again , but hooking all events
> should not a GTK thing
>
> >>
> >>Thanks for your help.
> >>
> >>_______________________________________________
> >>Devel mailing list
> >>[EMAIL PROTECTED]
> >>http://XFree86.Org/mailman/listinfo/devel
> >>
> >>
> >
> >
> >
> >
>
> --
> _____________________________________
> *Robert Woerle
> Linux & Customer Support*
> *PaceBlade Technology Europe SA*
> phone: +49 89 552 99935
> fax: +49 89 552 99910
> mobile: +49 179 474 45 27
> email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> web: http://www.paceblade.com
> _____________________________________
>
>
>
>
> _______________________________________________
> Devel mailing list
> [EMAIL PROTECTED]
> http://XFree86.Org/mailman/listinfo/devel
--
--------------- Codito, ergo sum - "I code, therefore I am" --------------------
The Rasterman (Carsten Haitzler) [EMAIL PROTECTED]
熊耳 - 車君 [EMAIL PROTECTED]
Mobile Phone: +61 (0)413 451 899 Home Phone: 02 9698 8615
_______________________________________________
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel