1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at [email protected].
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \page qt-embedded-architecture.html
|
---|
30 |
|
---|
31 | \title Qt for Embedded Linux Architecture
|
---|
32 | \ingroup qt-embedded-linux
|
---|
33 |
|
---|
34 | A \l{Qt for Embedded Linux} application requires a server
|
---|
35 | application to be running, or to be the server application itself.
|
---|
36 | Any \l{Qt for Embedded Linux} application can act as the server.
|
---|
37 | When more than one application is running, the subsequent
|
---|
38 | applications connect to the existing server application as clients.
|
---|
39 |
|
---|
40 | The server and client processes have different responsibilities:
|
---|
41 | The server process manages pointer handling, character input, and
|
---|
42 | screen output. In addition, the server controls the appearance of
|
---|
43 | the screen cursor and the screen saver. The client process
|
---|
44 | performs all application specific operations.
|
---|
45 |
|
---|
46 | The server application is represented by an instance of the
|
---|
47 | QWSServer class, while the client applications are represented by
|
---|
48 | instances of the QWSClient class. On each side, there are several
|
---|
49 | classes performing the various operations.
|
---|
50 |
|
---|
51 | \image qt-embedded-architecture2.png
|
---|
52 |
|
---|
53 | All system generated events, including keyboard and mouse events,
|
---|
54 | are passed to the server application which then propagates the
|
---|
55 | event to the appropriate client.
|
---|
56 |
|
---|
57 | When rendering, the default behavior is for each client to render
|
---|
58 | its widgets into memory while the server is responsible for
|
---|
59 | putting the contents of the memory onto the screen. But when the
|
---|
60 | hardware is known and well defined, as is often the case with
|
---|
61 | software for embedded devices, it may be useful for the clients to
|
---|
62 | manipulate and control the underlying hardware directly.
|
---|
63 | \l{Qt for Embedded Linux} provides two different approaches to
|
---|
64 | achieve this behavior, see the graphics rendering section below for
|
---|
65 | details.
|
---|
66 |
|
---|
67 | \tableofcontents
|
---|
68 |
|
---|
69 | \section1 Client/Server Communication
|
---|
70 |
|
---|
71 | The running applications continuously alter the appearance of the
|
---|
72 | screen by adding and removing widgets. The server maintains
|
---|
73 | information about each top-level window in a corresponding
|
---|
74 | QWSWindow object.
|
---|
75 |
|
---|
76 | Whenever the server receives an event, it queries its stack of
|
---|
77 | top-level windows to find the window containing the event's
|
---|
78 | position. Each window can identify the client application that
|
---|
79 | created it, and returns its ID to the server upon
|
---|
80 | request. Finally, the server forwards the event, encapsulated by
|
---|
81 | an instance of the QWSEvent class, to the appropriate client.
|
---|
82 |
|
---|
83 | \image qt-embedded-clientservercommunication.png
|
---|
84 |
|
---|
85 | If an input method is installed, it is used as a filter between
|
---|
86 | the server and the client application. Derive from the
|
---|
87 | QWSInputMethod class to implement custom input methods, and use
|
---|
88 | the server's \l {QWSServer::}{setCurrentInputMethod()} function to
|
---|
89 | install it. In addition, it is possible to implement global,
|
---|
90 | low-level filters on key events using the
|
---|
91 | QWSServer::KeyboardFilter class; this can be used to implement
|
---|
92 | things like advanced power management suspended from a button
|
---|
93 | without having to filter for it in all applications.
|
---|
94 |
|
---|
95 | \table 100%
|
---|
96 | \header \o UNIX Domain Socket
|
---|
97 | \row
|
---|
98 | \o
|
---|
99 |
|
---|
100 | \image qt-embedded-client.png
|
---|
101 |
|
---|
102 | The server communicates with the client applications over the UNIX
|
---|
103 | domain socket. You can retrieve direct access to all the events a
|
---|
104 | client receives from the server, by reimplementing QApplication's
|
---|
105 | \l {QApplication::}{qwsEventFilter()} function.
|
---|
106 |
|
---|
107 | \endtable
|
---|
108 |
|
---|
109 | The clients (and the server) communicate with each other using the
|
---|
110 | QCopChannel class. QCOP is a many-to-many communication protocol
|
---|
111 | for transferring messages on various channels. A channel is
|
---|
112 | identified by a name, and anyone who wants to can listen to
|
---|
113 | it. The QCOP protocol allows clients to communicate both within
|
---|
114 | the same address space and between different processes.
|
---|
115 |
|
---|
116 | \section1 Pointer Handling Layer
|
---|
117 |
|
---|
118 | \list
|
---|
119 | \o QWSMouseHandler
|
---|
120 | \o QMouseDriverPlugin
|
---|
121 | \o QMouseDriverFactory
|
---|
122 | \endlist
|
---|
123 |
|
---|
124 | The mouse driver (represented by an instance of the
|
---|
125 | QWSMouseHandler class) is loaded by the server application when it
|
---|
126 | starts running, using Qt's \l {How to Create Qt Plugins}{plugin
|
---|
127 | system}.
|
---|
128 |
|
---|
129 | \image qt-embedded-pointerhandlinglayer.png
|
---|
130 |
|
---|
131 | A mouse driver receives mouse events from the device and
|
---|
132 | encapsulates each event with an instance of the QWSEvent class
|
---|
133 | which it then passes to the server.
|
---|
134 |
|
---|
135 | \l{Qt for Embedded Linux} provides ready-made drivers for several mouse
|
---|
136 | protocols, see the \l{Qt for Embedded Linux Pointer Handling}{pointer
|
---|
137 | handling} documentation for details. Custom mouse drivers can be
|
---|
138 | implemented by subclassing the QWSMouseHandler class and creating
|
---|
139 | a mouse driver plugin. The default implementation of the
|
---|
140 | QMouseDriverFactory class will automatically detect the plugin,
|
---|
141 | loading the driver into the server application at runtime.
|
---|
142 |
|
---|
143 | In addition to the generic mouse handler, \l{Qt for Embedded Linux}
|
---|
144 | provides a calibrated mouse handler. Use the
|
---|
145 | QWSCalibratedMouseHandler class as the base class when the system
|
---|
146 | device does not have a fixed mapping between device and screen
|
---|
147 | coordinates and/or produces noisy events, e.g. a touchscreen.
|
---|
148 |
|
---|
149 | See also: \l{Qt for Embedded Linux Pointer Handling} and
|
---|
150 | \l{How to Create Qt Plugins}.
|
---|
151 |
|
---|
152 | \section1 Character Input Layer
|
---|
153 |
|
---|
154 | \list
|
---|
155 | \o QWSKeyboardHandler
|
---|
156 | \o QKbdDriverPlugin
|
---|
157 | \o QKbdDriverFactory
|
---|
158 | \endlist
|
---|
159 |
|
---|
160 | The keyboard driver (represented by an instance of the
|
---|
161 | QWSKeyboardHandler class) is loaded by the server application when
|
---|
162 | it starts running, using Qt's \l {How to Create Qt Plugins}{plugin
|
---|
163 | system}.
|
---|
164 |
|
---|
165 | \image qt-embedded-characterinputlayer.png
|
---|
166 |
|
---|
167 | A keyboard driver receives keyboard events from the device and
|
---|
168 | encapsulates each event with an instance of the QWSEvent class
|
---|
169 | which it then passes to the server.
|
---|
170 |
|
---|
171 | \l{Qt for Embedded Linux} provides ready-made drivers for several keyboard
|
---|
172 | protocols, see the \l {Qt for Embedded Linux Character Input}{character
|
---|
173 | input} documentation for details. Custom keyboard drivers can be
|
---|
174 | implemented by subclassing the QWSKeyboardHandler class and
|
---|
175 | creating a keyboard driver plugin. The default implementation of the
|
---|
176 | QKbdDriverFactory class will automatically detect the plugin, loading the
|
---|
177 | driver into the server application at run-time.
|
---|
178 |
|
---|
179 | See also: \l{Qt for Embedded Linux Character Input} and \l {How to Create
|
---|
180 | Qt Plugins}.
|
---|
181 |
|
---|
182 | \section1 Graphics Rendering
|
---|
183 |
|
---|
184 | \list
|
---|
185 | \o QApplication
|
---|
186 | \o QDecoration
|
---|
187 | \o QDecorationPlugin
|
---|
188 | \o QDecorationFactory
|
---|
189 | \endlist
|
---|
190 |
|
---|
191 | The default behavior is for each client to render its widgets as well
|
---|
192 | as its decorations into memory, while the server copies the memory content
|
---|
193 | to the device's framebuffer.
|
---|
194 |
|
---|
195 | Whenever a client receives an event that alters any of its
|
---|
196 | widgets, the application updates the relevant parts of its memory
|
---|
197 | buffer:
|
---|
198 |
|
---|
199 | \image qt-embedded-clientrendering.png
|
---|
200 |
|
---|
201 | The decoration is loaded by the client application when it starts
|
---|
202 | running (using Qt's \l {How to Create Qt Plugins}{plugin system}),
|
---|
203 | and can be customized by deriving from the QDecoration class and
|
---|
204 | creating a decoration plugin. The default implementation of
|
---|
205 | the QDecorationFactory class will automatically detect the plugin,
|
---|
206 | loading the decoration into the application at runtime. Call the
|
---|
207 | QApplication::qwsSetDecoration() function to actually apply the
|
---|
208 | given decoration to an application.
|
---|
209 |
|
---|
210 | \table 100%
|
---|
211 | \header \o Direct Painting \target Direct Painting
|
---|
212 | \row
|
---|
|
---|