Ignore:
Timestamp:
Apr 30, 2010, 5:45:52 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Fixed painting under the mouse pointer in Dive mode while performing a drag-n-drop operation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/painting/qwindowsurface_pm.cpp

    r714 r718  
    333333    bool vrnDirty;
    334334    bool vrnDisabled;
     335    bool inDrag;
    335336    SETUP_BLITTER setup;
    336337    QVector<RECTL> rcls;
     
    354355    d->vrnDirty = true;
    355356    d->vrnDisabled = false;
     357    d->inDrag = false;
    356358
    357359    memset(&d->setup, 0, sizeof(SETUP_BLITTER));
     
    399401    QRect wbr = br.translated(-wOffset);
    400402    br.translate(offset);
     403
     404    if (d->inDrag) {
     405        // In drag, DIVE seems to not synchronize well with the mouse buffer
     406        // that preserves the contents under the mouse pointer and the drag
     407        // image while dragging (even when we use DiveBlitImage()). As a result,
     408        // we will get some areas unpainted under if painting is done during
     409        // drag. Use the WinGetPS()/GpiDrawBits() way to fix it. The below code
     410        // is merely a copy of QT_BITMAP_MIRROR == 3 from qwindowsurface_raster.cpp
     411
     412        HPS wps = window()->getPS();
     413
     414        MATRIXLF m;
     415        m.fxM11 = MAKEFIXED(1, 0);
     416        m.fxM12 = 0;
     417        m.lM13 = 0;
     418        m.fxM21 = 0;
     419        m.fxM22 = MAKEFIXED(-1, 0);
     420        m.lM23 = 0;
     421        m.lM31 = 0;
     422        m.lM32 = window()->height() - 1;
     423        GpiSetDefaultViewMatrix(wps, 8, &m, TRANSFORM_REPLACE);
     424
     425        // make sure br doesn't exceed the backing storage size (it may happen
     426        // during resize & move due to the different event order)
     427        br = br.intersected(QRect(0, 0, d->image->width(), d->image->height()));
     428
     429        BITMAPINFOHEADER2 bmh;
     430        memset(&bmh, 0, sizeof(BITMAPINFOHEADER2));
     431        bmh.cbFix = sizeof(BITMAPINFOHEADER2);
     432        bmh.cPlanes = 1;
     433        bmh.cBitCount = d->image->depth();
     434        bmh.cx = d->image->width();
     435        bmh.cy = d->image->height();
     436
     437        // Note: target is inclusive-inclusive, source is inclusive-exclusive
     438        POINTL ptls[] = { { wbr.left(), wbr.top() },
     439                          { wbr.right(), wbr.bottom() },
     440                          { br.left(), br.top() },
     441                          { br.right() + 1, br.bottom() + 1 } };
     442        GpiDrawBits(wps, (PVOID) const_cast<const QImage *>(d->image)->bits(),
     443                    (PBITMAPINFO2) &bmh, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
     444
     445        window()->releasePS(wps);
     446
     447        return;
     448    }
    401449
    402450    if (d->vrnDisabled) {
     
    521569            *result = 0;
    522570            return true;
     571        }
     572        case DM_DRAGOVER: {
     573            d->inDrag = true;
     574            break;
     575        }
     576        case DM_DRAGLEAVE:
     577        case DM_DROP: {
     578            d->inDrag = false;
     579            break;
    523580        }
    524581        case WM_VRNENABLED: {
     
    537594
    538595            // process pending flush events
    539             foreach(QPMDiveWindowSurfacePrivate::FlushArgs args, d->pending) {
     596            foreach(QPMDiveWindowSurfacePrivate::FlushArgs args, d->pending)
    540597                doFlush(args.from, args.to);
    541             }
    542598            d->pending.clear();
    543599
Note: See TracChangeset for help on using the changeset viewer.