Re: Sending signals to programs
Jens.Toerring_at_physik.fu-berlin.de
Date: 12/15/04
- Next message: Call me Stupid: "Re: need help with compiling with GTK+2.0 (updated)"
- Previous message: Christopher Nehren: "Re: Sending signals to programs"
- In reply to: mfmilan_at_gmail.com: "Sending signals to programs"
- Next in thread: Darko: "Re: Sending signals to programs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 15 Dec 2004 17:17:24 GMT
mfmilan@gmail.com wrote:
> Is there any way to send signal(button pressed, mouse clicked,...) to a
> program in KDE? Asume that I have started that program, so I have all
> permissions.
Since KDE is based on X I am pretty sure (even though I never
have used it, only other toolkits) that dealing with mouse
clicks, pressing a button etc. is not done using signals.
Typically, an application requests to be told about certain
events (like, e.g. a mouse button becomes pressed in a window
the application owns) from the X server. The application in
turn checks if such an event has occurred. So a graphical
application usually is running in a loop, most of the time
waiting for such events to happen and then reacting to them
- quite often using a callback mechanism supplied by the
toolkit, i.e. you can install a callback handler for events
like a button becoming pressed and the toolkit takes care of
invoking this function when it happens.
Getting a signal on such events is hardly possible since the
X server does not raise signals but notifies the application
about events on request (since the X server and the client
can be running on different machines there's no way the X
server could send a signal to the client, it also can't
"push" events to the client, the client must ask for them).
And raising a signal in the callback function would normally
be rather useless since the application in that moment al-
ready knows that e.g. a button became pressed and is dealing
with that.
If you ask because you are writing an application that is
very computation-intensive and you want these computations to
become interrupted by an X event then you can't do that, you
need to check for such events regularly (the toolkits I have
seen had some function that when called, invoked the required
callback handlers). Even if it would be possible to get a
signal for X events it wouldn't make too much sense because
only a very restricted set of functions can be used in signal
handlers - and most of the graphic functions definitely can't.
Another way to deal with the problem would be to split your
application into two threads or processes - one for doing the
computations and the other one for interacting with the X
server (but if you use two processes take care that only one
of them is interacting with the X server and never the other,
and with threads either call XInitThreads() as the very first
function unless you can make sure that the threads will never
use the Xlib concurrently).
Regards, Jens
-- \ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de \__________________________ http://www.toerring.de
- Next message: Call me Stupid: "Re: need help with compiling with GTK+2.0 (updated)"
- Previous message: Christopher Nehren: "Re: Sending signals to programs"
- In reply to: mfmilan_at_gmail.com: "Sending signals to programs"
- Next in thread: Darko: "Re: Sending signals to programs"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]