Skip to content

Commit 392123e

Browse files
author
Kim Motoyoshi Kalland
committed
Fixed bug where GL widget was not fully updated on Vista.
There were cases where the QGLWidget would not be fully updated on screen on Windows Vista and Windows 7 with Aero disabled. Task-number: QTBUG-7865 Reviewed-by: Prasanth
1 parent 10ca680 commit 392123e

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

src/gui/kernel/qapplication_win.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,11 @@ const QString qt_reg_winclass(QWidget *w) // register window class
927927
uint style;
928928
bool icon;
929929
QString cname;
930-
if (flags & Qt::MSWindowsOwnDC) {
930+
if (qt_widget_private(w)->isGLWidget) {
931+
cname = QLatin1String("QGLWidget");
932+
style = CS_DBLCLKS;
933+
icon = true;
934+
} else if (flags & Qt::MSWindowsOwnDC) {
931935
cname = QLatin1String("QWidgetOwnDC");
932936
style = CS_DBLCLKS;
933937
#ifndef Q_OS_WINCE
@@ -1011,7 +1015,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
10111015

10121016
ATOM atom;
10131017
#ifndef Q_OS_WINCE
1014-
HBRUSH bgBrush = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
1018+
HBRUSH bgBrush = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
10151019
QT_WA({
10161020
WNDCLASS wc;
10171021
wc.style = style;
@@ -3626,13 +3630,19 @@ bool QETWidget::translatePaintEvent(const MSG &msg)
36263630
return true;
36273631

36283632
setAttribute(Qt::WA_PendingUpdate, false);
3629-
const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
3630-
// Make sure the invalidated region contains the region we're about to repaint.
3631-
// BeginPaint will set the clip to the invalidated region and it is impossible
3632-
// to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
3633-
// as it may return an invalid context (especially on Windows Vista).
3634-
if (!dirtyInBackingStore.isEmpty())
3635-
InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
3633+
3634+
if (d_func()->isGLWidget) {
3635+
if (d_func()->usesDoubleBufferedGLContext)
3636+
InvalidateRect(internalWinId(), 0, false);
3637+
} else {
3638+
const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
3639+
// Make sure the invalidated region contains the region we're about to repaint.
3640+
// BeginPaint will set the clip to the invalidated region and it is impossible
3641+
// to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
3642+
// as it may return an invalid context (especially on Windows Vista).
3643+
if (!dirtyInBackingStore.isEmpty())
3644+
InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
3645+
}
36363646
PAINTSTRUCT ps;
36373647
d_func()->hd = BeginPaint(internalWinId(), &ps);
36383648

src/gui/kernel/qwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ QWidgetPrivate::QWidgetPrivate(int version) :
183183
,inDirtyList(0)
184184
,isScrolled(0)
185185
,isMoved(0)
186+
, isGLWidget(0)
186187
,usesDoubleBufferedGLContext(0)
187188
#ifdef Q_WS_WIN
188189
,noPaintOnScreen(0)
@@ -194,7 +195,6 @@ QWidgetPrivate::QWidgetPrivate(int version) :
194195
#endif
195196
#ifdef Q_WS_MAC
196197
,needWindowChange(0)
197-
,isGLWidget(0)
198198
#endif
199199
,polished(0)
200200

src/gui/kernel/qwidget_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
537537
uint inDirtyList : 1;
538538
uint isScrolled : 1;
539539
uint isMoved : 1;
540+
uint isGLWidget : 1;
540541
uint usesDoubleBufferedGLContext : 1;
541542

542543
#ifdef Q_WS_WIN
@@ -593,7 +594,6 @@ class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
593594

594595
// This is new stuff
595596
uint needWindowChange : 1;
596-
uint isGLWidget : 1;
597597
#endif
598598

599599
#if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined(Q_WS_MAC)

src/opengl/qgl_mac.mm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,6 @@ QRegion qt_mac_get_widget_rgn(const QWidget *widget)
882882
break;
883883
current = current->parentWidget();
884884
}
885-
886-
isGLWidget = 1;
887885
}
888886

889887
bool QGLWidgetPrivate::renderCxPm(QPixmap*)

src/opengl/qgl_p.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ class QGLWidgetPrivate : public QWidgetPrivate
160160
#if defined(Q_WS_X11) && defined(QT_OPENGL_ES)
161161
, eglSurfaceWindowId(0)
162162
#endif
163-
{}
163+
{
164+
isGLWidget = 1;
165+
}
164166

165167
~QGLWidgetPrivate() {}
166168

0 commit comments

Comments
 (0)