Qt中为WindowSystemEvent事件定义了处理函数Handler,通过宏定义和模版来声明定义
---- QT_DEFINE_QPA_EVENT_HANDLER Matches (25 in 1 files) ----
qwindowsysteminterface.cpp (gui\kernel) line 199 : #define QT_DEFINE_QPA_EVENT_HANDLER(ReturnType, HandlerName, ...) \
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleEnterEvent, QWindow *window, const QPointF &local, const QPointF &global)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleLeaveEvent, QWindow *window)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleFocusWindowChanged, QWindow *window, Qt::FocusReason r)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowStates newState, int oldState)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowScreenChanged, QWindow *window, QScreen *screen)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowDevicePixelRatioChanged, QWindow *window)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleSafeAreaMarginsChanged, QWindow *window)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleApplicationStateChanged, Qt::ApplicationState newState, bool forcePropagate)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleApplicationTermination)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleGeometryChange, QWindow *window, const QRect &newRect)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleExposeEvent, QWindow *window, const QRegion ®ion)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handlePaintEvent, QWindow *window, const QRegion ®ion)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleCloseEvent, QWindow *window)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, const QPointingDevice *device,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong timestamp,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *window, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchEvent, QWindow *window, const QPointingDevice *device,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, const QPointingDevice *device,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
QT_DEFINE_QPA_EVENT_HANDLER in qwindowsysteminterface.cpp (gui\kernel) : QT_DEFINE_QPA_EVENT_HANDLER(void, handleThemeChange, QWindow *window)
以MouseEvent为例:
template<>
template<typename EventType, typename ...Args>
bool QWindowSystemHelper<QWindowSystemInterface::AsynchronousDelivery>::handleEvent(Args ...args)
{
QWindowSystemInterfacePrivate::windowSystemEventQueue.append(new EventType(args...));
if (QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher())
dispatcher->wakeUp();
return true;
}
template <typename EventType, typename Delivery = QWindowSystemInterface::DefaultDelivery, typename ...Args>
static bool handleWindowSystemEvent(Args ...args)
{
return QWindowSystemHelper<Delivery>::template handleEvent<EventType>(args...);
}
#define QT_DEFINE_QPA_EVENT_HANDLER(ReturnType, HandlerName, ...) \
template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::DefaultDelivery>(__VA_ARGS__); \
template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::SynchronousDelivery>(__VA_ARGS__); \
template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::AsynchronousDelivery>(__VA_ARGS__); \
template<typename Delivery> ReturnType QWindowSystemInterface::HandlerName(__VA_ARGS__)
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window,
const QPointF &local, const QPointF &global, Qt::MouseButtons state,
Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
Qt::MouseEventSource source)
{
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
return handleMouseEvent<Delivery>(window, time, local, global, state, button, type, mods, source);
}
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, const QPointingDevice *device,
const QPointF &local, const QPointF &global, Qt::MouseButtons state,
Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
Qt::MouseEventSource source)
{
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
return handleMouseEvent<Delivery>(window, time, device, local, global, state, button, type, mods, source);
}
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong timestamp,
const QPointF &local, const QPointF &global, Qt::MouseButtons state,
Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
Qt::MouseEventSource source)
{
return handleMouseEvent<Delivery>(window, timestamp, QPointingDevice::primaryPointingDevice(),
local, global, state, button, type, mods, source);
}
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
const QPointF &local, const QPointF &global, Qt::MouseButtons state,
Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
Qt::MouseEventSource source)
{
bool isNonClientArea = {};
switch (type) {
case QEvent::MouseButtonDblClick:
case QEvent::NonClientAreaMouseButtonDblClick:
Q_ASSERT_X(false, "QWindowSystemInterface::handleMouseEvent",
"QTBUG-71263: Native double clicks are not implemented.");
return false;
case QEvent::MouseMove:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
isNonClientArea = false;
break;
case QEvent::NonClientAreaMouseMove:
case QEvent::NonClientAreaMouseButtonPress:
case QEvent::NonClientAreaMouseButtonRelease:
isNonClientArea = true;
break;
default:
Q_UNREACHABLE();
}
auto localPos = QHighDpi::fromNativeLocalPosition(local, window);
auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window);
return handleWindowSystemEvent<QWindowSystemInterfacePrivate::MouseEvent, Delivery>(window,
timestamp, localPos, globalPos, state, mods, button, type, source, isNonClientArea, device);
}
标签:WindowSystemEvent,QT,QPA,window,HANDLER,EVENT,DEFINE
From: https://www.cnblogs.com/DesertCactus/p/18433446