Guard against the event.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-10-18 13:23:59 +08:00
parent f38b86e992
commit ae92a00628
1 changed files with 20 additions and 18 deletions

View File

@ -187,25 +187,27 @@ bool Widget::nativeEvent(const QByteArray &eventType, void *message, long *resul
Q_ASSERT(eventType == "windows_generic_MSG");
Q_ASSERT(message);
Q_ASSERT(result);
const auto msg = static_cast<LPMSG>(message);
const auto getCursorPosition = [](const LPARAM lParam) -> QPoint {
return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
};
switch (msg->message) {
case WM_NCRBUTTONUP: {
const QPoint pos = getCursorPosition(msg->lParam);
qDebug() << "WM_NCRBUTTONUP -->" << pos;
if (WinNativeEventFilter::displaySystemMenu(msg->hwnd, false, pos.x(), pos.y())) {
*result = 0;
return true;
if (ui->customizeTitleBarCB->isChecked()) {
const auto msg = static_cast<LPMSG>(message);
const auto getCursorPosition = [](const LPARAM lParam) -> QPoint {
return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
};
switch (msg->message) {
case WM_NCRBUTTONUP: {
const QPoint pos = getCursorPosition(msg->lParam);
qDebug() << "WM_NCRBUTTONUP -->" << pos;
if (WinNativeEventFilter::displaySystemMenu(msg->hwnd, false, pos.x(), pos.y())) {
*result = 0;
return true;
}
break;
}
case WM_RBUTTONUP:
qDebug() << "WM_RBUTTONUP -->" << getCursorPosition(msg->lParam);
break;
default:
break;
}
break;
}
case WM_RBUTTONUP:
qDebug() << "WM_RBUTTONUP -->" << getCursorPosition(msg->lParam);
break;
default:
break;
}
return QWidget::nativeEvent(eventType, message, result);
}