Changeset 458 for trunk/src/gui/kernel


Ignore:
Timestamp:
Jan 21, 2010, 12:46:24 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: DnD: Added support for drag sources that don't support synchronous data rendering (such as EPM). At present, these applications must be hard coded in qdnd_pm.cpp using the EXE name and the window class name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qdnd_pm.cpp

    r454 r458  
    5353#include "qdesktopwidget.h"
    5454#include "qfile.h"
     55
    5556#include "qdnd_p.h"
    5657#include "qdebug.h"
     
    9091    void reset() { reset(false); }
    9192
    92     void setDropped(bool d) { dropped = d; }
    93     bool isDropped() const { return dropped; }
     93    void set = d; }
     94    bool i; }
    9495
    9596    DRAGINFO *info() const { return di; }
     97
    9698
    9799    bool hasFormat_sys(const QString &mimeType);
     
    106108
    107109    bool initialized : 1;
    108     bool dropped : 1;
     110    bool : 1;
    109111    bool gotWorkers : 1;
     112
    110113
    111114    DRAGINFO *di;
     
    125128
    126129QPMDragData::QPMDragData()
    127     : initialized(false), dropped(false)
    128     , gotWorkers(false), di(NULL)
     130    : initialized(false), (false)
     131    , gotWorkers(false), di(NULL)
    129132    , lastDragOverWidget(0), lastDragOverOp(0)
    130133    , supportedOps(0), sourceAllowsOp(false)
     
    147150    initialized = true;
    148151    di = info;
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
    149208}
    150209
     
    196255    workers.clear();
    197256    di = 0;
    198     initialized = dropped = gotWorkers = false;
     257    initialized = = false;
    199258}
    200259
     
    229288    QVariant result;
    230289
    231     // we may only do data transfer after DM_DROP is sent. Return shortly.
    232     if (!isDropped())
     290    // If the source doesn't support synchronous rendering, we may only do data
     291    // transfer after DM_DROP is processed by us. Return shortly.
     292    if (!canSyncRender() && !inFakeDrop())
    233293        return result;
    234294
     
    360420void QDragManager::sendDropEvent(QWidget *receiver, QEvent *event)
    361421{
     422
     423
     424
     425
     426
     427
     428
    362429    Q_ASSERT(!inDrag);
    363     inDrag = true;
     430    if (!inFakeDrop)
     431        inDrag = true;
     432
    364433    QApplication::sendEvent(receiver, event);
    365     // make sure that all issued update requests are handled before we
    366     // return from the DM_DRAGOVER/DM_DRAGLEAVE/DM_DROP message; otherwise
    367     // we'll get screen corruption due to unexpected screen updates while
    368     // dragging
    369     QApplication::sendPostedEvents(0, QEvent::UpdateRequest);
    370     inDrag = false;
     434
     435    if (!inFakeDrop) {
     436        // make sure that all issued update requests are handled before we
     437        // return from the DM_DRAGOVER/DM_DRAGLEAVE/DM_DROP message; otherwise
     438        // we'll get screen corruption due to unexpected screen updates while
     439        // dragging
     440        QApplication::sendPostedEvents(0, QEvent::UpdateRequest);
     441        inDrag = false;
     442    }
    371443}
    372444
     
    561633            DEBUG(("DM_DROP: hwnd %lX di %p", qmsg.hwnd, qmsg.mp1));
    562634
    563             // Odin32 apps produce incorrect message flow, ignore
    564             Q_ASSERT(dragData->lastDragOverWidget != 0);
    565             if (dragData->lastDragOverWidget == 0)
    566                 return 0;
    567 
    568             // Odin32 apps send DM_DROP even if we replied DOR_NEVERDROP or
    569             // DOR_NODROP, simulate DM_DRAGLEAVE
    570             Q_ASSERT(dragData->lastDropReply == DOR_DROP);
    571             if (dragData->lastDropReply != DOR_DROP) {
    572                 QMSG qmsg2 = qmsg;
    573                 qmsg2.msg = DM_DRAGLEAVE;
    574                 dispatchDragAndDrop(widget, qmsg2);
    575                 return 0;
     635            // sanity
     636            Q_ASSERT(!dragData->canSyncRender() || qmsg.mp1);
     637
     638            DRAGINFO *info = 0;
     639
     640            if (dragData->canSyncRender() || qmsg.mp1) {
     641                // Odin32 apps produce incorrect message flow, ignore
     642                Q_ASSERT(dragData->lastDragOverWidget != 0);
     643                if (dragData->lastDragOverWidget == 0)
     644                    return 0;
     645
     646                // Odin32 apps send DM_DROP even if we replied DOR_NEVERDROP or
     647                // DOR_NODROP, simulate DM_DRAGLEAVE
     648                Q_ASSERT(dragData->lastDropReply == DOR_DROP);
     649                if (dragData->lastDropReply != DOR_DROP) {
     650                    QMSG qmsg2 = qmsg;
     651                    qmsg2.msg = DM_DRAGLEAVE;
     652                    dispatchDragAndDrop(widget, qmsg2);
     653                    return 0;
     654                }
     655
     656                // sanity
     657                Q_ASSERT((DRAGINFO *)qmsg.mp1 == dragData->info());
     658
     659                info = (DRAGINFO *)qmsg.mp1;
     660                ok = DrgAccessDraginfo(info);
     661                Q_ASSERT(ok && info);
     662                if (!ok || !info)
     663                    return 0;
     664
     665                if (!dragData->canSyncRender()) {
     666                    // The source doesn't support syncrhonous rendering (i.e.
     667                    // it won't issue DM_RENDERCOMPLETE until we return from
     668                    // DM_DROP) so we have to post a message to ourselves to do
     669                    // it asynchronously. For simplicity, we reuse DM_DRAG with
     670                    // mp1 = 0 for this purpose.
     671                    WinPostMsg(qmsg.hwnd, DM_DROP, 0, 0);
     672                    return 0;
     673                }
     674            } else {
     675                // we're in a fake DM_DROP we posted above
     676                dragData->setInFakeDrop(true);
     677                info = dragData->info();
     678                Q_ASSERT(info);
    576679            }
    577 
    578             DRAGINFO *info = (DRAGINFO *)qmsg.mp1;
    579             ok = DrgAccessDraginfo(info);
    580             Q_ASSERT(ok && info);
    581             if (!ok || !info)
    582                 return 0;
    583680
    584681            // flip y coordinate
     
    597694
    598695            QMimeData *data = manager->source() ? manager->dragPrivate()->data : manager->dropData;
    599 
    600             dragData->setDropped(true);
    601696
    602697            QDropEvent de(pnt, dragData->lastAction, data, mouseButtons(),
Note: See TracChangeset for help on using the changeset viewer.