[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2539.0. "XSendEvent problem..." by STKHLM::BERGGREN (Nils Berggren SWAS/Telecom,Sweden) Wed Mar 28 1990 20:58

    Hello,
    
    I have some problems with the XSendEvent routine.
    
    I'm working  on  a  project  were  we're  writing some widgets.  
    
    The widget I'm writing has an action-routine for the <Key> -event which
    takes care of keys pressed.  If it is a key which I don't want  I want 
    to send it upwards the hierarchy to the "grandfather" which I know
    has a translationtable set up for some <Key>-events it want to take action
    on. 
    
    When sending the event I get into a loop getting the event back and try to
    send it allower again.  
    
    The way I call XSendEvent is as follows:

       XSendEvent(XtDisplay(w),
       		  Xtwindow( grandfather ),
		  FALSE,
		  KeyPressMask,
		  event);
    where 'w' is the widget where the event occured, 'grandfather' is of course
    the grandfather-widget and 'event' is the event got as an argument to the
    action-routine.
    
    In between 'my' widget and the grandfather widget there's a DialogBox; can
    that cause any problems? 
    
    Any help is appreciated!


         /Nils Berggren
T.RTitleUserPersonal
Name
DateLines
2539.1Unrealized widget == PointerWindow (!)DECWIN::KLEINWed Mar 28 1990 21:2811
How are you getting the "grandfather" widget?  Check whether you're
getting back a zero for the window ID.  I suspect that you are passing
a zero, which means "PointerWindow".

Thus, if you are passing a zero window ID, then the event goes to whichever
window contains the pointer.

This will happen if the widget you're fetching the window ID from has not
been realized.

-steve-
2539.2No zero window-ID!STKHLM::BERGGRENNils Berggren SWAS/Telecom,SwedenThu Mar 29 1990 06:4416
    Re: .1
    >>> How are you getting the "grandfather" widget?  Check whether you're
    >>> getting back a zero for the window ID.  I suspect that you are
    >>> passing a zero, which means "PointerWindow".
    
    The grandfather widget is got by
           grandfather = XtParent( XtParent(ThisWidget) )
    and the window ID is got by
           XtWindow( grandfather )
    When run under the debugger I have checked that grandfather points
    correctly to the grandfather widget and XtWindow doesn't return zero..
    
    Any other clues?
    
           /Nils
    
2539.3worth a try...NRMACP::WATSONBecause Daddy says so...thats whyFri Mar 30 1990 08:5510
    I too have had lots of problems with XSendEvent - see note 809 in the X
    notes file.  In particular, I can't get PointerWindow or FocusWindow to
    work at all.  The only way I have got XSendEvent to work is by
    explicitly changing the "window" field of the event structure you are
    passing as well as passing the window argument.
    
    Jim Gettys has also suggested I try things out on a R4 server, but I don't
    have one available.
    
    -- Rob
2539.4Working example fragmentDECWIN::KLEINFri Mar 30 1990 15:5216
Just in case it helps, here is an example of XSendEvent that definitely
does work:

-steve-

------------------------------------------------------------------------------

    XEvent event;			/* allocate full event buffer */

    event.xclient.type = ClientMessage;
    event.xclient.display = XtDisplay (w);
    event.xclient.window = XtWindow (w);
    event.xclient.message_type = 0;
    event.xclient.format = 32;

    XSendEvent (XtDisplay (w), XtWindow (w), 0, 0, &event);
2539.5What out for those addresses!WILLET::frebKarl Freburger Object-based SystemsFri Mar 30 1990 17:1920
Re: .0:

I notice that your XSendEvent call looks like:

       XSendEvent(XtDisplay(w),
       		  Xtwindow( grandfather ),
		  FALSE,
		  KeyPressMask,
		  event);

If event is decalred as

	XEvent event;

then you probably should be passing &event.  As I recall, ancient C compilers
will treat event and &event the same, but newer ones can pass structs as
arguments, and event and &event are very different.  Then again, maybe
I'm just out in left field as usual...

	- karl
2539.6works when changing the "window"-fieldSTKHLM::BERGGRENNils Berggren SWAS/Telecom,SwedenMon Apr 02 1990 11:089
    Re .3 
    
    I got it to work by explicitly changing the "window" field of the event
    structure event though I don't think this is the correct wy to do
    it....
    
    Thanks!
    
       /Nils
2539.7re .5: event declared as a pointerSTKHLM::BERGGRENNils Berggren SWAS/Telecom,SwedenMon Apr 02 1990 11:128
    Re .5
    
    I have declared event as a pointer to XEvent, i.e.  XEvent *event;
    so that shouldn't be the problem I think.
    
    Thanks any way,
    
       /Nils
2539.8Server bug?NRMACP::WATSONBecause Daddy says so...thats whyTue Apr 03 1990 17:016
    RE .6
    
    Glad that worked.  I reckon this may be a server bug, and have SPRed
    it.  Could someone try this on an R4 server to check ?
    
    -- Rob