summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qwizard_win.cpp
diff options
context:
space:
mode:
authorJonathan Liu <net147@gmail.com>2012-06-09 01:09:39 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-12 11:00:38 +0200
commit9ab445d264fbcf57c48374526905a2f870de06a3 (patch)
tree3c778caaa3da47808d8e9392acef26aaa7d7d317 /src/widgets/dialogs/qwizard_win.cpp
parent378e65c07a6371f1c4047cc721f89a40dc3d734d (diff)
QWizard/Win: Handle hit testing correctly for Vista style
Clicking the area just below the close button when Aero is enabled reveals duplicate caption buttons. DwmDefWindowProc returns hit results for DWM caption buttons but DefWindowProc may also return hit results for non-DWM caption buttons. To resolve this issue, if DefWindowProc returns a window button hit result then we just use HTCLIENT (the client area) as the hit result instead. Change-Id: Ia741ce4f9aa944109d8de54c2f84009f5ea1883f Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/widgets/dialogs/qwizard_win.cpp')
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp89
1 files changed, 50 insertions, 39 deletions
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 6c24231a88..6359ebfb09 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -378,25 +378,24 @@ void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible)
bool QVistaHelper::winEvent(MSG* msg, long* result)
{
- bool retval = true;
-
switch (msg->message) {
case WM_NCHITTEST: {
LRESULT lResult;
- pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult);
- if (lResult == HTCLOSE || lResult == HTMAXBUTTON || lResult == HTMINBUTTON || lResult == HTHELP)
+ // Perform hit testing using DWM
+ if (pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult)) {
+ // DWM returned a hit, no further processing necessary
*result = lResult;
- else
- *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
- break;
- }
- case WM_NCMOUSEMOVE:
- case WM_NCLBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WIZ_WM_NCMOUSELEAVE: {
- LRESULT lResult;
- pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult);
- *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
+ } else {
+ // DWM didn't return a hit, process using DefWindowProc
+ lResult = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
+ // If DefWindowProc returns a window caption button, just return HTCLIENT (client area).
+ // This avoid unnecessary hits to Windows NT style caption buttons which aren't visible but are
+ // located just under the Aero style window close button.
+ if (lResult == HTCLOSE || lResult == HTMAXBUTTON || lResult == HTMINBUTTON || lResult == HTHELP)
+ *result = HTCLIENT;
+ else
+ *result = lResult;
+ }
break;
}
// case WM_NCCALCSIZE: { #fixme: If the frame size is changed, it needs to be communicated to the QWindow.
@@ -407,10 +406,16 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
// break;
// }
default:
- retval = false;
+ LRESULT lResult;
+ // Pass to DWM to handle
+ if (pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult))
+ *result = lResult;
+ // If the message wasn't handled by DWM, continue processing it as normal
+ else
+ return false;
}
- return retval;
+ return true;
}
void QVistaHelper::setMouseCursor(QPoint pos)
@@ -597,30 +602,36 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
winEvent(&msg, &result);
} else if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- long result;
- MSG msg;
- msg.message = WM_NCHITTEST;
- msg.wParam = 0;
- msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
- HWND handle = QApplicationPrivate::getHWNDForWidget(wizard);
- msg.hwnd = handle;
- winEvent(&msg, &result);
- msg.wParam = result;
- msg.message = WM_NCLBUTTONDOWN;
- winEvent(&msg, &result);
+
+ if (mouseEvent->button() == Qt::LeftButton) {
+ long result;
+ MSG msg;
+ msg.message = WM_NCHITTEST;
+ msg.wParam = 0;
+ msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
+ HWND handle = QApplicationPrivate::getHWNDForWidget(wizard);
+ msg.hwnd = handle;
+ winEvent(&msg, &result);
+ msg.wParam = result;
+ msg.message = WM_NCLBUTTONDOWN;
+ winEvent(&msg, &result);
+ }
} else if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- long result;
- MSG msg;
- msg.message = WM_NCHITTEST;
- msg.wParam = 0;
- msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
- HWND handle = QApplicationPrivate::getHWNDForWidget(wizard);
- msg.hwnd = handle;
- winEvent(&msg, &result);
- msg.wParam = result;
- msg.message = WM_NCLBUTTONUP;
- winEvent(&msg, &result);
+
+ if (mouseEvent->button() == Qt::LeftButton) {
+ long result;
+ MSG msg;
+ msg.message = WM_NCHITTEST;
+ msg.wParam = 0;
+ msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
+ HWND handle = QApplicationPrivate::getHWNDForWidget(wizard);
+ msg.hwnd = handle;
+ winEvent(&msg, &result);
+ msg.wParam = result;
+ msg.message = WM_NCLBUTTONUP;
+ winEvent(&msg, &result);
+ }
}
return false;