Where is the mouse pointer. - Motif

This is a discussion on Where is the mouse pointer. - Motif ; Whilst enhancing my application I found the following comment: If the user has left the window with one of the mouse buttons down, prevent any further messages getting to the (application) logic until we get an enter window event. This ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Where is the mouse pointer.

  1. Where is the mouse pointer.

    Whilst enhancing my application I found the following comment:

    If the user has left the window with one of the mouse buttons down,
    prevent any further messages getting to the (application) logic until
    we get an enter window event. This mimics the behaviour of the NT class
    which does not do a mouse capture when a button is pressed.
    Unfortunately Motif gives you a mouse capture for free. The really bad/
    news is that you don't always get an Enter Window event when you think
    you should get one, in particular when a modal dialog (parented from
    "this") gets deleted but the mouse is already over "this" not the
    departing dialog Hence always turning off the mouse logic doesn't
    work particularly well! You can be left with mouse events disabled
    until the user moves out then back into the window. Clearly this logic
    still fails if the user moves the mouse into a modal dialog, covering a
    canvas view, with the mouse held down then moves back out again before
    dismissing the dialog.

    To solve this he wrote a code #

    void
    U_M_VIEW_WND::OnEnterWindow(void)
    {
    m_bInhibitMouseLogic = False;
    }

    void
    U_M_VIEW_WND::OnLeaveWindow(void)
    {

    XQueryPointer( XtDisplay(map_entry->shell),
    XtWindow(map_entry->shell),
    &dummyw, &dummyw, &dummyi, &dummyi, &dummyi, &dummyi,
    &mask);

    if( mask & (Button1Mask|Button2Mask|Button3Mask) )
    m_bInhibitMouseLogic = True;
    }

    }

    The m_bInhibitMouseLogic is checked in all other routines to dissable
    in code like
    if( m_bInhibitMouseLogic )
    return;

    ...... rest of event handling code.

    I was considering if I can improve the situation by using the
    root_window and/or the child_window returned by XQueryPointer to
    determine if actually the mouse pointer is just on top of my current
    drawing area. Something to alter my logic to

    if( m_bInhibitMouseLogic ) {
    XQueryPointer(...,.., root_window, child_window,........ )

    if( root_window = my_drawingAreaWindow)
    m_bInhibitMouseLogic = FALSE;
    else
    return;
    }

    However, reading past posts here I am concerned that the XQueryPointer
    does not return the cursor window. Does it return then the top window?
    What is the difference between the root_window and the child_window?
    Which one is the best to use? Is any other way (my application is a
    Motif one) to determine the 'top level window'?

    Any help is welcome.


  2. Re: Where is the mouse pointer.

    Using XQueryPointer should be rare; it's probably better to get x/y
    coordinates out of the last event. Otherwise you're going to require a
    round-trip to the server, not to mention the mouse can move between the
    callback start and the time you call it.

    This looks like some sort of strange workaround to me, I'd investigate
    the original claim and see if that can be fixed a better way.

+ Reply to Thread