Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qeventdispatcher_win_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QEVENTDISPATCHER_WIN_P_H
5#define QEVENTDISPATCHER_WIN_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "QtCore/qabstracteventdispatcher.h"
19#include "QtCore/qt_windows.h"
20#include "QtCore/qhash.h"
21#include "QtCore/qatomic.h"
22
24
26
27class QEventDispatcherWin32Private;
28
29// forward declaration
30LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
31
32class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcherV2
33{
34 Q_OBJECT
35 Q_DECLARE_PRIVATE(QEventDispatcherWin32)
36
37public:
38 explicit QEventDispatcherWin32(QObject *parent = nullptr);
39 ~QEventDispatcherWin32();
40
41 bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) override;
42
43 void registerSocketNotifier(QSocketNotifier *notifier) override;
44 void unregisterSocketNotifier(QSocketNotifier *notifier) override;
45
46 void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType,
47 QObject *object) final;
48 bool unregisterTimer(Qt::TimerId timerId) final;
49 bool unregisterTimers(QObject *object) final;
50 QList<TimerInfoV2> timersForObject(QObject *object) const final;
51 Duration remainingTime(Qt::TimerId timerId) const final;
52
53 void wakeUp() override;
54 void interrupt() override;
55
56 void startingUp() override;
57 void closingDown() override;
58
59 bool event(QEvent *e) override;
60
61 HWND internalHwnd();
62
63protected:
64 QEventDispatcherWin32(QEventDispatcherWin32Private &dd, QObject *parent = nullptr);
65 virtual void sendPostedEvents();
66 void doUnregisterSocketNotifier(QSocketNotifier *notifier);
67
68private:
69 friend LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
70};
71
77
78struct QSockFd {
79 long event;
80 long mask;
82
83 explicit inline QSockFd(long ev = 0, long ma = 0) : event(ev), mask(ma), selected(false) { }
84};
86
87struct WinTimerInfo { // internal timer info
88 qint64 interval; // - in milliseconds
89 quint64 timeout; // - when to actually fire
91 QObject *obj; // - object to receive events
98};
99
101{
102public:
103 explicit inline QZeroTimerEvent(int timerId)
105 { t = QEvent::ZeroTimerEvent; }
106};
107
108typedef QHash<int, WinTimerInfo*> WinTimerDict; // fast dict of timers
109
110class Q_CORE_EXPORT QEventDispatcherWin32Private : public QAbstractEventDispatcherPrivate
111{
112 Q_DECLARE_PUBLIC(QEventDispatcherWin32)
113public:
114 QEventDispatcherWin32Private();
115 ~QEventDispatcherWin32Private();
116
117 QAtomicInt interrupt;
118
119 // internal window handle used for socketnotifiers/timers/etc
120 HWND internalHwnd;
121
122 // for controlling when to send posted events
123 UINT_PTR sendPostedEventsTimerId;
124 QAtomicInt wakeUps;
125 void startPostedEventsTimer();
126
127 // timers
128 WinTimerDict timerDict;
129 void registerTimer(WinTimerInfo *t);
130 void unregisterTimer(WinTimerInfo *t);
131 void sendTimerEvent(int timerId);
132
133 // socket notifiers
134 QSNDict sn_read;
135 QSNDict sn_write;
136 QSNDict sn_except;
137 QSFDict active_fd;
138 bool activateNotifiersPosted;
139 void postActivateSocketNotifiers();
140 void doWsaAsyncSelect(qintptr socket, long event);
141
142 bool closingDown = false;
143
144 QList<MSG> queuedUserInputEvents;
145 QList<MSG> queuedSocketEvents;
146};
147
148QT_END_NAMESPACE
149
150#endif // QEVENTDISPATCHER_WIN_P_H
static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher)
static quint64 qt_msectime()
#define TIME_KILL_SYNCHRONOUS
#define WM_GESTURE
@ SendPostedEventsTimerId
#define WM_GESTURENOTIFY
#define DWORD_PTR
@ WM_QT_ACTIVATENOTIFIERS
@ WM_QT_SOCKETNOTIFIER
@ WM_QT_SENDPOSTEDEVENTS
#define WM_TOUCH
static bool isUserInputMessage(UINT message)
static ULONG calculateNextTimeout(WinTimerInfo *t, quint64 currentTime)
QHash< qintptr, QSockFd > QSFDict
QHash< int, WinTimerInfo * > WinTimerDict
QHash< qintptr, QSockNot * > QSNDict
QSockFd(long ev=0, long ma=0)
QSocketNotifier * obj
Qt::TimerType timerType