Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XSendEvent

Posted on 1997-03-05
5
Medium Priority
?
582 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 300 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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