1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file. Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QWSEVENT_QWS_H
43 #define QWSEVENT_QWS_H
44
45 #include <QtGui/qwsutils_qws.h>
46 #include <QtGui/qwsprotocolitem_qws.h>
47 #include <QtCore/qrect.h>
48 #include <QtGui/qregion.h>
49 #include <QtCore/qvector.h>
50
51 QT_BEGIN_HEADER
52
53 QT_BEGIN_NAMESPACE
54
QT_MODULE(Gui)55 QT_MODULE(Gui)
56
57 struct QWSMouseEvent;
58
59 struct QWSEvent : QWSProtocolItem {
60
61 QWSEvent(int t, int len, char *ptr) : QWSProtocolItem(t,len,ptr) {}
62
63
64
65 enum Type {
66 NoEvent,
67 Connected,
68 Mouse,
69 Focus,
70 Key,
71 Region,
72 Creation,
73 PropertyNotify,
74 PropertyReply,
75 SelectionClear,
76 SelectionRequest,
77 SelectionNotify,
78 MaxWindowRect,
79 QCopMessage,
80 WindowOperation,
81 IMEvent,
82 IMQuery,
83 IMInit,
84 Embed,
85 Font,
86 ScreenTransformation,
87 NEvent
88 };
89
90 QWSMouseEvent *asMouse()
91 { return type == Mouse ? reinterpret_cast<QWSMouseEvent*>(this) : 0; }
92 int window() { return *(reinterpret_cast<int*>(simpleDataPtr)); }
93 int window() const { return *(reinterpret_cast<int*>(simpleDataPtr)); }
94 static QWSEvent *factory(int type);
95 };
96
97
98 //All events must start with windowID
99
100 struct QWSConnectedEvent : QWSEvent {
QWSConnectedEventQWSConnectedEvent101 QWSConnectedEvent()
102 : QWSEvent(QWSEvent::Connected, sizeof(simpleData),
103 reinterpret_cast<char*>(&simpleData)) {}
104
105 void setData(const char *d, int len, bool allocateMem = true) {
106 QWSEvent::setData(d, len, allocateMem);
107 display = reinterpret_cast<char*>(rawDataPtr);
108 }
109
110 struct SimpleData {
111 int window;
112 int len;
113 int clientId;
114 int servershmid;
115 } simpleData;
116
117 char *display;
118 };
119
120 struct QWSMaxWindowRectEvent : QWSEvent {
QWSMaxWindowRectEventQWSMaxWindowRectEvent121 QWSMaxWindowRectEvent()
122 : QWSEvent(MaxWindowRect, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }
123 struct SimpleData {
124 int window;
125 QRect rect;
126 } simpleData;
127 };
128
129 struct QWSMouseEvent : QWSEvent {
QWSMouseEventQWSMouseEvent130 QWSMouseEvent()
131 : QWSEvent(QWSEvent::Mouse, sizeof(simpleData),
132 reinterpret_cast<char*>(&simpleData)) {}
133 struct SimpleData {
134 int window;
135 int x_root, y_root, state, delta;
136 int time; // milliseconds
137 } simpleData;
138 };
139
140 struct QWSFocusEvent : QWSEvent {
QWSFocusEventQWSFocusEvent141 QWSFocusEvent()
142 : QWSEvent(QWSEvent::Focus, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
143 { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
144 struct SimpleData {
145 int window;
146 uint get_focus:1;
147 } simpleData;
148 };
149
150 struct QWSKeyEvent: QWSEvent {
QWSKeyEventQWSKeyEvent151 QWSKeyEvent()
152 : QWSEvent(QWSEvent::Key, sizeof(simpleData),
153 reinterpret_cast<char*>(&simpleData)) {}
154 struct SimpleData {
155 int window;
156 uint keycode;
157 Qt::KeyboardModifiers modifiers;
158 ushort unicode;
159 uint is_press:1;
160 uint is_auto_repeat:1;
161 } simpleData;
162 };
163
164
165 struct QWSCreationEvent : QWSEvent {
QWSCreationEventQWSCreationEvent166 QWSCreationEvent()
167 : QWSEvent(QWSEvent::Creation, sizeof(simpleData),
168 reinterpret_cast<char*>(&simpleData)) {}
169 struct SimpleData {
170 int objectid;
171 int count;
172 } simpleData;
173 };
174
175 #ifndef QT_NO_QWS_PROPERTIES
176 struct QWSPropertyNotifyEvent : QWSEvent {
QWSPropertyNotifyEventQWSPropertyNotifyEvent177 QWSPropertyNotifyEvent()
178 : QWSEvent(QWSEvent::PropertyNotify, sizeof(simpleData),
179 reinterpret_cast<char*>(&simpleData)) {}
180 enum State {
181 PropertyNewValue,
182 PropertyDeleted
183 };
184 struct SimpleData {
185 int window;
186 int property;
187 int state;
188 } simpleData;
189 };
190 #endif
191
192 struct QWSSelectionClearEvent : QWSEvent {
QWSSelectionClearEventQWSSelectionClearEvent193 QWSSelectionClearEvent()
194 : QWSEvent(QWSEvent::SelectionClear, sizeof(simpleData),
195 reinterpret_cast<char*>(&simpleData)) {}
196 struct SimpleData {
197 int window;
198 } simpleData;
199 };
200
201 struct QWSSelectionRequestEvent : QWSEvent {
QWSSelectionRequestEventQWSSelectionRequestEvent202 QWSSelectionRequestEvent()
203 : QWSEvent(QWSEvent::SelectionRequest, sizeof(simpleData),
204 reinterpret_cast<char*>(&simpleData)) {}
205 struct SimpleData {
206 int window;
207 int requestor; // window which wants the selection
208 int property; // property on requestor into which the selection should be stored, normally QWSProperty::PropSelection
209 int mimeTypes; // Value is stored in the property mimeType on the requestor window. This value may contain
210 // multiple mimeTypes separated by ;; where the order reflects the priority
211 } simpleData;
212 };
213
214 struct QWSSelectionNotifyEvent : QWSEvent {
QWSSelectionNotifyEventQWSSelectionNotifyEvent215 QWSSelectionNotifyEvent()
216 : QWSEvent(QWSEvent::SelectionNotify, sizeof(simpleData),
217 reinterpret_cast<char*>(&simpleData)) {}
218 struct SimpleData {
219 int window;
220 int requestor; // the window which wanted the selection and to which this event is sent
221 int property; // property of requestor in which the data of the selection is stored
222 int mimeType; // a property on the requestor in which the mime type in which the selection is, is stored
223 } simpleData;
224 };
225
226 //complex events:
227
228 struct QWSRegionEvent : QWSEvent {
QWSRegionEventQWSRegionEvent229 QWSRegionEvent()
230 : QWSEvent(QWSEvent::Region, sizeof(simpleData),
231 reinterpret_cast<char*>(&simpleData))
232 { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
233
234 void setData(const char *d, int len, bool allocateMem = true) {
235 QWSEvent::setData(d, len, allocateMem);
236 rectangles = reinterpret_cast<QRect*>(rawDataPtr);
237 }
238
setDataQWSRegionEvent239 void setData(int winId, const QRegion ®ion, uint type) {
240 const QVector<QRect> rects = region.rects();
241 setData(reinterpret_cast<const char*>(rects.constData()),
242 rects.size() * sizeof(QRect));
243 simpleData.window = winId;
244 simpleData.nrectangles = rects.size();
245 simpleData.type = type;
246 #ifdef QT_QWS_CLIENTBLIT
247 simpleData.id = 0;
248 #endif
249 }
250
251 enum Type {Allocation
252 #ifdef QT_QWS_CLIENTBLIT
253 , DirectPaint
254 #endif
255 };
256 struct SimpleData {
257 int window;
258 int nrectangles;
259 #ifdef QT_QWS_CLIENTBLIT
260 int id;
261 #endif
262 uint type:8;
263 } simpleData;
264
265 QRect *rectangles;
266 };
267
268 #ifndef QT_NO_QWSEMBEDWIDGET
269 struct QWSEmbedEvent : QWSEvent
270 {
QWSEmbedEventQWSEmbedEvent271 QWSEmbedEvent() : QWSEvent(QWSEvent::Embed, sizeof(simpleData),
272 reinterpret_cast<char*>(&simpleData))
273 {}
274
275 enum Type { StartEmbed = 1, StopEmbed = 2, Region = 4 };
276
277 void setData(const char *d, int len, bool allocateMem = true) {
278 QWSEvent::setData(d, len, allocateMem);
279 region.setRects(reinterpret_cast<const QRect *>(rawDataPtr),
280 simpleData.nrectangles);
281 }
282
283 void setData(int winId, Type type, const QRegion ® = QRegion()) {
284 simpleData.window = winId;
285 simpleData.nrectangles = reg.rects().size();
286 simpleData.type = type;
287 region = reg;
288 const QVector<QRect> rects = reg.rects();
289 QWSEvent::setData(reinterpret_cast<const char*>(rects.data()),
290 rects.size() * sizeof(QRect));
291 }
292
293 struct SimpleData {
294 int window;
295 int nrectangles;
296 Type type;
297 } simpleData;
298
299 QRegion region;
300 };
301 #endif // QT_NO_QWSEMBEDWIDGET
302
303 #ifndef QT_NO_QWS_PROPERTIES
304 struct QWSPropertyReplyEvent : QWSEvent {
QWSPropertyReplyEventQWSPropertyReplyEvent305 QWSPropertyReplyEvent()
306 : QWSEvent(QWSEvent::PropertyReply, sizeof(simpleData),
307 reinterpret_cast<char*>(&simpleData)) {}
308
309 void setData(const char *d, int len, bool allocateMem = true) {
310 QWSEvent::setData(d, len, allocateMem);
311 data = reinterpret_cast<char*>(rawDataPtr);
312 }
313
314 struct SimpleData {
315 int window;
316 int property;
317 int len;
318 } simpleData;
319 char *data;
320 };
321 #endif //QT_NO_QWS_PROPERTIES
322
323 #ifndef QT_NO_COP
324 struct QWSQCopMessageEvent : QWSEvent {
QWSQCopMessageEventQWSQCopMessageEvent325 QWSQCopMessageEvent()
326 : QWSEvent(QWSEvent::QCopMessage, sizeof(simpleData),
327 reinterpret_cast<char*>(&simpleData))
328 { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
329
330 void setData(const char *d, int len, bool allocateMem = true) {
331 QWSEvent::setData(d, len, allocateMem);
332 char* p = rawDataPtr;
333 channel = QByteArray(p, simpleData.lchannel);
334 p += simpleData.lchannel;
335 message = QByteArray(p, simpleData.lmessage);
336 p += simpleData.lmessage;
337 data = QByteArray(p, simpleData.ldata);
338 }
339
setDataDirectQWSQCopMessageEvent340 void setDataDirect(const char *d, int len) {
341 QWSEvent::setData(d, len, false);
342 deleteRaw = true;
343 }
344
345 struct SimpleData {
346 bool is_response;
347 int lchannel;
348 int lmessage;
349 int ldata;
350 } simpleData;
351
352 QByteArray channel;
353 QByteArray message;
354 QByteArray data;
355 };
356
357 #endif
358
359 struct QWSWindowOperationEvent : QWSEvent {
QWSWindowOperationEventQWSWindowOperationEvent360 QWSWindowOperationEvent()
361 : QWSEvent(WindowOperation, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }
362
363 enum Operation { Show, Hide, ShowMaximized, ShowNormal, ShowMinimized, Close };
364 struct SimpleData {
365 int window;
366 Operation op;
367 } simpleData;
368 };
369
370 #ifndef QT_NO_QWS_INPUTMETHODS
371
372
373 struct QWSIMEvent : QWSEvent {
QWSIMEventQWSIMEvent374 QWSIMEvent()
375 : QWSEvent(IMEvent, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
376 { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
377
378 struct SimpleData {
379 int window;
380 int replaceFrom;
381 int replaceLength;
382 } simpleData;
383
384 void setData(const char *d, int len, bool allocateMem = true) {
385 QWSEvent::setData(d, len, allocateMem);
386 streamingData = QByteArray::fromRawData(rawDataPtr, len);
387 }
388 QByteArray streamingData;
389 };
390
391
392 struct QWSIMInitEvent : QWSEvent {
QWSIMInitEventQWSIMInitEvent393 QWSIMInitEvent()
394 : QWSEvent(IMInit, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
395 { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
396
397 struct SimpleData {
398 int window;
399 int existence;
400 } simpleData;
401
402 void setData(const char *d, int len, bool allocateMem = true) {
403 QWSEvent::setData(d, len, allocateMem);
404 streamingData = QByteArray::fromRawData(rawDataPtr, len);
405 }
406 QByteArray streamingData;
407 };
408
409
410 struct QWSIMQueryEvent : QWSEvent {
QWSIMQueryEventQWSIMQueryEvent411 QWSIMQueryEvent()
412 : QWSEvent(QWSEvent::IMQuery, sizeof(simpleData),
413 reinterpret_cast<char*>(&simpleData)) {}
414
415 struct SimpleData {
416 int window;
417 int property;
418 } simpleData;
419
420 };
421
422 #endif
423
424 struct QWSFontEvent : QWSEvent {
QWSFontEventQWSFontEvent425 QWSFontEvent()
426 : QWSEvent(QWSEvent::Font, sizeof(simpleData),
427 reinterpret_cast<char*>(&simpleData)) {}
428
429 enum EventType {
430 FontRemoved
431 };
432
433 void setData(const char *d, int len, bool allocateMem = true) {
434 QWSEvent::setData(d, len, allocateMem);
435 fontName = QByteArray::fromRawData(rawDataPtr, len);
436 }
437
438 struct SimpleData {
439 uchar type;
440 } simpleData;
441 QByteArray fontName;
442 };
443
444 struct QWSScreenTransformationEvent : QWSEvent {
QWSScreenTransformationEventQWSScreenTransformationEvent445 QWSScreenTransformationEvent()
446 : QWSEvent(QWSEvent::ScreenTransformation, sizeof(simpleData),
447 reinterpret_cast<char*>(&simpleData)) {}
448
449 struct SimpleData {
450 int screen;
451 int transformation;
452 } simpleData;
453 };
454
455 QT_END_NAMESPACE
456
457 QT_END_HEADER
458
459 #endif // QWSEVENT_QWS_H
460