Solved

XSendEvent

Posted on 1997-03-05
5
545 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 171
ORA-01403: no data found 43 116
how to monitor remote shell execution on linux 9 113
zeroMAx challenge 20 135
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

739 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