Asian Application Developer's Guide

Chapter 5 X Input Method Architecture

This chapter describes the input method architecture of X Window applications in Asian locales. The architecture is based on the X Window System Input Method Specification, which is included in X11R6 documentation, and on the X Window System Input Method Protocol (XIMP).

Overview of the X Window System Input Method (XIM)

The X Window System Input Method (XIM) is a mechanism to input internationalized text, that is, text using other than ASCII characters. Before the X Window System was internationalized, the mapping between keystrokes and input characters was a simple one-to-one mapping. However, the increased demand for internationalized programs forced the abandonment of simple keymapping. For example, mappings between key strokes and Chinese, Korean, or Japanese characters are very different.

Without internationalization, the relevant parts of the X Window system could be depicted as follows:

Figure 5-1 X Window system architecture--not internationalized

Graphic

With internationalization, there is the added facility of an intelligent input method server, which can be either a library or server. Sun's X input method for Asian Solaris facilities is in the form of a server. This can be represented as follows:

Figure 5-2 Solaris Input Method Server Role

Graphic

X Window System internationalization involves more than just XIM. It also involves locale support and internationalized text drawing support, such as XmbDrawString() and XwcDrawString(). The X11R6 documentation provides more information on X Window System internationalization.

Architecture of XIM

This section describes how XIM works.

Figure 5-3 XIM Server Model

Graphic

XIM Protocol Interface

The current XIMP in Solaris software supports the following key event handling solutions:

Front-End IM Server Type1: XIMP_FE_TYPE1

All key events go through the IM server only when input conversion mode is ON to compose text.

The Conversion ON key is recognized in the IM library.

The Conversion OFF key is recognized in the IM server.

Figure 5-4 Event Flow in XIMP_FE_TYPE1

Graphic

Back-End IM Server Type2: XIMP_BE_TYPE2

All key events are sent first to the IM library and then to the IM server. The IM server is responsible for sending unused key events back to the IM library.

The Conversion ON/OFF key is recognized in IM server.

Figure 5-5 Event flow in XIMP_BE_TYPE2

Graphic

For XIMP_SYNC_BE_TYPE2, extra synchronization is done on XIMP_KEYPRESS.

IM Server

The IM server is implemented as a separate process. The Sun IM server, named htt, supports the following Asian locales:

For Korean or Chinese htt usage and options, refer to the htt(1) man pages and to the input methods chapter in the Asian Solaris user's guide appropriate to your product.

The IM server comprises the following functional components:

  1. XIMP

    XIMP is one of the most commonly used protocol interfaces between the IM server and the application side of the X library. Sun's implementation supports the latest version of XIMP, which is XIMP4.0.

  1. Event Handling

    Event-handling routines handle all key events coming to the IM server directly from the X server.

  1. Language Engine Interface

    htt communicates with language engines through its internal interface.

  1. Rendering

    Rendering routines support the lookup choice region, non-callback status style, and various preedit area styles:

    • Lookup Choice Region

      Support for lookup choice region

    • Status Area Style

      Support for status callbacks (XIMStatusCallbacks)

      Support for geometry management of status (XIMStatusArea)

      Support for root window status (XIMStatusNothing)

    • Preedit Style

      Support for "on-the-spot" style preedit area (XIMPreeditCallbacks)

      Support for "over-the-spot" style preedit area (XIMPreeditPosition)

      Support for "off-the-spot" style preedit area (XIMPreeditArea)

      Support for "root window" style preedit area (XIMPreeditNothing)

Setting Status and Preedit Styles

The X Window System resource entries in the .Xdefaults resource file specify the status style and preedit style as described in the following sections.

The default CDE settings are overTheSpot and status area.

Status Styles

The Status Area displays which input mode is in effect in the IM server window. You can set the style by entering one of the following lines in the .Xdefaults resource file:

Table 5-1 Status Styles

Status Styles 

X Resource  

callback 

N/A 

status area 

preeditType: overTheSpot

root window 

preeditType: root

Preedit Styles

Many scripts require multiple key strokes to form a single display character, syllable, symbol, ideogram, or other item. Adequate space is needed to display input keystrokes for these languages. For the Asian CDE environment, this intermediate display area is called the preedit area. The preedit area displays intermediate formations of input keystrokes while they are held in a buffer before being committed and sent to the application.

The available styles of preedit area positioning are discussed in the following sections. You can set the style by placing one of the following lines in the .Xdefaults resource file:

