Home > Archive > Unix Programming > December 2004 > Sending signals to programs
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Sending signals to programs
|
|
| mfmilan@gmail.com 2004-12-15, 3:59 pm |
| 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.
| |
| Christopher Nehren 2004-12-15, 3:59 pm |
| -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2004-12-15, mfmilan@gmail.com scribbled these
curious markings:
> 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.
Uhm, DCOP possibly? You may get a better response on a KDE mailing list
/ IRC channel.
Best Regards,
Christopher Nehren
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)
iD8DBQFBwHF4k/lo7zvzJioRAj+bAKCYzPhRcxS6XzbMXY0iw/f4OCdF4wCfSR4D
cxmNy0JKrVIEim41jO9oHIM=
=N+mC
-----END PGP SIGNATURE-----
--
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated". -- Ken Thompson
If you ask the wrong questions, you get answers like "42" and "God".
Unix is user friendly. However, it isn't idiot friendly.
| |
| Jens.Toerring@physik.fu-berlin.de 2004-12-15, 3:59 pm |
| 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
| |
|
|
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.
I'm sorry for continuing the conversation from another mail (You may
trust me about this), for a friend put the question instead of me for
my internet connection was down for a while.
Thank you for your quick answers.
I don't know what DCOP is, but I'll have to have a look. For the second
answer (the long one :) I'm afraid I'll have to say that it seems as if
my question was misunderstood. I'm not developing an application that's
got to receive peripherals' inputs as signals, but I'd like to
"generate" signals that would be sent to an already running application
(or to a controlling window manager or X server - whatever) so the
application would "think" it got a mouse (or keyboard) input. The idea
is, to be more clear, to "programatically press left mouse button at
34x56 coordinates at a specific window". I have the proc filesystem,
all ownerships necessary, everything). Could that be accomplished in a
way? It doesn't have to be simple ;)
Thank you once again.
| |
| Jens.Toerring@physik.fu-berlin.de 2004-12-16, 4:05 pm |
| Darko <mdanko@tesla.rcub.bg.ac.yu> wrote:
> I don't know what DCOP is, but I'll have to have a look. For the second
> answer (the long one :) I'm afraid I'll have to say that it seems as if
> my question was misunderstood. I'm not developing an application that's
> got to receive peripherals' inputs as signals, but I'd like to
> "generate" signals that would be sent to an already running application
> (or to a controlling window manager or X server - whatever) so the
> application would "think" it got a mouse (or keyboard) input. The idea
> is, to be more clear, to "programatically press left mouse button at
> 34x56 coordinates at a specific window". I have the proc filesystem,
> all ownerships necessary, everything). Could that be accomplished in a
> way? It doesn't have to be simple ;)
If I understand you correctly you want to generate synthetic events
for a different, unrelated process. I guess that you could use the
Xlib function XSendEvent() for that. The application you send the
event to must be prepared to accept these since it can (but probably
usually won't) check if the event was a genuin X server event or
generated via XSendEvent() and thus decide not to react to the later
kind of events. BTW, there's the newsgroup called
comp.windows.x
where you hopefully will find the experts on X related topics.
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.toerring.de
|
|
|
|
|