Next: NetworkStream, Up: Classes [Index]
X11TerminalStream
ClassX11TerminalStream
objects and methods handle input
events from X Window System displays. Ctalk’s X11 support
focuses on the windows themselves, so this class should
almost always be used with a X11Pane
object.
See X11Pane.
Here is an example program that uses InputEvent
objects created
by the window’s input stream, xPane
, to configure the
dimensions of the pane’s window. The X11TerminalStream
object
is contained in the X11Pane
’s inputStream
instance
variable.
int main () { X11Pane new xPane; InputEvent new e; xPane initialize 25, 30, 100, 100; xPane map; xPane raiseWindow; xPane openEventStream; WriteFileStream classInit; while (TRUE) { xPane inputStream queueInput; if (xPane inputStream eventPending) { e become xPane inputStream inputQueue unshift; switch (e eventClass value) { case CONFIGURENOTIFY: stdoutStream printOn "ConfigureNotify\t%d\t%d\t%d\t%d\n", e xEventData1, e xEventData2, e xEventData3, e xEventData4; stdoutStream printOn "Window\t\t%d\t%d\t%d\t%d\n", xPane origin x, xPane origin y, xPane size x, xPane size y; break; case WINDELETE: xPane deleteAndClose; exit (0); break; default: break; } } } }
When compiling this program, you might also need to add the directory that contains the X include files to the include search path. For example:
$ ctcc -I /usr/include/X11 windemo.c -o windemo # Recent Linux
Ctalk’s libraries are linked with the system’s X libraries during installation if they are present, but applications may also need to link with X libraries directly in some cases.
A X11TerminalStream
object recognizes the following
input event classes, and returns the following information
in the xEventData
instance variables, which are
defined in InputEvent
class. See InputEvent.
Event Class xEventData1 xEventData2 xEventData3 xEventData4 xEventData5 xEventData6 BUTTONPRESS x y state button root_x root_y BUTTONRELEASE x y state button root_x root_y KEYPRESS x y state keycode x_keycode[1] KEYRELEASE x y state keycode x_keycode[1] CONFIGURENOTIFY x y height width border MOVENOTIFY x y height width border RESIZENOTIFY x y height width border MOTIONNOTIFY x y state is_hint - MAPNOTIFY event window - - - EXPOSE x y width height count SELECTIONREQUEST - - - - - SELECTIONCLEAR - - - - - WINDELETE - - - - -
[1] The values of X keycodes are defined in X11/keysymdefs.h.
The x
and y
coordinates of the key and button
events are relative to the window’s origin. The x
and y
coordinates of a CONFIGURENOTIFY
event
are relative to the origin of the root window, normally the upper
left-hand corner of the display.
The MOVENOTIFY
and RESIZENOTIFY
events are
both derived from CONFIGURENOTIFY
events, depending
on whether the receiver’s window was moved or resized.
inputPID
clientFD
The file descriptor that the X11TerminalStream
event handler
uses when communicating with the main window’s process.
eventMask
An Integer
that contains the OR’d values of the window system
events that the program wants to be notified of. The window system
events are listed in the table above. If eventMask's
value is
zero, then the event handler assumes that the program wants to
receiver all window system events. Any non-zero value, however,
causes the program to receive only those events; for example:
myMainWindow inputStream eventMask = WINDELETE|KEYPRESS;
In this case the program only receives notice of key presses
(KEYPRESS
events) and requests from the GUI desktop to close
the window (WINDELETE
events) and exit the program.
openInputClient (void
)
Open the X input handler. This method is normally used by
X11Pane
class’s openEventStream
method. See X11Pane.
parentPane (void
)
Return the receiver’s X11Pane
parent object if present.
queueInput (void
)
Queue window system events as InputEvent
objects in the receiver’s inputQueue
instance
variable. The inputQueue
instance variable is
inherited from TerminalStream
class. See TerminalStream.
Next: NetworkStream, Up: Classes [Index]