QSizeGrip: Fix Windows.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Thu, 26 Jan 2012 10:01:13 +0000 (11:01 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 27 Jan 2012 20:18:54 +0000 (21:18 +0100)
Reactivate the old Windows code.

Change-Id: Ied467cf83d89c76a0fa8edf3c76bb207cc2a70e0
Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com>
src/widgets/dialogs/qmessagebox.cpp
src/widgets/widgets/qsizegrip.cpp
src/widgets/widgets/qsizegrip.h

index 115c41a..200c18b 100644 (file)
 QT_BEGIN_NAMESPACE
 
 #ifdef Q_OS_WIN
-static inline HMENU qt_getWindowsSystemMenu(const QWidget *w)
+HMENU qt_getWindowsSystemMenu(const QWidget *w)
 {
-    QWindow *window = w->windowHandle();
-    if (!window)
-        if (const QWidget *nativeParent = w->nativeParentWidget())
-            window = nativeParent->windowHandle();
-    if (window)
+    if (QWindow *window = QApplicationPrivate::windowForWidget(w))
         if (void *handle = QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window))
             return GetSystemMenu(reinterpret_cast<HWND>(handle), FALSE);
     return 0;
index 4db0677..5574811 100644 (file)
@@ -54,8 +54,9 @@
 
 #if defined(Q_WS_X11)
 #include <private/qt_x11_p.h>
-#elif defined (Q_WS_WIN)
-#include "qt_windows.h"
+#elif defined (Q_OS_WIN)
+#    include <QtCore/qt_windows.h>
+#    include "private/qapplication_p.h"
 #endif
 #ifdef Q_WS_MAC
 #include <private/qt_mac_p.h>
 #include <private/qwidget_p.h>
 #include <QtWidgets/qabstractscrollarea.h>
 
-#define SZ_SIZEBOTTOMRIGHT  0xf008
-#define SZ_SIZEBOTTOMLEFT   0xf007
-#define SZ_SIZETOPLEFT      0xf004
-#define SZ_SIZETOPRIGHT     0xf005
-
 QT_BEGIN_NAMESPACE
 
+#if defined (Q_OS_WIN)
+#    define SZ_SIZEBOTTOMRIGHT  0xf008
+#    define SZ_SIZEBOTTOMLEFT   0xf007
+#    define SZ_SIZETOPLEFT      0xf004
+#    define SZ_SIZETOPRIGHT     0xf005
+
+HMENU qt_getWindowsSystemMenu(const QWidget *w);
+
+#endif
+
 static QWidget *qt_sizegrip_topLevelWidget(QWidget* w)
 {
     while (w && !w->isWindow() && w->windowType() != Qt::SubWindow)
@@ -317,7 +323,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
         return;
     }
 #endif // Q_WS_X11
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
     if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
         uint orientation = 0;
         if (d->atBottom())
@@ -326,10 +332,10 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
             orientation = d->atLeft() ? SZ_SIZETOPLEFT : SZ_SIZETOPRIGHT;
 
         ReleaseCapture();
-        PostMessage(tlw->winId(), WM_SYSCOMMAND, orientation, 0);
+        PostMessage(QApplicationPrivate::getHWNDForWidget(tlw), WM_SYSCOMMAND, orientation, 0);
         return;
     }
-#endif // Q_WS_WIN
+#endif // Q_OS_WIN
 
     // Find available desktop/workspace geometry.
     QRect availableGeometry;
@@ -411,12 +417,13 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e)
         && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
         return;
 #endif
-#ifdef Q_WS_WIN
-    if (tlw->isWindow() && GetSystemMenu(tlw->winId(), FALSE) != 0 && internalWinId()
-        && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
-        MSG msg;
-        while(PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
-        return;
+#ifdef Q_OS_WIN
+    if (tlw->isWindow() && qt_getWindowsSystemMenu(tlw) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
+        if (const HWND hwnd = QApplicationPrivate::getHWNDForWidget(tlw)) {
+            MSG msg;
+            while (PeekMessage(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) ;
+            return;
+        }
     }
 #endif
 
@@ -541,14 +548,6 @@ bool QSizeGrip::event(QEvent *event)
     return QWidget::event(event);
 }
 
-#ifdef Q_WS_WIN
-/*! \reimp */
-bool QSizeGrip::winEvent( MSG *m, long *result )
-{
-    return QWidget::winEvent(m, result);
-}
-#endif
-
 QT_END_NAMESPACE
 
 #include "moc_qsizegrip.cpp"
index 44b27b2..8dccebb 100644 (file)
@@ -71,9 +71,6 @@ protected:
     void hideEvent(QHideEvent *hideEvent);
     bool eventFilter(QObject *, QEvent *);
     bool event(QEvent *);
-#ifdef Q_WS_WIN
-    bool winEvent(MSG *m, long *result);
-#endif
 
 public: