Submitted by Anonymous on Mon, 11/19/2001 - 15:58. Developers
Hello!
I have a program which needs to get user mouse
move events at certain point and thus get some
pseudorandom material. Is there any elegant method
to do this?
I now use XtOpenApplication, MrmOpenHierarchy, MrmFetchWidget, XtManageChild, XtRealizeWidget
to get my form visible, then my own event loop
checking if we got enough movements, and then
XtDestroyWidget, XtDestroyApplication and
MrmCloseHierarchy to get things back where they
were before calling this function.
And lo, it works fine, at least on first call to
this function. On second it crashes in XtOpenApplication somewhere deep in the bowels of Xt library
0xff02a3f0 XSaveContext+0x0138 st %o0, [%o1 + 0xc]
I use Solaris 8. Motif VERSION 2.1.1,REV=10.1999.12.02...
Thank You in advance! I can send this program
offlist, maybe it`s a bug after all...
http//www.motifzone.com/resources/man/XtOpenApplication.html implies that you`ll need to call this only once. I suspect that if there is a crash, it`s because you are passing the same argc/argv pair as in the first call, but those lists were exhausted by that first call. In any case, you can break down XtOpenApplication into its component calls to other Xt functions, as documented in the man page above, such that you can repeatedly connect to the display.
Note, however, that you don`t need Xt to get details of the mouse. You can use Xlib calls to open the display and query the pointer.
And further note that mouse motion isn`t likely to be occurring when you make this call; nor is it particularly random. Can`t you find a real random number generator?
Thank you for the feedback! Now i resolved the
problem by not calling XtDestroyApplicationContext,
but sucking out any remaining events left after DestroyWidget to get it removed from the screen.
I cannot notice any memory leaks so far.
About argc/argv - i pass 0 and NULL, so i think
this is not the matter. It works pretty well
without) And i`ll try to break down this call,
when i`m back on that code. It will be even better
as i don`t need any fallback resources, etc.
About Xt and not Xlib. I need to get these events
with all possible bells and whistles) It`s nice
Form with button i don`t want to draw myself nor
use simple X window with text in it. I need my "cancel" button)
And about pseudorandomness. I do realize the widget and then if user won`t move the mouse, it won`t come any further. He just NEEDS to give me
feedback, or he won`t leave that eventloop. And it`s exactly pseudorandom feedback (along with
gethrtime) to start real generator) I cannot see
any other way to get good pseudorandom events
short of getting almost random ones from physical
source (like diode noise or whatever it`s used there in hardware RNGs).
Thank You once again for Your responce! But the problem with XtOpenApplication still exists i think((