By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,247 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,247 IT Pros & Developers. It's quick & easy.

Xlib sync on different instance of Xlib.display.Display()?

P: n/a
Hi,

I'm relatively new to Xlib programming, and I ran into a little problem.

I'm trying to insert keypress events into a X window. The following code
works:

--8<------------------------------------------------------------
#!/usr/bin/python

import Xlib.display
import Xlib.X
import Xlib.XK

import time

display = Xlib.display.Display()
screen = display.screen()
root = screen.root
input_focus = display.get_input_focus()
window = input_focus._data["focus"];

ev = Xlib.protocol.event.KeyPress(
time = int(time.time()), root = root, window = window,
same_screen = 0, child = Xlib.X.NONE, root_x = 0,
root_y = 0, event_x = 0, event_y = 0, state = 0,
detail = 104
)

window.send_event(ev, propagate = True)
#display = Xlib.display.Display()
display.sync()
--8<------------------------------------------------------------

But when I comment out the "#display = Xlib.display.Display()" line, it
stops working. (Naturally doing this in this situation is stupid, but in
the real code I tried to pass the window as a parameter to a object
which had its own instance of display)

My guess is that any events that get sent to a window are cached by the
display the window was gotten from. Since I'm sync()-ing on a different
instance of display() the events aren't there. I initially thought this
caching would've been handled on a lower level (somewhere in the X
internals; not in python) so that the instance wouldn't matter.

Is there any way around this, or will I be forced to pass the correct
display instance as a param?
Thanks for any help,
Ferry

--
Ferry Boender
Dec 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.