Table 5-2 Preedit Styles

Preedit Style 

X Resource 

on-the-spot 

N/A 

over-the-spot 

*preeditType: overTheSpot

off-the-spot 

*preeditType: offTheSpot

root window 

*preeditType: root

On-the-Spot Style

The on-the-spot style in the preedit area is displayed directly in the application window, and grows to the right of the insertion point as text is typed. If existing text is located to the right of the insertion point, that text is moved further to the right, accommodating the expanding preedit text as it is typed. The following shows an example of this style:

Figure 5-6 On-the-Spot Style: Korean

Graphic

Figure 5-7 On-the-Spot Style: Simplified Chinese

Graphic

Figure 5-8 On-the-Spot Style: Traditional Chinese

Graphic

Over-the-Spot Style

As you type text, an over-the-spot style preedit area expands to the right of the insertion point and overwrites any existing display. After you finish typing and processing the preedit area input (in other words, once the text is converted, committed, or otherwise disposed), the processed preedit text is inserted at the insertion point and the preedit area disappears.

Existing text located to the right of the insertion point appears to be overwritten during typing, but when the processed text is inserted at the insertion point, previously existing text is moved and displayed further to the right. This text movement accommodates the input text being inserted.

Using Over-the-Spot Style with Korean Solaris Software

Before you type in an over-the-spot preedit area, the screen should resemble the following:

Figure 5-9 Over-the-Spot Style Before Korean Text is Typed

Graphic

  1. The following figure shows Korean text added on a line of existing text:

    Figure 5-10 Over-the-Spot Style After Korean Input

    Graphic

  2. The following figure shows Korean text after it is committed:

    Figure 5-11 Over-the-Spot Style After Korean Text is Committed

    Graphic

Using Over-the-Spot Style with Simplified Chinese Solaris Software

Before you type text in an over-the-spot preedit area, the screen should resemble the following:

Figure 5-12 Over-the-Spot Style Before Typing Simplified Chinese Text

Graphic

  1. The following figure shows text added at the insertion point on a line of existing text:

    Figure 5-13 Over-the-Spot Style After Typing Simplified Chinese Text

    Graphic

  2. The following figure shows Simplified Chinese text after it is committed:

    Figure 5-14 Over-the-Spot Style After Simplified Chinese Text is Committed

    Graphic

Using Over-the-Spot Style with Traditional Chinese Solaris Software

Before you type in an over-the-spot preedit area, the screen should resemble the following:

Figure 5-15 Over-the-Spot Style Before Typing Traditional Chinese Text

Graphic

  1. The following figure shows text added at the insertion point on a line of existing text:

    Figure 5-16 Over-the-Spot Style After Traditional Chinese Text is Typed

    Graphic

  2. The following figure shows Traditional Chinese text after it is committed:

    Figure 5-17 Over-the-Spot Style After Traditional Chinese Text is Committed

    Graphic

Off-the-Spot Style

An off-the-spot style preedit area is located inside an application window, but it is not at the insertion point. This style preedit area is a permanent part of the application's visual interface. For ease of viewing and consistency, the proposed standard location for off-the-spot preedit areas is in the bottom margin of the application window to the right of the status area.

After you finish typing and processing preedit area input (text converted, committed, or otherwise disposed), the text is sent to the insertion point. Text to the right of the insertion point is moved farther to the right, accommodating the preedit text as it is inserted.

Root-Window Style

A root-window style preedit area is provided by the system's workspace. The proposed standard location of the preedit area is at the bottom of the workspace. Input handling works the same as with off-the-spot style preedit areas.

Figure 5-18 Root-Window Style (Korean)

Graphic

Figure 5-19 Root-Window Style (Simplified Chinese)

Graphic

Figure 5-20 Root-Window Style (Traditional Chinese)

Graphic

Toolkit Use and Application Interfaces

Two methods are available for programming applications for Asian Solaris software:

  1. Write an application that includes its own direct interface to Xlib.

  2. Use Motif and other X toolkits that incorporate an XIM API in their interfaces to Xlib (usually the simpler method).

For more information, see Common Desktop Environment: Internationalization Programmers Guide. This guide provides instructions on writing international programs.

To write a program that interfaces directly with Xlib, a developer must use the internationalized APIs described earlier in this chapter. For additional information on the APIs, see the X11R6 documentation.