![Logitech Magellan/SPACE MOUSE Classic Programmer'S Manual Download Page 11](http://html1.mh-extra.com/html/logitech/magellan-space-mouse-classic/magellan-space-mouse-classic_programmers-manual_1937109011.webp)
11
X-Window Interface
This chapter describes the technical
background of the X-Window driver interface,
including how data is moved from the X-
Window driver to the application. This
information may be used to join the
Magellan/SPACE MOUSE with the X-Window
application. The file
xapp.c
, found on the
LogiCad3D CD-ROM under the directory
/unix/xdev
, contains a simple example of this
procedure.
Software Interface
The exchange of information between the X-
Window driver and the application happens in
"Events".
These are numbers that are globally
joined to the X-Window system. These events
are exchanged as client messages between the
partners. Four different events are joined
together.
§
CommandEvent
. A command
event.
MotionEvent
. An event of 3D files of
movements in X, Y, Z, A, B and C.
§
ButtonPressEvent
. An event of one pressed
key.
§
ButtonReleaseEvent
. An event of one
released key.
These events are joined together with the help
of the
XInternAtom
function and the X-Window
system. The numbers returned by
XInternAtom
are exclusively reserved for these events. If
the application is in relation to an event (over
the
XInternAtom
function), it will receive the
same number the X-Window driver received at
the installation of the interface. These events
equally formulate the joining parts between
the X-Window driver and the application. The
following program excerpt arranges the
agreement of the X-Window System.
AtomMotionEventNumber;
AtomButtonPressEventNumber;
AtomButtonReleaseEventNumber;
AtomCommandEventNumber;
MotionEventNumber =
XinternAtom(display,"MotionEvent",TRUE);
ButtonPressEventNumber =
XinternAtom(display,"ButtonPressEvent",TRUE);
ButtonReleaseEventNumber =
XinternAtom(display,"ButtonReleaseEvent",TRUE);
CommandEventNumber =
XInternAtom(display,"CommandEvent",TRUE);
X-Window Driver Window
The X-Window driver opens a window in which
it starts the application. Events can only be
sent to windows, but they can always be
received by the receiver (because the client
message information cannot be marked by the
receiver). For the application to receive the
window number of the X-Window driver, the
driver must put down the window number as a
characteristic of the
CommandEvent
. From
there the application can read the window
number of the X-Window driver. The following
program excerpt shows how this is possible.
AtomActualType;
intActualFormat;
unsigned long NItems,BytesReturn;
unsigned char *PropReturn;
Window root,MagellanWindow;
root = DefaultRootWindow(display);
XGetWindowProperty(display,root,CommandEventNumb
er,0,1,FALSE,
AnyProperty,&ActualType,&ActualFormat,&NItems,&Byte
sReturn,&PropReturn);
if ( PropReturn != NULL )
MagellanWindow = *(Window *)PropReturn;
else
MagellanWindow = NULL; /* driver not found */
Placing the Application Window
The X-Window driver sends the events it
receives from the Magellan/SPACE MOUSE to
the current input focus window, which the X-
Window system has been associated with
through the keyboard input. The driver asks
via the
InputFocus
constant which window
currently belongs to the input focus. It is also
possible to use a
CommandEvent
to let the X-
Window driver know which window will receive
routed events. This causes the driver to lose
the input focus and send all the events without
exception to the active window. However, the
driver automatically changes back to the input
focus when an event cannot be sent
successfully to the active window. (This
occurs, for example, if the active window has
been closed). The following program excerpt
shows how to place the window in the X-
Window driver.
Xevent Event;
Event.type = ClientMessage;
Event.xclient.format = 16;
Event.xclient.send_event = FALSE;
Event.xclient.display = display;
Event.xclient.window = MagellanWindow;
Summary of Contents for Magellan/SPACE MOUSE Classic
Page 1: ......