What's happening to DeviceMotionNotifies?

Peter Hutterer mailinglists at who-t.net
Tue Nov 28 19:39:01 PST 2006


Stumbled across a problem yesterday, took me a while to track it down.
A very simple application to print DeviceMotionEvents doesn't work  
any more with the current X server.
Tried it with MPX first, then with the master branch and event pulled  
a fresh copy from git today.

When I put xmond in between, I can see the events flying past but  
they do not actually arrive at the client. I don't yet know whether  
that's an XCB, Xlib or X.org issue. MotionNotifies arrive,  
DeviceMotionNotifies don't.
Can anyone replicate this? What am I missing here?

Simple test program, compile and run with $> foo <host:display>  
<inputdevice> where <inputdevice> is an XI device.


#include <stdio.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <assert.h>
#include <X11/extensions/XInput.h>

int main (int argc, char** argv)
{
     Display* display;
     Window win;
     XDevice* dev;
     XEventClass class_1;
     XSetWindowAttributes attr;
     int screen;
     int win_width, win_height;

     int type_1;

     display = XOpenDisplay(argv[1]);
     screen = DefaultScreen(display);
     assert(display != NULL);

     win_width = 640;
     win_height = 480;


     dev = XOpenDevice(display, atoi(argv[2]));
     assert(dev != NULL);
     DeviceMotionNotify(dev, type_1, class_1);

     attr.background_pixel = WhitePixel(display, screen);
     attr.event_mask = ExposureMask | StructureNotifyMask;//|  
PointerMotionMask;

     win = XCreateWindow(display,
             RootWindow(display, 0),
             0, 0,
             win_width,
             win_height,
             7,
             DefaultDepth(display, 0),
             InputOutput,
             DefaultVisual(display, 0),
             CWBackPixel | CWEventMask,
             &attr);

     XMapWindow(display, win);

     XSelectExtensionEvent(display, win, &class_1, 1);
     XSync(display, False);


     while(1)
     {
         XEvent e;
         XNextEvent(display, &e);
         XDeviceMotionEvent* mev;

         switch(e.type)
         {
             default:
                 if (e.type == type_1)
                 {
                     printf("Motion notify\n");
                     printf(" state %d\n", mev->state);
                     printf(" devstate %d\n", mev->device_state);
                 } else
                 {
                     printf("Unknown event type %d\n", e.type);
                 }
                 break;
         }
     }

     XCloseDisplay(display);
     return 0;
}




Cheers,
   Peter

--
Multi-Pointer X Server
http://wearables.unisa.edu.au/mpx





More information about the xorg mailing list