Chinaunix首页 | 论坛 | 博客
  • 博客访问: 628545
  • 博文数量: 112
  • 博客积分: 5011
  • 博客等级: 大校
  • 技术积分: 1406
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-25 18:46
文章分类
文章存档

2011年(1)

2010年(5)

2009年(25)

2008年(81)

我的朋友

分类: LINUX

2008-05-06 21:18:00

Internally in the client/server protocol, each key press and key release is sent as a QWSKeyEvent. A QWSKeyEvent contains the following fields:

unicode Unicode value
keycode Qt keycode value as defined in
modifier A bitfield consisting of some of , , and .
is_press TRUE if this is a key press, FALSE if it is a key release.
is_auto_repeat TRUE if this event is caused by auto repeat.

When the server receives a key event it is sent to each client process which is responsible for processing the key event and sending it to the right window, if any. Key events may come from several different sources.

Keyboard drivers

A keyboard driver reads data from a device and gives key events to the server.

Keyboard drivers can be compiled into the library or loaded as plugins. Running ./configure -help lists the available keyboard drivers. The "tty" driver is enabled in the default configuration.

The keyboard drivers all follow the same pattern. They read keyboard data from a device, find out which keys were pressed, and then call the static function QWSServer::processKeyEvent() with the key information.

At present, the console keyboard driver also handles console switching (Ctrl+Alt-F1...Ctrl+Alt+F10) and termination (Ctrl+Alt+Backspace).

To add a keyboard driver for a new device, subclasses of and can be written and installed as plugins.

Key event filters (input methods)

When the server receives a key event from a keyboard driver, it first passes it through a filter.

This can be used to implement input methods, providing input of characters that are not on the keyboard.

To make an input method, subclass QWSServer::KeyboardFilter (in src/kernel/qwindowsystem_qws.h) and implement the virtual function filter(). If filter() returns FALSE, the event will be sent to the clients (using ()). If filter() returns TRUE, the event will be stopped. To generate new key events, use QWSServer::sendKeyEvent(). (Do not use processKeyEvent(), since this will lead to infinite recursion.)

To install a keyboard event filter, use (). Currently, only one filter can be installed at a time.

Filtering must be done in the server process.

The launcher example contains an example of a simple input method, SimpleIM which reads a substitution table from a file.

 原文地址
阅读(1799) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~