summaryrefslogtreecommitdiffstats
path: root/src/gui/embedded/qwsevent_qws.h
blob: f439ee584300b767e78c3d7d13537d8d7a2666e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QWSEVENT_QWS_H
#define QWSEVENT_QWS_H

#include <QtGui/qwsutils_qws.h>
#include <QtGui/qwsprotocolitem_qws.h>
#include <QtCore/qrect.h>
#include <QtGui/qregion.h>
#include <QtCore/qvector.h>

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Gui)

struct QWSMouseEvent;

struct QWSEvent : QWSProtocolItem {

    QWSEvent(int t, int len, char *ptr) : QWSProtocolItem(t,len,ptr) {}



    enum Type {
        NoEvent,
        Connected,
        Mouse,
        Focus,
        Key,
        Region,
        Creation,
        PropertyNotify,
        PropertyReply,
        SelectionClear,
        SelectionRequest,
        SelectionNotify,
        MaxWindowRect,
        QCopMessage,
        WindowOperation,
        IMEvent,
        IMQuery,
        IMInit,
        Embed,
        Font,
        ScreenTransformation,
        NEvent
    };

    QWSMouseEvent *asMouse()
        { return type == Mouse ? reinterpret_cast<QWSMouseEvent*>(this) : 0; }
    int window() { return *(reinterpret_cast<int*>(simpleDataPtr)); }
    int window() const { return *(reinterpret_cast<int*>(simpleDataPtr)); }
    static QWSEvent *factory(int type);
};


//All events must start with windowID

struct QWSConnectedEvent : QWSEvent {
    QWSConnectedEvent()
        : QWSEvent(QWSEvent::Connected, sizeof(simpleData),
                reinterpret_cast<char*>(&simpleData)) {}

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        display = reinterpret_cast<char*>(rawDataPtr);
    }

    struct SimpleData {
        int window;
        int len;
        int clientId;
        int servershmid;
    } simpleData;

    char *display;
};

struct QWSMaxWindowRectEvent : QWSEvent {
    QWSMaxWindowRectEvent()
        : QWSEvent(MaxWindowRect, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }
    struct SimpleData {
        int window;
        QRect rect;
    } simpleData;
};

struct QWSMouseEvent : QWSEvent {
    QWSMouseEvent()
        : QWSEvent(QWSEvent::Mouse, sizeof(simpleData),
                reinterpret_cast<char*>(&simpleData)) {}
    struct SimpleData {
        int window;
        int x_root, y_root, state, delta;
        int time; // milliseconds
    } simpleData;
};

struct QWSFocusEvent : QWSEvent {
    QWSFocusEvent()
        : QWSEvent(QWSEvent::Focus, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
        { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
    struct SimpleData {
        int window;
        uint get_focus:1;
    } simpleData;
};

struct QWSKeyEvent: QWSEvent {
    QWSKeyEvent()
        : QWSEvent(QWSEvent::Key, sizeof(simpleData),
              reinterpret_cast<char*>(&simpleData)) {}
    struct SimpleData {
        int window;
        uint keycode;
        Qt::KeyboardModifiers modifiers;
        ushort unicode;
        uint is_press:1;
        uint is_auto_repeat:1;
    } simpleData;
};


struct QWSCreationEvent : QWSEvent {
    QWSCreationEvent()
        : QWSEvent(QWSEvent::Creation, sizeof(simpleData),
              reinterpret_cast<char*>(&simpleData)) {}
    struct SimpleData {
        int objectid;
        int count;
    } simpleData;
};

#ifndef QT_NO_QWS_PROPERTIES
struct QWSPropertyNotifyEvent : QWSEvent {
    QWSPropertyNotifyEvent()
        : QWSEvent(QWSEvent::PropertyNotify, sizeof(simpleData),
              reinterpret_cast<char*>(&simpleData)) {}
    enum State {
        PropertyNewValue,
        PropertyDeleted
    };
    struct SimpleData {
        int window;
        int property;
        int state;
    } simpleData;
};
#endif

struct QWSSelectionClearEvent : QWSEvent {
    QWSSelectionClearEvent()
        : QWSEvent(QWSEvent::SelectionClear, sizeof(simpleData),
              reinterpret_cast<char*>(&simpleData)) {}
    struct SimpleData {
        int window;
    } simpleData;
};

struct QWSSelectionRequestEvent : QWSEvent {
    QWSSelectionRequestEvent()
        : QWSEvent(QWSEvent::SelectionRequest, sizeof(simpleData),
              reinterpret_cast<char*>(&simpleData)) {}
    struct SimpleData {
        int window;
        int requestor; // window which wants the selection
        int property; // property on requestor into which the selection should be stored, normally QWSProperty::PropSelection
        int mimeTypes; // Value is stored in the property mimeType on the requestor window. This value may contain
        // multiple mimeTypes separated by ;; where the order reflects the priority
    } simpleData;
};

struct QWSSelectionNotifyEvent : QWSEvent {
    QWSSelectionNotifyEvent()
        : QWSEvent(QWSEvent::SelectionNotify, sizeof(simpleData),
              reinterpret_cast<char*>(&simpleData)) {}
    struct SimpleData {
        int window;
        int requestor; // the window which wanted the selection and to which this event is sent
        int property; // property of requestor in which the data of the selection is stored
        int mimeType; // a property on the requestor in which the mime type in which the selection is, is stored
    } simpleData;
};

//complex events:

struct QWSRegionEvent : QWSEvent {
    QWSRegionEvent()
        : QWSEvent(QWSEvent::Region, sizeof(simpleData),
                reinterpret_cast<char*>(&simpleData))
        { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        rectangles = reinterpret_cast<QRect*>(rawDataPtr);
    }

    void setData(int winId, const QRegion &region, uint type) {
        const QVector<QRect> rects = region.rects();
        setData(reinterpret_cast<const char*>(rects.constData()),
            rects.size() * sizeof(QRect));
        simpleData.window = winId;
        simpleData.nrectangles = rects.size();
        simpleData.type = type;
#ifdef QT_QWS_CLIENTBLIT
        simpleData.id = 0;
#endif
    }

    enum Type {Allocation
#ifdef QT_QWS_CLIENTBLIT
        , DirectPaint
#endif
    };
    struct SimpleData {
        int window;
        int nrectangles;
#ifdef QT_QWS_CLIENTBLIT
        int id;
#endif
        uint type:8;
    } simpleData;

    QRect *rectangles;
};

#ifndef QT_NO_QWSEMBEDWIDGET
struct QWSEmbedEvent : QWSEvent
{
    QWSEmbedEvent() : QWSEvent(QWSEvent::Embed, sizeof(simpleData),
                               reinterpret_cast<char*>(&simpleData))
    {}

    enum Type { StartEmbed = 1, StopEmbed = 2, Region = 4 };

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        region.setRects(reinterpret_cast<const QRect *>(rawDataPtr),
                        simpleData.nrectangles);
    }

    void setData(int winId, Type type, const QRegion &reg = QRegion()) {
        simpleData.window = winId;
        simpleData.nrectangles = reg.rects().size();
        simpleData.type = type;
        region = reg;
        const QVector<QRect> rects = reg.rects();
        QWSEvent::setData(reinterpret_cast<const char*>(rects.data()),
                          rects.size() * sizeof(QRect));
    }

    struct SimpleData {
        int window;
        int nrectangles;
        Type type;
    } simpleData;

    QRegion region;
};
#endif // QT_NO_QWSEMBEDWIDGET

#ifndef QT_NO_QWS_PROPERTIES
struct QWSPropertyReplyEvent : QWSEvent {
    QWSPropertyReplyEvent()
        : QWSEvent(QWSEvent::PropertyReply, sizeof(simpleData),
                reinterpret_cast<char*>(&simpleData)) {}

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        data = reinterpret_cast<char*>(rawDataPtr);
    }

