Solved

XSendEvent

Posted on 1997-03-05
5
541 Views
Last Modified: 2013-12-26
I am using XGrabPointer to grab all Button events.  I then
use XNextEvent to read the event in the queue that is waiting to be read.  (No problems to this point.)

I then attempt to repost the same event using XSendEvent.
I recieve absolutely no sign that the Send works.  It
does not return an error.  I have tried to tweek many of
the variables in the event with no change and even the
arguments to XSendEvent.  I tried changing the window I
was sending to, but that did not work either.

Here is what I used (and many other versions);
     XSendEvent(display, root, True, 0xFFFF, &report);

What am I forgetting to do?

0
Comment
Question by:tulip
  • 3
5 Comments
 

Author Comment

by:tulip
ID: 1292398
Adjusted points to 50
0
 

Author Comment

by:tulip
ID: 1292399
Adjusted points to 100
0
 
LVL 2

Accepted Solution

by:
lockhart earned 100 total points
ID: 1292400
Why don't you use XPeekEvent()?  Then if you want to remove the event and not put it back you can do it, but if you want to leave it on the queue XPeekEvent() does that.  Unless you want the event to go to the back of the queue (as would happen in your current scenario).  In any case, you should use the Display and Window members of the event structure as your 1st and 2nd args to make sure the event gets sent to the same display and window it was going to when you plucked it via XNextEvent().  So,  XSendEvent (report.display, report.window, True, 0xFFFFFFFFL, &report) would seem appropriate (and don't forget that the event mask is a LONG).

Another alternative would be XPutBackEvent().  To tell you the truth, I've never tried to do what you are trying to do and can't tell you why it is failing.  I've always used XPeekEvent() to look at an event and decide if I want to do something or postpone actions.  

I suspect that the problem is that XNextEvent() takes a display and event as args and XSendEvent() additionally takes a window, propogate boolean and event mask.  The target for the event seems to be different.  If you let X figure out where the event needs to go by using XPutBackEvent() or don't even deal with having to put it back by using XPeekEvent() you shouldn't have this problem.

If you need to search for specific kinds of events in the queue for some reason, you can use XCheckWindowEvent() to look for specific events going to specific windows.

Hope this helps.

Mike
0
 

Expert Comment

by:erb
ID: 1292401
FYI, there is a small program that uses XSendEvent to take
input from the serial port and make X think they are keystrokes.
The README tells some setup hints, like *AllowSendEvents: yes
in .xdefaults.  Source code included.

  http://www.tableau.com/kt21.README
  http://www.tableau.com/kt21.tar.gz

Dave

0
 

Author Comment

by:tulip
ID: 1292402
Thanks for the help!
I believe that a full description of the problems I ran into might help others.  Here goes:

-Definately check out the programs mentioned by erb.  It was invaluable.

-The window that you send to and the windows mentioned in the XEvent structure that one sends must be correct.  All events propagate up towards the root window until that are grabbed by an interested window.  Thus you must send to the window you are interested in communicating with.

-AllowSendEvent  will cause some hassles.  I have it working for most application now.  I am still working on the window manager so that it will accept my events properly.  Make sure to check resources if all else fails.

-Make sure to use XFlush() so that your XSendEvent will be
executed.

-Check the state value of the XEvent structure for correctness.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 54
haveThree challenge 22 121
how to split multiple lines delimiter : 8 109
Increment column based of a FK 8 30
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question