QSizeGrip: Fix Windows.

Reactivate the old Windows code.

Change-Id: Ied467cf83d89c76a0fa8edf3c76bb207cc2a70e0
Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-01-26 11:01:13 +01:00 committed by Qt by Nokia
parent 692a1babe5
commit 12b88cc7bb
3 changed files with 25 additions and 33 deletions

View File

@ -73,13 +73,9 @@
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;

View 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>
@ -64,13 +65,18 @@
#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,13 +417,14 @@ 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()) {
#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, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
while (PeekMessage(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) ;
return;
}
}
#endif
QPoint np(e->globalPos());
@ -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"

View 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: