Help: pointer passive motion

Hi guys,

Can any one show me a simple example on how to detect the Mouse Passive Motion in X?

I tried to do it in the following event callback
function, but it failed to work properly:


void input(Widget w, XtPointer data, XtPointer cd){
if(cd->event->type==keyPress){

}
else if(cd->event->type==ButtonPress){
buttondown=True;
HandleMouse(w,cd);
}

else if(cd->event->type==ButtonRelease)
buttondown=False;

else if(cd->event->type==MotionNotify){
if(buttondown) HandleMouseMotion(w,cd);
else HandlePassiveMotion(w,cd);
}


It seems to me that the event type “MotionNotify” only includes “pointer motion event with a button down”. My problem is I don’t know how to modify this default behavior for the glxarea widget.

Any help is very much appreciated!

Thanks,

Did you include PointerMotionMask in your event mask?

Alternatively, you can query mouse pointer outside the event loop like this:

    Window root;
    Window child;
    int root_x, root_y;
    int win_x, win_y;
    unsigned int button_mask;

    static int old_win_x;
    static int old_win_y;

    if( True == XQueryPointer(Interface::Window->GetDisplay(),
                              Interface::Window->GetWindow(),
                              &root, &child,
                              &root_x, &root_y,
                              &win_x, &win_y,
                              &button_mask) )
    {
        if( button_mask & Button1Mask ) // left button
        {
        }
        if( button_mask & Button3Mask ) // right button
        {
        }

        old_win_x = win_x;
        old_win_y = win_y;
    }
    else // outside window borders
    {
    }

In the above code, ‘Interface’ is my namespace for various singleton accessors.
I hope everything else is self-explanatory. You would do something like this on
per-frame basis.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.