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// Qt-Security score:significant reason:default
4
5#ifndef QEVENTDISPATCHER_WIN_P_H
6#define QEVENTDISPATCHER_WIN_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "QtCore/qabstracteventdispatcher.h"
20#include "QtCore/qt_windows.h"
21#include "QtCore/qhash.h"
22#include "QtCore/qatomic.h"
23
25
27
28class QEventDispatcherWin32Private;
29
30// forward declaration
31LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
32
33class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcherV2
34{
35 Q_OBJECT
36 Q_DECLARE_PRIVATE(QEventDispatcherWin32)
37
38public:
39 explicit QEventDispatcherWin32(QObject *parent = nullptr);
40 ~QEventDispatcherWin32();
41
42 bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) override;
43
44 void registerSocketNotifier(QSocketNotifier *notifier) override;
45 void unregisterSocketNotifier(QSocketNotifier *notifier) override;
46
47 void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType,
48 QObject *object) final;
49 bool unregisterTimer(Qt::TimerId timerId) final;
50 bool unregisterTimers(QObject *object) final;
51 QList<TimerInfoV2> timersForObject(QObject *object) const final;
52 Duration remainingTime(Qt::TimerId timerId) const final;
53
54 void wakeUp() override;
55 void interrupt() override;
56
57 void startingUp() override;
58 void closingDown() override;
59
60 bool event(QEvent *e) override;
61
62 HWND internalHwnd();
63
64protected:
65 QEventDispatcherWin32(QEventDispatcherWin32Private &dd, QObject *parent = nullptr);
66 virtual void sendPostedEvents();
67 void doUnregisterSocketNotifier(QSocketNotifier *notifier);
68
69private:
70 friend LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
71};
72
78
79struct QSockFd {
80 long event;
81 long mask;
83
84 explicit inline QSockFd(long ev = 0, long ma = 0) : event(ev), mask(ma), selected(false) { }
85};
87
88struct WinTimerInfo { // internal timer info
89 qint64 interval; // - in milliseconds
90 quint64 timeout; // - when to actually fire
92 QObject *obj; // - object to receive events
99};
100
102{
103public:
104 explicit inline QZeroTimerEvent(int timerId)
106 { t = QEvent::ZeroTimerEvent; }
107};
108
109typedef QHash<int, WinTimerInfo*> WinTimerDict; // fast dict of timers
110
111class Q_CORE_EXPORT QEventDispatcherWin32Private : public QAbstractEventDispatcherPrivate
112{
113 Q_DECLARE_PUBLIC(QEventDispatcherWin32)
114public:
115 QEventDispatcherWin32Private();
116 ~QEventDispatcherWin32Private();
117
118 QAtomicInt interrupt;
119
120 // internal window handle used for socketnotifiers/timers/etc
121 HWND internalHwnd;
122
123 // for controlling when to send posted events
124 UINT_PTR sendPostedEventsTimerId;
125 QAtomicInt wakeUps;
126 void startPostedEventsTimer();
127
128 // timers
129 WinTimerDict timerDict;
130 void registerTimer(WinTimerInfo *t);
131 void unregisterTimer(WinTimerInfo *t);
132 void sendTimerEvent(int timerId);
133
134 // socket notifiers
135 QSNDict sn_read;
136 QSNDict sn_write;
137 QSNDict sn_except;
138 QSFDict active_fd;
139 bool activateNotifiersPosted;
140 void postActivateSocketNotifiers();
141 void doWsaAsyncSelect(qintptr socket, long event);
142
143 bool closingDown = false;
144
145 QList<MSG> queuedUserInputEvents;
146 QList<MSG> queuedSocketEvents;
147};
148
149QT_END_NAMESPACE
150
151#endif // QEVENTDISPATCHER_WIN_P_H
Combined button and popup list for selecting options.
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