Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qcocoaview_mac.mm

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050#include <private/qdnd_p.h>
    5151#include <private/qmacinputcontext_p.h>
     52#include <private/qmultitouch_mac_p.h>
     53#include <private/qevent_p.h>
     54#include <private/qbackingstore_p.h>
    5255
    5356#include <qscrollarea.h>
     
    6265#include <qdebug.h>
    6366
     67@interface NSEvent (Qt_Compile_Leopard_DeviceDelta)
     68  - (CGFloat)deviceDeltaX;
     69  - (CGFloat)deviceDeltaY;
     70  - (CGFloat)deviceDeltaZ;
     71@end
     72
     73@interface NSEvent (Qt_Compile_Leopard_Gestures)
     74  - (CGFloat)magnification;
     75@end
    6476
    6577QT_BEGIN_NAMESPACE
     
    7284extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp
    7385extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm
     86extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
    7487
    7588Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
     
    101114    { NSDragOperationGeneric,  Qt::CopyAction, false },
    102115    { NSDragOperationEvery, Qt::ActionMask, false },
    103     { NSDragOperationNone, Qt::IgnoreAction, false } 
     116    { NSDragOperationNone, Qt::IgnoreAction, false }
    104117};
    105118
     
    182195QT_FORWARD_DECLARE_CLASS(QPainter)
    183196QT_FORWARD_DECLARE_CLASS(QHoverEvent)
     197QT_FORWARD_DECLARE_CLASS(QCursor)
    184198QT_USE_NAMESPACE
    185199extern "C" {
     
    196210        [self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
    197211    }
     212    composingText = new QString();
    198213    composing = false;
    199214    sendKeyEvents = true;
     215    currentCustomTypes = 0;
    200216    [self setHidden:YES];
    201217    return self;
     
    212228}
    213229
    214 -(void)registerDragTypes:(bool)accept
     230-(void)registerDragTypes
    215231{
    216232    QMacCocoaAutoReleasePool pool;
    217     if (accept) {
     233    // Calling registerForDraggedTypes is slow, so only do it once for each widget
     234    // or when the custom types change.
     235    const QStringList& customTypes = qEnabledDraggedTypes();
     236    if (currentCustomTypes == 0 || *currentCustomTypes != customTypes) {
     237        if (currentCustomTypes == 0)
     238            currentCustomTypes = new QStringList();
     239        *currentCustomTypes = customTypes;
    218240        const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName";
    219         NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, 
    220                                    NSFilenamesPboardType, NSStringPboardType, 
    221                                    NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, 
    222                                    NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, 
    223                                    NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, 
    224                                    NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, 
     241        NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType,
     242                                   NSFilenamesPboardType, NSStringPboardType,
     243                                   NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType,
     244                                   NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType,
     245                                   NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType,
     246                                   NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType,
    225247                                   NSURLPboardType, NSPDFPboardType, NSVCardPboardType,
    226                                    NSFilesPromisePboardType, NSInkTextPboardType, 
     248                                   NSFilesPromisePboardType, NSInkTextPboardType,
    227249                                   NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil];
    228250        // Add custom types supported by the application.
    229         const QStringList& customTypes = qEnabledDraggedTypes();
    230251        for (int i = 0; i < customTypes.size(); i++) {
    231252           [supportedTypes addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(customTypes[i]))];
    232253        }
    233254        [self registerForDraggedTypes:supportedTypes];
     255    }
     256}
     257
     258- (void)resetCursorRects
     259{
     260    QWidget *cursorWidget = qwidget;
     261
     262    if (cursorWidget->testAttribute(Qt::WA_TransparentForMouseEvents))
     263        cursorWidget = QApplication::widgetAt(qwidget->mapToGlobal(qwidget->rect().center()));
     264
     265    if (cursorWidget == 0)
     266        return;
     267
     268    if (!cursorWidget->testAttribute(Qt::WA_SetCursor)) {
     269        [super resetCursorRects];
     270        return;
     271    }
     272
     273    QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
     274    NSCursor *nscursor = static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursorWidget->cursor()));
     275    if (mask.isEmpty()) {
     276        [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
    234277    } else {
    235         [self unregisterDraggedTypes];
     278        const QVector<QRect> &rects = mask.rects();
     279        for (int i = 0; i < rects.size(); ++i) {
     280            const QRect &rect = rects.at(i);
     281            [self addCursorRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()) cursor:nscursor];
     282        }
    236283    }
    237284}
     
    244291    }
    245292}
    246  
    247 - (void)addDropData:(id <NSDraggingInfo>)sender 
     293
     294- (void)addDropData:(id <NSDraggingInfo>)sender
    248295{
    249296    [self removeDropData];
    250     CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name]; 
     297    CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name];
    251298    dropData = new QCocoaDropData(dropPasteboard);
    252 }
    253 
    254 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
    255 {
     299}
     300
     301- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
     302{
     303    if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false)
     304        return NSDragOperationNone;
     305    NSPoint windowPoint = [sender draggingLocation];
     306    if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {
     307        // pass the drag enter event to the view underneath.
     308        NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];
     309        if (candidateView && candidateView != self)
     310            return [candidateView draggingEntered:sender];
     311    }
     312    dragEnterSequence = [sender draggingSequenceNumber];
    256313    [self addDropData:sender];
    257314    QMimeData *mimeData = dropData;
    258315    if (QDragManager::self()->source())
    259316        mimeData = QDragManager::self()->dragPrivate()->data;
    260     NSPoint windowPoint = [sender draggingLocation];
    261317    NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
    262318    NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
    263319    QPoint posDrag(localPoint.x, localPoint.y);
    264     NSDragOperation nsActions = [sender draggingSourceOperationMask]; 
     320    NSDragOperation nsActions = [sender draggingSourceOperationMask];
    265321    Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
     322    QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
     323    Qt::KeyboardModifiers modifiers  = Qt::NoModifier;
     324    if ([sender draggingSource] != nil) {
     325        // modifier flags might have changed, update it here since we don't send any input events.
     326        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
     327        modifiers = QApplication::keyboardModifiers();
     328    } else {
     329        // when the source is from another application the above technique will not work.
     330        modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
     331    }
    266332    // send the drag enter event to the widget.
    267     QDragEnterEvent qDEEvent(posDrag, qtAllowed, mimeData,
    268             QApplication::mouseButtons(), QApplication::keyboardModifiers());
     333    QDragEnterEvent qDEEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
    269334    QApplication::sendEvent(qwidget, &qDEEvent);
    270335    if (!qDEEvent.isAccepted()) {
     
    273338        return NSDragOperationNone;
    274339    } else {
     340        // save the mouse position, used by draggingExited handler.
     341        DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
     342        dndParams->activeDragEnterPos = windowPoint;
    275343        // send a drag move event immediately after a drag enter event (as per documentation).
    276         QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData,
    277                 QApplication::mouseButtons(), QApplication::keyboardModifiers());
     344        QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
    278345        qDMEvent.setDropAction(qDEEvent.dropAction());
    279346        qDMEvent.accept(); // accept by default, since enter event was accepted.
    280347        QApplication::sendEvent(qwidget, &qDMEvent);
    281348        if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
    282             // since we accepted the drag enter event, the widget expects
    283             // future drage move events. 
    284             // ### check if we need to treat this like the drag enter event.
    285             nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDEEvent.dropAction());
     349            // since we accepted the drag enter event, the widget expects
     350            // future drage move events.
     351            // ### check if we need to treat this like the drag enter event.
     352            nsActions = NSDragOperationNone;
     353            // Save as ignored in the answer rect.
     354            qDMEvent.setDropAction(Qt::IgnoreAction);
    286355        } else {
    287356            nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction());
    288         }
     357        }
    289358        QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent);
    290         return nsActions;
    291     } 
     359        return nsActions;
     360    }
    292361 }
    293  
    294362- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
    295363{
    296     // drag enter event was rejected, so ignore the move event.
     364    NSPoint windowPoint = [sender draggingLocation];
     365    if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {
     366        // pass the drag move event to the view underneath.
     367        NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];
     368        if (candidateView && candidateView != self)
     369            return [candidateView draggingUpdated:sender];
     370    }
     371    // in cases like QFocusFrame, the view under the mouse might
     372    // not have received the drag enter. Generate a synthetic
     373    // drag enter event for that view.
     374    if (dragEnterSequence != [sender draggingSequenceNumber])
     375        [self draggingEntered:sender];
     376    // drag enter event was rejected, so ignore the move event.
    297377    if (dropData == 0)
    298378        return NSDragOperationNone;
    299379    // return last value, if we are still in the answerRect.
    300     NSPoint windowPoint = [sender draggingLocation];
    301380    NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
    302381    NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
     
    306385        && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions)
    307386        return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction));
    308     // send drag move event to the widget   
     387    // send drag move event to the widget
    309388    QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
    310389    Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions);
     390    Qt::KeyboardModifiers modifiers  = Qt::NoModifier;
     391    if ([sender draggingSource] != nil) {
     392        // modifier flags might have changed, update it here since we don't send any input events.
     393        QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
     394        modifiers = QApplication::keyboardModifiers();
     395    } else {
     396        // when the source is from another application the above technique will not work.
     397        modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
     398    }
    311399    QMimeData *mimeData = dropData;
    312400    if (QDragManager::self()->source())
    313401        mimeData = QDragManager::self()->dragPrivate()->data;
    314     QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData,
    315             QApplication::mouseButtons(), QApplication::keyboardModifiers());
     402    QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
    316403    qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction);
    317404    qDMEvent.accept();
    318405    QApplication::sendEvent(qwidget, &qDMEvent);
    319     qt_mac_copy_answer_rect(qDMEvent);
    320406
    321407    NSDragOperation operation = qt_mac_mapDropAction(qDMEvent.dropAction());
     
    323409        // ignore this event (we will still receive further notifications)
    324410        operation = NSDragOperationNone;
    325     }
     411        // Save as ignored in the answer rect.
     412        qDMEvent.setDropAction(Qt::IgnoreAction);
     413    }
     414    qt_mac_copy_answer_rect(qDMEvent);
    326415    return operation;
    327416}
     
    329418- (void)draggingExited:(id < NSDraggingInfo >)sender
    330419{
    331     Q_UNUSED(sender)
    332     // drag enter event was rejected, so ignore the move event.
     420    dragEnterSequence = -1;
     421    if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {
     422        // try sending the leave event to the last view which accepted drag enter.
     423        DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
     424        NSView *candidateView = [[[self window] contentView] hitTest:dndParams->activeDragEnterPos];
     425        if (candidateView && candidateView != self)
     426            return [candidateView draggingExited:sender];
     427    }
     428    // drag enter event was rejected, so ignore the move event.
    333429    if (dropData) {
    334430        QDragLeaveEvent de;
     
    336432        [self removeDropData];
    337433    }
    338 
    339434}
    340435
    341436- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
    342437{
     438    NSPoint windowPoint = [sender draggingLocation];
     439    dragEnterSequence = -1;
     440    if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {
     441        // pass the drop event to the view underneath.
     442        NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];
     443        if (candidateView && candidateView != self)
     444            return [candidateView performDragOperation:sender];
     445    }
    343446    [self addDropData:sender];
    344    
    345     NSPoint windowPoint = [sender draggingLocation];
     447
    346448    NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
    347449    NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
    348450    QPoint posDrop(localPoint.x, localPoint.y);
    349    
    350     NSDragOperation nsActions = [sender draggingSourceOperationMask]; 
     451
     452    NSDragOperation nsActions = [sender draggingSourceOperationMask];
    351453    Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
    352454    QMimeData *mimeData = dropData;
     
    359461        QDragManager::self()->dragPrivate()->target = qwidget;
    360462    QApplication::sendEvent(qwidget, &de);
     463    if (QDragManager::self()->object)
     464        QDragManager::self()->dragPrivate()->executed_action = de.dropAction();
    361465    if (!de.isAccepted())
    362466        return NO;
     
    367471- (void)dealloc
    368472{
     473    delete composingText;
    369474    [[NSNotificationCenter defaultCenter] removeObserver:self];
     475    delete currentCustomTypes;
     476    [self unregisterDraggedTypes];
    370477    [super dealloc];
    371478}
     
    389496{
    390497    [super setFrameSize:newSize];
    391  
     498
    392499    // A change in size has required the view to be invalidated.
    393     if ([self inLiveResize])
    394     {
     500    if ([self inLiveResize]) {
    395501        NSRect rects[4];
    396502        NSInteger count;
     
    400506            [self setNeedsDisplayInRect:rects[count]];
    401507        }
    402     }
    403     else
    404     {
     508    } else {
    405509        [self setNeedsDisplay:YES];
    406510    }
     
    409513- (void)drawRect:(NSRect)aRect
    410514{
     515    if (QApplicationPrivate::graphicsSystem() != 0) {
     516        if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore())
     517            bs->markDirty(qwidget->rect(), qwidget);
     518        qwidgetprivate->syncBackingStore(qwidget->rect());
     519        return;
     520    }
    411521    CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    412522    qwidgetprivate->hd = cg;
     
    462572#endif
    463573            QPainter p(qwidget);
    464             QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(qwidget->parent());
    465             QPoint scrollAreaOffset;
    466             if (scrollArea && scrollArea->viewport() == qwidget) {
    467                 QAbstractScrollAreaPrivate *priv
    468                         = static_cast<QAbstractScrollAreaPrivate *>(qt_widget_private(scrollArea));
    469                 scrollAreaOffset = priv->contentsOffset();
    470                 p.translate(-scrollAreaOffset);
    471             }
    472             qwidgetprivate->paintBackground(&p, qrgn, scrollAreaOffset,
     574            qwidgetprivate->paintBackground(&p, qrgn,
    473575                                            qwidget->isWindow() ? QWidgetPrivate::DrawAsRoot : 0);
    474576            p.end();
     
    481583        if (!redirectionOffset.isNull())
    482584            QPainter::restoreRedirected(qwidget);
    483 #ifdef QT_RASTER_PAINTENGINE
    484         if(engine && engine->type() == QPaintEngine::Raster)
    485             static_cast<QRasterPaintEngine*>(engine)->flush(qwidget,
    486                                                             qrgn.boundingRect().topLeft());
    487 #endif
    488585        if (engine)
    489586            engine->setSystemClip(QRegion());
     
    503600}
    504601
     602- (NSView *)hitTest:(NSPoint)aPoint
     603{
     604    if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents))
     605        return nil; // You cannot hit a transparent for mouse event widget.
     606    return [super hitTest:aPoint];
     607}
     608
    505609- (void)updateTrackingAreas
    506610{
     
    513617        }
    514618    }
     619
     620    // Ideally, we shouldn't have NSTrackingMouseMoved events included below, it should
     621    // only be turned on if mouseTracking, hover is on or a tool tip is set.
     622    // Unfortunately, Qt will send "tooltip" events on mouse moves, so we need to
     623    // turn it on in ALL case. That means EVERY QCocoaView gets to pay the cost of
     624    // mouse moves delivered to it (Apple recommends keeping it OFF because there
     625    // is a performance hit). So it goes.
    515626    NSUInteger trackingOptions = NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp
    516                                  | NSTrackingInVisibleRect;
    517     if (qwidget->hasMouseTracking() || !qwidgetprivate->toolTip.isEmpty()
    518         || qwidget->testAttribute(Qt::WA_Hover))
    519         trackingOptions |= NSTrackingMouseMoved;
     627                                 | NSTrackingInVisibleRect | NSTrackingMouseMoved;
    520628    NSTrackingArea *ta = [[NSTrackingArea alloc] initWithRect:NSMakeRect(0, 0,
    521629                                                                         qwidget->width(),
     
    537645        QApplication::sendEvent(qwidget, &enterEvent);
    538646        qt_mouseover = qwidget;
    539        
     647
    540648        // Update cursor and dispatch hover events.
    541649        qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint());
     
    545653            QApplicationPrivate::instance()->notify_helper(qwidget, &he);
    546654        }
    547     }   
     655    }
    548656}
    549657
     
    554662    if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) {
    555663        QApplication::sendEvent(qwidget, &leaveEvent);
    556        
     664
    557665        // ### Think about if it is necessary to update the cursor, should only be for a few cases.
    558666        qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint());
     
    579687- (void)mouseMoved:(NSEvent *)theEvent
    580688{
    581     qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
    582 }
    583 
    584 - (NSView *)viewUnderTransparentForMouseView:(NSView *)mouseView widget:(QWidget *)widgetToGetMouse
    585                              withWindowPoint:(NSPoint)windowPoint
    586 {
    587     NSMutableArray *viewsToLookAt = [NSMutableArray arrayWithCapacity:5];
    588     [viewsToLookAt addObject:mouseView];
    589     QWidget *parentWidget = widgetToGetMouse->parentWidget();
    590     while (parentWidget) {
    591         [viewsToLookAt addObject:qt_mac_nativeview_for(parentWidget)];
    592         parentWidget = parentWidget->parentWidget();
    593     }
    594    
    595     // Now walk through the subviews of each view and determine which subview should
    596     // get the event. We look through all the subviews at a given level with
    597     // the assumption that the last item to be found the candidate has a higher z-order.
    598     // Unfortunately, fast enumeration doesn't go backwards in 10.5, so assume go fast
    599     // forward is quicker than the slow normal way backwards.
    600     NSView *candidateView = nil;
    601     for (NSView *lookView in viewsToLookAt) {
    602         NSPoint tmpPoint = [lookView convertPoint:windowPoint fromView:nil];
    603         for (NSView *view in [lookView subviews]) {
    604             if (view == mouseView)
    605                 continue;
    606             NSRect frameRect = [view frame];
    607             if (NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
    608                 candidateView = view;
    609         }
    610         if (candidateView)
    611             break;
    612     }
    613    
    614    
    615     if (candidateView != nil) {
    616         // Now that we've got a candidate, we have to dig into it's tree and see where it is.
    617         NSView *lowerView = nil;
    618         NSView *viewForDescent = candidateView;
    619         while (viewForDescent) {
    620             NSPoint tmpPoint = [viewForDescent convertPoint:windowPoint fromView:nil];               
    621             // Apply same rule as above wrt z-order.
    622             for (NSView *view in [viewForDescent subviews]) {
    623                 if (NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
    624                     lowerView = view;
    625             }
    626             if (!lowerView) // Low as we can be at this point.
    627                 candidateView = viewForDescent;
    628 
    629             // Try to go deeper, will also exit out of the loop, if we found the point.
    630             viewForDescent = lowerView;
    631             lowerView = nil;
    632         }
    633     }
    634     // I am transparent, so I can't be a candidate.
    635     if (candidateView == mouseView)
    636         candidateView = nil;
    637     return candidateView;
     689    // We always enable mouse tracking for all QCocoaView-s. In cases where we have
     690    // child views, we will receive mouseMoved for both parent & the child (if
     691    // mouse is over the child). We need to ignore the parent mouseMoved in such
     692    // cases.
     693    NSPoint windowPoint = [theEvent locationInWindow];
     694    NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];
     695    if (candidateView && candidateView == self) {
     696        qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
     697    }
    638698}
    639699
    640700- (void)mouseDown:(NSEvent *)theEvent
    641701{
     702    if (!qt_button_down)
     703        qt_button_down = qwidget;
     704
    642705    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::LeftButton);
    643706    // Don't call super here. This prevents us from getting the mouseUp event,
    644     // which we need to send even if the mouseDown event was not accepted. 
     707    // which we need to send even if the mouseDown event was not accepted.
    645708    // (this is standard Qt behavior.)
    646709}
     
    649712- (void)mouseUp:(NSEvent *)theEvent
    650713{
    651     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::LeftButton);
    652 
    653     if (!mouseOK)
    654         [super mouseUp:theEvent];
     714    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::LeftButton);
     715
     716    qt_button_down = 0;
    655717}
    656718
    657719- (void)rightMouseDown:(NSEvent *)theEvent
    658 {       
    659     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::RightButton);
    660 
    661     if (!mouseOK)
    662         [super rightMouseDown:theEvent];
     720{
     721    if (!qt_button_down)
     722        qt_button_down = qwidget;
     723
     724    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, Qt::RightButton);
    663725}
    664726
    665727- (void)rightMouseUp:(NSEvent *)theEvent
    666728{
    667     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::RightButton);
    668 
    669     if (!mouseOK)
    670         [super rightMouseUp:theEvent];
     729    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonRelease, Qt::RightButton);
     730
     731    qt_button_down = 0;
    671732}
    672733
    673734- (void)otherMouseDown:(NSEvent *)theEvent
    674735{
     736    if (!qt_button_down)
     737        qt_button_down = qwidget;
     738
    675739    Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
    676     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, mouseButton);
    677 
    678     if (!mouseOK)
    679         [super otherMouseDown:theEvent];
     740    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseButtonPress, mouseButton);
    680741}
    681742
     
    683744{
    684745    Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
    685     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent,  QEvent::MouseButtonRelease, mouseButton);
    686 
    687     if (!mouseOK)
    688         [super otherMouseUp:theEvent];
    689 
     746    qt_mac_handleMouseEvent(self, theEvent,  QEvent::MouseButtonRelease, mouseButton);
     747
     748    qt_button_down = 0;
    690749}
    691750
     
    694753    qMacDnDParams()->view = self;
    695754    qMacDnDParams()->theEvent = theEvent;
    696     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::LeftButton);
    697 
    698     if (!mouseOK)
    699         [super mouseDragged:theEvent];
     755    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
    700756}
    701757
     
    704760    qMacDnDParams()->view = self;
    705761    qMacDnDParams()->theEvent = theEvent;
    706     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::RightButton);
    707 
    708     if (!mouseOK)
    709         [super rightMouseDragged:theEvent];
     762    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
    710763}
    711764
     
    714767    qMacDnDParams()->view = self;
    715768    qMacDnDParams()->theEvent = theEvent;
    716     Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]);
    717     bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, mouseButton);
    718 
    719     if (!mouseOK)
    720         [super otherMouseDragged:theEvent];
     769    qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton);
    721770}
    722771
     
    728777        [currentIManager handleMouseEvent:theEvent];
    729778    }
    730    
     779
    731780    NSPoint windowPoint = [theEvent locationInWindow];
    732781    NSPoint globalPoint = [[theEvent window] convertBaseToScreen:windowPoint];
    733782    NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
    734783    QPoint qlocal = QPoint(localPoint.x, localPoint.y);
    735     QPoint qglobal = QPoint(globalPoint.x, globalPoint.y);
    736     Qt::MouseButton buttons = cocoaButton2QtButton([theEvent buttonNumber]);
     784    QPoint qglobal = QPoint(globalPoint.x, flipYCoordinate(globalPoint.y));
     785    Qt::MouseButtons buttons = QApplication::mouseButtons();
    737786    bool wheelOK = false;
    738787    Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([theEvent modifierFlags]);
    739    
    740     // Mouse wheel deltas seem to tick in at increments of 0.1. Qt widgets
    741     // expect the delta to be a multiple of 120.
    742     const int ScrollFactor = 10 * 120;
    743     //                                              The qMax(...) factor reduces the
    744     //                                              acceleration for large wheel deltas.
    745     int deltaX = [theEvent deltaX] * ScrollFactor * qMax(0.6, 1.1 - qAbs([theEvent deltaX]));
    746     int deltaY = [theEvent deltaY] * ScrollFactor * qMax(0.6, 1.1 - qAbs([theEvent deltaY]));
    747     int deltaZ = [theEvent deltaZ] * ScrollFactor * qMax(0.6, 1.1 - qAbs([theEvent deltaZ]));
     788    QWidget *widgetToGetMouse = qwidget;
     789    // if popup is open it should get wheel events if the cursor is over the popup,
     790    // otherwise the event should be ignored.
     791    if (QWidget *popup = qAppInstance()->activePopupWidget()) {
     792        if (!popup->geometry().contains(qglobal))
     793            return;
     794    }
     795
     796    int deltaX = 0;
     797    int deltaY = 0;
     798    int deltaZ = 0;
     799
     800    const EventRef carbonEvent = (EventRef)[theEvent eventRef];
     801    const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
     802    const bool scrollEvent = carbonEventKind == kEventMouseScroll;
     803
     804    if (scrollEvent) {
     805        // The mouse device containts pixel scroll wheel support (Mighty Mouse, Trackpad).
     806        // Since deviceDelta is delivered as pixels rather than degrees, we need to
     807        // convert from pixels to degrees in a sensible manner.
     808        // It looks like four degrees per pixel behaves most native.
     809        // Qt expects the unit for delta to be 1/8 of a degree:
     810        deltaX = [theEvent deviceDeltaX];
     811        deltaY = [theEvent deviceDeltaY];
     812        deltaZ = [theEvent deviceDeltaZ];
     813    } else {
     814        // carbonEventKind == kEventMouseWheelMoved
     815        // Remove acceleration, and use either -120 or 120 as delta:
     816        deltaX = qBound(-120, int([theEvent deltaX] * 10000), 120);
     817        deltaY = qBound(-120, int([theEvent deltaY] * 10000), 120);
     818        deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120);
     819    }
    748820
    749821    if (deltaX != 0) {
    750822        QWheelEvent qwe(qlocal, qglobal, deltaX, buttons, keyMods, Qt::Horizontal);
    751         qt_sendSpontaneousEvent(qwidget, &qwe);
     823        qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
    752824        wheelOK = qwe.isAccepted();
    753825        if (!wheelOK && QApplicationPrivate::focus_widget
    754             && QApplicationPrivate::focus_widget != qwidget) {
     826            && QApplicationPrivate::focus_widget != widgetToGetMouse) {
    755827            QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
    756828                             deltaX, buttons, keyMods, Qt::Horizontal);
     
    759831        }
    760832    }
    761    
     833
    762834    if (deltaY) {
    763835        QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical);
    764         qt_sendSpontaneousEvent(qwidget, &qwe);
     836        qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
    765837        wheelOK = qwe.isAccepted();
    766         if (wheelOK && QApplicationPrivate::focus_widget
    767             && QApplicationPrivate::focus_widget != qwidget) {
     838        if (!wheelOK && QApplicationPrivate::focus_widget
     839            && QApplicationPrivate::focus_widget != widgetToGetMouse) {
    768840            QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
    769                              deltaZ, buttons, keyMods, Qt::Vertical);
     841                             deltaY, buttons, keyMods, Qt::Vertical);
    770842            qt_sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
    771843            wheelOK = qwe2.isAccepted();
    772844        }
    773845    }
    774    
     846
    775847    if (deltaZ) {
    776848        // Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to
    777849        // try to be ahead of the pack, I'm adding this extra value.
    778850        QWheelEvent qwe(qlocal, qglobal, deltaZ, buttons, keyMods, (Qt::Orientation)3);
    779         qt_sendSpontaneousEvent(qwidget, &qwe);
     851        qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
    780852        wheelOK = qwe.isAccepted();
    781853        if (!wheelOK && QApplicationPrivate::focus_widget
    782             && QApplicationPrivate::focus_widget != qwidget) {
     854            && QApplicationPrivate::focus_widget != widgetToGetMouse) {
    783855            QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(qglobal), qglobal,
    784856                             deltaZ, buttons, keyMods, (Qt::Orientation)3);
     
    801873    if (!qt_mac_handleTabletEvent(self, tabletEvent))
    802874        [super tabletPoint:tabletEvent];
     875}
     876
     877#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
     878- (void)touchesBeganWithEvent:(NSEvent *)event;
     879{
     880    bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
     881    qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
     882}
     883
     884- (void)touchesMovedWithEvent:(NSEvent *)event;
     885{
     886    bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
     887    qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
     888}
     889
     890- (void)touchesEndedWithEvent:(NSEvent *)event;
     891{
     892    bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
     893    qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
     894}
     895
     896- (void)touchesCancelledWithEvent:(NSEvent *)event;
     897{
     898    bool all = qwidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
     899    qt_translateRawTouchEvent(qwidget, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
     900}
     901#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
     902
     903- (void)magnifyWithEvent:(NSEvent *)event;
     904{
     905    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
     906        return;
     907
     908    QNativeGestureEvent qNGEvent;
     909    qNGEvent.gestureType = QNativeGestureEvent::Zoom;
     910    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
     911    qNGEvent.position = flipPoint(p).toPoint();
     912    qNGEvent.percentage = [event magnification];
     913    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     914}
     915
     916- (void)rotateWithEvent:(NSEvent *)event;
     917{
     918    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
     919        return;
     920
     921    QNativeGestureEvent qNGEvent;
     922    qNGEvent.gestureType = QNativeGestureEvent::Rotate;
     923    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
     924    qNGEvent.position = flipPoint(p).toPoint();
     925    qNGEvent.percentage = -[event rotation];
     926    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     927}
     928
     929- (void)swipeWithEvent:(NSEvent *)event;
     930{
     931    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
     932        return;
     933
     934    QNativeGestureEvent qNGEvent;
     935    qNGEvent.gestureType = QNativeGestureEvent::Swipe;
     936    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
     937    qNGEvent.position = flipPoint(p).toPoint();
     938    if ([event deltaX] == 1)
     939        qNGEvent.angle = 180.0f;
     940    else if ([event deltaX] == -1)
     941        qNGEvent.angle = 0.0f;
     942    else if ([event deltaY] == 1)
     943        qNGEvent.angle = 90.0f;
     944    else if ([event deltaY] == -1)
     945        qNGEvent.angle = 270.0f;
     946    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     947}
     948
     949- (void)beginGestureWithEvent:(NSEvent *)event;
     950{
     951    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
     952        return;
     953
     954    QNativeGestureEvent qNGEvent;
     955    qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
     956    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
     957    qNGEvent.position = flipPoint(p).toPoint();
     958    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     959}
     960
     961- (void)endGestureWithEvent:(NSEvent *)event;
     962{
     963    if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
     964        return;
     965
     966    QNativeGestureEvent qNGEvent;
     967    qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
     968    NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
     969    qNGEvent.position = flipPoint(p).toPoint();
     970    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
    803971}
    804972
     
    8451013}
    8461014
     1015- (BOOL)resignFirstResponder
     1016{
     1017    // Seems like the following test only triggers if this
     1018    // view is inside a QMacNativeWidget:
     1019    if (qwidget == QApplication::focusWidget())
     1020        QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
     1021    return YES;
     1022}
     1023
    8471024- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
    8481025{
     
    8611038    Q_UNUSED(aPoint);
    8621039    qMacDnDParams()->performedAction = operation;
     1040    if (QDragManager::self()->object
     1041        && QDragManager::self()->dragPrivate()->executed_action != Qt::ActionMask) {
     1042        qMacDnDParams()->performedAction =
     1043                qt_mac_mapDropAction(QDragManager::self()->dragPrivate()->executed_action);
     1044    }
    8631045}
    8641046
     
    8961078    }
    8971079
    898     if (widgetToGetKey->testAttribute(Qt::WA_InputMethodEnabled)) {
     1080    if (widgetToGetKey->testAttribute(Qt::WA_InputMethodEnabled)
     1081            && !(widgetToGetKey->inputMethodHints() & Qt::ImhDigitsOnly
     1082                 || widgetToGetKey->inputMethodHints() & Qt::ImhFormattedNumbersOnly
     1083                 || widgetToGetKey->inputMethodHints() & Qt::ImhHiddenText)) {
    8991084        [qt_mac_nativeview_for(widgetToGetKey) interpretKeyEvents:[NSArray arrayWithObject: theEvent]];
    9001085    }
     
    9411126- (void) insertText:(id)aString
    9421127{
    943     if (composing) {
    944         // Send the commit string to the widget.
    945         QString commitText;
     1128    QString commitText;
     1129    if ([aString length]) {
    9461130        if ([aString isKindOfClass:[NSAttributedString class]]) {
    947            commitText = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
     1131            commitText = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
    9481132        } else {
    9491133            commitText = QCFString::toQString(reinterpret_cast<CFStringRef>(aString));
    9501134        };
     1135    }
     1136
     1137    if ([aString length] && composing) {
     1138        // Send the commit string to the widget.
    9511139        composing = false;
    9521140        sendKeyEvents = false;
     
    9541142        e.setCommitString(commitText);
    9551143        qt_sendSpontaneousEvent(qwidget, &e);
    956     }
     1144    } else {
     1145        // The key sequence "`q" on a French Keyboard will generate two calls to insertText before
     1146        // it returns from interpretKeyEvents. The first call will turn off 'composing' and accept
     1147        // the "`" key. The last keyDown event needs to be processed by the widget to get the
     1148        // character "q". The string parameter is ignored for the second call.
     1149        sendKeyEvents = true;
     1150    }
     1151
     1152    composingText->clear();
    9571153}
    9581154
     
    9761172            NSRange effectiveRange;
    9771173            NSRange range = NSMakeRange(index, composingLength-index);
    978             NSDictionary *attributes = [aString attributesAtIndex:index 
     1174            NSDictionary *attributes = [aString attributesAtIndex:index
    9791175                                            longestEffectiveRange:&effectiveRange
    9801176                                                          inRange:range];
     
    9851181                if (color) {
    9861182                    clr = colorFrom(color);
    987                 } 
     1183                }
    9881184                QTextCharFormat format;
    9891185                format.setFontUnderline(true);
     
    10081204                                            0, composingLength, format);
    10091205    }
     1206    *composingText = qtText;
    10101207    QInputMethodEvent e(qtText, attrs);
    10111208    qt_sendSpontaneousEvent(qwidget, &e);
     1209    if (!composingLength)
     1210        composing = false;
    10121211}
    10131212
    10141213- (void) unmarkText
    10151214{
     1215    if (composing) {
     1216        QInputMethodEvent e;
     1217        e.setCommitString(*composingText);
     1218        qt_sendSpontaneousEvent(qwidget, &e);
     1219    }
     1220    composingText->clear();
    10161221    composing = false;
    10171222}
     
    10521257- (NSRange) markedRange
    10531258{
    1054     NSRange range; 
     1259    NSRange range;
    10551260    if (composing) {
    10561261        range.location = 0;
     
    10771282    }
    10781283    return selRange;
    1079    
     1284
    10801285}
    10811286
     
    10831288{
    10841289    Q_UNUSED(theRange);
    1085     // The returned rect is always based on the internal cursor. 
     1290    // The returned rect is always based on the internal cursor.
    10861291    QRect mr(qwidget->inputMethodQuery(Qt::ImMicroFocus).toRect());
    10871292    QPoint mp(qwidget->mapToGlobal(QPoint(mr.bottomLeft())));
     
    11741379    if(!(GetCurrentEventButtonState() & kEventMouseButtonPrimary))
    11751380        return Qt::IgnoreAction;
    1176    
     1381
    11771382    if(object) {
    11781383        dragPrivate()->source->removeEventFilter(this);
     
    11801385        beingCancelled = false;
    11811386    }
    1182    
     1387
    11831388    object = o;
    11841389    dragPrivate()->target = 0;
     
    11921397    dragPrivate()->data->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray());
    11931398    dragBoard.setMimeData(dragPrivate()->data);
    1194    
     1399
    11951400    // create the image
    11961401    QPoint hotspot;
     
    12301435    NSImage *image = (NSImage *)qt_mac_create_nsimage(pix);
    12311436    [image retain];
    1232     DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
    1233     // save supported actions 
    1234     [dndParams->view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)];
    1235     NSPoint imageLoc = {dndParams->localPoint.x - hotspot.x(),
    1236                         dndParams->localPoint.y + pix.height() - hotspot.y()};
     1437    DnDParams dndParams = *[QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];
     1438    // save supported actions
     1439    [dndParams.view setSupportedActions: qt_mac_mapDropActions(dragPrivate()->possible_actions)];
     1440    NSPoint imageLoc = {dndParams.localPoint.x - hotspot.x(),
     1441                        dndParams.localPoint.y + pix.height() - hotspot.y()};
    12371442    NSSize mouseOffset = {0.0, 0.0};
    12381443    NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
    1239     NSPoint windowPoint = [dndParams->theEvent locationInWindow];
     1444    NSPoint windowPoint = [dndParams.theEvent locationInWindow];
     1445    dragPrivate()->executed_action = Qt::ActionMask;
    12401446    // do the drag
    1241     [dndParams->view retain];
    1242     [dndParams->view dragImage:image
     1447    [dndParams.view retain];
     1448    [dndParams.view dragImage:image
    12431449                            at:imageLoc
    12441450                        offset:mouseOffset
    1245                          event:dndParams->theEvent
     1451                         event:dndParams.theEvent
    12461452                    pasteboard:pboard
    1247                         source:dndParams->view
     1453                        source:dndParams.view
    12481454                     slideBack:YES];
    1249     [dndParams->view release];
     1455    // reset the implicit grab widget when drag ends because we will not
     1456    // receive the mouse release event when DND is active.
     1457    qt_button_down = 0;
     1458    [dndParams.view release];
    12501459    [image release];
     1460    dragPrivate()->executed_action = Qt::IgnoreAction;
    12511461    object = 0;
    1252     Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams->performedAction));
     1462    Qt::DropAction performedAction(qt_mac_mapNSDragOperation(qMacDnDParams()->performedAction));
    12531463    // do post drag processing, if required.
    12541464    if(performedAction != Qt::IgnoreAction) {
    1255         // check if the receiver points us to a file location. 
     1465        // check if the receiver points us to a file location.
    12561466        // if so, we need to do the file copy/move ourselves.
    12571467        QCFType<CFURLRef> pasteLocation = 0;
Note: See TracChangeset for help on using the changeset viewer.