| 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 QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 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
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "qwsevent_qws.h"
|
|---|
| 43 |
|
|---|
| 44 | QT_BEGIN_NAMESPACE
|
|---|
| 45 |
|
|---|
| 46 | QWSEvent *QWSEvent::factory(int type)
|
|---|
| 47 | {
|
|---|
| 48 | QWSEvent *event = 0;
|
|---|
| 49 | switch (type) {
|
|---|
| 50 | case QWSEvent::Connected:
|
|---|
| 51 | event = new QWSConnectedEvent;
|
|---|
| 52 | break;
|
|---|
| 53 | case QWSEvent::MaxWindowRect:
|
|---|
| 54 | event = new QWSMaxWindowRectEvent;
|
|---|
| 55 | break;
|
|---|
| 56 | case QWSEvent::Mouse:
|
|---|
| 57 | event = new QWSMouseEvent;
|
|---|
| 58 | break;
|
|---|
| 59 | case QWSEvent::Focus:
|
|---|
| 60 | event = new QWSFocusEvent;
|
|---|
| 61 | break;
|
|---|
| 62 | case QWSEvent::Key:
|
|---|
| 63 | event = new QWSKeyEvent;
|
|---|
| 64 | break;
|
|---|
| 65 | case QWSEvent::Region:
|
|---|
| 66 | event = new QWSRegionEvent;
|
|---|
| 67 | break;
|
|---|
| 68 | case QWSEvent::Creation:
|
|---|
| 69 | event = new QWSCreationEvent;
|
|---|
| 70 | break;
|
|---|
| 71 | #ifndef QT_NO_QWS_PROPERTIES
|
|---|
| 72 | case QWSEvent::PropertyNotify:
|
|---|
| 73 | event = new QWSPropertyNotifyEvent;
|
|---|
| 74 | break;
|
|---|
| 75 | case QWSEvent::PropertyReply:
|
|---|
| 76 | event = new QWSPropertyReplyEvent;
|
|---|
| 77 | break;
|
|---|
| 78 | #endif // QT_NO_QWS_PROPERTIES
|
|---|
| 79 | case QWSEvent::SelectionClear:
|
|---|
| 80 | event = new QWSSelectionClearEvent;
|
|---|
| 81 | break;
|
|---|
| 82 | case QWSEvent::SelectionRequest:
|
|---|
| 83 | event = new QWSSelectionRequestEvent;
|
|---|
| 84 | break;
|
|---|
| 85 | case QWSEvent::SelectionNotify:
|
|---|
| 86 | event = new QWSSelectionNotifyEvent;
|
|---|
| 87 | break;
|
|---|
| 88 | #ifndef QT_NO_COP
|
|---|
| 89 | case QWSEvent::QCopMessage:
|
|---|
| 90 | event = new QWSQCopMessageEvent;
|
|---|
| 91 | break;
|
|---|
| 92 | #endif
|
|---|
| 93 | case QWSEvent::WindowOperation:
|
|---|
| 94 | event = new QWSWindowOperationEvent;
|
|---|
| 95 | break;
|
|---|
| 96 |
|
|---|
| 97 | #ifndef QT_NO_QWS_INPUTMETHODS
|
|---|
| 98 | case QWSEvent::IMEvent:
|
|---|
| 99 | event = new QWSIMEvent;
|
|---|
| 100 | break;
|
|---|
| 101 | case QWSEvent::IMQuery:
|
|---|
| 102 | event = new QWSIMQueryEvent;
|
|---|
| 103 | break;
|
|---|
| 104 | case QWSEvent::IMInit:
|
|---|
| 105 | event = new QWSIMInitEvent;
|
|---|
| 106 | break;
|
|---|
| 107 | #endif
|
|---|
| 108 | #ifndef QT_NO_QWSEMBEDWIDGET
|
|---|
| 109 | case QWSEvent::Embed:
|
|---|
| 110 | event = new QWSEmbedEvent;
|
|---|
| 111 | break;
|
|---|
| 112 | #endif
|
|---|
| 113 | case QWSEvent::Font:
|
|---|
| 114 | event = new QWSFontEvent;
|
|---|
| 115 | break;
|
|---|
| 116 | case QWSEvent::ScreenTransformation:
|
|---|
| 117 | event = new QWSScreenTransformationEvent;
|
|---|
| 118 | break;
|
|---|
| 119 | default:
|
|---|
| 120 | qCritical("QWSEvent::factory() : Unknown event type %08x!", type);
|
|---|
| 121 | }
|
|---|
| 122 | return event;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | /*!
|
|---|
| 126 | \class QWSEvent
|
|---|
| 127 | \ingroup qws
|
|---|
| 128 |
|
|---|
| 129 | \brief The QWSEvent class encapsulates an event in Qt for Embedded Linux.
|
|---|
| 130 |
|
|---|
| 131 | When running a \l{Qt for Embedded Linux} application, it either runs as a
|
|---|
| 132 | server or connects to an existing server. All system generated
|
|---|
| 133 | events are passed to the server application which then propagates
|
|---|
| 134 | the event to the appropriate client.
|
|---|
| 135 |
|
|---|
| 136 | Whenever the server receives an event, it queries its stack of
|
|---|
| 137 | top-level windows to find the window containing the event's
|
|---|
| 138 | position. Each window can identify the client application that
|
|---|
| 139 | created it, and returns its ID to the server upon
|
|---|
| 140 | request. Finally, the server forwards the event, encapsulated by
|
|---|
| 141 | an instance of the QWSEvent class, to the appropriate client.
|
|---|
| 142 |
|
|---|
| 143 | \image qt-embedded-client.png
|
|---|
| 144 |
|
|---|
| 145 | The server communicates with the client applications over the UNIX
|
|---|
| 146 | domain socket. You can retrieve direct access to all the events a
|
|---|
| 147 | client receives from the server, by reimplementing QApplication's
|
|---|
| 148 | \l {QApplication::}{qwsEventFilter()} function.
|
|---|
| 149 |
|
|---|
| 150 | QWSEvent provides the \l Type enum specifying the origin of the
|
|---|
| 151 | event. Internally, each type is represented by a QWSEvent
|
|---|
| 152 | subclass, e.g., \c QWSKeyEvent.
|
|---|
| 153 |
|
|---|
| 154 | \sa QWSServer, QWSClient, {Qt for Embedded Linux Architecture}
|
|---|
| 155 | */
|
|---|
| 156 |
|
|---|
| 157 | /*!
|
|---|
| 158 | \enum QWSEvent::Type
|
|---|
| 159 |
|
|---|
| 160 | This enum describes the origin of the event.
|
|---|
| 161 |
|
|---|
| 162 | \value NoEvent No event has occurred.
|
|---|
| 163 | \value Connected An application has connected to the server.
|
|---|
| 164 | \value Mouse A mouse button is pressed or released, or the mouse cursor is moved.
|
|---|
| 165 | See also \l{Qt for Embedded Linux Pointer Handling}.
|
|---|
| 166 | \value Focus A window has lost or received focus.
|
|---|
| 167 | \value Key A key is pressed or released. See also \l{Qt for Embedded Linux Character Input}.
|
|---|
| 168 | \value Region A region has changed.
|
|---|
| 169 | \value Creation The server has created an ID, typically for a window.
|
|---|
| 170 | \value PropertyNotify A property has changed.
|
|---|
| 171 | \value PropertyReply The server is responding to a request for a property's value.
|
|---|
| 172 | \value SelectionClear A selection is deleted.
|
|---|
| 173 | \value SelectionRequest The server has queried for a selection.
|
|---|
| 174 | \value SelectionNotify A new selection has been created.
|
|---|
| 175 | \value MaxWindowRect The server has changed the maximum window for an application.
|
|---|
| 176 | \value QCopMessage A new Qt Cop message has appeared. See also QCopChannel
|
|---|
| 177 | \value WindowOperation A window operation, e.g. resizing, has occurred.
|
|---|
| 178 | \value IMEvent An input method has been used to enter text for languages with
|
|---|
| 179 | non-Latin alphabets. See also QWSInputMethod.
|
|---|
| 180 | \value IMQuery An input method query for a specified property has occurred.
|
|---|
| 181 | See also QWSInputMethod.
|
|---|
| 182 | \value NEvent The number of events has changed.
|
|---|
| 183 | \value Embed An event used internally to implement embedded windows. See also
|
|---|
| 184 | QWSEmbedWidget.
|
|---|
| 185 | \value ScreenTransformation An event used internally to notify the client processes
|
|---|
| 186 | that the screen has changed for example, rotation, etc.
|
|---|
| 187 | \omitvalue Font
|
|---|
| 188 | \omitvalue IMInit
|
|---|
| 189 | */
|
|---|
| 190 |
|
|---|
| 191 | /*!
|
|---|
| 192 | \fn QWSMouseEvent *QWSEvent::asMouse()
|
|---|
| 193 | \internal
|
|---|
| 194 | */
|
|---|
| 195 |
|
|---|
| 196 | /*!
|
|---|
| 197 | \fn int QWSEvent::window()
|
|---|
| 198 | \internal
|
|---|
| 199 | */
|
|---|
| 200 |
|
|---|
| 201 | /*!
|
|---|
| 202 | \fn int QWSEvent::window() const
|
|---|
| 203 | \internal
|
|---|
| 204 | */
|
|---|
| 205 |
|
|---|
| 206 | /*!
|
|---|
| 207 | \fn QWSEvent *QWSEvent::factory(int type)
|
|---|
| 208 | \internal
|
|---|
| 209 | */
|
|---|
| 210 |
|
|---|
| 211 | /*!
|
|---|
| 212 | \fn QWSEvent::QWSEvent( int t, int len, char * ptr)
|
|---|
| 213 | \internal
|
|---|
| 214 | */
|
|---|
| 215 |
|
|---|
| 216 | QT_END_NAMESPACE
|
|---|