CustomFrame: Same some cpu cycles in case we don't care about the events

This commit is contained in:
Sergio Martins
2021-02-18 18:20:42 +00:00
parent 4c0f3bd7cb
commit 1afcf21529
2 changed files with 21 additions and 1 deletions

View File

@@ -534,6 +534,22 @@ void WidgetResizeHandler::setupWindow(QWindow *window)
#endif // Q_OS_WIN
}
bool WidgetResizeHandler::isInterestingNativeEvent(int nativeEvent)
{
#ifdef Q_OS_WIN
switch(nativeEvent) {
case WM_NCHITTEST:
case WM_NCCALCSIZE:
case WM_NCLBUTTONDBLCLK:
case WM_GETMINMAXINFO:
return true;
default:
return false;
}
#endif
return false;
}
#if defined(Q_OS_WIN) && defined(KDDOCKWIDGETS_QTWIDGETS)
bool NCHITTESTEventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
Qt5Qt6Compat::qintptr *result)
@@ -601,6 +617,10 @@ bool CustomFrameHelper::nativeEventFilter(const QByteArray &eventType, void *mes
return false;
auto msg = static_cast<MSG *>(message);
if (!WidgetResizeHandler::isInterestingNativeEvent(msg->message)) {
// Save some CPU cycles
return false;
}
QWindow *window = QWindow::fromWinId(WId(msg->hwnd));
if (!window)

View File

@@ -122,7 +122,7 @@ public:
static int widgetResizeHandlerMargin();
static void setupWindow(QWindow *window);
static bool isInterestingNativeEvent(int);
#ifdef Q_OS_WIN
static bool handleWindowsNativeEvent(QWindow *w, MSG *msg, Qt5Qt6Compat::qintptr *result, const NativeFeatures & = {});
static bool handleWindowsNativeEvent(FloatingWindow *w, const QByteArray &eventType,