diff options
author | Darrell Anderson <humanreadable@yahoo.com> | 2013-03-02 15:51:14 -0600 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2013-03-02 15:51:14 -0600 |
commit | 79751823a7e899821a14fd08c673ca0655ca4b51 (patch) | |
tree | eff23661b954ce94b6cc9bfb63fd99873ec77df9 | |
parent | 577ad042c85beec9b04041e4565eac34db57abb0 (diff) | |
parent | d10d2321a34ab6c157bdf2a2e900c0ee52f1bd79 (diff) | |
download | qt3-79751823a7e899821a14fd08c673ca0655ca4b51.tar.gz qt3-79751823a7e899821a14fd08c673ca0655ca4b51.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
-rw-r--r-- | changes-3.5 | 2 | ||||
-rw-r--r-- | src/iconview/qiconview.cpp | 51 | ||||
-rw-r--r-- | src/iconview/qiconview.h | 1 | ||||
-rw-r--r-- | src/kernel/qapplication.cpp | 9 | ||||
-rw-r--r-- | src/kernel/qeventloop_glib_p.h | 7 | ||||
-rw-r--r-- | src/kernel/qeventloop_x11_glib.cpp | 32 |
6 files changed, 85 insertions, 17 deletions
diff --git a/changes-3.5 b/changes-3.5 index 3e5a920..9aee75a 100644 --- a/changes-3.5 +++ b/changes-3.5 @@ -31,7 +31,7 @@ sizeFromContents styleHint stylePixmap visualRect -drawKStylePrimitive +drawTDEStylePrimitive polish unPolish diff --git a/src/iconview/qiconview.cpp b/src/iconview/qiconview.cpp index 66fa498..2272f83 100644 --- a/src/iconview/qiconview.cpp +++ b/src/iconview/qiconview.cpp @@ -214,6 +214,7 @@ public: QIconViewItem *currentItem, *tmpCurrentItem, *highlightedItem, *startDragItem, *pressedItem, *selectAnchor, *renamingItem; QRect *rubber; + QPixmap *backBuffer; QTimer *scrollTimer, *adjustTimer, *updateTimer, *inputTimer, *fullRedrawTimer; int rastX, rastY, spacing; @@ -2800,6 +2801,7 @@ QIconView::QIconView( QWidget *parent, const char *name, WFlags f ) d->currentItem = 0; d->highlightedItem = 0; d->rubber = 0; + d->backBuffer = 0; d->scrollTimer = 0; d->startDragItem = 0; d->tmpCurrentItem = 0; @@ -2953,6 +2955,8 @@ QIconView::~QIconView() delete item; item = tmp; } + delete d->backBuffer; + d->backBuffer = 0; delete d->fm; d->fm = 0; #ifndef QT_NO_TOOLTIP @@ -4973,6 +4977,47 @@ void QIconView::contentsDropEvent( QDropEvent *e ) #endif /*! + This function grabs all paintevents that otherwise would have been + processed by the QScrollView::viewportPaintEvent(). Here we use a + doublebuffer to reduce 'on-paint' flickering on QIconView + (and of course its children). + + \sa QScrollView::viewportPaintEvent(), QIconView::drawContents() +*/ + +void QIconView::bufferedPaintEvent( QPaintEvent* pe ) +{ + QWidget* vp = viewport(); + QRect r = pe->rect() & vp->rect(); + int ex = r.x() + contentsX(); + int ey = r.y() + contentsY(); + int ew = r.width(); + int eh = r.height(); + + if ( !d->backBuffer ) + d->backBuffer = new QPixmap(vp->size()); + if ( d->backBuffer->size() != vp->size() ) { + // Resize function (with hysteresis). Uses a good compromise between memory + // consumption and speed (number) of resizes. + float newWidth = (float)vp->width(); + float newHeight = (float)vp->height(); + if ( newWidth > d->backBuffer->width() || newHeight > d->backBuffer->height() ) + { + newWidth *= 1.1892; + newHeight *= 1.1892; + d->backBuffer->resize( (int)newWidth, (int)newHeight ); + } else if ( 1.5*newWidth < d->backBuffer->width() || 1.5*newHeight < d->backBuffer->height() ) + d->backBuffer->resize( (int)newWidth, (int)newHeight ); + } + + QPainter p; + p.begin(d->backBuffer, vp); + drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh); + p.end(); + bitBlt(vp, r.x(), r.y(), d->backBuffer, r.x(), r.y(), ew, eh); +} + +/*! \reimp */ @@ -5755,11 +5800,11 @@ bool QIconView::eventFilter( QObject * o, QEvent * e ) if ( d->dragging ) { if ( !d->rubber ) drawDragShapes( d->oldDragPos ); - } - viewportPaintEvent( (QPaintEvent*)e ); - if ( d->dragging ) { + viewportPaintEvent( (QPaintEvent*)e ); if ( !d->rubber ) drawDragShapes( d->oldDragPos ); + } else { + bufferedPaintEvent( (QPaintEvent*)e ); } } return TRUE; diff --git a/src/iconview/qiconview.h b/src/iconview/qiconview.h index 97780d8..109779f 100644 --- a/src/iconview/qiconview.h +++ b/src/iconview/qiconview.h @@ -452,6 +452,7 @@ protected: void contentsDropEvent( QDropEvent *e ); #endif + void bufferedPaintEvent( QPaintEvent* ); void resizeEvent( QResizeEvent* e ); void keyPressEvent( QKeyEvent *e ); void focusInEvent( QFocusEvent *e ); diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 5b43301..591fc8d 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -2931,7 +2931,14 @@ int QApplication::exec() */ void QApplication::exit( int retcode ) { - qApp->eventLoop()->exit( retcode ); + QThread* thread = qApp->guiThread(); + if (thread) { + if (thread->d) { + if (thread->d->eventLoop) { + thread->d->eventLoop->exit( retcode ); + } + } + } } /*! diff --git a/src/kernel/qeventloop_glib_p.h b/src/kernel/qeventloop_glib_p.h index 663f20e..4dfc02c 100644 --- a/src/kernel/qeventloop_glib_p.h +++ b/src/kernel/qeventloop_glib_p.h @@ -90,6 +90,9 @@ public: xfd = -1; x_gPollFD.fd = -1; #endif // Q_WS_X11 + singletoolkit = TRUE; + ctx = 0; + ctx_is_default = false; reset(); } @@ -99,9 +102,8 @@ public: quitnow = FALSE; exitloop = FALSE; shortcut = FALSE; - singletoolkit = TRUE; } - + int looplevel; int quitcode; unsigned int quitnow : 1; @@ -129,6 +131,7 @@ public: // main context GMainContext *ctx; + bool ctx_is_default; }; #endif // QEVENTLOOP_GLIB_P_H diff --git a/src/kernel/qeventloop_x11_glib.cpp b/src/kernel/qeventloop_x11_glib.cpp index 877ff44..d37fbee 100644 --- a/src/kernel/qeventloop_x11_glib.cpp +++ b/src/kernel/qeventloop_x11_glib.cpp @@ -79,8 +79,7 @@ static GSourceFuncs qt_gsource_funcs = { // forward main loop callbacks to QEventLoop methods! -static gboolean qt_gsource_prepare ( GSource *source, - gint *timeout ) +static gboolean qt_gsource_prepare ( GSource *source, gint *timeout ) { QtGSource * qtGSource = (QtGSource*) source; QEventLoop* candidateEventLoop = qtGSource->qeventLoop; @@ -95,7 +94,7 @@ static gboolean qt_gsource_prepare ( GSource *source, } } -static gboolean qt_gsource_check ( GSource *source ) +static gboolean qt_gsource_check ( GSource *source ) { QtGSource * qtGSource = (QtGSource*) source; QEventLoop* candidateEventLoop = qtGSource->qeventLoop; @@ -110,8 +109,7 @@ static gboolean qt_gsource_check ( GSource *source ) } } -static gboolean qt_gsource_dispatch ( GSource *source, - GSourceFunc callback, gpointer user_data ) +static gboolean qt_gsource_dispatch ( GSource *source, GSourceFunc callback, gpointer user_data ) { Q_UNUSED(callback); Q_UNUSED(user_data); @@ -215,6 +213,7 @@ void QEventLoop::init() // new main context for thread d->ctx = g_main_context_new(); g_main_context_push_thread_default(d->ctx); + d->ctx_is_default = true; // new GSource QtGSource * qtGSource = (QtGSource*) g_source_new(&qt_gsource_funcs, sizeof(QtGSource)); @@ -241,9 +240,9 @@ void QEventLoop::init() d->threadPipe_gPollFD.fd = d->thread_pipe[0]; d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR; - g_source_add_poll(d->gSource, &d->threadPipe_gPollFD); + g_source_add_poll(d->gSource, &d->threadPipe_gPollFD); -#ifdef DEBUG_QT_GLIBMAINLOOP +#ifdef DEBUG_QT_GLIBMAINLOOP printf("inside init(2)\n"); #endif @@ -375,7 +374,7 @@ bool QEventLoop::processX11Events() } -bool QEventLoop::gsourcePrepare(GSource *gs, int * timeout) +bool QEventLoop::gsourcePrepare(GSource *gs, int * timeout) { Q_UNUSED(gs); @@ -428,7 +427,7 @@ bool QEventLoop::gsourcePrepare(GSource *gs, int * timeout) #ifdef DEBUG_QT_GLIBMAINLOOP printf("inside gsourcePrepare(2) canwait=%d\n", canWait); -#endif +#endif if ( canWait ) { emit aboutToBlock(); @@ -440,7 +439,7 @@ bool QEventLoop::gsourcePrepare(GSource *gs, int * timeout) (**it)(); } -#ifdef DEBUG_QT_GLIBMAINLOOP +#ifdef DEBUG_QT_GLIBMAINLOOP printf("inside gsourcePrepare(2.1) canwait=%d\n", canWait); #endif @@ -649,4 +648,17 @@ void QEventLoop::appClosingDown() void QEventLoop::setSingleToolkitEventHandling(bool enabled) { d->singletoolkit = enabled; + + if (!d->singletoolkit) { + if (d->ctx_is_default) { + d->ctx_is_default = false; + g_main_context_pop_thread_default(d->ctx); + } + } + else { + if (!d->ctx_is_default) { + g_main_context_push_thread_default(d->ctx); + d->ctx_is_default = true; + } + } }
\ No newline at end of file |