src/gui/kernel/qcocoaview_mac.mm
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
child 30 5dc02b23752f
--- a/src/gui/kernel/qcocoaview_mac.mm	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/kernel/qcocoaview_mac.mm	Wed Mar 31 11:06:36 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -349,7 +349,9 @@
             // since we accepted the drag enter event, the widget expects
             // future drage move events.
             // ### check if we need to treat this like the drag enter event.
-            nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDEEvent.dropAction());
+            nsActions = NSDragOperationNone;
+            // Save as ignored in the answer rect.
+            qDMEvent.setDropAction(Qt::IgnoreAction);
         } else {
             nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction());
         }
@@ -357,7 +359,6 @@
         return nsActions;
     }
  }
-
 - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
 {
     NSPoint windowPoint = [sender draggingLocation];
@@ -402,13 +403,15 @@
     qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction);
     qDMEvent.accept();
     QApplication::sendEvent(qwidget, &qDMEvent);
-    qt_mac_copy_answer_rect(qDMEvent);
 
     NSDragOperation operation = qt_mac_mapDropAction(qDMEvent.dropAction());
     if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
         // ignore this event (we will still receive further notifications)
         operation = NSDragOperationNone;
+        // Save as ignored in the answer rect.
+        qDMEvent.setDropAction(Qt::IgnoreAction);
     }
+    qt_mac_copy_answer_rect(qDMEvent);
     return operation;
 }
 
@@ -505,15 +508,23 @@
     } else {
         [self setNeedsDisplay:YES];
     }
+
+    // Make sure the opengl context is updated on resize.
+    if (qwidgetprivate->isGLWidget) {
+        qwidgetprivate->needWindowChange = true;
+        QEvent event(QEvent::MacGLWindowChange);
+        qApp->sendEvent(qwidget, &event);
+    }
 }
 
 - (void)drawRect:(NSRect)aRect
 {
     if (QApplicationPrivate::graphicsSystem() != 0) {
-        if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore())
-            bs->markDirty(qwidget->rect(), qwidget);
-        qwidgetprivate->syncBackingStore(qwidget->rect());
-        return;
+        if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) {
+            // Drawing is handled on the window level
+            // See qcocoasharedwindowmethods_mac_p.
+            return;
+        }
     }
     CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
     qwidgetprivate->hd = cg;
@@ -634,6 +645,8 @@
 
 - (void)mouseEntered:(NSEvent *)event
 {
+    if (qwidgetprivate->data.in_destructor)
+        return;
     QEvent enterEvent(QEvent::Enter);
     NSPoint windowPoint = [event locationInWindow];
     NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint];
@@ -815,6 +828,7 @@
         deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120);
     }
 
+#ifndef QT_NO_WHEELEVENT
     if (deltaX != 0) {
         QWheelEvent qwe(qlocal, qglobal, deltaX, buttons, keyMods, Qt::Horizontal);
         qt_sendSpontaneousEvent(widgetToGetMouse, &qwe);
@@ -855,6 +869,8 @@
             wheelOK = qwe2.isAccepted();
         }
     }
+#endif //QT_NO_WHEELEVENT
+
     if (!wheelOK) {
         return [super scrollWheel:theEvent];
     }
@@ -1391,7 +1407,7 @@
 
     // setup the data
     QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacPasteboardMime::MIME_DND);
-    dragPrivate()->data->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray());
+    dragPrivate()->data->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
     dragBoard.setMimeData(dragPrivate()->data);
 
     // create the image