I am trying to integrate the SpaceNavigator in my custom 3D app. I have been able to run xapp with no problems, so I used xapp.c as a guide, the biggest difference being I have an existing Window. The two major methods I call are MagellanInit() andXSelectInput() before starting the loop to receive events. The debug statements that get printed to the console look the same as when I run xapp (with a few changes in numbers):
I do receive keyboard inputs since I followed xapp.c's example of calling XSelectInput with the KeyPressMask | KeyReleaseMask argument. However, I am not getting any SpaceNavigator events. Does anyone know what I am missing?
you have to select the ClientMessages and check with MagellanTranslateEvent() if this is a MagellanMotionEvent, a MagellanInputButtonPressEvent or a MagellanInputButtonReleaseEvent. In the example xapp.c this is done right after the case ClientMessage:
I do have the 'case ClientMessage' statement in there, but my problem is that it never gets called.
I forgot to mention that in my application, I don't want XNextEvent() to block, so I call XCheckWindowEvent() to see if there are any events in the queue first. The mask argument I am passing into XCheckWindowEvent() is 'KeyPressMask | KeyReleaseMask'. Should I be passing in something for it to check for SpaceNavigator events?
So my real problem is that XCheckWindowEvent() does not return true when I move the SpaceNavigator, which means XNextEvent() is not called, which means the 'case ClientMessage' is never reached. Sorry for not being more clear the first time.
The fix for XCheckWindowEvent() is to use XPending(), but that didn't fix the problem that my window isn't getting the SpaceNavigator events, even though it receives keyboard events (and mouse events too, with the proper masks set). I can get SpaceNavigator events when I create a brand new window using XCreateSimpleWindow(), followed by XSetWMProperties(), but I don't know how to register a window that I didn't create via XCreateSimpleWindow(). Do I need to set classhints->res_class to something other than "BasicWindow"? Do I call XSetWMProperties() on that window?
I am sorry for the delay. The problem is that I am not quite sure if the XSetWMProperties() sets something that is necessary to receive the XClientMessages. As far as I know there is nothing specific to prepare (set a mask or similar) to receive the ClientMessages.
When you invoke the XSetWMProperties() do you use the same properties as in the source code of xapp.c?
I'm still not certain what the problem is (it could be that this window, which is part of an app developed by many people, already has an xevent listener that is usurping all the xevents), but I created a workaround by using an invisible window as the event receiver so that the callbacks are made, and then I proceed to modify my app window as expected.