04.04.2013 Views

Volume One: Xlib Programming Manual - Niksula

Volume One: Xlib Programming Manual - Niksula

Volume One: Xlib Programming Manual - Niksula

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 9−5. Correct forms fill−in result using a synchronous key grab<br />

To summarize, the solution to this form of type−ahead problem is to use GrabModeSync as the keyboard_mode<br />

argument of the passive grab on the Tab key. Then call XAllowEvents() in response the arrival of the Tab key event<br />

that signals the change in windows. This synchronizes the change of keyboard focus from one window to another and<br />

assures that the events go to the intended window.<br />

9.5 Keyboard Preferences<br />

<strong>Xlib</strong> provides routines to control beep pitch and volume, key click, Shift−Lock mode, mouse acceleration, keyboard lights<br />

and keyboard auto−repeat. Not all servers will actually be able to control all of these parameters.<br />

There are five routines that deal with the keyboard and pointer preferences. XGetKeyboardControl() and<br />

XChangeKeyboardControl() are the primary routines for getting or setting all these preferences at once.<br />

XAutoRepeatOff() and XAutoRepeatOn() set the global keyboard auto−repeat status but are not able to control<br />

the auto−repeat of individual keys as XChangeKeyboardControl() can.<br />

9.5.1 Setting Keyboard Preferences<br />

XChangeKeyboardControl() uses the standard X method of changing internal structure members. The values<br />

argument to XChangeKeyboardControl() specifies the structure containing the desired values; the value_mask<br />

argument specifies which members in the structure specified in values should replace the current settings. See the<br />

reference page for XChangeKeyboardControl() in <strong>Volume</strong> Two, <strong>Xlib</strong> Reference <strong>Manual</strong>, for a list of the mask<br />

symbols.<br />

Example 9−13 shows the XKeyboardControl() structure.<br />

Example 9−13. The XKeyboardControl() structure<br />

typedef struct {<br />

int key_click_percent;<br />

int bell_percent;<br />

int bell_pitch;<br />

int bell_duration;<br />

int led;<br />

int led_mode; /* LedModeOn or LedModeOff */<br />

int key;<br />

int auto_repeat_mode; /* AutoRepeatModeOff, AutoRepeatModeOn,<br />

* AutoRepeatModeDefault */<br />

} XKeyboardControl;<br />

The following list describes each member of the XKeyboardControl() structure:<br />

• key_click_percent sets the volume for key clicks between 0 (off) and 100 (loud), inclusive.<br />

• bell_percent sets the base volume for the bell (or beep) between 0 (off) and 100 (loud), inclusive.<br />

• bell_pitch sets the pitch (specified in Hz) of the bell.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!