    struct SimpleData {
        int window;
        int property;
        int len;
    } simpleData;
    char *data;
};
#endif //QT_NO_QWS_PROPERTIES

#ifndef QT_NO_COP
struct QWSQCopMessageEvent : QWSEvent {
    QWSQCopMessageEvent()
        : QWSEvent(QWSEvent::QCopMessage, sizeof(simpleData),
                reinterpret_cast<char*>(&simpleData))
        { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        char* p = rawDataPtr;
	channel = QByteArray(p, simpleData.lchannel);
        p += simpleData.lchannel;
        message = QByteArray(p, simpleData.lmessage);
        p += simpleData.lmessage;
        data = QByteArray(p, simpleData.ldata);
    }

    void setDataDirect(const char *d, int len) {
        QWSEvent::setData(d, len, false);
        deleteRaw = true;
    }

    struct SimpleData {
        bool is_response;
        int lchannel;
        int lmessage;
        int ldata;
    } simpleData;

    QByteArray channel;
    QByteArray message;
    QByteArray data;
};

#endif

struct QWSWindowOperationEvent : QWSEvent {
    QWSWindowOperationEvent()
        : QWSEvent(WindowOperation, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }

    enum Operation { Show, Hide, ShowMaximized, ShowNormal, ShowMinimized, Close };
    struct SimpleData {
        int window;
        Operation op;
    } simpleData;
};

#ifndef QT_NO_QWS_INPUTMETHODS


struct QWSIMEvent : QWSEvent {
    QWSIMEvent()
        : QWSEvent(IMEvent, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
   { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }

    struct SimpleData {
        int window;
        int replaceFrom;
        int replaceLength;
    } simpleData;

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        streamingData = QByteArray::fromRawData(rawDataPtr, len);
    }
    QByteArray streamingData;
};


struct QWSIMInitEvent : QWSEvent {
    QWSIMInitEvent()
        : QWSEvent(IMInit, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
   { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }

    struct SimpleData {
        int window;
        int existence;
    } simpleData;

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        streamingData = QByteArray::fromRawData(rawDataPtr, len);
    }
    QByteArray streamingData;
};


struct QWSIMQueryEvent : QWSEvent {
    QWSIMQueryEvent()
        : QWSEvent(QWSEvent::IMQuery, sizeof(simpleData),
              reinterpret_cast<char*>(&simpleData)) {}

    struct SimpleData {
        int window;
        int property;
    } simpleData;

};

#endif

struct QWSFontEvent : QWSEvent {
    QWSFontEvent()
        : QWSEvent(QWSEvent::Font, sizeof(simpleData),
                reinterpret_cast<char*>(&simpleData)) {}

    enum EventType {
        FontRemoved
    };

    void setData(const char *d, int len, bool allocateMem = true) {
        QWSEvent::setData(d, len, allocateMem);
        fontName = QByteArray::fromRawData(rawDataPtr, len);
    }

    struct SimpleData {
        uchar type;
    } simpleData;
    QByteArray fontName;
};

struct QWSScreenTransformationEvent : QWSEvent {
    QWSScreenTransformationEvent()
        : QWSEvent(QWSEvent::ScreenTransformation, sizeof(simpleData),
                   reinterpret_cast<char*>(&simpleData)) {}

    struct SimpleData {
        int screen;
        int transformation;
    } simpleData;
};

QT_END_NAMESPACE

QT_END_HEADER

#endif // QWSEVENT_QWS_H