Clean-up a macro for Cocoa
authorMorten Sorvig <morten.sorvig@nokia.com>
Thu, 29 Sep 2011 12:29:05 +0000 (14:29 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 10 Oct 2011 05:47:58 +0000 (07:47 +0200)
Remove the usage of Q_MAC_USE_COCOA and Carbon code paths.

Change-Id: Ib569ad8c6d9ffe258f454b3c3b06e95294a10112
Reviewed-on: http://codereview.qt-project.org/5100
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Sanity-Review: Morten Johan Sørvig <morten.sorvig@nokia.com>

82 files changed:
doc/src/snippets/qmacnativewidget/main.mm
examples/mainwindows/macmainwindow/macmainwindow.h
examples/mainwindows/macmainwindow/macmainwindow.mm
src/corelib/global/qglobal.h
src/gui/painting/qregion.h
src/gui/painting/qtextureglyphcache.cpp
src/gui/text/qtextengine.cpp
src/gui/text/qtextlayout.cpp
src/opengl/qgl_p.h
src/printsupport/dialogs/qpagesetupdialog_mac.mm
src/printsupport/dialogs/qprintdialog_mac.mm
src/printsupport/dialogs/qprintpreviewdialog.cpp
src/testlib/qtestcase.cpp
src/testlib/qtestmouse.h
src/widgets/dialogs/qfiledialog.cpp
src/widgets/dialogs/qfiledialog_mac.mm
src/widgets/dialogs/qfiledialog_p.h
src/widgets/dialogs/qfontdialog_mac.mm
src/widgets/kernel/qapplication.cpp
src/widgets/kernel/qapplication_p.h
src/widgets/kernel/qgesturemanager.cpp
src/widgets/kernel/qwidget.cpp
src/widgets/kernel/qwidget_p.h
src/widgets/platforms/mac/qapplication_mac.mm
src/widgets/platforms/mac/qclipboard_mac.cpp
src/widgets/platforms/mac/qcocoaintrospection_mac.mm
src/widgets/platforms/mac/qcocoapanel_mac.mm
src/widgets/platforms/mac/qcocoapanel_mac_p.h
src/widgets/platforms/mac/qcocoaview_mac.mm
src/widgets/platforms/mac/qcocoaview_mac_p.h
src/widgets/platforms/mac/qcocoawindow_mac.mm
src/widgets/platforms/mac/qcocoawindow_mac_p.h
src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm
src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm
src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h
src/widgets/platforms/mac/qcursor_mac.mm
src/widgets/platforms/mac/qdnd_mac.mm
src/widgets/platforms/mac/qeventdispatcher_mac.mm
src/widgets/platforms/mac/qeventdispatcher_mac_p.h
src/widgets/platforms/mac/qfont_mac.cpp
src/widgets/platforms/mac/qfontdatabase_mac.cpp
src/widgets/platforms/mac/qfontengine_mac.mm
src/widgets/platforms/mac/qfontengine_mac_p.h
src/widgets/platforms/mac/qkeymapper_mac.cpp
src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm
src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h
src/widgets/platforms/mac/qmacinputcontext_mac.cpp
src/widgets/platforms/mac/qpaintengine_mac.cpp
src/widgets/platforms/mac/qpixmap_mac.cpp
src/widgets/platforms/mac/qprintengine_mac.mm
src/widgets/platforms/mac/qprintengine_mac_p.h
src/widgets/platforms/mac/qregion_mac.cpp
src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm
src/widgets/platforms/mac/qt_mac.cpp
src/widgets/platforms/mac/qt_mac_p.h
src/widgets/platforms/mac/qtextengine_mac.cpp
src/widgets/platforms/mac/qwidget_mac.mm
src/widgets/styles/qmacstyle_mac.mm
src/widgets/util/qcompleter.cpp
src/widgets/util/qsystemtrayicon_mac.mm
src/widgets/widgets/qcocoatoolbardelegate_mac.mm
src/widgets/widgets/qcocoatoolbardelegate_mac_p.h
src/widgets/widgets/qdockarealayout.cpp
src/widgets/widgets/qdockwidget.cpp
src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
src/widgets/widgets/qmainwindow.cpp
src/widgets/widgets/qmainwindowlayout_mac.mm
src/widgets/widgets/qmainwindowlayout_p.h
src/widgets/widgets/qtabbar.cpp
src/widgets/widgets/qtoolbar.cpp
src/widgets/widgets/qtoolbarlayout.cpp
tests/auto/gui/painting/qpainter/tst_qpainter.cpp
tests/auto/gui/text/qrawfont/tst_qrawfont.cpp
tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp
tests/auto/macnativeevents/tst_macnativeevents.cpp
tests/auto/qaccessibility_mac/tst_qaccessibility_mac.cpp
tests/auto/qfiledialog/tst_qfiledialog.cpp
tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
tests/auto/qgraphicsview/tst_qgraphicsview.cpp
tests/auto/qwidget/tst_qwidget.cpp
tests/auto/qwidget/tst_qwidget_mac_helpers.h
tests/auto/qwidget/tst_qwidget_mac_helpers.mm

index a57dc19..f83adef 100644 (file)
 
 #include <QtGui/QtGui>
 #include <QtGui/qmacnativewidget_mac.h>
-#ifdef QT_MAC_USE_COCOA
 #import <Cocoa/Cocoa.h>
-#else
-#include <Carbon/Carbon.h>
-#endif
 
 int main(int argc, char **argv)
 {
     QApplication app(argc, argv);
-#ifdef QT_MAC_USE_COCOA
 //![0]
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(200, app.desktop()->height() - 200, 239, 200)
@@ -85,50 +80,5 @@ int main(int argc, char **argv)
     [window makeKeyAndOrderFront:window];
     [pool release];
 //![0]
-#else
-//![1]
-    Rect contentRect;
-    SetRect(&contentRect, 200, 200, 400, 400);
-    HIWindowRef windowRef;
-    CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowCompositingAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute, &contentRect, &windowRef);
-    HIViewRef contentView = 0;
-    GetRootControl(windowRef, &contentView);
-
-    QMacNativeWidget *nativeWidget = new QMacNativeWidget();
-    nativeWidget->move(0, 0);
-    nativeWidget->setPalette(QPalette(Qt::red));
-    nativeWidget->setAutoFillBackground(true);
-    QVBoxLayout *layout = new QVBoxLayout();
-    QPushButton *pushButton = new QPushButton("An Embedded Qt Button!", nativeWidget);
-    pushButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // Don't use the layout rect calculated from QMacStyle.
-    layout->addWidget(pushButton);
-    nativeWidget->setLayout(layout);
-    HIViewRef nativeWidgetView = reinterpret_cast<HIViewRef>(nativeWidget->winId());
-    // Add the nativeWidget to the window.
-    HIViewAddSubview(contentView, nativeWidgetView);
-
-    // Adjust Carbon layouts
-    HILayoutInfo layoutInfo;
-    layoutInfo.version = kHILayoutInfoVersionZero;
-    HIViewGetLayoutInfo(nativeWidgetView, &layoutInfo);
-
-    layoutInfo.binding.top.toView = contentView;
-    layoutInfo.binding.top.kind = kHILayoutBindTop;
-    layoutInfo.binding.left.toView = contentView;
-    layoutInfo.binding.left.kind = kHILayoutBindLeft;
-    layoutInfo.binding.right.toView = contentView;
-    layoutInfo.binding.right.kind = kHILayoutBindRight;
-    layoutInfo.binding.bottom.toView = contentView;
-    layoutInfo.binding.bottom.kind = kHILayoutBindBottom;
-
-    HIViewSetLayoutInfo(nativeWidgetView, &layoutInfo);
-    HIViewApplyLayout(nativeWidgetView);
-
-    pushButton->show();
-    nativeWidget->show();
-    // Show the window.
-    ShowWindow(windowRef);
-//![1]
-#endif
     return app.exec(); // gives us the same behavior in both
 }
index d6f8b4c..6be3465 100644 (file)
@@ -47,7 +47,6 @@
 
 #import <qmaccocoaviewcontainer_mac.h>
 
-#ifdef QT_MAC_USE_COCOA
 class SearchWidget : public QMacCocoaViewContainer
 {
     Q_OBJECT
@@ -59,24 +58,6 @@ public:
 private:
 };
 
-#else
-#include <Carbon/Carbon.h>
-
-// The SearchWidget class wraps a native HISearchField.
-class SearchWidget : public QWidget
-{
-    Q_OBJECT
-private:
-    HIViewRef searchField;
-    CFStringRef searchFieldText;
-
-public:
-    QSize sizeHint() const;
-    SearchWidget(QWidget *parent = 0);
-    ~SearchWidget();
-};
-
-#endif
 
 QMenu *createMenu(QWidget *parent);
 
index 3b0ba6f..4ad0134 100644 (file)
@@ -47,7 +47,6 @@
 
 #include <Carbon/Carbon.h>
 
-#ifdef QT_MAC_USE_COCOA
 
 //![0]
 SearchWidget::SearchWidget(QWidget *parent)
@@ -84,56 +83,6 @@ QSize SearchWidget::sizeHint() const
     return QSize(150, 40);
 }
 
-#else
-
-// The SearchWidget class wraps a native HISearchField.
-SearchWidget::SearchWidget(QWidget *parent)
-    :QWidget(parent)
-{
-
-    // Create a native search field and pass its window id to QWidget::create.
-    searchFieldText = CFStringCreateWithCString(0, "search", 0);
-    HISearchFieldCreate(NULL/*bounds*/, kHISearchFieldAttributesSearchIcon | kHISearchFieldAttributesCancel,
-                        NULL/*menu ref*/, searchFieldText, &searchField);
-    create(reinterpret_cast<WId>(searchField));
-
-    // Use a Qt menu for the search field menu.
-    QMenu *searchMenu = createMenu(this);
-    MenuRef menuRef = searchMenu->macMenu(0);
-    HISearchFieldSetSearchMenu(searchField, menuRef);
-    setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
-}
-
-SearchWidget::~SearchWidget()
-{
-    CFRelease(searchField);
-    CFRelease(searchFieldText);
-}
-
-// Get the size hint from the search field.
-QSize SearchWidget::sizeHint() const
-{
-    EventRef event;
-    HIRect optimalBounds;
-    CreateEvent(0, kEventClassControl,
-        kEventControlGetOptimalBounds,
-        GetCurrentEventTime(),
-        kEventAttributeUserEvent, &event);
-
-    SendEventToEventTargetWithOptions(event,
-        HIObjectGetEventTarget(HIObjectRef(winId())),
-        kEventTargetDontPropagate);
-
-    GetEventParameter(event,
-        kEventParamControlOptimalBounds, typeHIRect,
-        0, sizeof(HIRect), 0, &optimalBounds);
-
-    ReleaseEvent(event);
-    return QSize(optimalBounds.size.width + 100, // make it a bit wider.
-                 optimalBounds.size.height);
-}
-
-#endif
 
 QMenu *createMenu(QWidget *parent)
 {
index 228c9a3..b079e31 100644 (file)
@@ -298,10 +298,6 @@ namespace QT_NAMESPACE {}
 #  endif
 #endif
 
-#if defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) && !defined(QT_BOOTSTRAPPED)
-#error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration."
-#endif
-
 #if defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN)
 #  undef Q_OS_UNIX
 #elif !defined(Q_OS_UNIX)
@@ -2740,7 +2736,6 @@ QT_LICENSED_MODULE(Sensors)
 #endif
 
 #if !(defined(Q_WS_WIN) && !defined(Q_WS_WINCE)) \
-    && !(defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) \
     && !(defined(Q_WS_X11) && !defined(QT_NO_FREETYPE)) \
     && !(defined(Q_WS_QPA))
 #  define QT_NO_RAWFONT
index 75d29e1..d1ec9c6 100644 (file)
@@ -152,13 +152,8 @@ public:
     RgnHandle toQDRgnForUpdate_sys() const;
     static QRegion fromQDRgn(RgnHandle shape);
 #endif
-#ifdef QT_MAC_USE_COCOA
     inline HIMutableShapeRef handle(bool unused = false) const
     { Q_UNUSED(unused); return toHIMutableShape(); }
-#else
-    inline RgnHandle handle() const { return handle(false); }
-    inline RgnHandle handle(bool) const { return toQDRgn(); }
-#endif
     HIMutableShapeRef toHIMutableShape() const;
     static QRegion fromHIShapeRef(HIShapeRef shape);
 #elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
@@ -201,8 +196,6 @@ Q_GUI_EXPORT
 #elif defined(Q_WS_X11)
         Region rgn;
         void *xrectangles;
-#elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-        mutable RgnHandle unused; // Here for binary compatibility reasons. ### Qt 5 remove.
 #endif
 #if defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
         QRegionPrivate *qt_rgn;
index 665efe0..0f9a82c 100644 (file)
@@ -367,7 +367,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
 
 int QImageTextureGlyphCache::glyphMargin() const
 {
-#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11)
+#if defined(Q_WS_MAC) || defined(Q_WS_X11)
     return 0;
 #else
     return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
index 93c9e1e..416a219 100644 (file)
@@ -1489,12 +1489,8 @@ void QTextEngine::itemize() const
     int length = layoutData->string.length();
     if (!length)
         return;
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    // ATSUI requires RTL flags to correctly identify the character stops.
-    bool ignore = false;
-#else
+
     bool ignore = ignoreBidi;
-#endif
 
     bool rtl = isRightToLeft();
 
index e1bbca6..8a77b07 100644 (file)
@@ -1290,7 +1290,7 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
                               && (p->transform().type() > QTransform::TxTranslate);
     if (toggleAntialiasing)
         p->setRenderHint(QPainter::Antialiasing);
-#if defined(QT_MAC_USE_COCOA)
+#ifdef Q_WS_MAC
     // Always draw the cursor aligned to pixel boundary.
     x = qRound(x);
 #endif
index 668728b..148cd68 100644 (file)
@@ -78,9 +78,6 @@ class QPixmap;
 #   undef qDebug
 # endif
 QT_BEGIN_INCLUDE_NAMESPACE
-#ifndef QT_MAC_USE_COCOA
-# include <AGL/agl.h>
-#endif
 QT_END_INCLUDE_NAMESPACE
 # ifdef old_qDebug
 #   undef qDebug
index 7255201..0bbdbcc 100644 (file)
@@ -96,110 +96,19 @@ class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate
 
 public:
     QPageSetupDialogPrivate() : ep(0)
-#ifndef QT_MAC_USE_COCOA
-    ,upp(0)
-#else
     ,pageLayout(0)
-#endif
     {}
 
     ~QPageSetupDialogPrivate() {
-#ifndef QT_MAC_USE_COCOA
-        if (upp) {
-            DisposePMSheetDoneUPP(upp);
-            upp = 0;
-        }
-        QHash<PMPrintSession, QPageSetupDialogPrivate *>::iterator it = sheetCallbackMap.begin();
-        while (it != sheetCallbackMap.end()) {
-            if (it.value() == this) {
-                it = sheetCallbackMap.erase(it);
-            } else {
-                ++it;
-            }
-        }
-#endif
     }
 
-#ifndef QT_MAC_USE_COCOA
-    void openCarbonPageLayout(Qt::WindowModality modality);
-    void closeCarbonPageLayout();
-    static void pageSetupDialogSheetDoneCallback(PMPrintSession printSession, WindowRef /*documentWindow*/, Boolean accepted) {
-        QPageSetupDialogPrivate *priv = sheetCallbackMap.value(printSession);
-        if (!priv) {
-            qWarning("%s:%d: QPageSetupDialog::exec: Could not retrieve data structure, "
-                     "you most likely now have an infinite modal loop", __FILE__, __LINE__);
-            return;
-        }
-        priv->q_func()->done(accepted ? QDialog::Accepted : QDialog::Rejected);
-    }
-#else
     void openCocoaPageLayout(Qt::WindowModality modality);
     void closeCocoaPageLayout();
-#endif
 
     QMacPrintEnginePrivate *ep;
-#ifndef QT_MAC_USE_COCOA
-    PMSheetDoneUPP upp;
-    static QHash<PMPrintSession, QPageSetupDialogPrivate*> sheetCallbackMap;
-#else
     NSPageLayout *pageLayout;
-#endif
 };
 
-#ifndef QT_MAC_USE_COCOA
-QHash<PMPrintSession, QPageSetupDialogPrivate*> QPageSetupDialogPrivate::sheetCallbackMap;
-void QPageSetupDialogPrivate::openCarbonPageLayout(Qt::WindowModality modality)
-{
-    Q_Q(QPageSetupDialog);
-    // If someone is reusing a QPrinter object, the end released all our old
-    // information. In this case, we must reinitialize.
-    if (ep->session == 0)
-        ep->initialize();
-
-    sheetCallbackMap.insert(ep->session, this);
-    if (modality == Qt::ApplicationModal) {
-       QWidget modal_widg(0, Qt::Window);
-        modal_widg.setObjectName(QLatin1String(__FILE__ "__modal_dlg"));
-        modal_widg.createWinId();
-       QApplicationPrivate::enterModal(&modal_widg);
-        QApplicationPrivate::native_modal_dialog_active = true;
-        Boolean accepted;
-        PMSessionPageSetupDialog(ep->session, ep->format, &accepted);
-       QApplicationPrivate::leaveModal(&modal_widg);
-        QApplicationPrivate::native_modal_dialog_active = false;
-        pageSetupDialogSheetDoneCallback(ep->session, 0, accepted);
-    } else {
-        // Window Modal means that we use a sheet at the moment, there's no other way to do it correctly.
-        if (!upp)
-            upp = NewPMSheetDoneUPP(QPageSetupDialogPrivate::pageSetupDialogSheetDoneCallback);
-        PMSessionUseSheets(ep->session, qt_mac_window_for(q->parentWidget()), upp);
-        Boolean unused;
-        PMSessionPageSetupDialog(ep->session, ep->format, &unused);
-    }
-}
-
-void QPageSetupDialogPrivate::closeCarbonPageLayout()
-{
-    // if the margins have changed, we have to use the margins from the new
-    // PMFormat object
-    if (q_func()->result() == QDialog::Accepted) {
-        PMPaper paper;
-        PMPaperMargins margins;
-        PMGetPageFormatPaper(ep->format, &paper);
-        PMPaperGetMargins(paper, &margins);
-        ep->leftMargin = margins.left;
-        ep->topMargin = margins.top;
-        ep->rightMargin = margins.right;
-        ep->bottomMargin = margins.bottom;
-
-       PMRect paperRect;
-       PMGetUnadjustedPaperRect(ep->format, &paperRect);
-       ep->customSize = QSizeF(paperRect.right - paperRect.left,
-                               paperRect.bottom - paperRect.top);
-    }
-    sheetCallbackMap.remove(ep->session);
-}
-#else
 void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality)
 {
     Q_Q(QPageSetupDialog);
@@ -240,7 +149,6 @@ void QPageSetupDialogPrivate::closeCocoaPageLayout()
     [pageLayout release];
     pageLayout = 0;
 }
-#endif
 
 QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
     : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
@@ -263,32 +171,19 @@ void QPageSetupDialog::setVisible(bool visible)
     if (d->printer->outputFormat() != QPrinter::NativeFormat)
         return;
 
-#ifndef QT_MAC_USE_COCOA
-    bool isCurrentlyVisible = d->sheetCallbackMap.contains(d->ep->session);
-#else
     bool isCurrentlyVisible = (d->pageLayout != 0);
-#endif
     if (!visible == !isCurrentlyVisible)
         return;
 
     if (visible) {
-#ifndef QT_MAC_USE_COCOA
-        d->openCarbonPageLayout(parentWidget() ? Qt::WindowModal
-                                               : Qt::ApplicationModal);
-#else
         d->openCocoaPageLayout(parentWidget() ? Qt::WindowModal
                                               : Qt::ApplicationModal);
-#endif
         return;
     } else {
-#ifndef QT_MAC_USE_COCOA
-        d->closeCarbonPageLayout();
-#else
         if (d->pageLayout) {
             d->closeCocoaPageLayout();
             return;
         }
-#endif
     }
 }
 
@@ -299,14 +194,9 @@ int QPageSetupDialog::exec()
     if (d->printer->outputFormat() != QPrinter::NativeFormat)
         return Rejected;
 
-#ifndef QT_MAC_USE_COCOA
-    d->openCarbonPageLayout(Qt::ApplicationModal);
-    d->closeCarbonPageLayout();
-#else
     QMacCocoaAutoReleasePool pool;
     d->openCocoaPageLayout(Qt::ApplicationModal);
     d->closeCocoaPageLayout();
-#endif
     return result();
 }
 
index cb95f6b..b1f211f 100644 (file)
@@ -57,44 +57,10 @@ class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
 
 public:
     QPrintDialogPrivate() : ep(0), printPanel(0)
-#ifndef QT_MAC_USE_COCOA
-       ,upp(0)
-#endif
        {}
-#ifndef QT_MAC_USE_COCOA
-    ~QPrintDialogPrivate() {
-        if (upp) {
-            DisposePMSheetDoneUPP(upp);
-            upp = 0;
-        }
-        QHash<PMPrintSession, QPrintDialogPrivate *>::iterator it = sheetCallbackMap.begin();
-        while (it != sheetCallbackMap.end()) {
-            if (it.value() == this) {
-                it = sheetCallbackMap.erase(it);
-            } else {
-                ++it;
-            }
-        }
-    }
-#endif
 
-#ifndef QT_MAC_USE_COCOA
-    void openCarbonPrintPanel(Qt::WindowModality modality);
-    void closeCarbonPrintPanel();
-    static void printDialogSheetDoneCallback(PMPrintSession printSession, WindowRef /*documentWindow*/, Boolean accepted) {
-        QPrintDialogPrivate *priv = sheetCallbackMap.value(printSession);
-        if (!priv) {
-            qWarning("%s:%d: QPrintDialog::exec: Could not retrieve data structure, "
-                     "you most likely now have an infinite loop", __FILE__, __LINE__);
-            return;
-        }
-        priv->q_func()->done(accepted ? QDialog::Accepted : QDialog::Rejected);
-        priv->closeCarbonPrintPanel();
-    }
-#else
     void openCocoaPrintPanel(Qt::WindowModality modality);
     void closeCocoaPrintPanel();
-#endif
     void initBeforeRun();
 
     inline QPrintDialog *printDialog() { return q_func(); }
@@ -112,17 +78,12 @@ public:
 
     QMacPrintEnginePrivate *ep;
     NSPrintPanel *printPanel;
-#ifndef QT_MAC_USE_COCOA
-    PMSheetDoneUPP upp;
-    static QHash<PMPrintSession, QPrintDialogPrivate *> sheetCallbackMap;
-#endif
 };
 
 QT_END_NAMESPACE
 
 QT_USE_NAMESPACE
 
-#ifdef QT_MAC_USE_COCOA
 
 @class QT_MANGLE_NAMESPACE(QCocoaPrintPanelDelegate);
 
@@ -190,7 +151,6 @@ QT_USE_NAMESPACE
 }
 @end
 
-#endif
 
 QT_BEGIN_NAMESPACE
 
@@ -218,76 +178,6 @@ void QPrintDialogPrivate::initBeforeRun()
     }
 }
 
-#ifndef QT_MAC_USE_COCOA
-QHash<PMPrintSession, QPrintDialogPrivate *> QPrintDialogPrivate::sheetCallbackMap;
-void QPrintDialogPrivate::openCarbonPrintPanel(Qt::WindowModality modality)
-{
-    Q_Q(QPrintDialog);
-    initBeforeRun();
-    sheetCallbackMap.insert(ep->session, this);
-    if (modality == Qt::ApplicationModal) {
-        QWidget modal_widg(0, Qt::Window);
-        modal_widg.setObjectName(QLatin1String(__FILE__ "__modal_dlg"));
-        modal_widg.createWinId();
-        QApplicationPrivate::enterModal(&modal_widg);
-        QApplicationPrivate::native_modal_dialog_active = true;
-        Boolean acceptStatus;
-        PMSessionPrintDialog(ep->session, ep->settings, ep->format, &acceptStatus);
-        QApplicationPrivate::leaveModal(&modal_widg);
-        QApplicationPrivate::native_modal_dialog_active = false;
-        printDialogSheetDoneCallback(ep->session, 0, acceptStatus);
-    } else {
-        // Window Modal means that we use a sheet at the moment, there's no other way to do it correctly.
-        if (!upp)
-            upp = NewPMSheetDoneUPP(QPrintDialogPrivate::printDialogSheetDoneCallback);
-        PMSessionUseSheets(ep->session, qt_mac_window_for(q->parentWidget()), upp);
-        QApplicationPrivate::native_modal_dialog_active = true;
-        Boolean unused;
-        PMSessionPrintDialog(ep->session, ep->settings, ep->format, &unused);
-    }
-}
-
-void QPrintDialogPrivate::closeCarbonPrintPanel()
-{
-    Q_Q(QPrintDialog);
-    QApplicationPrivate::native_modal_dialog_active = false;
-    if (q->result() == QDialog::Accepted) {
-        UInt32 frompage, topage;
-        PMGetFirstPage(ep->settings, &frompage);
-        PMGetLastPage(ep->settings, &topage);
-        topage = qMin(UInt32(INT_MAX), topage);
-        q->setFromTo(frompage, topage);
-
-        // OK, I need to map these values back let's see
-        // If from is 1 and to is INT_MAX, then print it all
-        // (Apologies to the folks with more than INT_MAX pages)
-        // ...that's a joke.
-        if (q->fromPage() == 1 && q->toPage() == INT_MAX) {
-            q->setPrintRange(QAbstractPrintDialog::AllPages);
-            q->setFromTo(0,0);
-        } else {
-            q->setPrintRange(QAbstractPrintDialog::PageRange); // In a way a lie, but it shouldn't hurt.
-            // Carbon hands us back a very large number here even for ALL, set it to max
-            // in that case to follow the behavior of the other print dialogs.
-            if (q->maxPage() < q->toPage())
-                q->setFromTo(q->fromPage(), q->maxPage());
-        }
-        // Keep us in sync with file output
-        PMDestinationType dest;
-        PMSessionGetDestinationType(ep->session, ep->settings, &dest);
-        if (dest == kPMDestinationFile) {
-            QCFType<CFURLRef> file;
-            PMSessionCopyDestinationLocation(ep->session, ep->settings, &file);
-            UInt8 localFile[2048];  // Assuming there's a POSIX file system here.
-            CFURLGetFileSystemRepresentation(file, true, localFile, sizeof(localFile));
-            ep->outputFilename = QString::fromUtf8(reinterpret_cast<const char *>(localFile));
-        } else {
-            ep->outputFilename = QString();
-        }
-    }
-    sheetCallbackMap.remove(ep->session);
-}
-#else
 void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
 {
     Q_Q(QPrintDialog);
@@ -327,7 +217,6 @@ void QPrintDialogPrivate::closeCocoaPrintPanel()
 {
     // ###
 }
-#endif
 
 static bool warnIfNotNative(QPrinter *printer)
 {
@@ -367,14 +256,10 @@ int QPrintDialog::exec()
     if (!warnIfNotNative(d->printer))
         return QDialog::Rejected;
 
-#ifndef QT_MAC_USE_COCOA
-    d->openCarbonPrintPanel(Qt::ApplicationModal);
-#else
     QMacCocoaAutoReleasePool pool;
 
     d->openCocoaPrintPanel(Qt::ApplicationModal);
     d->closeCocoaPrintPanel();
-#endif
     return result();
 }
 
@@ -395,21 +280,12 @@ void QPrintDialog::setVisible(bool visible)
         return;
 
     if (visible) {
-#ifndef QT_MAC_USE_COCOA
-        d->openCarbonPrintPanel(parentWidget() ? Qt::WindowModal
-                                               : Qt::ApplicationModal);
-#else
         d->openCocoaPrintPanel(parentWidget() ? Qt::WindowModal
                                               : Qt::ApplicationModal);
-#endif
         return;
     } else {
         if (d->printPanel) {
-#ifndef QT_MAC_USE_COCOA
-            d->closeCarbonPrintPanel();
-#else
             d->closeCocoaPrintPanel();
-#endif
             return;
         }
     }
index 886ba84..90e29ac 100644 (file)
@@ -208,9 +208,6 @@ public:
     QActionGroup *printerGroup;
     QAction *printAction;
     QAction *pageSetupAction;
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    QAction *closeAction;
-#endif
 
     QPointer<QObject> receiverToDisconnectOnClose;
     QByteArray memberToDisconnectOnClose;
@@ -304,9 +301,6 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
     toolbar->addSeparator();
     toolbar->addAction(pageSetupAction);
     toolbar->addAction(printAction);
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    toolbar->addAction(closeAction);
-#endif
 
     // Cannot use the actions' triggered signal here, since it doesn't autorepeat
     QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction));
@@ -426,10 +420,6 @@ void QPrintPreviewDialogPrivate::setupActions()
     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close"));
-    QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject()));
-#endif
 
     // Initial state:
     fitPageAction->setChecked(true);
index 1178b50..41bdd9b 100644 (file)
 
 #ifdef Q_WS_MAC
 #include <Carbon/Carbon.h> // for SetFrontProcess
-#ifdef QT_MAC_USE_COCOA
 #include <IOKit/pwr_mgt/IOPMLib.h>
-#else
-#include <Security/AuthSession.h>
-#endif
 #undef verify
 #endif
 
@@ -1797,10 +1793,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
 
 #ifdef Q_WS_MAC
     bool macNeedsActivate = qApp && (qstrcmp(qApp->metaObject()->className(), "QApplication") == 0);
-#ifdef QT_MAC_USE_COCOA
     IOPMAssertionID powerID;
 #endif
-#endif
 #ifndef QT_NO_EXCEPTIONS
     try {
 #endif
@@ -1816,13 +1810,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
     if (macNeedsActivate) {
         ProcessSerialNumber psn = { 0, kCurrentProcess };
         SetFrontProcess(&psn);
-#ifdef QT_MAC_USE_COCOA
         IOReturn ok = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &powerID);
         if (ok != kIOReturnSuccess)
             macNeedsActivate = false; // no need to release the assertion on exit.
-#else
-        UpdateSystemActivity(1); // Wake the display.
-#endif
     }
 #endif
 
@@ -1873,7 +1863,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
          }
 
         QTestLog::stopLogging();
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
          if (macNeedsActivate) {
              IOPMAssertionRelease(powerID);
          }
@@ -1887,7 +1877,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
 #endif
 
     currentTestObject = 0;
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
      if (macNeedsActivate) {
          IOPMAssertionRelease(powerID);
      }
index dd6d632..7a928a0 100644 (file)
@@ -117,7 +117,7 @@ namespace QTest
             case MouseMove:
                 QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton);
                 //QCursor::setPos(window->mapToGlobal(pos));
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_OS_MAC
                 QTest::qWait(20);
 #else
                 qApp->processEvents();
@@ -183,7 +183,7 @@ namespace QTest
                 break;
             case MouseMove:
                 QCursor::setPos(widget->mapToGlobal(pos));
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_OS_MAC
                 QTest::qWait(20);
 #else
                 qApp->processEvents();
index 2a402f5..c74d56d 100644 (file)
@@ -517,11 +517,6 @@ QFileDialogPrivate::QFileDialogPrivate()
         nativeDialogInUse(false),
 #ifdef Q_WS_MAC
         mDelegate(0),
-#ifndef QT_MAC_USE_COCOA
-        mDialog(0),
-        mDialogStarted(false),
-        mDialogClosed(true),
-#endif
 #endif
         qFileDialogUi(0)
 {
index 885ce77..62654f5 100644 (file)
@@ -276,11 +276,7 @@ QT_USE_NAMESPACE
     [mSavePanel 
         beginSheetForDirectory:mCurrentDir
         file:selectable ? filename : nil
-#ifdef QT_MAC_USE_COCOA
         modalForWindow:QT_PREPEND_NAMESPACE(qt_mac_window_for)(docWidget)
-#else
-        modalForWindow:nil
-#endif
         modalDelegate:self
         didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
         contextInfo:nil];
@@ -558,34 +554,16 @@ extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding
 
 void QFileDialogPrivate::setDirectory_sys(const QString &directory)
 {
-#ifndef QT_MAC_USE_COCOA
-    if (directory == mCurrentLocation)
-        return;
-    mCurrentLocation = directory;
-    emit q_func()->directoryEntered(mCurrentLocation);
-
-    FSRef fsRef;
-    if (qt_mac_create_fsref(directory, &fsRef) == noErr) {
-        AEDesc desc;
-        if (AECreateDesc(typeFSRef, &fsRef, sizeof(FSRef), &desc) == noErr)
-            NavCustomControl(mDialog, kNavCtlSetLocation, (void*)&desc);
-    }
-#else
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
     [delegate->mSavePanel setDirectory:qt_mac_QStringToNSString(directory)];
-#endif
 }
 
 QString QFileDialogPrivate::directory_sys() const
 {
-#ifndef QT_MAC_USE_COCOA
-    return mCurrentLocation;
-#else
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
     return qt_mac_NSStringToQString([delegate->mSavePanel directory]);
-#endif
 }
 
 void QFileDialogPrivate::selectFile_sys(const QString &filename)
@@ -594,73 +572,28 @@ void QFileDialogPrivate::selectFile_sys(const QString &filename)
     if (QDir::isRelativePath(filePath))
         filePath = QFileInfo(directory_sys(), filePath).filePath();
 
-#ifndef QT_MAC_USE_COCOA
-    // Update the selection list immidiatly, so
-    // subsequent calls to selectedFiles() gets correct:
-    mCurrentSelectionList.clear();
-    mCurrentSelectionList << filename;
-    if (mCurrentSelection != filename){
-        mCurrentSelection = filename;
-        emit q_func()->currentChanged(mCurrentSelection);
-    }
-
-    AEDescList descList;
-    if (AECreateList(0, 0, false, &descList) != noErr)
-        return;
-
-    FSRef fsRef;
-    if (qt_mac_create_fsref(filePath, &fsRef) == noErr) {
-        AEDesc desc;
-        if (AECreateDesc(typeFSRef, &fsRef, sizeof(FSRef), &desc) == noErr){
-            if (AEPutDesc(&descList, 0, &desc) == noErr)
-                NavCustomControl(mDialog, kNavCtlSetSelection, (void*)&descList);
-        }
-    }
-
-    // Type the file name into the save dialog's text field:
-    UInt8 *strBuffer = (UInt8 *)malloc(1024);
-    qt_mac_to_pascal_string(QFileInfo(filename).fileName(), strBuffer);
-    NavCustomControl(mDialog, kNavCtlSetEditFileName, strBuffer);
-    free(strBuffer);
-#else
     // There seems to no way to select a file once the dialog is running.
     // So do the next best thing, set the file's directory:
     setDirectory_sys(QFileInfo(filePath).absolutePath());
-#endif
 }
 
 QStringList QFileDialogPrivate::selectedFiles_sys() const
 {
-#ifndef QT_MAC_USE_COCOA
-    if (q_func()->acceptMode() == QFileDialog::AcceptOpen){
-        return mCurrentSelectionList;
-    } else {
-        return QStringList() << mCurrentLocation + QLatin1Char('/')
-                                + QCFString::toQString(NavDialogGetSaveFileName(mDialog));
-    }
-#else
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
     return [delegate selectedFiles];
-#endif
 }
 
 void QFileDialogPrivate::setNameFilters_sys(const QStringList &filters)
 {
-#ifndef QT_MAC_USE_COCOA
-    Q_UNUSED(filters);
-#else
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
     bool hideDetails = q_func()->testOption(QFileDialog::HideNameFilterDetails);
     [delegate setNameFilters:filters hideDetails:hideDetails];
-#endif
 }
 
 void QFileDialogPrivate::setFilter_sys()
 {
-#ifndef QT_MAC_USE_COCOA
-#else
     Q_Q(QFileDialog);
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
@@ -672,51 +605,32 @@ void QFileDialogPrivate::setFilter_sys()
         [delegate->mSavePanel setNameFieldLabel:[delegate strip:qFileDialogUi->fileNameLabel->text()]];
 
     [delegate updateProperties];
-#endif
 }
 
 void QFileDialogPrivate::selectNameFilter_sys(const QString &filter)
 {
     int index = nameFilters.indexOf(filter);
     if (index != -1) {
-#ifndef QT_MAC_USE_COCOA
-        NavMenuItemSpec navSpec;
-        bzero(&navSpec, sizeof(NavMenuItemSpec));
-        navSpec.menuType = index;
-        NavCustomControl(mDialog, kNavCtlSelectCustomType, &navSpec);
-#else
         QMacCocoaAutoReleasePool pool;
         QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
         [delegate->mPopUpButton selectItemAtIndex:index];
         [delegate filterChanged:nil];
-#endif
     }
 }
 
 QString QFileDialogPrivate::selectedNameFilter_sys() const
 {
-#ifndef QT_MAC_USE_COCOA
-    int index = filterInfo.currentSelection;
-#else
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
     int index = [delegate->mPopUpButton indexOfSelectedItem];
-#endif
     return index != -1 ? nameFilters.at(index) : QString();
 }
 
 void QFileDialogPrivate::deleteNativeDialog_sys()
 {
-#ifndef QT_MAC_USE_COCOA
-    if (mDialog)
-        NavDialogDispose(mDialog);
-    mDialog = 0;
-    mDialogStarted = false;
-#else
     QMacCocoaAutoReleasePool pool;
     [reinterpret_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate) release];
     mDelegate = 0;
-#endif
     nativeDialogInUse = false;
 }
 
@@ -734,326 +648,9 @@ bool QFileDialogPrivate::setVisible_sys(bool visible)
         return false;
     }
 
-#ifndef QT_MAC_USE_COCOA
-    return visible ? showCarbonNavServicesDialog() : hideCarbonNavServicesDialog();
-#else
     return visible ? showCocoaFilePanel() : hideCocoaFilePanel();
-#endif
 }
 
-#ifndef QT_MAC_USE_COCOA
-Boolean QFileDialogPrivate::qt_mac_filedialog_filter_proc(AEDesc *theItem, void *info,
-                                                                 void *data, NavFilterModes)
-{
-    QFileDialogPrivate *fileDialogPrivate = static_cast<QFileDialogPrivate *>(data);
-
-    if (!fileDialogPrivate || fileDialogPrivate->filterInfo.filters.isEmpty()
-        || (fileDialogPrivate->filterInfo.currentSelection < 0
-                && fileDialogPrivate->filterInfo.currentSelection
-                        >= fileDialogPrivate->filterInfo.filters.size()))
-        return true;
-
-    NavFileOrFolderInfo *theInfo = static_cast<NavFileOrFolderInfo *>(info);
-    QString file;
-    QString path;
-    const QtMacFilterName &fn
-           = fileDialogPrivate->filterInfo.filters.at(fileDialogPrivate->filterInfo.currentSelection);
-    if (theItem->descriptorType == typeFSRef) {
-        FSRef ref;
-        AEGetDescData(theItem, &ref, sizeof(ref));
-        UInt8 str_buffer[1024];
-        FSRefMakePath(&ref, str_buffer, 1024);
-        path = QString::fromUtf8(reinterpret_cast<const char *>(str_buffer));
-        int slsh = path.lastIndexOf(QLatin1Char('/'));
-        if (slsh != -1)
-            file = path.right(path.length() - slsh - 1);
-        else
-            file = path;
-    }
-    QStringList reg = fn.regexp.split(QLatin1String(";"));
-    for (QStringList::const_iterator it = reg.constBegin(); it != reg.constEnd(); ++it) {
-        QRegExp rg(*it, Qt::CaseInsensitive, QRegExp::Wildcard);
-#ifdef DEBUG_FILEDIALOG_FILTERS
-        qDebug("QFileDialogPrivate::qt_mac_filedialog_filter_proc:%d, asked to filter.. %s (%s)", __LINE__,
-                qPrintable(file), qPrintable(*it));
-#endif
-        if (rg.exactMatch(file))
-            return true;
-    }
-
-    if (theInfo->isFolder) {
-        if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:qt_mac_QStringToNSString(path)])
-            return false;
-        return true;
-    }
-    return false;
-}
-
-void QFileDialogPrivate::qt_mac_filedialog_event_proc(const NavEventCallbackMessage msg,
-        NavCBRecPtr p, NavCallBackUserData data)
-{
-    QFileDialogPrivate *fileDialogPrivate = static_cast<QFileDialogPrivate *>(data);
-
-    switch(msg) {
-    case kNavCBPopupMenuSelect: {
-        NavMenuItemSpec *s = static_cast<NavMenuItemSpec *>(p->eventData.eventDataParms.param);
-        if (int(s->menuType) != fileDialogPrivate->filterInfo.currentSelection) {
-            fileDialogPrivate->filterInfo.currentSelection = s->menuType;
-            emit fileDialogPrivate->q_func()->filterSelected(fileDialogPrivate->nameFilters.at(s->menuType));
-        }
-        if (fileDialogPrivate->acceptMode == QFileDialog::AcceptSave) {
-            QString base = QCFString::toQString(NavDialogGetSaveFileName(p->context));
-            QFileInfo fi(base);
-            base = fi.completeBaseName();
-            const QtMacFilterName &fn = fileDialogPrivate->filterInfo.filters.at(
-                                                       fileDialogPrivate->filterInfo.currentSelection);
-            QStringList reg = fn.regexp.split(QLatin1String(";"), QString::SkipEmptyParts);
-            if (reg.count()) {
-                QString r = reg.first();
-                r  = r.right(r.length()-1);      // Strip the *
-                base += r;                        //"." + QString::number(s->menuType);
-            }
-            NavDialogSetSaveFileName(p->context, QCFString::toCFStringRef(base));
-        }
-#ifdef DEBUG_FILEDIALOG_FILTERS
-        qDebug("QFileDialogPrivate::qt_mac_filedialog_event_proc:%d - Selected a filter: %ld", __LINE__, s->menuType);
-#endif
-        break; }
-    case kNavCBStart:{
-        fileDialogPrivate->mDialogStarted = true;
-        // Set selected file:
-        QModelIndexList indexes = fileDialogPrivate->qFileDialogUi->listView->selectionModel()->selectedRows();
-        QString selected;
-        if (!indexes.isEmpty())
-            selected = indexes.at(0).data(QFileSystemModel::FilePathRole).toString();
-        else
-            selected = fileDialogPrivate->typedFiles().value(0);
-        fileDialogPrivate->selectFile_sys(selected);
-        fileDialogPrivate->selectNameFilter_sys(fileDialogPrivate->qFileDialogUi->fileTypeCombo->currentText());
-        break; }
-    case kNavCBSelectEntry:{
-        // Event: Current selection has changed.
-        QStringList prevSelectionList = fileDialogPrivate->mCurrentSelectionList;
-        fileDialogPrivate->mCurrentSelectionList.clear();
-        QString fileNameToEmit;
-
-        AEDescList *descList = (AEDescList *)p->eventData.eventDataParms.param;
-        // Get the number of files selected:
-        UInt8 strBuffer[1024];
-        long count;
-        OSErr err = AECountItems(descList, &count);
-        if (err != noErr || !count)
-            break;
-
-        for (long index=1; index<=count; ++index) {
-            FSRef ref;
-            err = AEGetNthPtr(descList, index, typeFSRef, 0, 0, &ref, sizeof(ref), 0);
-            if (err != noErr)
-                break;
-            FSRefMakePath(&ref, strBuffer, 1024);
-            QString selected = QString::fromUtf8((const char *)strBuffer);
-            fileDialogPrivate->mCurrentSelectionList << selected;
-            if (!prevSelectionList.contains(selected))
-                fileNameToEmit = selected;
-        }
-
-        if (!fileNameToEmit.isEmpty() && fileNameToEmit != fileDialogPrivate->mCurrentSelection)
-            emit fileDialogPrivate->q_func()->currentChanged(fileNameToEmit);
-        fileDialogPrivate->mCurrentSelection = fileNameToEmit;
-        break; }
-    case kNavCBShowDesktop:
-    case kNavCBNewLocation:{
-        // Event: Current directory has changed.
-        AEDesc *desc = (AEDesc *)p->eventData.eventDataParms.param;
-        FSRef ref;
-        AEGetDescData(desc, &ref, sizeof(ref));
-        UInt8 *strBuffer = (UInt8 *)malloc(1024);
-        FSRefMakePath(&ref, strBuffer, 1024);
-        QString newLocation = QString::fromUtf8((const char *)strBuffer);
-        free(strBuffer);
-        if (fileDialogPrivate->mCurrentLocation != newLocation){
-            fileDialogPrivate->mCurrentLocation = newLocation;
-            QFileDialog::FileMode mode = fileDialogPrivate->fileMode;
-            if (mode == QFileDialog::AnyFile || mode == QFileDialog::ExistingFile
-                    || mode == QFileDialog::ExistingFiles){
-                // When changing directory, the current selection is cleared if
-                // we are supposed to be selecting files only:
-                if (!fileDialogPrivate->mCurrentSelection.isEmpty()){
-                    fileDialogPrivate->mCurrentSelectionList.clear();
-                    fileDialogPrivate->mCurrentSelection.clear();
-                    emit fileDialogPrivate->q_func()->currentChanged(fileDialogPrivate->mCurrentSelection);
-                }
-            }
-            fileDialogPrivate->setLastVisitedDirectory(newLocation);
-            emit fileDialogPrivate->q_func()->directoryEntered(newLocation);
-        }
-        break; }
-    case kNavCBAccept:
-        fileDialogPrivate->mDialogClosed = true;
-        fileDialogPrivate->q_func()->accept();
-        break;
-    case kNavCBCancel:
-        fileDialogPrivate->mDialogClosed = true;
-        fileDialogPrivate->q_func()->reject();
-        break;
-    }
-}
-
-static QFileDialogPrivate::QtMacFilterName qt_mac_extract_filter(const QString &rawFilter, bool showDetails)
-{
-    QFileDialogPrivate::QtMacFilterName ret;
-    ret.filter = rawFilter;
-    QString result = rawFilter;
-    QRegExp r(QString::fromLatin1(qt_file_dialog_filter_reg_exp));
-    int index = r.indexIn(result);
-    if (index >= 0)
-        result = r.cap(2);
-
-    if (showDetails) {
-        ret.description = rawFilter;
-    } else {
-        if (index >= 0)
-            ret.description = r.cap(1).trimmed();
-        if (ret.description.isEmpty())
-            ret.description = result;
-    }
-    ret.regexp = result.replace(QLatin1Char(' '), QLatin1Char(';'));
-    return ret;
-}
-
-static QList<QFileDialogPrivate::QtMacFilterName> qt_mac_make_filters_list(const QString &filter, bool showDetails)
-{
-#ifdef DEBUG_FILEDIALOG_FILTERS
-    qDebug("QFileDialog:%d - Got filter (%s)", __LINE__, filter.latin1());
-#endif
-
-    QList<QFileDialogPrivate::QtMacFilterName> ret;
-    QString f(filter);
-    if (f.isEmpty())
-        f = QFileDialog::tr("All Files (*)");
-    if (f.isEmpty())
-        return ret;
-    QStringList filts = qt_make_filter_list(f);
-    for (QStringList::const_iterator it = filts.constBegin(); it != filts.constEnd(); ++it) {
-        QFileDialogPrivate::QtMacFilterName filter = qt_mac_extract_filter(*it, showDetails);
-#ifdef DEBUG_FILEDIALOG_FILTERS
-        qDebug("QFileDialog:%d Split out filter (%d) '%s' '%s' [%s]", __LINE__, ret.count(),
-                filter->regxp.latin1(), filter->description.latin1(), (*it).latin1());
-#endif
-        ret.append(filter);
-    }
-    return ret;
-}
-
-void QFileDialogPrivate::createNavServicesDialog()
-{
-    Q_Q(QFileDialog);
-    if (mDialog)
-        deleteNativeDialog_sys();
-
-    NavDialogCreationOptions navOptions;
-    NavGetDefaultDialogCreationOptions(&navOptions);
-
-    // Translate QFileDialog settings into NavDialog options:
-    if (qt_mac_is_macsheet(q)) {
-        navOptions.modality = kWindowModalityWindowModal;
-        navOptions.parentWindow = qt_mac_window_for(q->parentWidget());
-    } else if (q->windowModality() ==  Qt::ApplicationModal)
-        navOptions.modality = kWindowModalityAppModal;
-    else
-        navOptions.modality = kWindowModalityNone;
-    navOptions.optionFlags |= kNavSupportPackages;
-    if (q->testOption(QFileDialog::DontConfirmOverwrite))
-        navOptions.optionFlags |= kNavDontConfirmReplacement;
-    if (fileMode != QFileDialog::ExistingFiles)
-        navOptions.optionFlags &= ~kNavAllowMultipleFiles;
-
-    navOptions.windowTitle = QCFString::toCFStringRef(q->windowTitle());
-
-    navOptions.location.h = -1;
-    navOptions.location.v = -1;
-
-    QWidget *parent = q->parentWidget();
-    if (parent && parent->isVisible()) {
-        WindowClass wclass;
-        GetWindowClass(qt_mac_window_for(parent), &wclass);
-        parent = parent->window();
-        QString s = parent->windowTitle();
-        navOptions.clientName = QCFString::toCFStringRef(s);
-    }
-
-    filterInfo.currentSelection = 0;
-    filterInfo.filters = qt_mac_make_filters_list(nameFilters.join(QLatin1String(";;")), q->isNameFilterDetailsVisible());
-    QCFType<CFArrayRef> filterArray;
-    if (filterInfo.filters.size() > 1) {
-        int i = 0;
-        CFStringRef *cfstringArray = static_cast<CFStringRef *>(malloc(sizeof(CFStringRef)
-                                                                   * filterInfo.filters.size()));
-        for (i = 0; i < filterInfo.filters.size(); ++i) {
-            cfstringArray[i] = QCFString::toCFStringRef(filterInfo.filters.at(i).description);
-        }
-        filterArray = CFArrayCreate(kCFAllocatorDefault,
-                        reinterpret_cast<const void **>(cfstringArray), filterInfo.filters.size(),
-                        &kCFTypeArrayCallBacks);
-        navOptions.popupExtension = filterArray;
-        free(cfstringArray);
-    }
-
-    if (q->acceptMode() == QFileDialog::AcceptSave) {
-        if (NavCreatePutFileDialog(&navOptions, 'cute', kNavGenericSignature,
-                    QFileDialogPrivate::qt_mac_filedialog_event_proc, this, &mDialog)) {
-            qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
-            return;
-        }
-    } else if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory) {
-        if (NavCreateChooseFolderDialog(&navOptions,
-                    QFileDialogPrivate::qt_mac_filedialog_event_proc, 0, this, &mDialog)) {
-            qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
-            return;
-        }
-    } else {
-        if (NavCreateGetFileDialog(&navOptions, 0,
-                    QFileDialogPrivate::qt_mac_filedialog_event_proc, 0,
-                    QFileDialogPrivate::qt_mac_filedialog_filter_proc, this, &mDialog)) {
-            qDebug("Shouldn't happen %s:%d", __FILE__, __LINE__);
-            return;
-        }
-    }
-
-    // Set start-up directory:
-    if (mCurrentLocation.isEmpty())
-        mCurrentLocation = rootPath();
-    FSRef fsRef;
-    if (qt_mac_create_fsref(mCurrentLocation, &fsRef) == noErr) {
-        AEDesc desc;
-        if (AECreateDesc(typeFSRef, &fsRef, sizeof(FSRef), &desc) == noErr)
-            NavCustomControl(mDialog, kNavCtlSetLocation, (void*)&desc);
-    }
-}
-
-bool QFileDialogPrivate::showCarbonNavServicesDialog()
-{
-    Q_Q(QFileDialog);
-    if (q->acceptMode() == QFileDialog::AcceptSave && q->windowModality() == Qt::NonModal)
-        return false; // cannot do native no-modal save dialogs.
-    createNavServicesDialog();
-    mDialogClosed = false;
-    if (q->windowModality() != Qt::ApplicationModal)
-        NavDialogRun(mDialog);
-    return true;
-}
-
-bool QFileDialogPrivate::hideCarbonNavServicesDialog()
-{
-    if (!mDialogClosed){
-        mDialogClosed = true;
-        NavCustomControl(mDialog, kNavCtlCancel, 0);
-    }
-    return true;
-}
-
-#else // Cocoa
-
 void QFileDialogPrivate::createNSOpenSavePanelDelegate()
 {
     Q_Q(QFileDialog);
@@ -1105,7 +702,6 @@ bool QFileDialogPrivate::hideCocoaFilePanel()
     }
 }
 
-#endif
 
 void QFileDialogPrivate::mac_nativeDialogModalHelp()
 {
@@ -1125,29 +721,17 @@ void QFileDialogPrivate::mac_nativeDialogModalHelp()
 void QFileDialogPrivate::_q_macRunNativeAppModalPanel()
 {
     QBoolBlocker nativeDialogOnTop(QApplicationPrivate::native_modal_dialog_active);
-#ifndef QT_MAC_USE_COCOA
-    NavDialogRun(mDialog);
-#else
     Q_Q(QFileDialog);
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
     [delegate runApplicationModalPanel];
     dialogResultCode_sys() == QDialog::Accepted ? q->accept() : q->reject();
-#endif
 }
 
 QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys()
 {
-#ifndef QT_MAC_USE_COCOA
-    NavUserAction result = NavDialogGetUserAction(mDialog);
-    if (result == kNavUserActionCancel || result == kNavUserActionNone)
-        return QDialog::Rejected;
-    else
-        return QDialog::Accepted;
-#else
     QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
     return [delegate dialogResultCode];
-#endif
 }
 
 
index 6a534bb..c820202 100644 (file)
@@ -279,36 +279,8 @@ public:
 
 #if defined(Q_WS_MAC)
     void *mDelegate;
-#ifndef QT_MAC_USE_COCOA
-    NavDialogRef mDialog;
-    bool mDialogStarted;
-    bool mDialogClosed;
-    QString mCurrentLocation;
-    QString mCurrentSelection;
-    QStringList mCurrentSelectionList;
-
-    struct QtMacFilterName {
-        QString description;
-        QString regexp;
-        QString filter;
-    };
-    struct QtMacNavFilterInfo {
-        QtMacNavFilterInfo() : currentSelection(-1) {}
-        int currentSelection;
-        QList<QtMacFilterName> filters;
-    } filterInfo;
-
-    static void qt_mac_filedialog_event_proc(const NavEventCallbackMessage msg, NavCBRecPtr p,
-                                             NavCallBackUserData data);
-    static Boolean qt_mac_filedialog_filter_proc(AEDesc *theItem, void *info, void *data,
-                                                 NavFilterModes);
-    bool showCarbonNavServicesDialog();
-    bool hideCarbonNavServicesDialog();
-    void createNavServicesDialog();
-#else
     bool showCocoaFilePanel();
     bool hideCocoaFilePanel();
-#endif
     void createNSOpenSavePanelDelegate();
     void QNSOpenSavePanelDelegate_selectionChanged(const QString &newPath);
     void QNSOpenSavePanelDelegate_panelClosed(bool accepted);
index 088aa52..d4d3c6a 100644 (file)
@@ -196,7 +196,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
 
 - (void)setSubwindowStacking
 {
-#ifdef QT_MAC_USE_COCOA
     // Stack the native dialog in front of its parent, if any:
     QFontDialog *q = mPriv->fontDialog();
     if (!qt_mac_is_macsheet(q)) {
@@ -207,7 +206,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
             }
         }
     }
-#endif
 }
 
 - (void)dealloc
@@ -245,13 +243,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
 
 - (void)showWindowModalSheet:(QWidget *)docWidget
 {
-#ifdef QT_MAC_USE_COCOA
     NSWindow *window = qt_mac_window_for(docWidget);
-#else
-    WindowRef hiwindowRef = qt_mac_window_for(docWidget);
-    NSWindow *window = [[NSWindow alloc] initWithWindowRef:hiwindowRef];
-    CFRetain(hiwindowRef);
-#endif
 
     mAppModal = false;
     NSWindow *ourPanel = [mStolenContentView window];
@@ -261,9 +253,6 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
         didEndSelector:0
         contextInfo:0 ];
 
-#ifndef QT_MAC_USE_COCOA
-    CFRelease(hiwindowRef);
-#endif
 }
 
 - (void)changeFont:(id)sender
@@ -279,13 +268,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
     NSDictionary *dummyAttribs = [NSDictionary dictionary];
     NSDictionary *attribs = [sender convertAttributes:dummyAttribs];
 
-#ifdef QT_MAC_USE_COCOA
     for (id key in attribs) {
-#else
-    NSEnumerator *enumerator = [attribs keyEnumerator];
-    id key;
-    while((key = [enumerator nextObject])) {
-#endif
         NSNumber *number = static_cast<NSNumber *>([attribs objectForKey:key]);
         if ([key isEqual:NSUnderlineStyleAttributeName]) {
             mQtFont->setUnderline([number intValue] != NSUnderlineStyleNone);
@@ -441,14 +424,12 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
 
 - (void)finishOffWithCode:(NSInteger)code
 {
-#ifdef QT_MAC_USE_COCOA
     QFontDialog *q = mPriv->fontDialog();
     if (QWidget *parent = q->parentWidget()) {
         if (parent->isWindow()) {
             [qt_mac_window_for(parent) removeChildWindow:[mStolenContentView window]];
         }
     }
-#endif
 
     if(code == NSOKButton)
         mPriv->sampleEdit->setFont([self qtFont]);
@@ -479,9 +460,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
     }
     [mFontPanel setDelegate:nil];
     [[NSFontManager sharedFontManager] setDelegate:nil];
-#ifdef QT_MAC_USE_COCOA
     [[NSFontManager sharedFontManager] setTarget:nil];
-#endif
 }
 @end
 
@@ -609,9 +588,7 @@ void QFontDialogPrivate::createNSFontPanelDelegate()
     [ourPanel setDelegate:del];
 
     [[NSFontManager sharedFontManager] setDelegate:del];
-#ifdef QT_MAC_USE_COCOA
     [[NSFontManager sharedFontManager] setTarget:del];
-#endif
     setFont(del, q_func()->currentFont());
 
     {
index 5d5098c..b182399 100644 (file)
@@ -115,7 +115,7 @@ extern bool qt_wince_is_pocket_pc();  //qguifunctions_wince.cpp
 
 #include "qdatetime.h"
 
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
 #include <private/qt_cocoa_helpers_mac_p.h>
 #endif
 
@@ -2306,7 +2306,7 @@ bool QApplication::event(QEvent *e)
     }
 
     if(e->type() == QEvent::LanguageChange) {
-#if defined(QT_MAC_USE_COCOA)
+#ifdef Q_WS_MAC
         qt_mac_post_retranslateAppMenu();
 #endif
         QWidgetList list = topLevelWidgets();
@@ -2430,7 +2430,7 @@ void QApplication::setActiveWindow(QWidget* act)
         sendSpontaneousEvent(w, &activationChange);
     }
 
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
     // In case the user clicked on a child window, we need to
     // reestablish the stacking order of the window so
     // it pops in front of other child windows in cocoa:
@@ -2852,7 +2852,7 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop)
     if (QApplication::activePopupWidget())
         return true;
 
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_MAC)
     top = QApplicationPrivate::tryModalHelper_sys(top);
     if (rettop)
         *rettop = top;
@@ -4136,7 +4136,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
         break;
     }
 #endif // QT_NO_GESTURES
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
     case QEvent::Enter:
         if (receiver->isWidgetType()) {
             QWidget *w = static_cast<QWidget *>(receiver);
index 2130a97..ed15135 100644 (file)
@@ -127,7 +127,7 @@ struct QTabletDeviceData
                               int outOriginY, int outExtentY) const;
 #endif
 
-#if defined(Q_WS_X11) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
+#ifdef Q_WS_X11
     QPointer<QWidget> widgetToGetPress;
 #endif
 
@@ -438,10 +438,8 @@ public:
     static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
     static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long);
     static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *);
-#ifdef QT_MAC_USE_COCOA
     static void qt_initAfterNSAppStarted();
     static void setupAppleEvents();
-#endif
     static bool qt_mac_apply_settings();
 #endif
 
index d3d34c2..5b5d8dc 100644 (file)
@@ -78,9 +78,7 @@ QGestureManager::QGestureManager(QObject *parent)
 #if defined(Q_WS_MAC)
     registerGestureRecognizer(new QMacSwipeGestureRecognizer);
     registerGestureRecognizer(new QMacPinchGestureRecognizer);
-  #if defined(QT_MAC_USE_COCOA)
     registerGestureRecognizer(new QMacPanGestureRecognizer);
-  #endif
 #else
     registerGestureRecognizer(new QPanGestureRecognizer);
     registerGestureRecognizer(new QPinchGestureRecognizer);
index af5e2ef..7f19f2b 100644 (file)
@@ -132,7 +132,7 @@ Q_WIDGETS_EXPORT void qt_x11_set_global_double_buffer(bool enable)
 }
 #endif
 
-#if defined(QT_MAC_USE_COCOA)
+#ifdef Q_WS_MAC
 bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false;
 #endif
 
@@ -306,7 +306,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
 
     isWidget = true;
     memset(high_attributes, 0, sizeof(high_attributes));
-#if QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
     drawRectOriginalAdded = false;
     originalDrawMethod = true;
     changeMethods = false;
@@ -315,7 +315,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
     toolbar_ancestor = 0;
     flushRequested = false;
     touchEventsEnabled = false;
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
 #ifdef QWIDGET_EXTRA_DEBUG
     static int count = 0;
     qDebug() << "widgets" << ++count;
@@ -1272,7 +1272,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
 
     extraPaintEngine = 0;
 
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
     // If we add a child to the unified toolbar, we have to redirect the painting.
     if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
         if (parentWidget->d_func()->unifiedSurface) {
@@ -1280,7 +1280,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
             parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
         }
     }
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
 }
 
 
@@ -1527,7 +1527,7 @@ QWidget::~QWidget()
         d->declarativeData = 0;                 // don't activate again in ~QObject
     }
 
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
     // QCocoaView holds a pointer back to this widget. Clear it now
     // to make sure it's not followed later on. The lifetime of the
     // QCocoaView might exceed the lifetime of this widget in cases
@@ -1613,9 +1613,7 @@ void QWidgetPrivate::createTLExtra()
         x->inRepaint = false;
         x->embedded = 0;
 #ifdef Q_WS_MAC
-#ifdef QT_MAC_USE_COCOA
         x->wasMaximized = false;
-#endif // QT_MAC_USE_COCOA
 #endif // Q_WS_MAC
         createTLSysExtra();
 #ifdef QWIDGET_EXTRA_DEBUG
@@ -1963,10 +1961,10 @@ void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirt
     if (disableSubtractOpaqueSiblings || q->isWindow())
         return;
 
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
     if (q->d_func()->isInUnifiedToolbar)
         return;
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
 
     QRect clipBoundingRect;
     bool dirtyClipBoundingRect = true;
@@ -5097,7 +5095,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
     if (rgn.isEmpty())
         return;
 
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#ifdef Q_WS_MAC
     if (qt_mac_clearDirtyOnWidgetInsideDrawWidget)
         dirtyOnWidget = QRegion();
 
@@ -5105,7 +5103,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
     // it's supposed to be in the unified toolbar on Mac OS X.
     if (backingStore && isInUnifiedToolbar)
         return;
-#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
 
 
     Q_Q(QWidget);
@@ -6597,7 +6595,7 @@ void QWidget::setGeometry(const QRect &r)
 */
 QByteArray QWidget::saveGeometry() const
 {
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
     // We check if the window was maximized during this invocation. If so, we need to record the
     // starting position as 0,0.
     Q_D(const QWidget);
@@ -6608,7 +6606,7 @@ QByteArray QWidget::saveGeometry() const
         newFramePosition.moveTo(0, 0);
         newNormalPosition.moveTo(0, 0);
     }
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
     QByteArray array;
     QDataStream stream(&array, QIODevice::WriteOnly);
     stream.setVersion(QDataStream::Qt_4_0);
@@ -6618,13 +6616,10 @@ QByteArray QWidget::saveGeometry() const
     stream << magicNumber
            << majorVersion
            << minorVersion
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
            << newFramePosition
            << newNormalPosition
-#else
-           << frameGeometry()
-           << normalGeometry()
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
            << qint32(QApplication::desktop()->screenNumber(this))
            << quint8(windowState() & Qt::WindowMaximized)
            << quint8(windowState() & Qt::WindowFullScreen);
@@ -7452,7 +7447,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
         QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
         if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
             continue;
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
         // Before doing anything we need to make sure that we don't leave anything in a non-consistent state.
         // When hiding a widget we need to make sure that no mouse_down events are active, because
         // the mouse_up event will never be received by a hidden widget or one of its descendants.
@@ -7468,7 +7463,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
         // supposed to trigger because it is not visible.
         if(widget == qt_button_down)
             qt_button_down = 0;
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
         if (spontaneous)
             widget->setAttribute(Qt::WA_Mapped, false);
         else
@@ -9700,11 +9695,11 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
 #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
     if (newParent && parent && !desktopWidget) {
         if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#ifdef Q_WS_MAC
             // On Mac, toolbars inside the unified title bar will never overlap with
             // siblings in the content view. So we skip enforce native siblings in that case
             && !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow()
-#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
         )
             parent->d_func()->enforceNativeChildren();
         else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
@@ -9966,12 +9961,12 @@ void QWidget::repaint(const QRect &rect)
         return;
 
     if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
         if (qt_widget_private(this)->isInUnifiedToolbar) {
             qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
             return;
         }
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
         QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
         if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
             tlwExtra->inRepaint = true;
@@ -10001,12 +9996,12 @@ void QWidget::repaint(const QRegion &rgn)
         return;
 
     if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
         if (qt_widget_private(this)->isInUnifiedToolbar) {
             qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
             return;
         }
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
         QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
         if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
             tlwExtra->inRepaint = true;
@@ -10064,12 +10059,12 @@ void QWidget::update(const QRect &rect)
     }
 
     if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
         if (qt_widget_private(this)->isInUnifiedToolbar) {
             qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
             return;
         }
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
         QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
         if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
             tlwExtra->backingStoreTracker->markDirty(rect, this);
@@ -10094,12 +10089,12 @@ void QWidget::update(const QRegion &rgn)
     }
 
     if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
         if (qt_widget_private(this)->isInUnifiedToolbar) {
             qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
             return;
         }
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
         QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
         if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
             tlwExtra->backingStoreTracker->markDirty(rgn, this);
@@ -10274,11 +10269,11 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
             qApp->inputPanel()->setInputItem(0);
         }
         if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#ifdef Q_WS_MAC
             // On Mac, toolbars inside the unified title bar will never overlap with
             // siblings in the content view. So we skip enforce native siblings in that case
             && !d->isInUnifiedToolbar && parentWidget()->isWindow()
-#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
         )
             parentWidget()->d_func()->enforceNativeChildren();
         if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
@@ -11997,7 +11992,7 @@ void QWidget::setMask(const QRegion &newMask)
     d->extra->mask = newMask;
     d->extra->hasMask = !newMask.isEmpty();
 
-#ifndef QT_MAC_USE_COCOA
+#ifndef Q_WS_MAC
     if (!testAttribute(Qt::WA_WState_Created))
         return;
 #endif
@@ -12100,7 +12095,7 @@ void QWidgetPrivate::_q_delayedDestroy(WId winId)
 }
 #endif
 
-#if QT_MAC_USE_COCOA
+#ifdef Q_WS_MAC
 void QWidgetPrivate::syncUnifiedMode() {
     // The whole purpose of this method is to keep the unifiedToolbar in sync.
     // That means making sure we either exchange the drawing methods or we let
@@ -12120,7 +12115,7 @@ void QWidgetPrivate::syncUnifiedMode() {
     }
 }
 
-#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
 
 QT_END_NAMESPACE
 
index 775152b..102f61f 100644 (file)
@@ -218,13 +218,11 @@ struct QTLWExtra {
     WindowGroupRef group;
     IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
     quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
-#ifdef QT_MAC_USE_COCOA
     // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
     // manually resized.
     // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
     // starting position as 0,0 instead of the normal starting position.
     bool wasMaximized;
-#endif // QT_MAC_USE_COCOA
 
 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
 #ifndef QT_NO_QWS_MANAGER
@@ -285,11 +283,9 @@ struct QWExtra {
     uint compress_events : 1;
     WId xDndProxy; // XDND forwarding to embedded windows
 #elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
-#ifdef QT_MAC_USE_COCOA
     // Cocoa Mask stuff
     QImage maskBits;
     CGImageRef imageMask;
-#endif
 #elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
     uint activated : 1; // RWindowBase::Activated has been called
 
@@ -844,10 +840,6 @@ public:
     void setWindowFilePath_sys(const QString &filePath);
     void createWindow_sys();
     void recreateMacWindow();
-#ifndef QT_MAC_USE_COCOA
-    void initWindowPtr();
-    void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
-#else
     void setSubWindowStacking(bool set);
     void setWindowLevel();
     void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
@@ -868,7 +860,6 @@ public:
     QWidget *toolbar_ancestor;
     bool flushRequested;
     bool touchEventsEnabled;
-#endif // QT_MAC_USE_COCOA
     void determineWindowClass();
     void transferChildren();
     bool qt_mac_dnd_event(uint, DragRef);
index d77c01f..cab207e 100644 (file)
@@ -186,19 +186,9 @@ static bool qt_mac_collapse_on_dblclick = true;
 extern int qt_antialiasing_threshold; // from qapplication.cpp
 QWidget * qt_button_down;                // widget got last button-down
 QPointer<QWidget> qt_last_mouse_receiver;
-#ifndef QT_MAC_USE_COCOA
-static bool qt_button_down_in_content; // whether the button_down was in the content area.
-static bool qt_mac_previous_press_in_popup_mode = false;
-static bool qt_mac_no_click_through_mode = false;
-static int tablet_button_state = 0;
-#endif
 #if defined(QT_DEBUG)
 static bool        appNoGrab        = false;        // mouse/keyboard grabbing
 #endif
-#ifndef QT_MAC_USE_COCOA
-static EventHandlerRef app_proc_handler = 0;
-static EventHandlerUPP app_proc_handlerUPP = 0;
-#endif
 static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL;
 static EventHandlerRef tablet_proximity_handler = 0;
 static EventHandlerUPP tablet_proximity_UPP = 0;
@@ -356,74 +346,20 @@ static void qt_mac_debug_palette(const QPalette &pal, const QPalette &pal2, cons
 #endif
 
 //raise a notification
-#ifndef QT_MAC_USE_COCOA
-static NMRec qt_mac_notification = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-#endif
 void qt_mac_send_notification()
 {
-#ifndef QT_MAC_USE_COCOA
-    //send it
-    qt_mac_notification.nmMark = 1; //non-zero magic number
-    qt_mac_notification.qType = nmType;
-    NMInstall(&qt_mac_notification);
-#else
     QMacCocoaAutoReleasePool pool;
     [[NSApplication sharedApplication] requestUserAttention:NSInformationalRequest];
-#endif
 }
 
 void qt_mac_cancel_notification()
 {
-#ifndef QT_MAC_USE_COCOA
-    NMRemove(&qt_mac_notification);
-#else
     QMacCocoaAutoReleasePool pool;
     [[NSApplication sharedApplication] cancelUserAttentionRequest:NSInformationalRequest];
-#endif
 }
 
-#ifndef QT_MAC_USE_COCOA
-//find widget (and part) at a given point
-static short qt_mac_window_at(int x, int y, QWidget **w=0)
-{
-    Point p;
-    p.h = x;
-    p.v = y;
-    OSWindowRef wp;
-    WindowPartCode wpc;
-    OSStatus err = FindWindowOfClass(&p, kAllWindowClasses, &wp, &wpc);
-    if(err != noErr) {
-        if(w)
-            (*w) = 0;
-        return wpc;
-    }
-    if(w) {
-        if(wp) {
-            *w = qt_mac_find_window(wp);
-#if 0
-            if(!*w)
-                qWarning("QApplication: qt_mac_window_at: Couldn't find %d",(int)wp);
-#endif
-        } else {
-            *w = 0;
-        }
-    }
-    return wpc;
-}
-
-#endif
-
 void qt_mac_set_app_icon(const QPixmap &pixmap)
 {
-#ifndef QT_MAC_USE_COCOA
-    if(pixmap.isNull()) {
-        RestoreApplicationDockTileImage();
-    } else {
-        CGImageRef img = (CGImageRef)pixmap.macCGHandle();
-        SetApplicationDockTileImage(img);
-        CGImageRelease(img);
-    }
-#else
     QMacCocoaAutoReleasePool pool;
     NSImage *image = NULL;
     if (pixmap.isNull()) {
@@ -435,7 +371,6 @@ void qt_mac_set_app_icon(const QPixmap &pixmap)
 
     [NSApp setApplicationIconImage:image];
     [image release];
-#endif
 }
 
 Q_GUI_EXPORT void qt_mac_set_press_and_hold_context(bool b)
@@ -680,49 +615,13 @@ static void qt_mac_event_release(EventRef &event)
     ReleaseEvent(event);
     event = 0;
 }
-#ifndef QT_MAC_USE_COCOA
-static void qt_mac_event_release(QWidget *w, EventRef &event)
-{
-    if (event) {
-        QWidget *widget = 0;
-        if (GetEventParameter(event, kEventParamQWidget, typeQWidget, 0, sizeof(widget), 0, &widget) == noErr
-           && w == widget) {
-            if (IsEventInQueue(GetMainEventQueue(), event))
-                RemoveEventFromQueue(GetMainEventQueue(), event);
-            qt_mac_event_release(event);
-        }
-    }
-}
-
-static bool qt_mac_event_remove(EventRef &event)
-{
-    if (event) {
-        if (IsEventInQueue(GetMainEventQueue(), event))
-            RemoveEventFromQueue(GetMainEventQueue(), event);
-        qt_mac_event_release(event);
-        return true;
-    }
-    return false;
-}
-#endif
 
 /* sheets */
-#ifndef QT_MAC_USE_COCOA
-static EventRef request_showsheet_pending = 0;
-#endif
 void qt_event_request_showsheet(QWidget *w)
 {
     Q_ASSERT(qt_mac_is_macsheet(w));
-#ifdef QT_MAC_USE_COCOA
     [NSApp beginSheet:qt_mac_window_for(w) modalForWindow:qt_mac_window_for(w->parentWidget())
         modalDelegate:nil didEndSelector:nil contextInfo:0];
-#else
-    qt_mac_event_remove(request_showsheet_pending);
-    CreateEvent(0, kEventClassQt, kEventQtRequestShowSheet, GetCurrentEventTime(),
-                kEventAttributeUserEvent, &request_showsheet_pending);
-    SetEventParameter(request_showsheet_pending, kEventParamQWidget, typeQWidget, sizeof(w), &w);
-    PostEventToQueue(GetMainEventQueue(), request_showsheet_pending, kEventPriorityStandard);
-#endif
 }
 
 static void qt_post_window_change_event(QWidget *widget)
@@ -770,37 +669,7 @@ void qt_mac_send_posted_gl_updates(QWidget *widget)
 */
 static void qt_mac_update_intersected_gl_widgets(QWidget *widget)
 {
-#ifndef QT_MAC_USE_COCOA
-    QList<QWidgetPrivate::GlWidgetInfo> &glWidgets = qt_widget_private(widget->window())->glWidgets;
-    if (glWidgets.isEmpty())
-        return;
-
-    // Exit if the window has not been created yet (mapToGlobal/size will force create it)
-    if (widget->testAttribute(Qt::WA_WState_Created) == false || HIViewGetWindow(qt_mac_nativeview_for(widget)) == 0)
-        return;
-
-    const QRect globalWidgetRect = QRect(widget->mapToGlobal(QPoint(0, 0)), widget->size());
-
-    QList<QWidgetPrivate::GlWidgetInfo>::iterator end = glWidgets.end();
-    QList<QWidgetPrivate::GlWidgetInfo>::iterator it = glWidgets.begin();
-
-    for (;it != end; ++it){
-        QWidget *glWidget = it->widget;
-        const QRect globalGlWidgetRect = QRect(glWidget->mapToGlobal(QPoint(0, 0)), glWidget->size());
-        if (globalWidgetRect.intersects(globalGlWidgetRect)) {
-            qt_post_window_change_event(glWidget);
-            it->lastUpdateWidget = widget;
-        } else if (it->lastUpdateWidget == widget) {
-            // Update the gl wigets that the widget intersected the last time around,
-            // and that we are not intersecting now. This prevents paint errors when the
-            // intersecting widget leaves a gl widget.
-            qt_post_window_change_event(glWidget);
-            it->lastUpdateWidget = 0;
-        }
-    }
-#else
     Q_UNUSED(widget);
-#endif
 }
 
 /*
@@ -888,46 +757,13 @@ void qt_event_request_activate(QWidget *w)
 
 
 /* menubars */
-#ifndef QT_MAC_USE_COCOA
-static EventRef request_menubarupdate_pending = 0;
-#endif
 void qt_event_request_menubarupdate()
 {
-#ifndef QT_MAC_USE_COCOA
-    if (request_menubarupdate_pending) {
-        if (IsEventInQueue(GetMainEventQueue(), request_menubarupdate_pending))
-            return;
-#ifdef DEBUG_DROPPED_EVENTS
-        qDebug("%s:%d Whoa, we dropped an event on the floor!", __FILE__, __LINE__);
-#endif
-    }
-
-    CreateEvent(0, kEventClassQt, kEventQtRequestMenubarUpdate, GetCurrentEventTime(),
-                kEventAttributeUserEvent, &request_menubarupdate_pending);
-    PostEventToQueue(GetMainEventQueue(), request_menubarupdate_pending, kEventPriorityHigh);
-#else
     // Just call this. The request has the benefit that we don't call this multiple times, but
     // we can optimize this.
     QMenuBar::macUpdateMenuBar();
-#endif
 }
 
-#ifndef QT_MAC_USE_COCOA
-//context menu
-static EventRef request_context_pending = 0;
-static void qt_event_request_context(QWidget *w=0, EventRef *where=0)
-{
-    if (!where)
-        where = &request_context_pending;
-    if (*where)
-        return;
-    CreateEvent(0, kEventClassQt, kEventQtRequestContext, GetCurrentEventTime(),
-                kEventAttributeUserEvent, where);
-    if (w)
-        SetEventParameter(*where, kEventParamQWidget, typeQWidget, sizeof(w), &w);
-    PostEventToQueue(GetMainEventQueue(), *where, kEventPriorityStandard);
-}
-#endif
 
 void QApplicationPrivate::createEventDispatcher()
 {
@@ -941,13 +777,6 @@ void QApplicationPrivate::createEventDispatcher()
 /* clipboard */
 void qt_event_send_clipboard_changed()
 {
-#ifndef QT_MAC_USE_COCOA
-    AppleEvent ae;
-    if (AECreateAppleEvent(kEventClassQt, typeAEClipboardChanged, 0, kAutoGenerateReturnID, kAnyTransactionID, &ae) != noErr)
-        qDebug("Can't happen!!");
-    AppleEvent reply;
-    AESend(&ae, &reply, kAENoReply, kAENormalPriority, kAEDefaultTimeout, 0, 0);
-#endif
 }
 
 /* app menu */
@@ -955,28 +784,16 @@ static QMenu *qt_mac_dock_menu = 0;
 Q_GUI_EXPORT void qt_mac_set_dock_menu(QMenu *menu)
 {
     qt_mac_dock_menu = menu;
-#ifdef QT_MAC_USE_COCOA
     [NSApp setDockMenu:menu->macMenu()];
-#else
-    SetApplicationDockTileMenu(menu->macMenu());
-#endif
 }
 
 /* events that hold pointers to widgets, must be cleaned up like this */
 void qt_mac_event_release(QWidget *w)
 {
     if (w) {
-#ifndef QT_MAC_USE_COCOA
-        qt_mac_event_release(w, request_showsheet_pending);
-        qt_mac_event_release(w, request_context_pending);
-#endif
         if (w == qt_mac_dock_menu) {
             qt_mac_dock_menu = 0;
-#ifndef QT_MAC_USE_COCOA
-            SetApplicationDockTileMenu(0);
-#else
             [NSApp setDockMenu:0];
-#endif
         }
     }
 }
@@ -990,62 +807,6 @@ struct QMacAppleEventTypeSpec {
     { kInternetEventClass, kAEGetURL },
 };
 
-#ifndef QT_MAC_USE_COCOA
-
-#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
-enum
-{
-    kEventMouseScroll                          = 11,
-    kEventParamMouseWheelSmoothVerticalDelta   = 'saxy',
-    kEventParamMouseWheelSmoothHorizontalDelta = 'saxx',
-};
-#endif
-
-/* watched events */
-static EventTypeSpec app_events[] = {
-    { kEventClassQt, kEventQtRequestWindowChange },
-    { kEventClassQt, kEventQtRequestShowSheet },
-    { kEventClassQt, kEventQtRequestContext },
-    { kEventClassQt, kEventQtRequestActivate },
-    { kEventClassQt, kEventQtRequestMenubarUpdate },
-
-    { kEventClassWindow, kEventWindowActivated },
-    { kEventClassWindow, kEventWindowDeactivated },
-
-    { kEventClassMouse, kEventMouseScroll },
-    { kEventClassMouse, kEventMouseWheelMoved },
-    { kEventClassMouse, kEventMouseDown },
-    { kEventClassMouse, kEventMouseUp },
-    { kEventClassMouse, kEventMouseDragged },
-    { kEventClassMouse, kEventMouseMoved },
-
-    { kEventClassTablet, kEventTabletProximity },
-
-    { kEventClassApplication, kEventAppActivated },
-    { kEventClassApplication, kEventAppDeactivated },
-    { kEventClassApplication, kEventAppAvailableWindowBoundsChanged },
-
-    //    { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
-    { kEventClassKeyboard, kEventRawKeyModifiersChanged },
-    { kEventClassKeyboard, kEventRawKeyRepeat },
-    { kEventClassKeyboard, kEventRawKeyUp },
-    { kEventClassKeyboard, kEventRawKeyDown },
-
-    { kEventClassCommand, kEventCommandProcess },
-
-    { kEventClassAppleEvent, kEventAppleEvent },
-
-    { kAppearanceEventClass, kAEAppearanceChanged }
-};
-
-void qt_init_app_proc_handler()
-{
-    InstallEventHandler(GetApplicationEventTarget(), app_proc_handlerUPP,
-                        GetEventTypeCount(app_events), app_events, (void *)qApp,
-                        &app_proc_handler);
-}
-#endif // QT_MAC_USE_COCOA
-
 static void qt_init_tablet_proximity_handler()
 {
     EventTypeSpec      tabletProximityEvent = { kEventClassTablet, kEventTabletProximity };
@@ -1075,12 +836,6 @@ QString QApplicationPrivate::appName() const
 
 void qt_release_app_proc_handler()
 {
-#ifndef QT_MAC_USE_COCOA
-    if (app_proc_handler) {
-        RemoveEventHandler(app_proc_handler);
-        app_proc_handler = 0;
-    }
-#endif
 }
 
 void qt_color_profile_changed(CFNotificationCenterRef, void *, CFStringRef, const void *,
@@ -1211,13 +966,6 @@ void qt_init(QApplicationPrivate *priv, int)
 
         if (QApplication::desktopSettingsAware())
             qt_mac_update_os_settings();
-#ifndef QT_MAC_USE_COCOA
-        if (!app_proc_handler) {
-            app_proc_handlerUPP = NewEventHandlerUPP(QApplicationPrivate::globalEventProcessor);
-            qt_init_app_proc_handler();
-        }
-
-#endif
         if (!app_proc_ae_handlerUPP && !QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
             app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor);
             for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) {
@@ -1241,7 +989,6 @@ void qt_init(QApplicationPrivate *priv, int)
         QApplicationPrivate::qt_mac_apply_settings();
 
     // Cocoa application delegate
-#ifdef QT_MAC_USE_COCOA
     NSApplication *cocoaApp = [QNSApplication sharedApplication];
     qt_redirectNSApplicationSendEvent();
 
@@ -1266,7 +1013,6 @@ void qt_init(QApplicationPrivate *priv, int)
         [newDelegate setMenuLoader:qtMenuLoader];
         [qtMenuLoader release];
     }
-#endif
     // Register for Carbon tablet proximity events on the event monitor target.
     // This means that we should receive proximity events even when we aren't the active application.
     if (!tablet_proximity_handler) {
@@ -1302,13 +1048,6 @@ void qt_cleanup()
     CFNotificationCenterRemoveObserver(center, qApp, kCMDeviceProfilesNotification, 0);
     CFNotificationCenterRemoveObserver(center, qApp, kCMDefaultDeviceProfileNotification, 0);
 
-#ifndef QT_MAC_USE_COCOA
-    qt_release_app_proc_handler();
-    if (app_proc_handlerUPP) {
-        DisposeEventHandlerUPP(app_proc_handlerUPP);
-        app_proc_handlerUPP = 0;
-    }
-#endif
     qt_release_apple_event_handler();
     qt_release_tablet_proximity_handler();
     if (tablet_proximity_UPP)
@@ -1360,12 +1099,7 @@ void QApplication::setOverrideCursor(const QCursor &cursor)
 {
     qApp->d_func()->cursor_list.prepend(cursor);
 
-#ifdef QT_MAC_USE_COCOA
     qt_mac_update_cursor();
-#else
-    if (qApp && qApp->activeWindow())
-        qt_mac_set_cursor(&qApp->d_func()->cursor_list.first());
-#endif
 }
 
 void QApplication::restoreOverrideCursor()
@@ -1374,24 +1108,12 @@ void QApplication::restoreOverrideCursor()
         return;
     qApp->d_func()->cursor_list.removeFirst();
 
-#ifdef QT_MAC_USE_COCOA
     qt_mac_update_cursor();
-#else
-    if (qApp && qApp->activeWindow()) {
-        const QCursor def(Qt::ArrowCursor);
-        qt_mac_set_cursor(qApp->d_func()->cursor_list.isEmpty() ? &def : &qApp->d_func()->cursor_list.first());
-    }
-#endif
 }
 #endif // QT_NO_CURSOR
 
 QWidget *QApplication::topLevelAt(const QPoint &p)
 {
-#ifndef QT_MAC_USE_COCOA
-    QWidget *widget;
-    qt_mac_window_at(p.x(), p.y(), &widget);
-    return widget;
-#else
     // Use a cache to avoid iterate through the whole list of windows for all
     // calls to to topLevelAt. We e.g. do this for each and every mouse
     // move since we need to find the widget under mouse:
@@ -1440,7 +1162,6 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
 
     topLevelAt_cache = 0;
     return 0;
-#endif
 }
 
 /*****************************************************************************
@@ -1452,8 +1173,6 @@ bool QApplicationPrivate::modalState()
     return app_do_modal;
 }
 
-#ifdef QT_MAC_USE_COCOA
-#endif
 
 void QApplicationPrivate::enterModal_sys(QWidget *widget)
 {
@@ -1474,10 +1193,8 @@ void QApplicationPrivate::enterModal_sys(QWidget *widget)
     app_do_modal = true;
     qt_button_down = 0;
 
-#ifdef QT_MAC_USE_COCOA
     if (!qt_mac_is_macsheet(widget))
         QEventDispatcherMacPrivate::beginModalSession(widget);
-#endif
 }
 
 void QApplicationPrivate::leaveModal_sys(QWidget *widget)
@@ -1500,10 +1217,8 @@ void QApplicationPrivate::leaveModal_sys(QWidget *widget)
             dispatchEnterLeave(w, qt_last_mouse_receiver); // send synthetic enter event
             qt_last_mouse_receiver = w;
         }
-#ifdef QT_MAC_USE_COCOA
         if (!qt_mac_is_macsheet(widget))
             QEventDispatcherMacPrivate::endModalSession(widget);
-#endif
     }
 #ifdef DEBUG_MODAL_EVENTS
     else qDebug("Failure to remove %s::%s::%p -- %p", widget->metaObject()->className(), widget->objectName().toLocal8Bit().constData(), widget, qt_modal_stack);
@@ -1515,52 +1230,9 @@ void QApplicationPrivate::leaveModal_sys(QWidget *widget)
 
 QWidget *QApplicationPrivate::tryModalHelper_sys(QWidget *top)
 {
-#ifndef QT_MAC_USE_COCOA
-    if(top && qt_mac_is_macsheet(top) && !IsWindowVisible(qt_mac_window_for(top))) {
-        if(OSWindowRef wp = GetFrontWindowOfClass(kSheetWindowClass, true)) {
-            if(QWidget *sheet = qt_mac_find_window(wp))
-                top = sheet;
-        }
-    }
-#endif
     return top;
 }
 
-#ifndef QT_MAC_USE_COCOA
-static bool qt_try_modal(QWidget *widget, EventRef event)
-{
-    QWidget * top = 0;
-
-    if (QApplicationPrivate::tryModalHelper(widget, &top))
-        return true;
-
-    // INVARIANT: widget is modally shaddowed within its
-    // window, and should therefore not handle the event.
-    // However, if the window is not active, the event
-    // might suggest that we should bring it to front:
-
-    bool block_event = false;
-
-    if (event) {
-        switch (GetEventClass(event)) {
-        case kEventClassMouse:
-        case kEventClassKeyboard:
-            block_event = true;
-            break;
-        }
-    }
-
-    QWidget *activeWidget = QApplication::activeWindow();
-    if ((!activeWidget || QApplicationPrivate::isBlockedByModal(activeWidget)) &&
-       top->isWindow() && block_event && !QApplicationPrivate::native_modal_dialog_active)
-        top->raise();
-
-#ifdef DEBUG_MODAL_EVENTS
-    qDebug("%s:%d -- final decision! (%s)", __FILE__, __LINE__, block_event ? "false" : "true");
-#endif
-    return !block_event;
-}
-#endif
 
 OSStatus QApplicationPrivate::tabletProximityCallback(EventHandlerCallRef, EventRef carbonEvent,
                                                       void *)
@@ -1581,910 +1253,12 @@ OSStatus QApplicationPrivate::tabletProximityCallback(EventHandlerCallRef, Event
 OSStatus
 QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event, void *data)
 {
-#ifndef QT_MAC_USE_COCOA
-    QApplication *app = (QApplication *)data;
-    QScopedLoopLevelCounter loopLevelCounter(app->d_func()->threadData);
-    long result;
-    if (app->filterEvent(&event, &result))
-        return result;
-    if(app->macEventFilter(er, event)) //someone else ate it
-        return noErr;
-    QPointer<QWidget> widget;
-
-    /*We assume all events are handled and in
-      the code below we set it to false when we know we didn't handle it, this
-      will let rogue events through (shouldn't really happen, but better safe
-      than sorry) */
-    bool handled_event=true;
-    UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
-    switch(eclass)
-    {
-    case kEventClassQt:
-        if(ekind == kEventQtRequestShowSheet) {
-            request_showsheet_pending = 0;
-            QWidget *widget = 0;
-            GetEventParameter(event, kEventParamQWidget, typeQWidget, 0,
-                              sizeof(widget), 0, &widget);
-            if(widget) {
-                if (widget->macEvent(er, event))
-                    return noErr;
-                WindowPtr window = qt_mac_window_for(widget);
-                bool just_show = !qt_mac_is_macsheet(widget);
-                if(!just_show) {
-                    OSStatus err = ShowSheetWindow(window, qt_mac_window_for(widget->parentWidget()));
-                    if(err != noErr)
-                        qWarning("Qt: QWidget: Unable to show as sheet %s::%s [%ld]", widget->metaObject()->className(),
-                                 widget->objectName().toLocal8Bit().constData(), long(err));
-                    just_show = true;
-                }
-                if(just_show) //at least the window will be visible, but the sheet flag doesn't work sadly (probalby too many sheets)
-                    ShowHide(window, true);
-            }
-        } else if(ekind == kEventQtRequestWindowChange) {
-            qt_mac_event_release(request_window_change_pending);
-        } else if(ekind == kEventQtRequestMenubarUpdate) {
-            qt_mac_event_release(request_menubarupdate_pending);
-            QMenuBar::macUpdateMenuBar();
-        } else if(ekind == kEventQtRequestActivate) {
-            qt_mac_event_release(request_activate_pending.event);
-            if(request_activate_pending.widget) {
-                QWidget *tlw = request_activate_pending.widget->window();
-                if (tlw->macEvent(er, event))
-                    return noErr;
-                request_activate_pending.widget = 0;
-                tlw->activateWindow();
-                SelectWindow(qt_mac_window_for(tlw));
-            }
-        } else if(ekind == kEventQtRequestContext) {
-            bool send = false;
-            if ((send = (event == request_context_pending)))
-                qt_mac_event_release(request_context_pending);
-            if(send) {
-                //figure out which widget to send it to
-                QPoint where = QCursor::pos();
-                QWidget *widget = 0;
-                GetEventParameter(event, kEventParamQWidget, typeQWidget, 0,
-                                  sizeof(widget), 0, &widget);
-                if(!widget) {
-                    if(qt_button_down)
-                        widget = qt_button_down;
-                    else
-                        widget = QApplication::widgetAt(where.x(), where.y());
-                }
-                if(widget && !isBlockedByModal(widget)) {
-                    if (widget->macEvent(er, event))
-                        return noErr;
-                    QPoint plocal(widget->mapFromGlobal(where));
-                    const Qt::KeyboardModifiers keyboardModifiers = qt_mac_get_modifiers(GetCurrentEventKeyModifiers());
-                    QContextMenuEvent qme(QContextMenuEvent::Mouse, plocal, where, keyboardModifiers);
-                    QApplication::sendEvent(widget, &qme);
-                    if(qme.isAccepted()) { //once this happens the events before are pitched
-                        qt_button_down = 0;
-                        qt_mac_dblclick.last_widget = 0;
-                    }
-                } else {
-                    handled_event = false;
-                }
-            }
-        } else {
-            handled_event = false;
-        }
-        break;
-    case kEventClassTablet:
-        switch (ekind) {
-        case kEventTabletProximity:
-            // Get the current point of the device and its unique ID.
-            ::TabletProximityRec proxRec;
-            GetEventParameter(event, kEventParamTabletProximityRec, typeTabletProximityRec, 0,
-                              sizeof(proxRec), 0, &proxRec);
-            qt_dispatchTabletProximityEvent(proxRec);
-        }
-        break;
-    case kEventClassMouse:
-    {
-        static const int kEventParamQAppSeenMouseEvent = 'QASM';
-        // Check if we've seen the event, if we have we shouldn't process
-        // it again as it may lead to spurious "double events"
-        bool seenEvent;
-        if (GetEventParameter(event, kEventParamQAppSeenMouseEvent,
-                              typeBoolean, 0, sizeof(bool), 0, &seenEvent) == noErr) {
-            if (seenEvent)
-                return eventNotHandledErr;
-        }
-        seenEvent = true;
-        SetEventParameter(event, kEventParamQAppSeenMouseEvent, typeBoolean,
-                          sizeof(bool), &seenEvent);
-
-        Point where;
-        bool inNonClientArea = false;
-        GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0,
-                          sizeof(where), 0, &where);
-#if defined(DEBUG_MOUSE_MAPS)
-        const char *edesc = 0;
-        switch(ekind) {
-        case kEventMouseDown: edesc = "MouseButtonPress"; break;
-        case kEventMouseUp: edesc = "MouseButtonRelease"; break;
-        case kEventMouseDragged: case kEventMouseMoved: edesc = "MouseMove"; break;
-        case kEventMouseScroll: edesc = "MouseWheelScroll"; break;
-        case kEventMouseWheelMoved: edesc = "MouseWheelMove"; break;
-        }
-        if(ekind == kEventMouseDown || ekind == kEventMouseUp)
-            qDebug("Handling mouse: %s", edesc);
-#endif
-        QEvent::Type etype = QEvent::None;
-        Qt::KeyboardModifiers modifiers;
-        {
-            UInt32 mac_modifiers = 0;
-            GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
-                              sizeof(mac_modifiers), 0, &mac_modifiers);
-            modifiers = qt_mac_get_modifiers(mac_modifiers);
-        }
-        Qt::MouseButtons buttons;
-        {
-            UInt32 mac_buttons = 0;
-            GetEventParameter(event, kEventParamMouseChord, typeUInt32, 0,
-                              sizeof(mac_buttons), 0, &mac_buttons);
-            if (ekind != kEventMouseWheelMoved)
-                buttons = qt_mac_get_buttons(mac_buttons);
-            else
-                buttons = QApplication::mouseButtons();
-        }
-
-        int wheel_deltaX = 0;
-        int wheel_deltaY = 0;
-        static EventRef compatibilityEvent = 0;
-
-        if (ekind == kEventMouseScroll) {
-            // kEventMouseScroll is the new way of dealing with mouse wheel
-            // events (kEventMouseWheelMoved was the old). kEventMouseScroll results
-            // in much smoother scrolling when using Mighty Mouse or TrackPad. For
-            // compatibility with older applications, carbon will also send us
-            // kEventMouseWheelMoved events if we dont eat this event
-            // (actually two events; one for horizontal and one for vertical).
-            // As a results of this, and to make sure we dont't receive duplicate events,
-            // we try to detect when this happend by checking the 'compatibilityEvent'.
-            // Since delta is delivered as pixels rather than degrees, we need to
-            // convert from pixels to degrees in a sensible manner.
-            // It looks like 1/4 degrees per pixel behaves most native.
-            // (NB: Qt expects the unit for delta to be 8 per degree):
-            const int pixelsToDegrees = 2;
-            SInt32 mdelt = 0;
-            GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0,
-                              sizeof(mdelt), 0, &mdelt);
-            wheel_deltaX = mdelt * pixelsToDegrees;
-            mdelt = 0;
-            GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0,
-                              sizeof(mdelt), 0, &mdelt);
-            wheel_deltaY = mdelt * pixelsToDegrees;
-            GetEventParameter(event, kEventParamEventRef, typeEventRef, 0,
-                              sizeof(compatibilityEvent), 0, &compatibilityEvent);
-        } else if (ekind == kEventMouseWheelMoved) {
-            if (event != compatibilityEvent) {
-                compatibilityEvent = 0;
-                int mdelt = 0;
-                GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0,
-                        sizeof(mdelt), 0, &mdelt);
-                EventMouseWheelAxis axis;
-                GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, 0,
-                        sizeof(axis), 0, &axis);
-
-                // Remove acceleration, and use either -120 or 120 as delta:
-                if (axis == kEventMouseWheelAxisX)
-                    wheel_deltaX = qBound(-120, int(mdelt * 10000), 120);
-                else
-                    wheel_deltaY = qBound(-120, int(mdelt * 10000), 120);
-            }
-        }
-
-        Qt::MouseButton button = Qt::NoButton;
-        if(ekind == kEventMouseDown || ekind == kEventMouseUp) {
-            EventMouseButton mac_button = 0;
-            GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0,
-                              sizeof(mac_button), 0, &mac_button);
-            button = qt_mac_get_button(mac_button);
-        }
-
-        switch(ekind) {
-        case kEventMouseDown:
-            etype = QEvent::MouseButtonPress;
-            break;
-        case kEventMouseUp:
-            etype = QEvent::MouseButtonRelease;
-            break;
-        case kEventMouseDragged:
-        case kEventMouseMoved:
-            etype = QEvent::MouseMove;
-            break;
-        }
-
-        const bool inPopupMode = app->d_func()->inPopupMode();
-
-        // A click outside a popup closes the popup. Make sure
-        // that no events are generated for the release part of that click.
-        // (The press goes to the popup and closes it.)
-        if (etype == QEvent::MouseButtonPress) {
-            qt_mac_previous_press_in_popup_mode = inPopupMode;
-        } else if (qt_mac_previous_press_in_popup_mode && !inPopupMode && etype == QEvent::MouseButtonRelease) {
-            qt_mac_previous_press_in_popup_mode = false;
-            handled_event = true;
-#if defined(DEBUG_MOUSE_MAPS)
-            qDebug("Bail out early due to qt_mac_previous_press_in_popup_mode");
-#endif
-            break; // break from case kEventClassMouse
-        }
-
-        //figure out which widget to send it to
-        if(inPopupMode) {
-            QWidget *popup = qApp->activePopupWidget();
-            if (qt_button_down && qt_button_down->window() == popup) {
-                widget = qt_button_down;
-            } else {
-                QPoint pos = popup->mapFromGlobal(QPoint(where.h, where.v));
-                widget = popup->childAt(pos);
-            }
-            if(!widget)
-                widget = popup;
-        } else {
-            if(mac_mouse_grabber) {
-                widget = mac_mouse_grabber;
-            } else if (qt_button_down) {
-                widget = qt_button_down;
-            } else {
-                {
-                    WindowPtr window = 0;
-                    if(GetEventParameter(event, kEventParamWindowRef, typeWindowRef, 0,
-                                         sizeof(window), 0, &window) != noErr)
-                        FindWindowOfClass(&where, kAllWindowClasses, &window, 0);
-                    if(window) {
-                        HIViewRef hiview;
-                        if(HIViewGetViewForMouseEvent(HIViewGetRoot(window), event, &hiview) == noErr) {
-                            widget = QWidget::find((WId)hiview);
-                            if (widget) {
-                                // Make sure we didn't pass over a widget with a "fake hole" in it.
-                                QWidget *otherWidget = QApplication::widgetAt(where.h, where.v);
-                                if (otherWidget && otherWidget->testAttribute(Qt::WA_MouseNoMask))
-                                    widget = otherWidget;
-                            }
-                        }
-                    }
-                }
-                if(!widget) //fallback
-                    widget = QApplication::widgetAt(where.h, where.v);
-                if(ekind == kEventMouseUp && widget) {
-                    short part = qt_mac_window_at(where.h, where.v);
-                    if(part == inDrag) {
-                        UInt32 count = 0;
-                        GetEventParameter(event, kEventParamClickCount, typeUInt32, NULL,
-                                          sizeof(count), NULL, &count);
-                        if(count == 2 && qt_mac_collapse_on_dblclick) {
-                            if (widget->macEvent(er, event))
-                                return noErr;
-                            widget->setWindowState(widget->windowState() | Qt::WindowMinimized);
-                            //we send a hide to be like X11/Windows
-                            QEvent e(QEvent::Hide);
-                            QApplication::sendSpontaneousEvent(widget, &e);
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        if (widget && widget->macEvent(er, event))
-            return noErr;
-        WindowPartCode wpc = qt_mac_window_at(where.h, where.v, 0);
-        if (wpc == inProxyIcon && modifiers == Qt::ControlModifier && buttons != Qt::NoButton) {
-            QIconDragEvent e;
-            QApplication::sendSpontaneousEvent(widget, &e);
-            if (e.isAccepted()) {
-                return noErr; // IconDrag ate it.
-            }
-        }
-        if (inPopupMode == false
-                && (qt_button_down == 0 || qt_button_down_in_content == false)
-                && (wpc != inContent && wpc != inStructure)) {
-            inNonClientArea = true;
-            switch (etype) {
-            case QEvent::MouseButtonPress: {
-                UInt32 count = 0;
-                GetEventParameter(event, kEventParamClickCount, typeUInt32, 0,
-                                      sizeof(count), 0, &count);
-                if(count % 2 || count == 0) {
-                    etype = QEvent::NonClientAreaMouseButtonPress;
-                } else {
-                    etype = QEvent::NonClientAreaMouseButtonDblClick;
-                }} break;
-            case QEvent::MouseButtonRelease:
-                etype = QEvent::NonClientAreaMouseButtonRelease;
-                break;
-            case QEvent::MouseMove:
-                if (widget == 0 || widget->hasMouseTracking())
-                    etype = QEvent::NonClientAreaMouseMove;
-                break;
-            default:
-                break;
-            }
-        }
-
-        if(qt_mac_find_window((FrontWindow()))) { //set the cursor up
-            QCursor cursor(Qt::ArrowCursor);
-            QWidget *cursor_widget = widget;
-            if(cursor_widget && cursor_widget == qt_button_down && ekind == kEventMouseUp)
-                cursor_widget = QApplication::widgetAt(where.h, where.v);
-            if(cursor_widget) { //only over the app, do we set a cursor..
-                if(!qApp->d_func()->cursor_list.isEmpty()) {
-                    cursor = qApp->d_func()->cursor_list.first();
-                } else {
-                    for(; cursor_widget; cursor_widget = cursor_widget->parentWidget()) {
-                        QWExtra *extra = cursor_widget->d_func()->extraData();
-                        if(extra && extra->curs && cursor_widget->isEnabled()) {
-                            cursor = *extra->curs;
-                            break;
-                        }
-                    }
-                }
-            }
-            qt_mac_set_cursor(&cursor);
-        }
-
-        //This mouse button state stuff looks like this on purpose
-        //although it looks hacky it is VERY intentional..
-        if(widget && app_do_modal && !qt_try_modal(widget, event)) {
-            if(ekind == kEventMouseDown && qt_mac_is_macsheet(QApplication::activeModalWidget()))
-                QApplication::activeModalWidget()->parentWidget()->activateWindow(); //sheets have a parent
-            handled_event = false;
-#if defined(DEBUG_MOUSE_MAPS)
-            qDebug("Bail out early due to qt_try_modal");
-#endif
-            break;
-        }
-
-        UInt32 tabletEventType = 0;
-        GetEventParameter(event, kEventParamTabletEventType, typeUInt32, 0,
-                          sizeof(tabletEventType), 0, &tabletEventType);
-        if (tabletEventType == kEventTabletPoint) {
-            TabletPointRec tabletPointRec;
-            GetEventParameter(event, kEventParamTabletPointRec, typeTabletPointRec, 0,
-                              sizeof(tabletPointRec), 0, &tabletPointRec);
-            QEvent::Type t = QEvent::TabletMove; //default
-            int new_tablet_button_state = tabletPointRec.buttons ? 1 : 0;
-            if (new_tablet_button_state != tablet_button_state)
-                if (new_tablet_button_state)
-                    t = QEvent::TabletPress;
-                else
-                    t = QEvent::TabletRelease;
-            tablet_button_state = new_tablet_button_state;
-
-            QMacTabletHash *tabletHash = qt_mac_tablet_hash();
-            if (!tabletHash->contains(tabletPointRec.deviceID) && t != QEvent::TabletRelease) {
-                // Never discard TabletRelease events as they may be delivered *after* TabletLeaveProximity events
-                qWarning("handleTabletEvent: This tablet device is unknown"
-                         " (received no proximity event for it). Discarding event.");
-                return false;
-            }
-            QTabletDeviceData &deviceData = tabletHash->operator[](tabletPointRec.deviceID);
-            if (t == QEvent::TabletPress) {
-                deviceData.widgetToGetPress = widget;
-            } else if (t == QEvent::TabletRelease && deviceData.widgetToGetPress) {
-                widget = deviceData.widgetToGetPress;
-                deviceData.widgetToGetPress = 0;
-            }
-
-            if (widget) {
-                int tiltX = ((int)tabletPointRec.tiltX)/(32767/64); // 32K -> 60
-                int tiltY = ((int)tabletPointRec.tiltY)/(-32767/64); // 32K -> 60
-                HIPoint hiPoint;
-                GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, 0, sizeof(HIPoint), 0, &hiPoint);
-                QPointF hiRes(hiPoint.x, hiPoint.y);
-                QPoint global(where.h, where.v);
-
-
-
-                QPoint local(widget->mapFromGlobal(global));
-                int z = 0;
-                qreal rotation = 0.0;
-                qreal tp = 0.0;
-                // Again from the Wacom.h header
-
-                if (deviceData.capabilityMask & 0x0200)     // Z-axis
-                    z = tabletPointRec.absZ;
-
-                if (deviceData.capabilityMask & 0x0800)  // Tangential pressure
-                    tp = tabletPointRec.tangentialPressure / 32767.0;
-
-                if (deviceData.capabilityMask & 0x2000) // Rotation
-                    rotation = qreal(tabletPointRec.rotation) / 64.0;
-
-                QTabletEvent e(t, local, global, hiRes, deviceData.tabletDeviceType,
-                               deviceData.tabletPointerType,
-                               qreal(tabletPointRec.pressure / qreal(0xffff)), tiltX, tiltY,
-                               tp, rotation, z, modifiers, deviceData.tabletUniqueID);
-                QApplication::sendSpontaneousEvent(widget, &e);
-                if (e.isAccepted()) {
-                    if (t == QEvent::TabletPress) {
-                        qt_button_down = widget;
-                    } else if (t == QEvent::TabletRelease) {
-                        qt_button_down = 0;
-                    }
-#if defined(DEBUG_MOUSE_MAPS)
-                    qDebug("Bail out early due to tablet acceptance");
-#endif
-                    break;
-                }
-            }
-        }
-
-        if(ekind == kEventMouseDown) {
-            qt_mac_no_click_through_mode = false;
-            const short windowPart = qt_mac_window_at(where.h, where.v, 0);
-            // Menubar almost always wins.
-            if (!inPopupMode && windowPart == inMenuBar) {
-                MenuSelect(where); //allow menu tracking
-                return noErr;
-            }
-
-            if (widget && !(GetCurrentKeyModifiers() & cmdKey)) {
-                extern bool qt_isGenuineQWidget(const QWidget *); // qwidget_mac.cpp
-                QWidget *window = widget->window();
-                bool genuineQtWidget = qt_isGenuineQWidget(widget);  // the widget, not the window.
-                window->raise();
-
-                bool needActivate = (window->windowType() != Qt::Desktop)
-                                     && (window->windowType() != Qt::Popup)
-                                     && !qt_mac_is_macsheet(window);
-                if (needActivate && (!window->isModal() && qobject_cast<QDockWidget *>(window)))
-                    needActivate = false;
-
-                if (genuineQtWidget && needActivate)
-                    needActivate = !window->isActiveWindow()
-                                    || !IsWindowActive(qt_mac_window_for(window));
-
-                if (needActivate) {
-                    window->activateWindow();
-                    if (!qt_mac_can_clickThrough(widget)) {
-                        qt_mac_no_click_through_mode = true;
-                        handled_event = false;
-#if defined(DEBUG_MOUSE_MAPS)
-                        qDebug("Bail out early due to qt_mac_canClickThrough %s::%s", widget->metaObject()->className(),
-                                widget->objectName().toLocal8Bit().constData());
-#endif
-                        break;
-                    }
-                }
-            }
-
-            if(qt_mac_dblclick.last_widget &&
-               qt_mac_dblclick.last_x != -1 && qt_mac_dblclick.last_y != -1 &&
-               QRect(qt_mac_dblclick.last_x-2, qt_mac_dblclick.last_y-2, 4, 4).contains(QPoint(where.h, where.v))) {
-                if(qt_mac_dblclick.use_qt_time_limit) {
-                    EventTime now = GetEventTime(event);
-                    if(qt_mac_dblclick.last_time != -2 && qt_mac_dblclick.last_widget == widget &&
-                       now - qt_mac_dblclick.last_time <= ((double)QApplicationPrivate::mouse_double_click_time)/1000 &&
-                       qt_mac_dblclick.last_button == button)
-                        etype = QEvent::MouseButtonDblClick;
-                } else {
-                    UInt32 count = 0;
-                    GetEventParameter(event, kEventParamClickCount, typeUInt32, 0,
-                                      sizeof(count), 0, &count);
-                    if(!(count % 2) && qt_mac_dblclick.last_modifiers == modifiers &&
-                       qt_mac_dblclick.last_widget == widget && qt_mac_dblclick.last_button == button)
-                        etype = QEvent::MouseButtonDblClick;
-                }
-                if(etype == QEvent::MouseButtonDblClick)
-                    qt_mac_dblclick.last_widget = 0;
-            }
-            if(etype != QEvent::MouseButtonDblClick) {
-                qt_mac_dblclick.last_x = where.h;
-                qt_mac_dblclick.last_y = where.v;
-            } else {
-                qt_mac_dblclick.last_x = qt_mac_dblclick.last_y = -1;
-            }
-        } else if(qt_mac_no_click_through_mode) {
-            if(ekind == kEventMouseUp)
-                qt_mac_no_click_through_mode = false;
-            handled_event = false;
-#if defined(DEBUG_MOUSE_MAPS)
-            qDebug("Bail out early due to qt_mac_no_click_through_mode");
-#endif
-            break;
-        }
-
-        QPointer<QWidget> leaveAfterRelease = 0;
-        switch(ekind) {
-        case kEventMouseUp:
-            if (!buttons) {
-                if (!inPopupMode && !QWidget::mouseGrabber())
-                    leaveAfterRelease = qt_button_down;
-                qt_button_down = 0;
-            }
-            break;
-        case kEventMouseDown: {
-            if (!qt_button_down)
-                qt_button_down = widget;
-            WindowPartCode wpc = qt_mac_window_at(where.h, where.v, 0);
-            qt_button_down_in_content = (wpc == inContent || wpc == inStructure);
-            break;  }
-        }
-
-        // Check if we should send enter/leave events:
-        switch(ekind) {
-        case kEventMouseDragged:
-        case kEventMouseMoved:
-        case kEventMouseUp:
-        case kEventMouseDown: {
-            // If we are in popup mode, widget will point to the current popup no matter
-            // where the mouse cursor is. In that case find out if the mouse cursor is
-            // really over the popup in order to send correct enter / leave envents.
-            QWidget * const enterLeaveWidget = (inPopupMode || ekind == kEventMouseUp) ?
-                    QApplication::widgetAt(where.h, where.v) :  static_cast<QWidget*>(widget);
-
-            if ((QWidget *) qt_last_mouse_receiver != enterLeaveWidget || inNonClientArea) {
-#ifdef DEBUG_MOUSE_MAPS
-                qDebug("Entering: %p - %s (%s), Leaving %s (%s)", (QWidget*)enterLeaveWidget,
-                       enterLeaveWidget ? enterLeaveWidget->metaObject()->className() : "none",
-                       enterLeaveWidget ? enterLeaveWidget->objectName().toLocal8Bit().constData() : "",
-                       qt_last_mouse_receiver ? qt_last_mouse_receiver->metaObject()->className() : "none",
-                       qt_last_mouse_receiver ? qt_last_mouse_receiver->objectName().toLocal8Bit().constData() : "");
-#endif
-
-                QWidget * const mouseGrabber = QWidget::mouseGrabber();
-
-                if (inPopupMode) {
-                    QWidget *enter = enterLeaveWidget;
-                    QWidget *leave = qt_last_mouse_receiver;
-                    if (mouseGrabber) {
-                        QWidget * const popupWidget = qApp->activePopupWidget();
-                        if (leave == popupWidget)
-                            enter = mouseGrabber;
-                        if (enter == popupWidget)
-                            leave = mouseGrabber;
-                        if ((enter == mouseGrabber && leave == popupWidget)
-                            || (leave == mouseGrabber  && enter == popupWidget)) {
-                            QApplicationPrivate::dispatchEnterLeave(enter, leave);
-                            qt_last_mouse_receiver = enter;
-                        }
-                    } else {
-                        QApplicationPrivate::dispatchEnterLeave(enter, leave);
-                        qt_last_mouse_receiver = enter;
-                    }
-                } else if ((!qt_button_down || !qt_last_mouse_receiver) && !mouseGrabber && !leaveAfterRelease) {
-                    QApplicationPrivate::dispatchEnterLeave(enterLeaveWidget, qt_last_mouse_receiver);
-                    qt_last_mouse_receiver = enterLeaveWidget;
-                }
-            }
-            break; }
-        }
-
-        if(widget) {
-            QPoint p(where.h, where.v);
-            QPoint plocal(widget->mapFromGlobal(p));
-            if(etype == QEvent::MouseButtonPress) {
-                qt_mac_dblclick.last_widget = widget;
-                qt_mac_dblclick.last_modifiers = modifiers;
-                qt_mac_dblclick.last_button = button;
-                qt_mac_dblclick.last_time = GetEventTime(event);
-            }
-
-            if (wheel_deltaX || wheel_deltaY) {
-#ifndef QT_NO_WHEELEVENT
-                if (wheel_deltaX) {
-                    QWheelEvent qwe(plocal, p, wheel_deltaX, buttons, modifiers, Qt::Horizontal);
-                    QApplication::sendSpontaneousEvent(widget, &qwe);
-                    if (!qwe.isAccepted() && QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget != widget) {
-                        QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(p), p,
-                                wheel_deltaX, buttons, modifiers, Qt::Horizontal);
-                        QApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
-                        if (!qwe2.isAccepted())
-                            handled_event = false;
-                    }
-                }
-                if (wheel_deltaY) {
-                    QWheelEvent qwe(plocal, p, wheel_deltaY, buttons, modifiers, Qt::Vertical);
-                    QApplication::sendSpontaneousEvent(widget, &qwe);
-                    if (!qwe.isAccepted() && QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget != widget) {
-                        QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(p), p,
-                                wheel_deltaY, buttons, modifiers, Qt::Vertical);
-                        QApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
-                        if (!qwe2.isAccepted())
-                            handled_event = false;
-                    }
-                }
-#endif // QT_NO_WHEELEVENT
-            } else {
-#ifdef QMAC_SPEAK_TO_ME
-                const int speak_keys = Qt::AltModifier | Qt::ShiftModifier;
-               if(etype == QMouseEvent::MouseButtonDblClick && ((modifiers & speak_keys) == speak_keys)) {
-                    QVariant v = widget->property("displayText");
-                    if(!v.isValid()) v = widget->property("text");
-                    if(!v.isValid()) v = widget->property("windowTitle");
-                    if(v.isValid()) {
-                        QString s = v.toString();
-                        s.replace(QRegExp(QString::fromLatin1("(\\&|\\<[^\\>]*\\>)")), QLatin1String(""));
-                        SpeechChannel ch;
-                        NewSpeechChannel(0, &ch);
-                        SpeakText(ch, s.toLatin1().constData(), s.length());
-                        DisposeSpeechChannel(ch);
-                    }
-                }
-#endif
-                Qt::MouseButton buttonToSend = button;
-                static bool lastButtonTranslated = false;
-                if(ekind == kEventMouseDown &&
-                   button == Qt::LeftButton && (modifiers & Qt::MetaModifier)) {
-                    buttonToSend = Qt::RightButton;
-                    lastButtonTranslated = true;
-                } else if(ekind == kEventMouseUp && lastButtonTranslated) {
-                    buttonToSend = Qt::RightButton;
-                    lastButtonTranslated = false;
-                }
-                QMouseEvent qme(etype, plocal, p, buttonToSend, buttons, modifiers);
-                QApplication::sendSpontaneousEvent(widget, &qme);
-                if(!qme.isAccepted() || inNonClientArea)
-                    handled_event = false;
-            }
-
-            if (leaveAfterRelease) {
-                QWidget *enter = QApplication::widgetAt(where.h, where.v);
-                QApplicationPrivate::dispatchEnterLeave(enter, leaveAfterRelease);
-                qt_last_mouse_receiver = enter;
-                leaveAfterRelease = 0;
-            }
-
-            if(ekind == kEventMouseDown &&
-               ((button == Qt::RightButton) ||
-                (button == Qt::LeftButton && (modifiers & Qt::MetaModifier))))
-                qt_event_request_context();
-
-#ifdef DEBUG_MOUSE_MAPS
-            const char *event_desc = edesc;
-            if(etype == QEvent::MouseButtonDblClick)
-                event_desc = "Double Click";
-            else if(etype == QEvent::NonClientAreaMouseButtonPress)
-                event_desc = "NonClientMousePress";
-            else if(etype == QEvent::NonClientAreaMouseButtonRelease)
-                event_desc = "NonClientMouseRelease";
-            else if(etype == QEvent::NonClientAreaMouseMove)
-                event_desc = "NonClientMouseMove";
-            else if(etype == QEvent::NonClientAreaMouseButtonDblClick)
-                event_desc = "NonClientMouseDblClick";
-            qDebug("%d %d (%d %d) - Would send (%s) event to %p %s %s (%d 0x%08x 0x%08x %d)", p.x(), p.y(),
-                   plocal.x(), plocal.y(), event_desc, (QWidget*)widget,
-                   widget ? widget->objectName().toLocal8Bit().constData() : "*Unknown*",
-                   widget ? widget->metaObject()->className() : "*Unknown*",
-                   button, (int)buttons, (int)modifiers, wheel_deltaX);
-#endif
-        } else {
-            handled_event = false;
-        }
-        break;
-    }
-    case kEventClassTextInput:
-    case kEventClassKeyboard: {
-        EventRef key_event = event;
-        if(eclass == kEventClassTextInput) {
-            Q_ASSERT(ekind == kEventTextInputUnicodeForKeyEvent);
-            OSStatus err = GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0,
-                                             sizeof(key_event), 0, &key_event);
-            Q_ASSERT(err == noErr);
-            Q_UNUSED(err);
-        }
-        const UInt32 key_ekind = GetEventKind(key_event);
-        Q_ASSERT(GetEventClass(key_event) == kEventClassKeyboard);
-
-        if(key_ekind == kEventRawKeyDown)
-            qt_keymapper_private()->updateKeyMap(er, key_event, data);
-        if(mac_keyboard_grabber)
-            widget = mac_keyboard_grabber;
-        else if (app->activePopupWidget())
-            widget = (app->activePopupWidget()->focusWidget() ?
-                      app->activePopupWidget()->focusWidget() : app->activePopupWidget());
-        else if(QApplication::focusWidget())
-            widget = QApplication::focusWidget();
-        else
-            widget = app->activeWindow();
-
-        if (widget) {
-            if (widget->macEvent(er, event))
-                return noErr;
-        } else {
-            // Darn, I need to update tho modifier state, even though
-            // Qt itself isn't getting them, otherwise the keyboard state get inconsistent.
-            if (key_ekind == kEventRawKeyModifiersChanged) {
-                UInt32 modifiers = 0;
-                GetEventParameter(key_event, kEventParamKeyModifiers, typeUInt32, 0,
-                                  sizeof(modifiers), 0, &modifiers);
-                extern void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object); // qkeymapper_mac.cpp
-                // Just send it to the qApp for the time being.
-                qt_mac_send_modifiers_changed(modifiers, qApp);
-            }
-            handled_event = false;
-            break;
-        }
-
-        if(app_do_modal && !qt_try_modal(widget, key_event))
-            break;
-        if (eclass == kEventClassTextInput) {
-            handled_event = false;
-        } else {
-            handled_event = qt_keymapper_private()->translateKeyEvent(widget, er, key_event, data,
-                                                                      widget == mac_keyboard_grabber);
-        }
-        break; }
-    case kEventClassWindow: {
-        WindowRef wid = 0;
-        GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 0,
-                          sizeof(WindowRef), 0, &wid);
-        widget = qt_mac_find_window(wid);
-        if (widget && widget->macEvent(er, event))
-            return noErr;
-        if(ekind == kEventWindowActivated) {
-            if(QApplicationPrivate::app_style) {
-                QEvent ev(QEvent::Style);
-                QApplication::sendSpontaneousEvent(QApplicationPrivate::app_style, &ev);
-            }
-
-            if(widget && app_do_modal && !qt_try_modal(widget, event))
-                break;
-
-            if(widget && widget->window()->isVisible()) {
-                QWidget *tlw = widget->window();
-               if(tlw->isWindow() && !(tlw->windowType() == Qt::Popup)
-                   && !qt_mac_is_macdrawer(tlw)
-                   && (!tlw->parentWidget() || tlw->isModal()
-                       || !(tlw->windowType() == Qt::Tool))) {
-                    bool just_send_event = false;
-                    {
-                        WindowActivationScope scope;
-                        if(GetWindowActivationScope((WindowRef)wid, &scope) == noErr &&
-                           scope == kWindowActivationScopeIndependent) {
-                            if(GetFrontWindowOfClass(kAllWindowClasses, true) != wid)
-                                just_send_event = true;
-                        }
-                    }
-                    if(just_send_event) {
-                        QEvent e(QEvent::WindowActivate);
-                        QApplication::sendSpontaneousEvent(widget, &e);
-                    } else {
-                        app->setActiveWindow(tlw);
-                    }
-                }
-                QMenuBar::macUpdateMenuBar();
-            }
-        } else if(ekind == kEventWindowDeactivated) {
-            if(widget && QApplicationPrivate::active_window == widget)
-                app->setActiveWindow(0);
-        } else {
-            handled_event = false;
-        }
-        break; }
-    case kEventClassApplication:
-        if(ekind == kEventAppActivated) {
-            if(QApplication::desktopSettingsAware())
-                qt_mac_update_os_settings();
-            if(qt_clipboard) { //manufacture an event so the clipboard can see if it has changed
-                QEvent ev(QEvent::Clipboard);
-                QApplication::sendSpontaneousEvent(qt_clipboard, &ev);
-            }
-            if(app) {
-                QEvent ev(QEvent::ApplicationActivate);
-                QApplication::sendSpontaneousEvent(app, &ev);
-            }
-            if(!app->activeWindow()) {
-                WindowPtr wp = ActiveNonFloatingWindow();
-                if(QWidget *tmp_w = qt_mac_find_window(wp))
-                    app->setActiveWindow(tmp_w);
-            }
-            QMenuBar::macUpdateMenuBar();
-        } else if(ekind == kEventAppDeactivated) {
-            //qt_mac_no_click_through_mode = false;
-            while(app->d_func()->inPopupMode())
-                app->activePopupWidget()->close();
-            if(app) {
-                QEvent ev(QEvent::ApplicationDeactivate);
-                QApplication::sendSpontaneousEvent(app, &ev);
-            }
-            app->setActiveWindow(0);
-        } else if(ekind == kEventAppAvailableWindowBoundsChanged) {
-            QDesktopWidgetImplementation::instance()->onResize();
-        } else {
-            handled_event = false;
-        }
-        break;
-    case kAppearanceEventClass:
-        if(ekind == kAEAppearanceChanged) {
-            if(QApplication::desktopSettingsAware())
-                qt_mac_update_os_settings();
-            if(QApplicationPrivate::app_style) {
-                QEvent ev(QEvent::Style);
-                QApplication::sendSpontaneousEvent(QApplicationPrivate::app_style, &ev);
-            }
-        } else {
-            handled_event = false;
-        }
-        break;
-    case kEventClassAppleEvent:
-        if(ekind == kEventAppleEvent) {
-            EventRecord erec;
-            if(!ConvertEventRefToEventRecord(event, &erec))
-                qDebug("Qt: internal: WH0A, unexpected condition reached. %s:%d", __FILE__, __LINE__);
-            else if(AEProcessAppleEvent(&erec) != noErr)
-                handled_event = false;
-        } else {
-            handled_event = false;
-        }
-        break;
-    case kEventClassCommand:
-        if(ekind == kEventCommandProcess) {
-            HICommand cmd;
-            GetEventParameter(event, kEventParamDirectObject, typeHICommand,
-                              0, sizeof(cmd), 0, &cmd);
-            handled_event = false;
-            if(!cmd.menu.menuRef && GetApplicationDockTileMenu()) {
-                EventRef copy = CopyEvent(event);
-                HICommand copy_cmd;
-                GetEventParameter(event, kEventParamDirectObject, typeHICommand,
-                                  0, sizeof(copy_cmd), 0, &copy_cmd);
-                copy_cmd.menu.menuRef = GetApplicationDockTileMenu();
-                SetEventParameter(copy, kEventParamDirectObject, typeHICommand, sizeof(copy_cmd), &copy_cmd);
-                if(SendEventToMenu(copy, copy_cmd.menu.menuRef) == noErr)
-                    handled_event = true;
-            }
-            if(!handled_event) {
-                if(cmd.commandID == kHICommandQuit) {
-                    // Quitting the application is not Qt's responsibility if
-                    // used in a plugin or just embedded into a native application.
-                    // In that case, let the event pass down to the native apps event handler.
-                    if (!QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
-                        handled_event = true;
-                        HiliteMenu(0);
-                        bool handle_quit = true;
-                        if(QApplicationPrivate::modalState()) {
-                            int visible = 0;
-                            const QWidgetList tlws = QApplication::topLevelWidgets();
-                            for(int i = 0; i < tlws.size(); ++i) {
-                                if(tlws.at(i)->isVisible())
-                                    ++visible;
-                            }
-                            handle_quit = (visible <= 1);
-                        }
-                        if(handle_quit) {
-                            QCloseEvent ev;
-                            QApplication::sendSpontaneousEvent(app, &ev);
-                            if(ev.isAccepted())
-                                app->quit();
-                        } else {
-                            QApplication::beep();
-                        }
-                    }
-                } else if(cmd.commandID == kHICommandSelectWindow) {
-                    if((GetCurrentKeyModifiers() & cmdKey))
-                        handled_event = true;
-                } else if(cmd.commandID == kHICommandAbout) {
-                    QMessageBox::aboutQt(0);
-                    HiliteMenu(0);
-                    handled_event = true;
-                }
-            }
-        }
-        break;
-    }
-
-#ifdef DEBUG_EVENTS
-    qDebug("%shandled event %c%c%c%c %d", handled_event ? "(*) " : "",
-           char(eclass >> 24), char((eclass >> 16) & 255), char((eclass >> 8) & 255),
-           char(eclass & 255), (int)ekind);
-#endif
-    if(!handled_event) //let the event go through
-        return eventNotHandledErr;
-    return noErr; //we eat the event
-#else
     Q_UNUSED(er);
     Q_UNUSED(event);
     Q_UNUSED(data);
     return eventNotHandledErr;
-#endif
 }
 
-#ifdef QT_MAC_USE_COCOA
 void QApplicationPrivate::qt_initAfterNSAppStarted()
 {
     setupAppleEvents();
@@ -2511,7 +1285,6 @@ void QApplicationPrivate::setupAppleEvents()
     [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:)
       forEventClass:kInternetEventClass andEventID:kAEGetURL];
 }
-#endif
 
 // In Carbon this is your one stop for apple events.
 // In Cocoa, it ISN'T. This is the catch-all Apple Event handler that exists
@@ -3013,15 +1786,8 @@ bool QApplicationPrivate::qt_mac_apply_settings()
 
 bool QApplicationPrivate::canQuit()
 {
-#ifndef QT_MAC_USE_COCOA
-    return true;
-#else
     Q_Q(QApplication);
-#ifdef QT_MAC_USE_COCOA
     [[NSApp mainMenu] cancelTracking];
-#else
-    HiliteMenu(0);
-#endif
 
     bool handle_quit = true;
     if (QApplicationPrivate::modalState() && [[[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]
@@ -3042,12 +1808,10 @@ bool QApplicationPrivate::canQuit()
         }
     }
     return false;
-#endif
 }
 
 void onApplicationWindowChangedActivation(QWidget *widget, bool activated)
 {
-#if QT_MAC_USE_COCOA
     if (!widget)
         return;
 
@@ -3064,16 +1828,11 @@ void onApplicationWindowChangedActivation(QWidget *widget, bool activated)
 
     QMenuBar::macUpdateMenuBar();
     qt_mac_update_cursor();
-#else
-    Q_UNUSED(widget);
-    Q_UNUSED(activated);
-#endif
 }
 
 
 void onApplicationChangedActivation( bool activated )
 {
-#if QT_MAC_USE_COCOA
     QApplication    *app    = qApp;
 
 //NSLog(@"App Changed Activation\n");
@@ -3109,9 +1868,6 @@ void onApplicationChangedActivation( bool activated )
         }
         app->setActiveWindow(0);
     }
-#else
-    Q_UNUSED(activated);
-#endif
 }
 
 void QApplicationPrivate::initializeMultitouch_sys()
index 002b8da..b8a4d29 100644 (file)
@@ -388,7 +388,6 @@ QMacPasteboard::setMimeData(QMimeData *mime_src)
         clear_helper();
         QStringList formats = mime_src->formats();
 
-#ifdef QT_MAC_USE_COCOA
         // QMimeData sub classes reimplementing the formats() might not expose the
         // temporary "application/x-qt-mime-type-name" mimetype. So check the existence
         // of this mime type while doing drag and drop.
@@ -399,7 +398,6 @@ QMacPasteboard::setMimeData(QMimeData *mime_src)
                 formats.append(dummyMimeType);
             }
         }
-#endif
         for(int f = 0; f < formats.size(); ++f) {
             QString mimeType = formats.at(f);
             for (QList<QMacPasteboardMime *>::Iterator it = availableConverters.begin(); it != availableConverters.end(); ++it) {
index ed2fbea..7388f5a 100644 (file)
@@ -79,9 +79,6 @@ QT_BEGIN_NAMESPACE
 
 void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
 {
-#ifndef QT_MAC_USE_COCOA
-    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
-#endif
     {
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
         // The following code replaces the _implementation_ for the selector we want to hack
@@ -110,9 +107,6 @@ void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class prox
 
 void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)
 {
-#ifndef QT_MAC_USE_COCOA
-    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
-#endif
     {
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
         Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
index 5b490cf..2dca64d 100644 (file)
@@ -40,7 +40,6 @@
 ****************************************************************************/
 
 #import <private/qcocoapanel_mac_p.h>
-#ifdef QT_MAC_USE_COCOA
 #import <private/qt_cocoa_helpers_mac_p.h>
 #import <private/qcocoawindow_mac_p.h>
 #import <private/qcocoawindowdelegate_mac_p.h>
@@ -67,4 +66,3 @@ QT_USE_NAMESPACE
 #include "qcocoasharedwindowmethods_mac_p.h"
 
 @end
-#endif
index ad02b16..43282be 100644 (file)
@@ -54,7 +54,6 @@
 #define QCOCOAPANEL_MAC_P
 
 #include "qmacdefines_mac.h"
-#ifdef QT_MAC_USE_COCOA
 #import <Cocoa/Cocoa.h>
 
 QT_FORWARD_DECLARE_CLASS(QStringList);
@@ -78,6 +77,5 @@ QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
 - (void)drawRectOriginal:(NSRect)rect;
 
 @end
-#endif
 
 #endif
index 6c5e05b..61a5ee1 100644 (file)
@@ -40,7 +40,6 @@
 ****************************************************************************/
 
 #import <private/qcocoaview_mac_p.h>
-#ifdef QT_MAC_USE_COCOA
 
 #include <private/qwidget_p.h>
 #include <private/qt_mac_p.h>
@@ -1385,4 +1384,3 @@ Qt::DropAction QDragManager::drag(QDrag *o)
 
 QT_END_NAMESPACE
 
-#endif // QT_MAC_USE_COCOA
index 963cbe0..928e489 100644 (file)
@@ -51,7 +51,6 @@
 //
 
 #include <qevent.h>
-#ifdef QT_MAC_USE_COCOA
 #import <Cocoa/Cocoa.h>
 
 @class QT_MANGLE_NAMESPACE(QCocoaView);
@@ -84,4 +83,3 @@ Q_WIDGETS_EXPORT
 - (void) qt_clearQWidget;
 
 @end
-#endif
index fba69a3..730504f 100644 (file)
@@ -40,7 +40,6 @@
 ****************************************************************************/
 
 #include "qmacdefines_mac.h"
-#ifdef QT_MAC_USE_COCOA
 #import <private/qcocoawindow_mac_p.h>
 #import <private/qcocoawindowdelegate_mac_p.h>
 #import <private/qcocoaview_mac_p.h>
@@ -87,4 +86,3 @@ QT_USE_NAMESPACE
 #include "qcocoasharedwindowmethods_mac_p.h"
 
 @end
-#endif
index 9013f66..704e6bd 100644 (file)
@@ -53,7 +53,6 @@
 #ifndef QCOCOAWINDOW_MAC_P
 #define QCOCOAWINDOW_MAC_P
 
-#ifdef QT_MAC_USE_COCOA
 #include "qmacdefines_mac.h"
 #import <Cocoa/Cocoa.h>
 #include <private/qapplication_p.h>
@@ -92,6 +91,5 @@ QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
 - (void)drawRectOriginal:(NSRect)rect;
 
 @end
-#endif
 
 #endif
index cc25542..9e3b4cf 100644 (file)
@@ -41,7 +41,6 @@
 
 #include "qmacdefines_mac.h"
 
-#ifdef QT_MAC_USE_COCOA
 
 #import "private/qcocoawindowcustomthemeframe_mac_p.h"
 #import "private/qcocoawindow_mac_p.h"
@@ -59,4 +58,3 @@
 
 @end
 
-#endif
index 772fd2b..44fb9b6 100644 (file)
@@ -40,7 +40,6 @@
 ****************************************************************************/
 
 #import "private/qcocoawindowdelegate_mac_p.h"
-#ifdef QT_MAC_USE_COCOA
 #include <private/qwidget_p.h>
 #include <private/qapplication_p.h>
 #include <private/qt_cocoa_helpers_mac_p.h>
@@ -436,4 +435,3 @@ static void cleanupCocoaWindowDelegate()
 }
 
 @end
-#endif// QT_MAC_USE_COCOA
index a510ae4..261d1d1 100644 (file)
@@ -52,7 +52,6 @@
 
 #include "qmacdefines_mac.h"
 
-#ifdef QT_MAC_USE_COCOA
 #import <Cocoa/Cocoa.h>
 
 QT_BEGIN_NAMESPACE
@@ -107,4 +106,3 @@ QT_FORWARD_DECLARE_CLASS(QWidgetData)
 - (QWidget *)qt_qwidgetForWindow:(NSWindow *)window;
 - (void)syncContentViewFrame: (NSNotification *)notification;
 @end
-#endif
index 0b0abaa..4247e18 100644 (file)
@@ -107,33 +107,8 @@ static QCursorData *currentCursor = 0; //current cursor
 
 void qt_mac_set_cursor(const QCursor *c)
 {
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(*c)) set];
-#else
-    if (!c) {
-        currentCursor = 0;
-        return;
-    }
-    c->handle(); //force the cursor to get loaded, if it's not
-
-    if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor
-            && currentCursor->curs.tc.anim)
-        currentCursor->curs.tc.anim->stop();
-    if(c->d->type == QCursorData::TYPE_ImageCursor) {
-        [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set];
-    } else if(c->d->type == QCursorData::TYPE_ThemeCursor) {
-        if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) {
-            SetThemeCursor(c->d->curs.tc.curs);
-        } else {
-            if(!c->d->curs.tc.anim)
-                c->d->curs.tc.anim = new QMacAnimateCursor;
-            c->d->curs.tc.anim->start(c->d->curs.tc.curs);
-        }
-    }
-
-    currentCursor = c->d;
-#endif
 }
 
 static QPointer<QWidget> lastWidgetUnderMouse = 0;
@@ -186,16 +161,12 @@ void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse)
         }
     }
 
-#ifdef QT_MAC_USE_COCOA
     cursor.d->update();
     NSCursor *nsCursor = static_cast<NSCursor *>(cursor.d->curs.cp.nscursor);
     if ([NSCursor currentCursor] != nsCursor) {
         QMacCocoaAutoReleasePool pool;
         [nsCursor set];
     }
-#else
-    qt_mac_set_cursor(&cursor);
-#endif
 }
 
 void qt_mac_update_cursor()
@@ -206,7 +177,6 @@ void qt_mac_update_cursor()
     // application has been deactivated/activated etc.
     // NB: since we dont have any true native widget, the call to
     // qt_mac_getTargetForMouseEvent will fail when the mouse is over QMacNativeWidgets.
-#ifdef QT_MAC_USE_COCOA
     lastWidgetUnderMouse = 0;
     lastMouseCursorWidget = 0;
     QWidget *widgetUnderMouse = 0;
@@ -219,9 +189,6 @@ void qt_mac_update_cursor()
         qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, 0, &widgetUnderMouse);
     }
     qt_mac_updateCursorWithWidgetUnderMouse(widgetUnderMouse);
-#else
-    qt_mac_updateCursorWithWidgetUnderMouse(QApplication::widgetAt(QCursor::pos()));
-#endif
 }
 
 void qt_mac_setMouseGrabCursor(bool set, QCursor *const cursor = 0)
@@ -241,12 +208,6 @@ void qt_mac_setMouseGrabCursor(bool set, QCursor *const cursor = 0)
     qt_mac_update_cursor();
 }
 
-#ifndef QT_MAC_USE_COCOA
-void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
-{
-    qt_mac_updateCursorWithWidgetUnderMouse(QApplication::widgetAt(globalPos));
-}
-#endif
 
 static int nextCursorId = Qt::BitmapCursor;
 
@@ -314,7 +275,6 @@ QPoint QCursor::pos()
 
 void QCursor::setPos(int x, int y)
 {
-#ifdef QT_MAC_USE_COCOA
     CGPoint pos;
     pos.x = x;
     pos.y = y;
@@ -322,24 +282,6 @@ void QCursor::setPos(int x, int y)
     CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0);
     CGEventPost(kCGHIDEventTap, e);
     CFRelease(e);
-#else
-    CGWarpMouseCursorPosition(CGPointMake(x, y));
-
-    /* I'm not too keen on doing this, but this makes it a lot easier, so I just
-       send the event back through the event system and let it get propagated correctly
-       ideally this would not really need to be faked --Sam
-    */
-    QWidget *widget = 0;
-    if(QWidget *grb = QWidget::mouseGrabber())
-        widget = grb;
-    else
-        widget = QApplication::widgetAt(QPoint(x, y));
-    if(widget) {
-        QMouseEvent me(QMouseEvent::MouseMove, widget->mapFromGlobal(QPoint(x, y)), Qt::NoButton,
-                       QApplication::mouseButtons(), QApplication::keyboardModifiers());
-        qt_sendSpontaneousEvent(widget, &me);
-    }
-#endif
 }
 
 void QCursorData::initCursorFromBitmap()
@@ -453,7 +395,6 @@ void QCursorData::update()
 #endif
     const uchar *cursorData = 0;
     const uchar *cursorMaskData = 0;
-#ifdef QT_MAC_USE_COCOA
     switch (cshape) {                        // map Q cursor to MAC cursor
     case Qt::BitmapCursor: {
         if (pixmap.isNull())
@@ -561,114 +502,6 @@ void QCursorData::update()
         qWarning("Qt: QCursor::update: Invalid cursor shape %d", cshape);
         return;
     }
-#else
-    // Carbon
-    switch (cshape) {                        // map Q cursor to MAC cursor
-    case Qt::BitmapCursor: {
-        if (pixmap.isNull())
-            initCursorFromBitmap();
-        else
-            initCursorFromPixmap();
-        break; }
-    case Qt::BlankCursor: {
-        pixmap = QPixmap(16, 16);
-        pixmap.fill(Qt::transparent);
-        initCursorFromPixmap();
-        break; }
-    case Qt::ArrowCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeArrowCursor;
-        break; }
-    case Qt::CrossCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeCrossCursor;
-        break; }
-    case Qt::WaitCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeWatchCursor;
-        break; }
-    case Qt::IBeamCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeIBeamCursor;
-        break; }
-    case Qt::SizeAllCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemePlusCursor;
-        break; }
-    case Qt::WhatsThisCursor: { //for now just use the pointing hand
-    case Qt::PointingHandCursor:
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemePointingHandCursor;
-        break; }
-    case Qt::BusyCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeSpinningCursor;
-        break; }
-    case Qt::SplitVCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeResizeUpDownCursor;
-        break; }
-    case Qt::SplitHCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeResizeLeftRightCursor;
-        break; }
-    case Qt::ForbiddenCursor: {
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeNotAllowedCursor;
-        break; }
-    case Qt::OpenHandCursor:
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeOpenHandCursor;
-        break;
-    case Qt::ClosedHandCursor:
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeClosedHandCursor;
-        break;
-    case Qt::DragMoveCursor:
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeArrowCursor;
-        break;
-    case Qt::DragCopyCursor:
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeCopyArrowCursor;
-        break;
-    case Qt::DragLinkCursor:
-        type = QCursorData::TYPE_ThemeCursor;
-        curs.tc.curs = kThemeAliasArrowCursor;
-        break;
-#define QT_USE_APPROXIMATE_CURSORS
-#ifdef QT_USE_APPROXIMATE_CURSORS
-    case Qt::SizeVerCursor:
-        cursorData = cur_ver_bits;
-        cursorMaskData = mcur_ver_bits;
-        hx = hy = 8;
-        break;
-    case Qt::SizeHorCursor:
-        cursorData = cur_hor_bits;
-        cursorMaskData = mcur_hor_bits;
-        hx = hy = 8;
-        break;
-    case Qt::SizeBDiagCursor:
-        cursorData = cur_fdiag_bits;
-        cursorMaskData = mcur_fdiag_bits;
-        hx = hy = 8;
-        break;
-    case Qt::SizeFDiagCursor:
-        cursorData = cur_bdiag_bits;
-        cursorMaskData = mcur_bdiag_bits;
-        hx = hy = 8;
-        break;
-    case Qt::UpArrowCursor:
-        cursorData = cur_up_arrow_bits;
-        cursorMaskData = mcur_up_arrow_bits;
-        hx = 8;
-        break;
-#endif
-    default:
-        qWarning("Qt: QCursor::update: Invalid cursor shape %d", cshape);
-        return;
-    }
-#endif
 
     if (cursorData) {
         bm = new QBitmap(QBitmap::fromData(QSize(16, 16), cursorData,
index 77926bd..73acb93 100644 (file)
@@ -76,9 +76,6 @@ QMacDndAnswerRecord qt_mac_dnd_answer_rec;
   QDnD globals
  *****************************************************************************/
 bool qt_mac_in_drag = false;
-#ifndef QT_MAC_USE_COCOA
-static DragReference qt_mac_current_dragRef = 0;
-#endif
 
 /*****************************************************************************
   Externals
@@ -91,27 +88,6 @@ extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp
   QDnD utility functions
  *****************************************************************************/
 
-//default pixmap
-static const int default_pm_hotx = -2;
-static const int default_pm_hoty = -16;
-#ifndef QT_MAC_USE_COCOA
-static const char * const default_pm[] = {
-    "13 9 3 1",
-    ".      c None",
-    "       c #000000",
-    "X      c #FFFFFF",
-    "X X X X X X X",
-    " X X X X X X ",
-    "X ......... X",
-    " X.........X ",
-    "X ......... X",
-    " X.........X ",
-    "X ......... X",
-    " X X X X X X ",
-    "X X X X X X X",
-};
-#endif
-
 //action management
 #ifdef DEBUG_DRAG_EVENTS
 # define MAP_MAC_ENUM(x) x, #x
@@ -126,134 +102,26 @@ struct mac_enum_mapper
     char *qt_desc;
 #endif
 };
-#ifndef QT_MAC_USE_COCOA
-static mac_enum_mapper dnd_action_symbols[] = {
-    { kDragActionAlias, MAP_MAC_ENUM(Qt::LinkAction) },
-    { kDragActionMove, MAP_MAC_ENUM(Qt::MoveAction) },
-    { kDragActionGeneric, MAP_MAC_ENUM(Qt::CopyAction) },
-    { kDragActionCopy, MAP_MAC_ENUM(Qt::CopyAction) },
-    { 0, MAP_MAC_ENUM(0) }
-};
-static DragActions qt_mac_dnd_map_qt_actions(Qt::DropActions qActions)
-{
-    DragActions ret = kDragActionNothing;
-    for(int i = 0; dnd_action_symbols[i].qt_code; ++i) {
-        if(qActions & dnd_action_symbols[i].qt_code)
-            ret |= dnd_action_symbols[i].mac_code;
-    }
-    return ret;
-}
-static Qt::DropActions qt_mac_dnd_map_mac_actions(DragActions macActions)
-{
-#ifdef DEBUG_DRAG_EVENTS
-    qDebug("Converting DND ActionList: 0x%lx", macActions);
-#endif
-    Qt::DropActions ret = Qt::IgnoreAction;
-    for(int i = 0; dnd_action_symbols[i].qt_code; ++i) {
-#ifdef DEBUG_DRAG_EVENTS
-        qDebug(" %d) [%s] : %s", i, dnd_action_symbols[i].qt_desc,
-                (macActions & dnd_action_symbols[i].mac_code) ? "true" : "false");
-#endif
-        if(macActions & dnd_action_symbols[i].mac_code)
-            ret |= Qt::DropAction(dnd_action_symbols[i].qt_code);
-    }
-    return ret;
-}
-static Qt::DropAction qt_mac_dnd_map_mac_default_action(DragActions macActions)
-{
-    static Qt::DropAction preferred_actions[] = { Qt::CopyAction, Qt::LinkAction, //in order
-        Qt::MoveAction, Qt::IgnoreAction };
-    Qt::DropAction ret = Qt::IgnoreAction;
-    const Qt::DropActions qtActions = qt_mac_dnd_map_mac_actions(macActions);
-    for(int i = 0; preferred_actions[i] != Qt::IgnoreAction; ++i) {
-        if(qtActions & preferred_actions[i]) {
-            ret = preferred_actions[i];
-            break;
-        }
-    }
-#ifdef DEBUG_DRAG_EVENTS
-    for(int i = 0; dnd_action_symbols[i].qt_code; ++i) {
-        if(dnd_action_symbols[i].qt_code == ret) {
-            qDebug("Got default action: %s [0x%lx]", dnd_action_symbols[i].qt_desc, macActions);
-            break;
-        }
-    }
-#endif
-    return ret;
-}
-static void qt_mac_dnd_update_action(DragReference dragRef) {
-    SInt16 modifiers;
-    GetDragModifiers(dragRef, &modifiers, 0, 0);
-    qt_mac_send_modifiers_changed(modifiers, qApp);
-
-    Qt::DropAction qtAction = Qt::IgnoreAction;
-    {
-        DragActions macAllowed = kDragActionNothing;
-        GetDragDropAction(dragRef, &macAllowed);
-        Qt::DropActions qtAllowed = qt_mac_dnd_map_mac_actions(macAllowed);
-        qtAction = QDragManager::self()->defaultAction(qtAllowed, QApplication::keyboardModifiers());
-#if 1
-        if(!(qtAllowed & qtAction))
-            qtAction = qt_mac_dnd_map_mac_default_action(macAllowed);
-#endif
-    }
-    DragActions macAction = qt_mac_dnd_map_qt_actions(qtAction);
-
-    DragActions currentActions;
-    GetDragDropAction(dragRef, &currentActions);
-    if(currentActions != macAction) {
-        SetDragDropAction(dragRef, macAction);
-        QDragManager::self()->emitActionChanged(qtAction);
-    }
-}
-#endif // !QT_MAC_USE_COCOA
 
 /*****************************************************************************
   DnD functions
  *****************************************************************************/
 bool QDropData::hasFormat_sys(const QString &mime) const
 {
-#ifndef QT_MAC_USE_COCOA
-    OSPasteboardRef board;
-    if(GetDragPasteboard(qt_mac_current_dragRef, &board) != noErr) {
-        qDebug("DnD: Cannot get PasteBoard!");
-        return false;
-    }
-    return QMacPasteboard(board, QMacPasteboardMime::MIME_DND).hasFormat(mime);
-#else
     Q_UNUSED(mime);
     return false;
-#endif // !QT_MAC_USE_COCOA
 }
 
 QVariant QDropData::retrieveData_sys(const QString &mime, QVariant::Type type) const
 {
-#ifndef QT_MAC_USE_COCOA
-    OSPasteboardRef board;
-    if(GetDragPasteboard(qt_mac_current_dragRef, &board) != noErr) {
-        qDebug("DnD: Cannot get PasteBoard!");
-        return QVariant();
-    }
-    return QMacPasteboard(board, QMacPasteboardMime::MIME_DND).retrieveData(mime, type);
-#else
     Q_UNUSED(mime);
     Q_UNUSED(type);
     return QVariant();
-#endif // !QT_MAC_USE_COCOA
 }
 
 QStringList QDropData::formats_sys() const
 {
-#ifndef QT_MAC_USE_COCOA
-    OSPasteboardRef board;
-    if(GetDragPasteboard(qt_mac_current_dragRef, &board) != noErr) {
-        qDebug("DnD: Cannot get PasteBoard!");
-        return QStringList();
-    }
-    return QMacPasteboard(board, QMacPasteboardMime::MIME_DND).formats();
-#else
     return QStringList();
-#endif
 }
 
 void QDragManager::timerEvent(QTimerEvent*)
@@ -295,18 +163,8 @@ void QDragManager::drop()
 */
 static inline bool qt_mac_set_existing_drop_action(const DragRef &dragRef, QDropEvent &event)
 {
-#ifndef QT_MAC_USE_COCOA
-    DragActions currentAction = kDragActionNothing;        
-    OSStatus err = GetDragDropAction(dragRef, &currentAction);
-    if (err == noErr && currentAction != kDragActionNothing) {
-        // This looks a bit evil, but we only ever set one action, so it's OK.
-        event.setDropAction(Qt::DropAction(int(qt_mac_dnd_map_mac_actions(currentAction))));
-        return true;
-    }
-#else
     Q_UNUSED(dragRef);
     Q_UNUSED(event);
-#endif
     return false;
 }
 
@@ -338,361 +196,11 @@ bool qt_mac_mouse_inside_answer_rect(QPoint mouse)
 
 bool QWidgetPrivate::qt_mac_dnd_event(uint kind, DragRef dragRef)
 {
-#ifndef QT_MAC_USE_COCOA
-    Q_Q(QWidget);
-    qt_mac_current_dragRef = dragRef;
-    if (kind != kEventControlDragLeave)
-        qt_mac_dnd_update_action(dragRef);
-
-    Point mouse;
-    GetDragMouse(dragRef, &mouse, 0L);
-    if(!mouse.h && !mouse.v)
-        GetGlobalMouse(&mouse);
-
-    if(QApplicationPrivate::modalState()) {
-        for(QWidget *modal = q; modal; modal = modal->parentWidget()) {
-            if(modal->isWindow()) {
-                if(modal != QApplication::activeModalWidget())
-                    return noErr;
-                break;
-            }
-        }
-    }
-
-    //lookup the possible actions
-    DragActions allowed = kDragActionNothing;
-    GetDragAllowableActions(dragRef, &allowed);
-    Qt::DropActions qtAllowed = qt_mac_dnd_map_mac_actions(allowed);
-
-    //lookup the source dragAccepted 
-    QMimeData *dropdata = QDragManager::self()->dropData;
-    if(QDragManager::self()->source())
-        dropdata = QDragManager::self()->dragPrivate()->data;
-
-    // 'interrestedInDrag' should end up being 'true' if a later drop
-    // will be accepted by the widget for the current mouse position 
-    bool interrestedInDrag = true;
-
-    //Dispatch events
-    if (kind == kEventControlDragWithin) {
-        if (qt_mac_mouse_inside_answer_rect(q->mapFromGlobal(QPoint(mouse.h, mouse.v))))
-            return qt_mac_dnd_answer_rec.lastAction == Qt::IgnoreAction;
-        else
-            qt_mac_dnd_answer_rec.clear();
-        
-        QDragMoveEvent qDMEvent(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
-                QApplication::mouseButtons(), QApplication::keyboardModifiers());
-                
-        // Accept the event by default if a
-        // drag action exists on the carbon event
-        if (qt_mac_set_existing_drop_action(dragRef, qDMEvent))
-            qDMEvent.accept();
-            
-        QApplication::sendEvent(q, &qDMEvent);
-        if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction)
-            interrestedInDrag = false;
-
-        qt_mac_copy_answer_rect(qDMEvent);
-        SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(qDMEvent.dropAction()));
-        
-    } else if (kind == kEventControlDragEnter) {
-        qt_mac_dnd_answer_rec.clear();
-        
-        QDragEnterEvent qDEEvent(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
-                QApplication::mouseButtons(), QApplication::keyboardModifiers());
-        qt_mac_set_existing_drop_action(dragRef, qDEEvent);                         
-        QApplication::sendEvent(q, &qDEEvent);
-        SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(qDEEvent.dropAction()));
-        
-        if (!qDEEvent.isAccepted())
-            // The widget is simply not interested in this
-            // drag. So tell carbon this by returning 'false'. We will then
-            // not receive any further move, drop or leave events for this widget.
-            return false;
-        else {
-            // Documentation states that a drag move event is sent immediately after
-            // a drag enter event. So we do that. This will honor widgets overriding
-            // 'dragMoveEvent' only, and not 'dragEnterEvent' 
-            QDragMoveEvent qDMEvent(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
-                    QApplication::mouseButtons(), QApplication::keyboardModifiers());
-            qDMEvent.accept(); // accept by default, since enter event was accepted.
-            qDMEvent.setDropAction(qDEEvent.dropAction());         
-            QApplication::sendEvent(q, &qDMEvent);
-            if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction)
-                interrestedInDrag = false;
-            
-            qt_mac_copy_answer_rect(qDMEvent);           
-            SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(qDMEvent.dropAction()));
-        }
-        
-    } else if(kind == kEventControlDragLeave) {
-        QDragLeaveEvent de;
-        QApplication::sendEvent(q, &de);
-    } else if(kind == kEventControlDragReceive) {
-        QDropEvent de(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
-                      QApplication::mouseButtons(), QApplication::keyboardModifiers());
-        if(QDragManager::self()->object)
-            QDragManager::self()->dragPrivate()->target = q;
-        QApplication::sendEvent(q, &de);
-        if(!de.isAccepted()) {
-            interrestedInDrag = false;
-            SetDragDropAction(dragRef, kDragActionNothing);
-        } else {
-            if(QDragManager::self()->object)
-                QDragManager::self()->dragPrivate()->executed_action = de.dropAction();
-            SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(de.dropAction()));
-        }
-    }
-
-#ifdef DEBUG_DRAG_EVENTS
-    {
-        const char *desc = 0;
-        switch(kind) {
-        case kEventControlDragWithin: desc = "DragMove"; break;
-        case kEventControlDragEnter: desc = "DragEnter"; break;
-        case kEventControlDragLeave: desc = "DragLeave"; break;
-        case kEventControlDragReceive: desc = "DragDrop"; break;
-        }
-        if(desc) {
-            QPoint pos(q->mapFromGlobal(QPoint(mouse.h, mouse.v)));
-            qDebug("Sending <%s>(%d, %d) event to %p(%s::%s) [%d] (%p)",
-                   desc, pos.x(), pos.y(), q, q->metaObject()->className(),
-                   q->objectName().toLocal8Bit().constData(), ret, dragRef);
-        }
-    }
-#endif
-
-    //set the cursor
-    bool found_cursor = false;
-    if(kind == kEventControlDragWithin || kind == kEventControlDragEnter) {
-        ThemeCursor cursor = kThemeNotAllowedCursor;
-        found_cursor = true;
-        if (interrestedInDrag) {
-            DragActions action = kDragActionNothing;
-            GetDragDropAction(dragRef, &action);
-            switch(qt_mac_dnd_map_mac_default_action(action)) {
-            case Qt::IgnoreAction:
-                cursor = kThemeNotAllowedCursor;
-                break;
-            case Qt::MoveAction:
-                cursor = kThemeArrowCursor;
-                break;
-            case Qt::CopyAction:
-                cursor = kThemeCopyArrowCursor;
-                break;
-            case Qt::LinkAction:
-                cursor = kThemeAliasArrowCursor;
-                break;
-            default:
-                cursor = kThemeNotAllowedCursor;
-                break;
-            }
-        }
-        SetThemeCursor(cursor);
-    }
-    if(found_cursor) {
-        qt_mac_set_cursor(0); //just use our's
-    } else {
-        QCursor cursor(Qt::ArrowCursor);
-        if(qApp && qApp->overrideCursor()) {
-            cursor = *qApp->overrideCursor();
-        } else if(q) {
-            for(QWidget *p = q; p; p = p->parentWidget()) {
-                if(p->isEnabled() && p->testAttribute(Qt::WA_SetCursor)) {
-                    cursor = p->cursor();
-                    break;
-                }
-            }
-        }
-        qt_mac_set_cursor(&cursor);
-    }
-
-    //idle things
-    if(qGlobalPostedEventsCount()) {
-        QApplication::sendPostedEvents();
-        QApplication::flush();
-    }
-    
-    // If this was not a drop, tell carbon that we will be interresed in receiving more
-    // events for the current drag. We do that by returning true. 
-    if (kind == kEventControlDragReceive)
-        return interrestedInDrag;
-    else
-        return true;
-#else
     Q_UNUSED(kind);
     Q_UNUSED(dragRef);
     return false;
-#endif // !QT_MAC_USE_COCOA
 }
 
-#ifndef QT_MAC_USE_COCOA
-Qt::DropAction QDragManager::drag(QDrag *o)
-{
-  
-    if(qt_mac_in_drag) {     //just make sure..
-        qWarning("Qt: Internal error: WH0A, unexpected condition reached");
-        return Qt::IgnoreAction;
-    }
-    if(object == o)
-        return Qt::IgnoreAction;
-    /* At the moment it seems clear that Mac OS X does not want to drag with a non-left button
-       so we just bail early to prevent it */
-    if(!(GetCurrentEventButtonState() & kEventMouseButtonPrimary))
-        return Qt::IgnoreAction;
-
-    if(object) {
-        dragPrivate()->source->removeEventFilter(this);
-        cancel();
-        beingCancelled = false;
-    }
-
-    object = o;
-    dragPrivate()->target = 0;
-
-#ifndef QT_NO_ACCESSIBILITY
-    QAccessible::updateAccessibility(this, 0, QAccessible::DragDropStart);
-#endif
-
-    //setup the data
-    QMacPasteboard dragBoard(QMacPasteboardMime::MIME_DND);
-    dragBoard.setMimeData(dragPrivate()->data);
-
-    //create the drag
-    OSErr result;
-    DragRef dragRef;
-    if((result = NewDragWithPasteboard(dragBoard.pasteBoard(), &dragRef)))
-        return Qt::IgnoreAction;
-    //setup the actions
-    DragActions possibleActions = qt_mac_dnd_map_qt_actions(dragPrivate()->possible_actions);
-    SetDragAllowableActions(dragRef, //local
-                            possibleActions,
-                            true);
-    SetDragAllowableActions(dragRef, //remote (same as local)
-                            possibleActions,
-                            false);
-
-
-    QPoint hotspot;
-    QPixmap pix = dragPrivate()->pixmap;
-    if(pix.isNull()) {
-        if(dragPrivate()->data->hasText() || dragPrivate()->data->hasUrls()) {
-            //get the string
-            QString s = dragPrivate()->data->hasText() ? dragPrivate()->data->text()
-                                                : dragPrivate()->data->urls().first().toString();
-            if(s.length() > 26)
-                s = s.left(23) + QChar(0x2026);
-            if(!s.isEmpty()) {
-                //draw it
-                QFont f(qApp->font());
-                f.setPointSize(12);
-                QFontMetrics fm(f);
-                const int width = fm.width(s);
-                const int height = fm.height();
-                if(width > 0 && height > 0) {
-                    QPixmap tmp(width, height);
-                    QPainter p(&tmp);
-                    p.fillRect(0, 0, tmp.width(), tmp.height(), Qt::color0);
-                    p.setPen(Qt::color1);
-                    p.setFont(f);
-                    p.drawText(0, fm.ascent(), s);
-                    p.end();
-                    //save it
-                    pix = tmp;
-                    hotspot = QPoint(tmp.width() / 2, tmp.height() / 2);
-                }
-            }
-        } else {
-            pix = QPixmap(default_pm);
-            hotspot = QPoint(default_pm_hotx, default_pm_hoty);
-        }
-    } else {
-        hotspot = dragPrivate()->hotspot;
-    }
-
-    //so we must fake an event
-    EventRecord fakeEvent;
-    GetGlobalMouse(&(fakeEvent.where));
-    fakeEvent.message = 0;
-    fakeEvent.what = mouseDown;
-    fakeEvent.when = EventTimeToTicks(GetCurrentEventTime());
-    fakeEvent.modifiers = GetCurrentKeyModifiers();
-    if(GetCurrentEventButtonState() & 2)
-        fakeEvent.modifiers |= controlKey;
-
-    //find the hotspot in relation to the pixmap
-    Point boundsPoint;
-    boundsPoint.h = fakeEvent.where.h - hotspot.x();
-    boundsPoint.v = fakeEvent.where.v - hotspot.y();
-    Rect boundsRect;
-    SetRect(&boundsRect, boundsPoint.h, boundsPoint.v, boundsPoint.h + pix.width(), boundsPoint.v + pix.height());
-
-    //set the drag image
-    QRegion dragRegion(boundsPoint.h, boundsPoint.v, pix.width(), pix.height()), pixRegion;
-    if(!pix.isNull()) {
-        HIPoint hipoint = { -hotspot.x(), -hotspot.y() };
-        CGImageRef img = (CGImageRef)pix.macCGHandle();
-        SetDragImageWithCGImage(dragRef, img, &hipoint, 0);
-        CGImageRelease(img);
-    }
-
-    SetDragItemBounds(dragRef, (ItemReference)1 , &boundsRect);
-    { //do the drag
-        qt_mac_in_drag = true;
-        qt_mac_dnd_update_action(dragRef);
-        result = TrackDrag(dragRef, &fakeEvent, QMacSmartQuickDrawRegion(dragRegion.toQDRgn()));
-        qt_mac_in_drag = false;
-    }
-    object = 0;
-    if(result == noErr) {
-        // Check if the receiver points us to
-        // a file location. If so, we need to do
-        // the file copy/move ourselves:
-        QCFType<CFURLRef> pasteLocation = 0;
-        PasteboardCopyPasteLocation(dragBoard.pasteBoard(), &pasteLocation);
-        if (pasteLocation){
-            Qt::DropAction action = o->d_func()->defaultDropAction;
-            if (action == Qt::IgnoreAction){
-                if (o->d_func()->possible_actions & Qt::MoveAction)
-                    action = Qt::MoveAction;
-                else if (o->d_func()->possible_actions & Qt::CopyAction)
-                    action = Qt::CopyAction;
-                
-            }
-            bool atleastOne = false;
-            QList<QUrl> urls = o->mimeData()->urls();
-            for (int i = 0; i < urls.size(); ++i){
-                QUrl fromUrl = urls.at(i);
-                QString filename = QFileInfo(fromUrl.path()).fileName();
-                QUrl toUrl(QCFString::toQString(CFURLGetString(pasteLocation)) + filename);
-                if (action == Qt::MoveAction){
-                    if (QFile::rename(fromUrl.path(), toUrl.path()))
-                        atleastOne = true;
-                } else if (action == Qt::CopyAction){
-                    if (QFile::copy(fromUrl.path(), toUrl.path()))
-                        atleastOne = true;
-                }
-            }
-            if (atleastOne){
-                DisposeDrag(dragRef);
-                o->setMimeData(0);
-                o->deleteLater();
-                return action;
-            }
-        }
-
-        DragActions ret = kDragActionNothing;
-        GetDragDropAction(dragRef, &ret);
-        DisposeDrag(dragRef); //cleanup
-        o->setMimeData(0);
-        o->deleteLater();
-        return qt_mac_dnd_map_mac_default_action(ret);
-    }
-    DisposeDrag(dragRef); //cleanup
-    return Qt::IgnoreAction;
-}
-#endif
-
 void QDragManager::updatePixmap()
 {
 }
index f90fb5a..2a5227c 100644 (file)
@@ -110,11 +110,7 @@ extern bool qt_mac_is_macsheet(const QWidget *); //qwidget_mac.cpp
 
 static inline CFRunLoopRef mainRunLoop()
 {
-#ifndef QT_MAC_USE_COCOA
-    return reinterpret_cast<CFRunLoopRef>(const_cast<void *>(GetCFRunLoopFromEventLoop(GetMainEventLoop())));
-#else
     return CFRunLoopGetMain();
-#endif
 }
 
 /*****************************************************************************
@@ -453,20 +449,13 @@ bool QEventDispatcherMac::hasPendingEvents()
 
 static bool qt_mac_send_event(QEventLoop::ProcessEventsFlags, OSEventRef event, OSWindowRef pt)
 {
-#ifndef QT_MAC_USE_COCOA
-    if(pt && SendEventToWindow(event, pt) != eventNotHandledErr)
-        return true;
-    return !SendEventToEventTarget(event, GetEventDispatcherTarget());
-#else // QT_MAC_USE_COCOA
     if (pt)
         [pt sendEvent:event];
     else
         [NSApp sendEvent:event];
     return true;
-#endif
 }
 
-#ifdef QT_MAC_USE_COCOA
 static bool IsMouseOrKeyEvent( NSEvent* event )
 {
     bool    result    = false;
@@ -510,13 +499,9 @@ static bool IsMouseOrKeyEvent( NSEvent* event )
     }
     return result;
 }
-#endif
 
 static inline void qt_mac_waitForMoreEvents()
 {
-#ifndef QT_MAC_USE_COCOA
-    while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e20, true) == kCFRunLoopRunTimedOut) ;
-#else
     // If no event exist in the cocoa event que, wait
     // (and free up cpu time) until at least one event occur.
     // This implementation is a bit on the edge, but seems to
@@ -527,10 +512,8 @@ static inline void qt_mac_waitForMoreEvents()
         dequeue:YES];
     if (event)
         [NSApp postEvent:event atStart:YES];
-#endif
 }
 
-#ifdef QT_MAC_USE_COCOA
 static inline void qt_mac_waitForMoreModalSessionEvents()
 {
     // If no event exist in the cocoa event que, wait
@@ -544,17 +527,14 @@ static inline void qt_mac_waitForMoreModalSessionEvents()
     if (event)
         [NSApp postEvent:event atStart:YES];
 }
-#endif
 
 bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
 {
     Q_D(QEventDispatcherMac);
     d->interrupt = false;
 
-#ifdef QT_MAC_USE_COCOA
     bool interruptLater = false;
     QtMacInterruptDispatcherHelp::cancelInterruptLater();
-#endif
 
     // In case we end up recursing while we now process events, make sure
     // that we send remaining posted Qt events before this call returns:
@@ -567,7 +547,6 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
         if (d->interrupt)
             break;
 
-#ifdef QT_MAC_USE_COCOA
         QMacCocoaAutoReleasePool pool;
         NSEvent* event = 0;
 
@@ -685,40 +664,6 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
             // disturb the 'wait for more events' below (as deleteLater will post an event):
             interruptLater = true;
         }
-#else
-        do {
-            EventRef event;
-            if (!(flags & QEventLoop::ExcludeUserInputEvents)
-                    && !d->queuedUserInputEvents.isEmpty()) {
-                // process a pending user input event
-                event = static_cast<EventRef>(d->queuedUserInputEvents.takeFirst());
-            } else {
-                OSStatus err = ReceiveNextEvent(0,0, kEventDurationNoWait, true, &event);
-                if(err != noErr)
-                    continue;
-                // else
-                if (flags & QEventLoop::ExcludeUserInputEvents) {
-                    UInt32 ekind = GetEventKind(event),
-                           eclass = GetEventClass(event);
-                    switch(eclass) {
-                        case kEventClassQt:
-                            if(ekind != kEventQtRequestContext)
-                                break;
-                            // fall through
-                        case kEventClassMouse:
-                        case kEventClassKeyboard:
-                            d->queuedUserInputEvents.append(event);
-                            continue;
-                    }
-                }
-            }
-
-            if (!filterEvent(&event) && qt_mac_send_event(flags, event, 0))
-                retVal = true;
-            ReleaseEvent(event);
-        } while(!d->interrupt && GetNumEventsInQueue(GetMainEventQueue()) > 0);
-
-#endif
 
         bool canWait = (d->threadData->canWait
                 && !retVal
@@ -744,10 +689,8 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags)
     if (d->interrupt)
         interrupt();
 
-#ifdef QT_MAC_USE_COCOA
     if (interruptLater)
         QtMacInterruptDispatcherHelp::interruptLater();
-#endif
 
     return retVal;
 }
@@ -779,7 +722,6 @@ MacTimerHash QEventDispatcherMacPrivate::macTimerHash;
 bool QEventDispatcherMacPrivate::blockSendPostedEvents = false;
 bool QEventDispatcherMacPrivate::interrupt = false;
 
-#ifdef QT_MAC_USE_COCOA
 QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStack;
 bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
 bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
@@ -973,7 +915,6 @@ void QEventDispatcherMacPrivate::endModalSession(QWidget *widget)
     }
 }
 
-#endif
 
 QEventDispatcherMacPrivate::QEventDispatcherMacPrivate()
 {
@@ -1043,13 +984,10 @@ inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, cons
         return;
     }
 
-#ifdef QT_MAC_USE_COCOA
     if (d->cleanupModalSessionsNeeded)
         d->cleanupModalSessions();
-#endif
 
     if (d->interrupt) {
-#ifdef QT_MAC_USE_COCOA
         if (d->currentExecIsNSAppRun) {
             // The event dispatcher has been interrupted. But since
             // [NSApplication run] is running the event loop, we
@@ -1060,7 +998,6 @@ inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, cons
             [NSApp stop:NSApp];
             d->cancelWaitForMoreEvents();
         }
-#endif
         return;
     }
 
@@ -1076,9 +1013,7 @@ void QEventDispatcherMacPrivate::firstLoopEntry(CFRunLoopObserverRef ref,
 {
     Q_UNUSED(ref);
     Q_UNUSED(activity);
-#ifdef QT_MAC_USE_COCOA
     QApplicationPrivate::qt_initAfterNSAppStarted();
-#endif
     processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
 }
 
@@ -1087,7 +1022,6 @@ void QEventDispatcherMacPrivate::postedEventsSourcePerformCallback(void *info)
     processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
 }
 
-#ifdef QT_MAC_USE_COCOA
 void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
 {
     // In case the event dispatcher is waiting for more
@@ -1097,7 +1031,6 @@ void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
         modifierFlags:0 timestamp:0. windowNumber:0 context:0
         subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
 }
-#endif
 
 void QEventDispatcherMac::interrupt()
 {
@@ -1105,9 +1038,6 @@ void QEventDispatcherMac::interrupt()
     d->interrupt = true;
     wakeUp();
 
-#ifndef QT_MAC_USE_COCOA
-    CFRunLoopStop(mainRunLoop());
-#else
     // We do nothing more here than setting d->interrupt = true, and
     // poke the event loop if it is sleeping. Actually stopping
     // NSApp, or the current modal session, is done inside the send
@@ -1116,7 +1046,6 @@ void QEventDispatcherMac::interrupt()
     // the last event loop recursion, cocoa will just drop pending posted
     // events on the floor before we get a chance to reestablish a new session.
     d->cancelWaitForMoreEvents();
-#endif
 }
 
 QEventDispatcherMac::~QEventDispatcherMac()
@@ -1156,7 +1085,6 @@ QEventDispatcherMac::~QEventDispatcherMac()
     CFRelease(d->firstTimeObserver);
 }
 
-#ifdef QT_MAC_USE_COCOA
 
 QtMacInterruptDispatcherHelp* QtMacInterruptDispatcherHelp::instance = 0;
 
@@ -1194,7 +1122,6 @@ void QtMacInterruptDispatcherHelp::interruptLater()
     instance = new QtMacInterruptDispatcherHelp;
 }
 
-#endif
 
 QT_END_NAMESPACE
 
index f4cf16e..241adf2 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-#ifdef QT_MAC_USE_COCOA
 typedef struct _NSModalSession *NSModalSession;
 typedef struct _QCocoaModalSessionInfo {
     QPointer<QWidget> widget;
     NSModalSession session;
     void *nswindow;
 } QCocoaModalSessionInfo;
-#endif
 
 class QEventDispatcherMacPrivate;
 
@@ -170,7 +168,6 @@ public:
     // low-level cocoa functions (like beginModalForWindow). And
     // use a QBoolBlocker to be safe:
     static bool blockSendPostedEvents;
-#ifdef QT_MAC_USE_COCOA
     // The following variables help organizing modal sessions:
     static QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;
     static bool currentExecIsNSAppRun;
@@ -185,7 +182,6 @@ public:
     static void cancelWaitForMoreEvents();
     static void cleanupModalSessions();
     static void ensureNSAppInitialized();
-#endif
 
     MacSocketHash macSockets;
     QList<void *> queuedUserInputEvents; // List of EventRef in Carbon, and NSEvent * in Cocoa
@@ -204,7 +200,6 @@ private:
     static void firstLoopEntry(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info);
 };
 
-#ifdef QT_MAC_USE_COCOA
 class QtMacInterruptDispatcherHelp : public QObject
 {
     static QtMacInterruptDispatcherHelp *instance;
@@ -217,7 +212,6 @@ class QtMacInterruptDispatcherHelp : public QObject
     static void interruptLater();
     static void cancelInterruptLater();
 };
-#endif
 
 QT_END_NAMESPACE
 
index 3bbff7f..4a7692a 100644 (file)
@@ -100,31 +100,20 @@ void QFont::cleanup()
 */
 quint32 QFont::macFontID() const  // ### need 64-bit version
 {
-#ifdef QT_MAC_USE_COCOA
     return 0;
 #elif 1
     QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
     if (fe && fe->type() == QFontEngine::Multi)
         return static_cast<QFontEngineMacMulti*>(fe)->macFontID();
-#else
-    Str255 name;
-    if(FMGetFontFamilyName((FMFontFamily)((UInt32)handle()), name) == noErr) {
-        short fnum;
-        GetFNum(name, &fnum);
-        return fnum;
-    }
-#endif
     return 0;
 }
 
 // Returns an ATSUFonFamilyRef
 Qt::HANDLE QFont::handle() const
 {
-#ifdef QT_MAC_USE_COCOA
     QFontEngine *fe = d->engineForScript(QUnicodeTables::Common);
     if (fe && fe->type() == QFontEngine::Multi)
         return (Qt::HANDLE)static_cast<QCoreTextFontEngineMulti*>(fe)->macFontID();
-#endif
     return 0;
 }
 
index 6876fae..bbe6b56 100644 (file)
@@ -53,38 +53,6 @@ QT_BEGIN_NAMESPACE
 int qt_mac_pixelsize(const QFontDef &def, int dpi); //qfont_mac.cpp
 int qt_mac_pointsize(const QFontDef &def, int dpi); //qfont_mac.cpp
 
-#ifndef QT_MAC_USE_COCOA
-static void initWritingSystems(QtFontFamily *family, ATSFontRef atsFont)
-{
-    ByteCount length = 0;
-    if (ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, 0, 0, &length) != noErr)
-        return;
-    QVarLengthArray<uchar> os2Table(length);
-    if (length < 86
-        || ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, length, os2Table.data(), &length) != noErr)
-        return;
-
-    // See also qfontdatabase_win.cpp, offsets taken from OS/2 table in the TrueType spec
-    quint32 unicodeRange[4] = {
-        qFromBigEndian<quint32>(os2Table.data() + 42),
-        qFromBigEndian<quint32>(os2Table.data() + 46),
-        qFromBigEndian<quint32>(os2Table.data() + 50),
-        qFromBigEndian<quint32>(os2Table.data() + 54)
-    };
-    quint32 codePageRange[2] = { qFromBigEndian<quint32>(os2Table.data() + 78), qFromBigEndian<quint32>(os2Table.data() + 82) };
-    QList<QFontDatabase::WritingSystem> systems = qt_determine_writing_systems_from_truetype_bits(unicodeRange, codePageRange);
-#if 0
-    QCFString name;
-    ATSFontGetName(atsFont, kATSOptionFlagsDefault, &name);
-    qDebug() << systems.count() << "writing systems for" << QString(name);
-qDebug() << "first char" << hex << unicodeRange[0];
-    for (int i = 0; i < systems.count(); ++i)
-        qDebug() << QFontDatabase::writingSystemName(systems.at(i));
-#endif
-    for (int i = 0; i < systems.count(); ++i)
-        family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
-}
-#endif
 
 static void initializeDb()
 {
@@ -92,7 +60,7 @@ static void initializeDb()
     if(!db || db->count)
         return;
 
-#if defined(QT_MAC_USE_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
     QCFType<CTFontCollectionRef> collection = CTFontCollectionCreateFromAvailableFonts(0);
     if(!collection)
@@ -156,66 +124,6 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
 } else 
 #endif
     {
-#ifndef QT_MAC_USE_COCOA
-        FMFontIterator it;
-        if (!FMCreateFontIterator(0, 0, kFMUseGlobalScopeOption, &it)) {
-            while (true) {
-                FMFont fmFont;
-                if (FMGetNextFont(&it, &fmFont) != noErr)
-                    break;
-
-                FMFontFamily fmFamily;
-                FMFontStyle fmStyle;
-                QString familyName;
-
-                QtFontStyle::Key styleKey;
-
-                ATSFontRef atsFont = FMGetATSFontRefFromFont(fmFont);
-
-                if (!FMGetFontFamilyInstanceFromFont(fmFont, &fmFamily, &fmStyle)) {
-                    { //sanity check the font, and see if we can use it at all! --Sam
-                        ATSUFontID fontID;
-                        if(ATSUFONDtoFontID(fmFamily, 0, &fontID) != noErr)
-                            continue;
-                    }
-
-                    if (fmStyle & ::italic)
-                        styleKey.style = QFont::StyleItalic;
-                    if (fmStyle & ::bold)
-                        styleKey.weight = QFont::Bold;
-
-                    ATSFontFamilyRef familyRef = FMGetATSFontFamilyRefFromFontFamily(fmFamily);
-                    QCFString cfFamilyName;;
-                    ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &cfFamilyName);
-                    familyName = cfFamilyName;
-                } else {
-                    QCFString cfFontName;
-                    ATSFontGetName(atsFont, kATSOptionFlagsDefault, &cfFontName);
-                    familyName = cfFontName;
-                    quint16 macStyle = 0;
-                    {
-                        uchar data[4];
-                        ByteCount len = 4;
-                        if (ATSFontGetTable(atsFont, MAKE_TAG('h', 'e', 'a', 'd'), 44, 4, &data, &len) == noErr)
-                            macStyle = qFromBigEndian<quint16>(data);
-                    }
-                    if (macStyle & 1)
-                        styleKey.weight = QFont::Bold;
-                    if (macStyle & 2)
-                        styleKey.style = QFont::StyleItalic;
-                }
-
-                QtFontFamily *family = db->family(familyName, true);
-                QtFontFoundry *foundry = family->foundry(QString(), true);
-                QtFontStyle *style = foundry->style(styleKey, QString(), true);
-                style->pixelSize(0, true);
-                style->smoothScalable = true;
-
-                initWritingSystems(family, atsFont);
-            }
-            FMDisposeFontIterator(&it);
-        }
-#endif
     }
 
 }
@@ -253,12 +161,7 @@ static inline float weightToFloat(unsigned int weight)
 
 static QFontEngine *loadFromDatabase(const QFontDef &req, const QFontPrivate *d)
 {
-#if defined(QT_MAC_USE_COCOA)
     QCFString fontName = NULL;
-#else
-    ATSFontFamilyRef familyRef = 0;
-    ATSFontRef fontRef = 0;
-#endif
 
     QStringList family_list = familyList(req);
 
@@ -277,34 +180,17 @@ static QFontEngine *loadFromDatabase(const QFontDef &req, const QFontPrivate *d)
         for (int k = 0; k < db->count; ++k) {
             if (db->families[k]->name.compare(family_list.at(i), Qt::CaseInsensitive) == 0) {
                 QByteArray family_name = db->families[k]->name.toUtf8();
-#if defined(QT_MAC_USE_COCOA)
                 QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->name), 12, NULL);
                 if (ctFont) {
                     fontName = CTFontCopyFullName(ctFont);
                     goto found;
                 }
-#else
-                familyRef = ATSFontFamilyFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
-                if (familyRef) {
-                    fontRef = ATSFontFindFromName(QCFString(db->families[k]->name), kATSOptionFlagsDefault);
-                    goto found;
-                }
-#endif
             }
         }
     }
 found:
-#ifdef QT_MAC_USE_COCOA
     if (fontName)
         return new QCoreTextFontEngineMulti(fontName, req, d->kerning);
-#else
-    if (familyRef) {
-        QCFString actualName;
-        if (ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &actualName) == noErr)
-            req.family = actualName;
-        return new QFontEngineMacMulti(familyRef, req, fontDef, d->kerning);
-    }
-#endif
     return NULL;
 }
 
@@ -349,7 +235,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
     }
 
     QFontEngine *engine = NULL;
-#if defined(QT_MAC_USE_COCOA)
     // Shortcut to get the font directly without going through the font database
     if (!req.family.isEmpty() && !req.styleName.isEmpty()) {
         QCFString expectedFamily = QCFString(req.family);
@@ -371,7 +256,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
             }
         }
     }
-#endif
     if (!engine)
         engine = loadFromDatabase(req, d);
 
@@ -430,7 +314,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
         return;
 
     fnt->families.clear();
-#if defined(QT_MAC_USE_COCOA)
     // Make sure that the family name set on the font matches what
     // kCTFontFamilyNameAttribute returns in initializeDb().
     // So far the best solution seems find the installed font
@@ -444,13 +327,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
         QCFString familyName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
         fnt->families.append(familyName);
     }
-#else
-    for(int i = 0; i < containedFonts.size(); ++i) {
-        QCFString family;
-        ATSFontGetName(containedFonts[i], kATSOptionFlagsDefault, &family);
-        fnt->families.append(family);
-    }
-#endif
 
     fnt->handle = handle;
 }
index 6186b2f..d043c03 100644 (file)
@@ -121,1109 +121,4 @@ OSStatus QMacFontPath::closePath(void *data)
     return noErr;
 }
 
-
-#ifndef QT_MAC_USE_COCOA
-QFontEngineMacMulti::QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning)
-    : QFontEngineMulti(0)
-{
-    this->fontDef = fontDef;
-    this->kerning = kerning;
-
-    // hopefully (CTFontCreateWithName or CTFontCreateWithFontDescriptor) + CTFontCreateCopyWithSymbolicTraits
-    // (or CTFontCreateWithQuickdrawInstance)
-    FMFontFamily fmFamily;
-    FMFontStyle fntStyle = 0;
-    fmFamily = FMGetFontFamilyFromATSFontFamilyRef(atsFamily);
-    if (fmFamily == kInvalidFontFamily) {
-        // Use the ATSFont then...
-        fontID = FMGetFontFromATSFontRef(atsFontRef);
-    } else {
-        if (fontDef.weight >= QFont::Bold)
-            fntStyle |= ::bold;
-        if (fontDef.style != QFont::StyleNormal)
-            fntStyle |= ::italic;
-
-        FMFontStyle intrinsicStyle;
-        FMFont fnt = 0;
-        if (FMGetFontFromFontFamilyInstance(fmFamily, fntStyle, &fnt, &intrinsicStyle) == noErr)
-           fontID = FMGetATSFontRefFromFont(fnt);
-    }
-
-    // CFDictionaryRef, <CTStringAttributes.h>
-    OSStatus status;
-
-    status = ATSUCreateTextLayout(&textLayout);
-    Q_ASSERT(status == noErr);
-
-    const int maxAttributeCount = 5;
-    ATSUAttributeTag tags[maxAttributeCount + 1];
-    ByteCount sizes[maxAttributeCount + 1];
-    ATSUAttributeValuePtr values[maxAttributeCount + 1];
-    int attributeCount = 0;
-
-    Fixed size = FixRatio(fontDef.pixelSize, 1);
-    tags[attributeCount] = kATSUSizeTag;
-    sizes[attributeCount] = sizeof(size);
-    values[attributeCount] = &size;
-    ++attributeCount;
-
-    tags[attributeCount] = kATSUFontTag;
-    sizes[attributeCount] = sizeof(fontID);
-    values[attributeCount] = &this->fontID;
-    ++attributeCount;
-
-    transform = CGAffineTransformIdentity;
-    if (fontDef.stretch != 100) {
-        transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
-        tags[attributeCount] = kATSUFontMatrixTag;
-        sizes[attributeCount] = sizeof(transform);
-        values[attributeCount] = &transform;
-        ++attributeCount;
-    }
-
-    status = ATSUCreateStyle(&style);
-    Q_ASSERT(status == noErr);
-
-    Q_ASSERT(attributeCount < maxAttributeCount + 1);
-    status = ATSUSetAttributes(style, attributeCount, tags, sizes, values);
-    Q_ASSERT(status == noErr);
-
-    QFontEngineMac *fe = new QFontEngineMac(style, fontID, fontDef, this);
-    fe->ref.ref();
-    engines.append(fe);
-}
-
-QFontEngineMacMulti::~QFontEngineMacMulti()
-{
-    ATSUDisposeTextLayout(textLayout);
-    ATSUDisposeStyle(style);
-
-    for (int i = 0; i < engines.count(); ++i) {
-        QFontEngineMac *fe = const_cast<QFontEngineMac *>(static_cast<const QFontEngineMac *>(engines.at(i)));
-        fe->multiEngine = 0;
-        if (!fe->ref.deref())
-            delete fe;
-    }
-    engines.clear();
-}
-
-struct QGlyphLayoutInfo
-{
-    QGlyphLayout *glyphs;
-    int *numGlyphs;
-    bool callbackCalled;
-    int *mappedFonts;
-    QTextEngine::ShaperFlags flags;
-    QFontEngineMacMulti::ShaperItem *shaperItem;
-    unsigned int styleStrategy;
-};
-
-static OSStatus atsuPostLayoutCallback(ATSULayoutOperationSelector selector, ATSULineRef lineRef, URefCon refCon,
-                                 void *operationExtraParameter, ATSULayoutOperationCallbackStatus *callbackStatus)
-{
-    Q_UNUSED(selector);
-    Q_UNUSED(operationExtraParameter);
-
-    QGlyphLayoutInfo *nfo = reinterpret_cast<QGlyphLayoutInfo *>(refCon);
-    nfo->callbackCalled = true;
-
-    ATSLayoutRecord *layoutData = 0;
-    ItemCount itemCount = 0;
-
-    OSStatus e = noErr;
-    e = ATSUDirectGetLayoutDataArrayPtrFromLineRef(lineRef, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
-                                                   /*iCreate =*/ false,
-                                                   (void **) &layoutData,
-                                                   &itemCount);
-    if (e != noErr)
-        return e;
-
-    *nfo->numGlyphs = itemCount - 1;
-
-    Fixed *baselineDeltas = 0;
-
-    e = ATSUDirectGetLayoutDataArrayPtrFromLineRef(lineRef, kATSUDirectDataBaselineDeltaFixedArray,
-                                                   /*iCreate =*/ true,
-                                                   (void **) &baselineDeltas,
-                                                   &itemCount);
-    if (e != noErr)
-        return e;
-
-    int nextCharStop = -1;
-    int currentClusterGlyph = -1; // first glyph in log cluster
-    QFontEngineMacMulti::ShaperItem *item = nfo->shaperItem;
-    if (item->charAttributes) {
-        item = nfo->shaperItem;
-#if !defined(QT_NO_DEBUG)
-        int surrogates = 0;
-        const QChar *str = item->string;
-        for (int i = item->from; i < item->from + item->length - 1; ++i)
-            surrogates += (str[i].isHighSurrogate() && str[i+1].isLowSurrogate());
-#endif
-        for (nextCharStop = item->from; nextCharStop < item->from + item->length; ++nextCharStop)
-            if (item->charAttributes[nextCharStop].charStop)
-                break;
-        nextCharStop -= item->from;
-    }
-
-    nfo->glyphs->attributes[0].clusterStart = true;
-    int glyphIdx = 0;
-    int glyphIncrement = 1;
-    if (nfo->flags & QTextEngine::RightToLeft) {
-        glyphIdx  = itemCount - 2;
-        glyphIncrement = -1;
-    }
-    for (int i = 0; i < *nfo->numGlyphs; ++i, glyphIdx += glyphIncrement) {
-
-        int charOffset = layoutData[glyphIdx].originalOffset / sizeof(UniChar);
-        const int fontIdx = nfo->mappedFonts[charOffset];
-
-        ATSGlyphRef glyphId = layoutData[glyphIdx].glyphID;
-
-        QFixed yAdvance = FixedToQFixed(baselineDeltas[glyphIdx]);
-        QFixed xAdvance = FixedToQFixed(layoutData[glyphIdx + 1].realPos - layoutData[glyphIdx].realPos);
-
-        if (nfo->styleStrategy & QFont::ForceIntegerMetrics) {
-            yAdvance = yAdvance.round();
-            xAdvance = xAdvance.round();
-        }
-
-        if (glyphId != 0xffff || i == 0) {
-            if (i < nfo->glyphs->numGlyphs)
-            {
-                nfo->glyphs->glyphs[i] = (glyphId & 0x00ffffff) | (fontIdx << 24);
-
-                nfo->glyphs->advances_y[i] = yAdvance;
-                nfo->glyphs->advances_x[i] = xAdvance;
-            }
-        } else {
-            // ATSUI gives us 0xffff as glyph id at the index in the glyph array for
-            // a character position that maps to a ligtature. Such a glyph id does not
-            // result in any visual glyph, but it may have an advance, which is why we
-            // sum up the glyph advances.
-            --i;
-            nfo->glyphs->advances_y[i] += yAdvance;
-            nfo->glyphs->advances_x[i] += xAdvance;
-            *nfo->numGlyphs -= 1;
-        }
-
-        if (item->log_clusters) {
-            if (charOffset >= nextCharStop) {
-                nfo->glyphs->attributes[i].clusterStart = true;
-                currentClusterGlyph = i;
-
-                ++nextCharStop;
-                for (; nextCharStop < item->length; ++nextCharStop)
-                    if (item->charAttributes[item->from + nextCharStop].charStop)
-                        break;
-            } else {
-                if (currentClusterGlyph == -1)
-                    currentClusterGlyph = i;
-            }
-            item->log_clusters[charOffset] = currentClusterGlyph;
-
-            // surrogate handling
-            if (charOffset < item->length - 1) {
-                QChar current = item->string[item->from + charOffset];
-                QChar next = item->string[item->from + charOffset + 1];
-                if (current.isHighSurrogate() && next.isLowSurrogate())
-                    item->log_clusters[charOffset + 1] = currentClusterGlyph;
-            }
-        }
-    }
-
-    /*
-    if (item) {
-        qDebug() << "resulting logclusters:";
-        for (int i = 0; i < item->length; ++i)
-            qDebug() << "logClusters[" << i << "] =" << item->log_clusters[i];
-        qDebug() << "clusterstarts:";
-        for (int i = 0; i < *nfo->numGlyphs; ++i)
-            qDebug() << "clusterStart[" << i << "] =" << nfo->glyphs[i].attributes.clusterStart;
-    }
-    */
-
-    ATSUDirectReleaseLayoutDataArrayPtr(lineRef, kATSUDirectDataBaselineDeltaFixedArray,
-                                        (void **) &baselineDeltas);
-
-    ATSUDirectReleaseLayoutDataArrayPtr(lineRef, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent,
-                                        (void **) &layoutData);
-
-    *callbackStatus = kATSULayoutOperationCallbackStatusHandled;
-    return noErr;
-}
-
-int QFontEngineMacMulti::fontIndexForFontID(ATSUFontID id) const
-{
-    for (int i = 0; i < engines.count(); ++i) {
-        if (engineAt(i)->fontID == id)
-            return i;
-    }
-
-    QFontEngineMacMulti *that = const_cast<QFontEngineMacMulti *>(this);
-    QFontEngineMac *fe = new QFontEngineMac(style, id, fontDef, that);
-    fe->ref.ref();
-    that->engines.append(fe);
-    return engines.count() - 1;
-}
-
-bool QFontEngineMacMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
-{
-    return stringToCMap(str, len, glyphs, nglyphs, flags, /*logClusters=*/0, /*charAttributes=*/0);
-}
-
-bool QFontEngineMacMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
-                                       unsigned short *logClusters, const HB_CharAttributes *charAttributes, QScriptItem *) const
-{
-    if (*nglyphs < len) {
-        *nglyphs = len;
-        return false;
-    }
-
-    ShaperItem shaperItem;
-    shaperItem.string = str;
-    shaperItem.from = 0;
-    shaperItem.length = len;
-    shaperItem.glyphs = *glyphs;
-    shaperItem.glyphs.numGlyphs = *nglyphs;
-    shaperItem.flags = flags;
-    shaperItem.log_clusters = logClusters;
-    shaperItem.charAttributes = charAttributes;
-
-    const int maxChars = qMax(1,
-                              int(SHRT_MAX / maxCharWidth())
-                              - 10 // subtract a few to be on the safe side
-                             );
-    if (len < maxChars || !charAttributes)
-        return stringToCMapInternal(str, len, glyphs, nglyphs, flags, &shaperItem);
-
-    int charIdx = 0;
-    int glyphIdx = 0;
-    ShaperItem tmpItem = shaperItem;
-
-    do {
-        tmpItem.from = shaperItem.from + charIdx;
-
-        int charCount = qMin(maxChars, len - charIdx);
-
-        int lastWhitespace = tmpItem.from + charCount - 1;
-        int lastSoftBreak = lastWhitespace;
-        int lastCharStop = lastSoftBreak;
-        for (int i = lastCharStop; i >= tmpItem.from; --i) {
-            if (tmpItem.charAttributes[i].whiteSpace) {
-                lastWhitespace = i;
-                break;
-            } if (tmpItem.charAttributes[i].lineBreakType != HB_NoBreak) {
-                lastSoftBreak = i;
-            } if (tmpItem.charAttributes[i].charStop) {
-                lastCharStop = i;
-            }
-        }
-        charCount = qMin(lastWhitespace, qMin(lastSoftBreak, lastCharStop)) - tmpItem.from + 1;
-
-        int glyphCount = shaperItem.glyphs.numGlyphs - glyphIdx;
-        if (glyphCount <= 0)
-            return false;
-        tmpItem.length = charCount;
-        tmpItem.glyphs = shaperItem.glyphs.mid(glyphIdx, glyphCount);
-        tmpItem.log_clusters = shaperItem.log_clusters + charIdx;
-        if (!stringToCMapInternal(tmpItem.string + tmpItem.from, tmpItem.length,
-                                  &tmpItem.glyphs, &glyphCount, flags,
-                                  &tmpItem)) {
-            *nglyphs = glyphIdx + glyphCount;
-            return false;
-       }
-        for (int i = 0; i < charCount; ++i)
-            tmpItem.log_clusters[i] += glyphIdx;
-        glyphIdx += glyphCount;
-        charIdx += charCount;
-    } while (charIdx < len);
-    *nglyphs = glyphIdx;
-    glyphs->numGlyphs = glyphIdx;
-
-    return true;
-}
-
-bool QFontEngineMacMulti::stringToCMapInternal(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,ShaperItem *shaperItem) const
-{
-    //qDebug() << "stringToCMap" << QString(str, len);
-
-    OSStatus e = noErr;
-
-    e = ATSUSetTextPointerLocation(textLayout, (UniChar *)(str), 0, len, len);
-    if (e != noErr) {
-        qWarning("Qt: internal: %ld: Error ATSUSetTextPointerLocation %s: %d", long(e), __FILE__, __LINE__);
-        return false;
-    }
-
-    QGlyphLayoutInfo nfo;
-    nfo.glyphs = glyphs;
-    nfo.numGlyphs = nglyphs;
-    nfo.callbackCalled = false;
-    nfo.flags = flags;
-    nfo.shaperItem = shaperItem;
-    nfo.styleStrategy = fontDef.styleStrategy;
-
-    int prevNumGlyphs = *nglyphs;
-
-    QVarLengthArray<int> mappedFonts(len);
-    for (int i = 0; i < len; ++i)
-        mappedFonts[i] = 0;
-    nfo.mappedFonts = mappedFonts.data();
-
-    Q_ASSERT(sizeof(void *) <= sizeof(URefCon));
-    e = ATSUSetTextLayoutRefCon(textLayout, (URefCon)&nfo);
-    if (e != noErr) {
-        qWarning("Qt: internal: %ld: Error ATSUSetTextLayoutRefCon %s: %d", long(e), __FILE__, __LINE__);
-        return false;
-    }
-
-    {
-        const int maxAttributeCount = 3;
-        ATSUAttributeTag tags[maxAttributeCount + 1];
-        ByteCount sizes[maxAttributeCount + 1];
-        ATSUAttributeValuePtr values[maxAttributeCount + 1];
-        int attributeCount = 0;
-
-        tags[attributeCount] = kATSULineLayoutOptionsTag;
-        ATSLineLayoutOptions layopts = kATSLineHasNoOpticalAlignment
-                                       | kATSLineIgnoreFontLeading
-                                       | kATSLineNoSpecialJustification // we do kashidas ourselves
-                                       | kATSLineDisableAllJustification
-                                       ;
-
-        if (fontDef.styleStrategy & QFont::NoAntialias)
-            layopts |= kATSLineNoAntiAliasing;
-
-        if (!kerning)
-            layopts |= kATSLineDisableAllKerningAdjustments;
-
-        values[attributeCount] = &layopts;
-        sizes[attributeCount] = sizeof(layopts);
-        ++attributeCount;
-
-        tags[attributeCount] = kATSULayoutOperationOverrideTag;
-        ATSULayoutOperationOverrideSpecifier spec;
-        spec.operationSelector = kATSULayoutOperationPostLayoutAdjustment;
-        spec.overrideUPP = atsuPostLayoutCallback;
-        values[attributeCount] = &spec;
-        sizes[attributeCount] = sizeof(spec);
-        ++attributeCount;
-
-        // CTWritingDirection
-        Boolean direction;
-        if (flags & QTextEngine::RightToLeft)
-            direction = kATSURightToLeftBaseDirection;
-        else
-            direction = kATSULeftToRightBaseDirection;
-        tags[attributeCount] = kATSULineDirectionTag;
-        values[attributeCount] = &direction;
-        sizes[attributeCount] = sizeof(direction);
-        ++attributeCount;
-
-        Q_ASSERT(attributeCount < maxAttributeCount + 1);
-        e = ATSUSetLayoutControls(textLayout, attributeCount, tags, sizes, values);
-        if (e != noErr) {
-            qWarning("Qt: internal: %ld: Error ATSUSetLayoutControls %s: %d", long(e), __FILE__, __LINE__);
-            return false;
-        }
-
-    }
-
-    e = ATSUSetRunStyle(textLayout, style, 0, len);
-    if (e != noErr) {
-        qWarning("Qt: internal: %ld: Error ATSUSetRunStyle %s: %d", long(e), __FILE__, __LINE__);
-        return false;
-    }
-
-    if (!(fontDef.styleStrategy & QFont::NoFontMerging)) {
-        int pos = 0;
-        do {
-            ATSUFontID substFont = 0;
-            UniCharArrayOffset changedOffset = 0;
-            UniCharCount changeCount = 0;
-
-            e = ATSUMatchFontsToText(textLayout, pos, len - pos,
-                                     &substFont, &changedOffset,
-                                     &changeCount);
-            if (e == kATSUFontsMatched) {
-                int fontIdx = fontIndexForFontID(substFont);
-                for (uint i = 0; i < changeCount; ++i)
-                    mappedFonts[changedOffset + i] = fontIdx;
-                pos = changedOffset + changeCount;
-                ATSUSetRunStyle(textLayout, engineAt(fontIdx)->style, changedOffset, changeCount);
-            } else if (e == kATSUFontsNotMatched) {
-                pos = changedOffset + changeCount;
-            }
-        } while (pos < len && e != noErr);
-    }
-    {    // trigger the a layout
-        // CFAttributedStringCreate, CTFramesetterCreateWithAttributedString (or perhaps Typesetter)
-        Rect rect;
-        e = ATSUMeasureTextImage(textLayout, kATSUFromTextBeginning, kATSUToTextEnd,
-                                 /*iLocationX =*/ 0, /*iLocationY =*/ 0,
-                                 &rect);
-        if (e != noErr) {
-            qWarning("Qt: internal: %ld: Error ATSUMeasureTextImage %s: %d", long(e), __FILE__, __LINE__);
-            return false;
-        }
-    }
-
-    if (!nfo.callbackCalled) {
-            qWarning("Qt: internal: %ld: Error ATSUMeasureTextImage did not trigger callback %s: %d", long(e), __FILE__, __LINE__);
-            return false;
-    }
-
-    ATSUClearLayoutCache(textLayout, kATSUFromTextBeginning);
-    if (prevNumGlyphs < *nfo.numGlyphs)
-        return false;
-    return true;
-}
-
-void QFontEngineMacMulti::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
-{
-    Q_ASSERT(false);
-    Q_UNUSED(glyphs);
-    Q_UNUSED(flags);
-}
-
-void QFontEngineMacMulti::doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const
-{
-    //Q_ASSERT(false);
-}
-
-void QFontEngineMacMulti::loadEngine(int /*at*/)
-{
-    // should never be called!
-    Q_ASSERT(false);
-}
-
-bool QFontEngineMacMulti::canRender(const QChar *string, int len)
-{
-    ATSUSetTextPointerLocation(textLayout, reinterpret_cast<const UniChar *>(string), 0, len, len);
-    ATSUSetRunStyle(textLayout, style, 0, len);
-
-    OSStatus e = noErr;
-    int pos = 0;
-    do {
-        FMFont substFont = 0;
-        UniCharArrayOffset changedOffset = 0;
-        UniCharCount changeCount = 0;
-
-        // CTFontCreateForString
-        e = ATSUMatchFontsToText(textLayout, pos, len - pos,
-                                 &substFont, &changedOffset,
-                                 &changeCount);
-        if (e == kATSUFontsMatched) {
-            pos = changedOffset + changeCount;
-        } else if (e == kATSUFontsNotMatched) {
-            break;
-        }
-    } while (pos < len && e != noErr);
-
-    return e == noErr || e == kATSUFontsMatched;
-}
-
-QFontEngineMac::QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine)
-    : fontID(fontID), multiEngine(multiEngine), cmap(0), symbolCMap(false)
-{
-    fontDef = def;
-    ATSUCreateAndCopyStyle(baseStyle, &style);
-    ATSFontRef atsFont = FMGetATSFontRefFromFont(fontID);
-    cgFont = CGFontCreateWithPlatformFont(&atsFont);
-
-    const int maxAttributeCount = 4;
-    ATSUAttributeTag tags[maxAttributeCount + 1];
-    ByteCount sizes[maxAttributeCount + 1];
-    ATSUAttributeValuePtr values[maxAttributeCount + 1];
-    int attributeCount = 0;
-
-    synthesisFlags = 0;
-
-    // synthesizing using CG is not recommended
-    quint16 macStyle = 0;
-    {
-        uchar data[4];
-        ByteCount len = 4;
-        if (ATSFontGetTable(atsFont, MAKE_TAG('h', 'e', 'a', 'd'), 44, 4, &data, &len) == noErr)
-            macStyle = qFromBigEndian<quint16>(data);
-    }
-
-    Boolean atsuBold = false;
-    Boolean atsuItalic = false;
-    if (fontDef.weight >= QFont::Bold) {
-        if (!(macStyle & 1)) {
-            synthesisFlags |= SynthesizedBold;
-            atsuBold = true;
-            tags[attributeCount] = kATSUQDBoldfaceTag;
-            sizes[attributeCount] = sizeof(atsuBold);
-            values[attributeCount] = &atsuBold;
-            ++attributeCount;
-        }
-    }
-    if (fontDef.style != QFont::StyleNormal) {
-        if (!(macStyle & 2)) {
-            synthesisFlags |= SynthesizedItalic;
-            atsuItalic = true;
-            tags[attributeCount] = kATSUQDItalicTag;
-            sizes[attributeCount] = sizeof(atsuItalic);
-            values[attributeCount] = &atsuItalic;
-            ++attributeCount;
-        }
-    }
-
-    tags[attributeCount] = kATSUFontTag;
-    values[attributeCount] = &fontID;
-    sizes[attributeCount] = sizeof(fontID);
-    ++attributeCount;
-
-    Q_ASSERT(attributeCount < maxAttributeCount + 1);
-    OSStatus err = ATSUSetAttributes(style, attributeCount, tags, sizes, values);
-    Q_ASSERT(err == noErr);
-    Q_UNUSED(err);
-
-    // CTFontCopyTable
-    quint16 tmpFsType;
-    if (ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 8, 2, &tmpFsType, 0) == noErr)
-       fsType = qFromBigEndian<quint16>(tmpFsType);
-    else
-        fsType = 0;
-
-    if (multiEngine)
-       transform = multiEngine->transform;
-    else
-       transform = CGAffineTransformIdentity;
-
-    ATSUTextMeasurement metric;
-
-    ATSUGetAttribute(style, kATSUAscentTag, sizeof(metric), &metric, 0);
-    m_ascent = FixRound(metric);
-
-    ATSUGetAttribute(style, kATSUDescentTag, sizeof(metric), &metric, 0);
-    m_descent = FixRound(metric);
-
-    ATSUGetAttribute(style, kATSULeadingTag, sizeof(metric), &metric, 0);
-    m_leading = FixRound(metric);
-
-    ATSFontMetrics metrics;
-
-    ATSFontGetHorizontalMetrics(FMGetATSFontRefFromFont(fontID), kATSOptionFlagsDefault, &metrics);
-    m_maxCharWidth = metrics.maxAdvanceWidth * fontDef.pointSize;
-
-    ATSFontGetHorizontalMetrics(FMGetATSFontRefFromFont(fontID), kATSOptionFlagsDefault, &metrics);
-    m_xHeight = QFixed::fromReal(metrics.xHeight * fontDef.pointSize);
-
-    ATSFontGetHorizontalMetrics(FMGetATSFontRefFromFont(fontID), kATSOptionFlagsDefault, &metrics);
-    m_averageCharWidth = QFixed::fromReal(metrics.avgAdvanceWidth * fontDef.pointSize);
-
-    // Use width of 'X' if ATSFontGetHorizontalMetrics returns 0 for avgAdvanceWidth.
-    if (m_averageCharWidth == QFixed(0)) {
-        QChar c('X');
-        QGlyphLayoutArray<1> glyphs;
-        int nglyphs = 1;
-        stringToCMap(&c, 1, &glyphs, &nglyphs, 0);
-        glyph_metrics_t metrics = boundingBox(glyphs);
-        m_averageCharWidth =  metrics.width;
-    }
-}
-
-QFontEngineMac::~QFontEngineMac()
-{
-    ATSUDisposeStyle(style);
-}
-
-static inline unsigned int getChar(const QChar *str, int &i, const int len)
-{
-    uint ucs4 = str[i].unicode();
-    if (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate()) {
-        ++i;
-        ucs4 = QChar::surrogateToUcs4(ucs4, str[i].unicode());
-    }
-    return ucs4;
-}
-
-// Not used directly for shaping, only used to calculate m_averageCharWidth
-bool QFontEngineMac::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
-{
-    if (!cmap) {
-        cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p'));
-        int size = 0;
-        cmap = getCMap(reinterpret_cast<const uchar *>(cmapTable.constData()), cmapTable.size(), &symbolCMap, &size);
-        if (!cmap)
-            return false;
-    }
-    if (symbolCMap) {
-        for (int i = 0; i < len; ++i) {
-            unsigned int uc = getChar(str, i, len);
-            glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, uc);
-            if(!glyphs->glyphs[i] && uc < 0x100)
-                glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, uc + 0xf000);
-        }
-    } else {
-        for (int i = 0; i < len; ++i) {
-            unsigned int uc = getChar(str, i, len);
-            glyphs->glyphs[i] = getTrueTypeGlyphIndex(cmap, uc);
-        }
-    }
-
-    *nglyphs = len;
-    glyphs->numGlyphs = *nglyphs;
-
-    if (!(flags & QTextEngine::GlyphIndicesOnly))
-        recalcAdvances(glyphs, flags);
-
-    return true;
-}
-
-void QFontEngineMac::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
-{
-    Q_UNUSED(flags)
-
-    QVarLengthArray<GlyphID> atsuGlyphs(glyphs->numGlyphs);
-    for (int i = 0; i < glyphs->numGlyphs; ++i)
-        atsuGlyphs[i] = glyphs->glyphs[i];
-
-    QVarLengthArray<ATSGlyphScreenMetrics> metrics(glyphs->numGlyphs);
-
-    ATSUGlyphGetScreenMetrics(style, glyphs->numGlyphs, atsuGlyphs.data(), sizeof(GlyphID),
-                              /* iForcingAntiAlias =*/ false,
-                              /* iAntiAliasSwitch =*/true,
-                              metrics.data());
-
-    for (int i = 0; i < glyphs->numGlyphs; ++i) {
-        glyphs->advances_x[i] = QFixed::fromReal(metrics[i].deviceAdvance.x);
-        glyphs->advances_y[i] = QFixed::fromReal(metrics[i].deviceAdvance.y);
-
-        if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
-            glyphs->advances_x[i] = glyphs->advances_x[i].round();
-            glyphs->advances_y[i] = glyphs->advances_y[i].round();
-        }
-    }
-}
-
-glyph_metrics_t QFontEngineMac::boundingBox(const QGlyphLayout &glyphs)
-{
-    QFixed w;
-    bool round = fontDef.styleStrategy & QFont::ForceIntegerMetrics;
-    for (int i = 0; i < glyphs.numGlyphs; ++i) {
-        w += round ? glyphs.effectiveAdvance(i).round()
-                   : glyphs.effectiveAdvance(i);
-    }
-    return glyph_metrics_t(0, -(ascent()), w - lastRightBearing(glyphs, round), ascent()+descent(), w, 0);
-}
-
-glyph_metrics_t QFontEngineMac::boundingBox(glyph_t glyph)
-{
-    GlyphID atsuGlyph = glyph;
-
-    ATSGlyphScreenMetrics metrics;
-
-    ATSUGlyphGetScreenMetrics(style, 1, &atsuGlyph, 0,
-                              /* iForcingAntiAlias =*/ false,
-                              /* iAntiAliasSwitch =*/true,
-                              &metrics);
-
-    // ### check again
-
-    glyph_metrics_t gm;
-    gm.width = int(metrics.width);
-    gm.height = int(metrics.height);
-    gm.x = QFixed::fromReal(metrics.topLeft.x);
-    gm.y = -QFixed::fromReal(metrics.topLeft.y);
-    gm.xoff = QFixed::fromReal(metrics.deviceAdvance.x);
-    gm.yoff = QFixed::fromReal(metrics.deviceAdvance.y);
-
-    if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) {
-        gm.x = gm.x.floor();
-        gm.y = gm.y.floor();
-        gm.xoff = gm.xoff.round();
-        gm.yoff = gm.yoff.round();
-    }
-
-    return gm;
-}
-
-QFixed QFontEngineMac::ascent() const
-{
-    return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
-            ? m_ascent.round()
-            : m_ascent;
-}
-
-QFixed QFontEngineMac::descent() const
-{
-    // subtract a pixel to even out the historical +1 in QFontMetrics::height().
-    // Fix in Qt 5.
-    return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
-            ? m_descent.round() - 1
-            : m_descent;
-}
-
-QFixed QFontEngineMac::leading() const
-{
-    return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
-            ? m_leading.round()
-            : m_leading;
-}
-
-qreal QFontEngineMac::maxCharWidth() const
-{
-    return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
-            ? qRound(m_maxCharWidth)
-            : m_maxCharWidth;
-}
-
-QFixed QFontEngineMac::xHeight() const
-{
-    return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
-            ? m_xHeight.round()
-            : m_xHeight;
-}
-
-QFixed QFontEngineMac::averageCharWidth() const
-{
-    return (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
-            ? m_averageCharWidth.round()
-            : m_averageCharWidth;
-}
-
-static void addGlyphsToPathHelper(ATSUStyle style, glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path)
-{
-    if (!numGlyphs)
-        return;
-
-    OSStatus e;
-
-    QMacFontPath fontpath(0, 0, path);
-    ATSCubicMoveToUPP moveTo = NewATSCubicMoveToUPP(QMacFontPath::moveTo);
-    ATSCubicLineToUPP lineTo = NewATSCubicLineToUPP(QMacFontPath::lineTo);
-    ATSCubicCurveToUPP cubicTo = NewATSCubicCurveToUPP(QMacFontPath::cubicTo);
-    ATSCubicClosePathUPP closePath = NewATSCubicClosePathUPP(QMacFontPath::closePath);
-
-    // CTFontCreatePathForGlyph
-    for (int i = 0; i < numGlyphs; ++i) {
-        GlyphID glyph = glyphs[i];
-
-        fontpath.setPosition(positions[i].x.toReal(), positions[i].y.toReal());
-        ATSUGlyphGetCubicPaths(style, glyph, moveTo, lineTo,
-                               cubicTo, closePath, &fontpath, &e);
-    }
-
-    DisposeATSCubicMoveToUPP(moveTo);
-    DisposeATSCubicLineToUPP(lineTo);
-    DisposeATSCubicCurveToUPP(cubicTo);
-    DisposeATSCubicClosePathUPP(closePath);
-}
-
-void QFontEngineMac::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path,
-                                           QTextItem::RenderFlags)
-{
-    addGlyphsToPathHelper(style, glyphs, positions, numGlyphs, path);
-}
-
-
-/*!
-  Helper function for alphaMapForGlyph and alphaRGBMapForGlyph. The two are identical, except for
-  the subpixel antialiasing...
-*/
-QImage QFontEngineMac::imageForGlyph(glyph_t glyph, int margin, bool colorful)
-{
-    const glyph_metrics_t br = boundingBox(glyph);
-    QImage im(qRound(br.width)+2, qRound(br.height)+4, QImage::Format_RGB32);
-    im.fill(0xff000000);
-
-    CGColorSpaceRef colorspace = QCoreGraphicsPaintEngine::macGenericColorSpace();
-    uint cgflags = kCGImageAlphaNoneSkipFirst;
-#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
-    cgflags |= kCGBitmapByteOrder32Host;
-#endif
-    CGContextRef ctx = CGBitmapContextCreate(im.bits(), im.width(), im.height(),
-                                             8, im.bytesPerLine(), colorspace,
-                                             cgflags);
-    CGContextSetFontSize(ctx, fontDef.pixelSize);
-    CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias));
-    // turn off sub-pixel hinting - no support for that in OpenGL
-    CGContextSetShouldSmoothFonts(ctx, colorful);
-    CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
-    CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
-    CGAffineTransformConcat(cgMatrix, oldTextMatrix);
-
-    if (synthesisFlags & QFontEngine::SynthesizedItalic)
-        cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0));
-
-    cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
-
-    CGContextSetTextMatrix(ctx, cgMatrix);
-    CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
-    CGContextSetTextDrawingMode(ctx, kCGTextFill);
-    CGContextSetFont(ctx, cgFont);
-
-    qreal pos_x = -br.x.toReal() + 1;
-    qreal pos_y = im.height() + br.y.toReal() - 2;
-    CGContextSetTextPosition(ctx, pos_x, pos_y);
-
-    CGSize advance;
-    advance.width = 0;
-    advance.height = 0;
-    CGGlyph cgGlyph = glyph;
-    CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1);
-
-    if (synthesisFlags & QFontEngine::SynthesizedBold) {
-        CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
-        CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1);
-    }
-
-    CGContextRelease(ctx);
-
-    return im;
-}
-
-QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
-{
-    QImage im = imageForGlyph(glyph, 2, false);
-
-    QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
-    QVector<QRgb> colors(256);
-    for (int i=0; i<256; ++i)
-        colors[i] = qRgba(0, 0, 0, i);
-    indexed.setColorTable(colors);
-
-    for (int y=0; y<im.height(); ++y) {
-        uint *src = (uint*) im.scanLine(y);
-        uchar *dst = indexed.scanLine(y);
-        for (int x=0; x<im.width(); ++x) {
-            *dst = qGray(*src);
-            ++dst;
-            ++src;
-        }
-    }
-
-    return indexed;
-}
-
-QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, QFixed, int margin, const QTransform &t)
-{
-    QImage im = imageForGlyph(glyph, margin, true);
-
-    if (t.type() >= QTransform::TxScale) {
-        im = im.transformed(t);
-    }
-
-    qGamma_correct_back_to_linear_cs(&im);
-
-    return im;
-}
-
-
-bool QFontEngineMac::canRender(const QChar *string, int len)
-{
-    Q_ASSERT(false);
-    Q_UNUSED(string);
-    Q_UNUSED(len);
-    return false;
-}
-
-void QFontEngineMac::draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight)
-{
-    QVarLengthArray<QFixedPoint> positions;
-    QVarLengthArray<glyph_t> glyphs;
-    QTransform matrix;
-    matrix.translate(x, y);
-    getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
-    if (glyphs.size() == 0)
-        return;
-
-    CGContextSetFontSize(ctx, fontDef.pixelSize);
-
-    CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
-
-    CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, -1, 0, -paintDeviceHeight);
-
-    CGAffineTransformConcat(cgMatrix, oldTextMatrix);
-
-    if (synthesisFlags & QFontEngine::SynthesizedItalic)
-        cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0));
-
-    cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
-
-    CGContextSetTextMatrix(ctx, cgMatrix);
-
-    CGContextSetTextDrawingMode(ctx, kCGTextFill);
-
-
-    QVarLengthArray<CGSize> advances(glyphs.size());
-    QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
-
-    for (int i = 0; i < glyphs.size() - 1; ++i) {
-        advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
-        advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
-        cgGlyphs[i] = glyphs[i];
-    }
-    advances[glyphs.size() - 1].width = 0;
-    advances[glyphs.size() - 1].height = 0;
-    cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
-
-    CGContextSetFont(ctx, cgFont);
-
-    CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
-
-    CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
-
-    if (synthesisFlags & QFontEngine::SynthesizedBold) {
-        CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
-                                      positions[0].y.toReal());
-
-        CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
-    }
-
-    CGContextSetTextMatrix(ctx, oldTextMatrix);
-}
-
-QFontEngine::FaceId QFontEngineMac::faceId() const
-{
-    FaceId ret;
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
-if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
-    // CTFontGetPlatformFont
-    FSRef ref;
-    if (ATSFontGetFileReference(FMGetATSFontRefFromFont(fontID), &ref) != noErr)
-        return ret;
-    ret.filename = QByteArray(128, 0);
-    ret.index = fontID;
-    FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size());
-}else
-#endif
-{
-    FSSpec spec;
-    if (ATSFontGetFileSpecification(FMGetATSFontRefFromFont(fontID), &spec) != noErr)
-        return ret;
-
-    FSRef ref;
-    FSpMakeFSRef(&spec, &ref);
-    ret.filename = QByteArray(128, 0);
-    ret.index = fontID;
-    FSRefMakePath(&ref, (UInt8 *)ret.filename.data(), ret.filename.size());
-}
-    return ret;
-}
-
-QByteArray QFontEngineMac::getSfntTable(uint tag) const
-{
-    ATSFontRef atsFont = FMGetATSFontRefFromFont(fontID);
-
-    ByteCount length;
-    OSStatus status = ATSFontGetTable(atsFont, tag, 0, 0, 0, &length);
-    if (status != noErr)
-        return QByteArray();
-    QByteArray table(length, 0);
-    // CTFontCopyTable
-    status = ATSFontGetTable(atsFont, tag, 0, table.length(), table.data(), &length);
-    if (status != noErr)
-        return QByteArray();
-    return table;
-}
-
-QFontEngine::Properties QFontEngineMac::properties() const
-{
-    QFontEngine::Properties props;
-    ATSFontRef atsFont = FMGetATSFontRefFromFont(fontID);
-    quint16 tmp;
-    // CTFontGetUnitsPerEm
-    if (ATSFontGetTable(atsFont, MAKE_TAG('h', 'e', 'a', 'd'), 18, 2, &tmp, 0) == noErr)
-       props.emSquare = qFromBigEndian<quint16>(tmp);
-    struct {
-        qint16 xMin;
-        qint16 yMin;
-        qint16 xMax;
-        qint16 yMax;
-    } bbox;
-    bbox.xMin = bbox.xMax = bbox.yMin = bbox.yMax = 0;
-    // CTFontGetBoundingBox
-    if (ATSFontGetTable(atsFont, MAKE_TAG('h', 'e', 'a', 'd'), 36, 8, &bbox, 0) == noErr) {
-        bbox.xMin = qFromBigEndian<quint16>(bbox.xMin);
-        bbox.yMin = qFromBigEndian<quint16>(bbox.yMin);
-        bbox.xMax = qFromBigEndian<quint16>(bbox.xMax);
-        bbox.yMax = qFromBigEndian<quint16>(bbox.yMax);
-    }
-    struct {
-        qint16 ascender;
-        qint16 descender;
-        qint16 linegap;
-    } metrics;
-    metrics.ascender = metrics.descender = metrics.linegap = 0;
-    // CTFontGetAscent, etc.
-    if (ATSFontGetTable(atsFont, MAKE_TAG('h', 'h', 'e', 'a'), 4, 6, &metrics, 0) == noErr) {
-        metrics.ascender = qFromBigEndian<quint16>(metrics.ascender);
-        metrics.descender = qFromBigEndian<quint16>(metrics.descender);
-        metrics.linegap = qFromBigEndian<quint16>(metrics.linegap);
-    }
-    props.ascent = metrics.ascender;
-    props.descent = -metrics.descender;
-    props.leading = metrics.linegap;
-    props.boundingBox = QRectF(bbox.xMin, -bbox.yMax,
-                           bbox.xMax - bbox.xMin,
-                           bbox.yMax - bbox.yMin);
-    props.italicAngle = 0;
-    props.capHeight = props.ascent;
-
-    qint16 lw = 0;
-    // fonts lie
-    if (ATSFontGetTable(atsFont, MAKE_TAG('p', 'o', 's', 't'), 10, 2, &lw, 0) == noErr)
-       lw = qFromBigEndian<quint16>(lw);
-    props.lineWidth = lw;
-
-    // CTFontCopyPostScriptName
-    QCFString psName;
-    if (ATSFontGetPostScriptName(FMGetATSFontRefFromFont(fontID), kATSOptionFlagsDefault, &psName) == noErr)
-        props.postscriptName = QString(psName).toUtf8();
-    props.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(props.postscriptName);
-    return props;
-}
-
-void QFontEngineMac::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
-{
-    ATSUStyle unscaledStyle;
-    ATSUCreateAndCopyStyle(style, &unscaledStyle);
-
-    int emSquare = properties().emSquare.toInt();
-
-    const int maxAttributeCount = 4;
-    ATSUAttributeTag tags[maxAttributeCount + 1];
-    ByteCount sizes[maxAttributeCount + 1];
-    ATSUAttributeValuePtr values[maxAttributeCount + 1];
-    int attributeCount = 0;
-
-    Fixed size = FixRatio(emSquare, 1);
-    tags[attributeCount] = kATSUSizeTag;
-    sizes[attributeCount] = sizeof(size);
-    values[attributeCount] = &size;
-    ++attributeCount;
-
-    Q_ASSERT(attributeCount < maxAttributeCount + 1);
-    OSStatus err = ATSUSetAttributes(unscaledStyle, attributeCount, tags, sizes, values);
-    Q_ASSERT(err == noErr);
-    Q_UNUSED(err);
-
-    // various CTFont metrics functions: CTFontGetBoundingRectsForGlyphs, CTFontGetAdvancesForGlyphs
-    GlyphID atsuGlyph = glyph;
-    ATSGlyphScreenMetrics atsuMetrics;
-    ATSUGlyphGetScreenMetrics(unscaledStyle, 1, &atsuGlyph, 0,
-                              /* iForcingAntiAlias =*/ false,
-                              /* iAntiAliasSwitch =*/true,
-                              &atsuMetrics);
-
-    metrics->width = int(atsuMetrics.width);
-    metrics->height = int(atsuMetrics.height);
-    metrics->x = QFixed::fromReal(atsuMetrics.topLeft.x);
-    metrics->y = -QFixed::fromReal(atsuMetrics.topLeft.y);
-    metrics->xoff = QFixed::fromReal(atsuMetrics.deviceAdvance.x);
-    metrics->yoff = QFixed::fromReal(atsuMetrics.deviceAdvance.y);
-
-    QFixedPoint p;
-    addGlyphsToPathHelper(unscaledStyle, &glyph, &p, 1, path);
-
-    ATSUDisposeStyle(unscaledStyle);
-}
-#endif // !QT_MAC_USE_COCOA
-
 QT_END_NAMESPACE
index 10561e5..eab28ca 100644 (file)
 
 #include <private/qfontengine_p.h>
 
-#ifndef QT_MAC_USE_COCOA
-class QFontEngineMacMulti;
-class QFontEngineMac : public QFontEngine
-{
-    friend class QFontEngineMacMulti;
-public:
-    QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFontDef &def, QFontEngineMacMulti *multiEngine = 0);
-    virtual ~QFontEngineMac();
-
-    virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *numGlyphs, QTextEngine::ShaperFlags flags) const;
-    virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-
-    virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
-    virtual glyph_metrics_t boundingBox(glyph_t glyph);
-
-    virtual QFixed ascent() const;
-    virtual QFixed descent() const;
-    virtual QFixed leading() const;
-    virtual QFixed xHeight() const;
-    virtual qreal maxCharWidth() const;
-    virtual QFixed averageCharWidth() const;
-
-    virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs,
-                                 QPainterPath *path, QTextItem::RenderFlags);
-
-    virtual const char *name() const { return "QFontEngineMac"; }
-
-    virtual bool canRender(const QChar *string, int len);
-
-    virtual int synthesized() const { return synthesisFlags; }
-
-    virtual Type type() const { return QFontEngine::Mac; }
-
-    void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
-
-    virtual FaceId faceId() const;
-    virtual QByteArray getSfntTable(uint tag) const;
-    virtual Properties properties() const;
-    virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
-    virtual QImage alphaMapForGlyph(glyph_t);
-    virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
-
-private:
-    QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
-
-    ATSUFontID fontID;
-    QCFType<CGFontRef> cgFont;
-    ATSUStyle style;
-    int synthesisFlags;
-    mutable QGlyphLayout kashidaGlyph;
-    QFontEngineMacMulti *multiEngine;
-    mutable const unsigned char *cmap;
-    mutable bool symbolCMap;
-    mutable QByteArray cmapTable;
-    CGAffineTransform transform;
-    QFixed m_ascent;
-    QFixed m_descent;
-    QFixed m_leading;
-    qreal m_maxCharWidth;
-    QFixed m_xHeight;
-    QFixed m_averageCharWidth;
-};
-
-class QFontEngineMacMulti : public QFontEngineMulti
-{
-    friend class QFontEngineMac;
-public:
-    // internal
-    struct ShaperItem
-    {
-        inline ShaperItem() : string(0), from(0), length(0),
-        log_clusters(0), charAttributes(0) {}
-
-        const QChar *string;
-        int from;
-        int length;
-        QGlyphLayout glyphs;
-        unsigned short *log_clusters;
-        const HB_CharAttributes *charAttributes;
-        QTextEngine::ShaperFlags flags;
-    };
-
-    QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning);
-    virtual ~QFontEngineMacMulti();
-
-    virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
-    bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags,
-                      unsigned short *logClusters, const HB_CharAttributes *charAttributes, QScriptItem *) const;
-
-    virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-    virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
-
-    virtual const char *name() const { return "ATSUI"; }
-
-    virtual bool canRender(const QChar *string, int len);
-
-    inline ATSUFontID macFontID() const { return fontID; }
-
-protected:
-    virtual void loadEngine(int at);
-
-private:
-    inline const QFontEngineMac *engineAt(int i) const
-    { return static_cast<const QFontEngineMac *>(engines.at(i)); }
-
-    bool stringToCMapInternal(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags, ShaperItem *item) const;
-
-    int fontIndexForFontID(ATSUFontID id) const;
-
-    ATSUFontID fontID;
-    uint kerning : 1;
-
-    mutable ATSUTextLayout textLayout;
-    mutable ATSUStyle style;
-    CGAffineTransform transform;
-};
-#endif //!QT_MAC_USE_COCOA
 
 #endif // QFONTENGINE_MAC_P_H
index 75a3667..df18511 100644 (file)
@@ -435,10 +435,6 @@ static Boolean qt_KeyEventComparatorProc(EventRef inEvent, void *data)
 static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent, int *qtKey,
                                       QChar *outChar, Qt::KeyboardModifiers *outModifiers, bool *outHandled)
 {
-#if !defined(QT_MAC_USE_COCOA) || defined(Q_OS_MAC64)
-    Q_UNUSED(er);
-    Q_UNUSED(outHandled);
-#endif
     const UInt32 ekind = GetEventKind(keyEvent);
     {
         UInt32 mac_modifiers = 0;
@@ -534,14 +530,12 @@ static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent,
                                                               rightShiftKey|alphaLock)) | keyCode,
                                            &tmp_unused_state);
         if (!translatedChar) {
-#ifdef QT_MAC_USE_COCOA
             if (outHandled) {
                 qt_mac_eat_unicode_key = false;
                 if (er)
                     CallNextEventHandler(er, keyEvent);
                 *outHandled = qt_mac_eat_unicode_key;
             }
-#endif
             return false;
         }
 
@@ -774,26 +768,6 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
 
 
     if (widget) {
-#ifndef QT_MAC_USE_COCOA
-        Q_UNUSED(info);
-        // Try not to call "other" event handlers if we have a popup,
-        // However, if the key has text
-        // then we should pass it along because otherwise then people
-        // can use input method stuff.
-        if (!qApp->activePopupWidget()
-                || (qApp->activePopupWidget() && !text.isEmpty())) {
-            //Find out if someone else wants the event, namely
-            //is it of use to text services? If so we won't bother
-            //with a QKeyEvent.
-            qt_mac_eat_unicode_key = false;
-            if (er)
-                CallNextEventHandler(er, event);
-            extern bool qt_mac_menubar_is_open();   
-            if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
-                return true;
-            }
-        }
-#endif
         // Try to compress key events.
         if (!text.isEmpty() && widget->testAttribute(Qt::WA_KeyCompression)) {
             EventTime lastTime = GetEventTime(event);
@@ -866,7 +840,6 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
         UInt32 macModifiers = 0;
         GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
                           sizeof(macModifiers), 0, &macModifiers);
-#ifdef QT_MAC_USE_COCOA
         // The unicode characters in the range 0xF700-0xF747 are reserved
         // by Mac OS X for transient use as keyboard function keys. We
         // wont send 'text' for such key events. This is done to match
@@ -875,27 +848,20 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
         if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747)
             text = QString();
         bool isAccepted;
-#endif
         handled_event = QKeyMapper::sendKeyEvent(widget, grab,
                                                  (ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress,
                                                  qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0,
                                                  macScanCode, macVirtualKey, macModifiers
-#ifdef QT_MAC_USE_COCOA
                                                  ,&isAccepted
-#endif
                                                  );
-#ifdef QT_MAC_USE_COCOA
         *unicodeKey = (unsigned int)isAccepted;
-#endif
     }
     return handled_event;
 }
 
 void
 QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *
-#if defined(QT_MAC_USE_COCOA)
                                 unicodeKey // unicode character from NSEvent (modifiers applied)
-#endif
                                 )
 {
     UInt32 macVirtualKey = 0;
index 321f4fd..6e77f41 100644 (file)
@@ -159,7 +159,6 @@ void QMacPinchGestureRecognizer::reset(QGesture *gesture)
 
 ////////////////////////////////////////////////////////////////////////
 
-#if defined(QT_MAC_USE_COCOA)
 
 QMacPanGestureRecognizer::QMacPanGestureRecognizer() : _panCanceled(true)
 {
@@ -265,7 +264,6 @@ void QMacPanGestureRecognizer::reset(QGesture *gesture)
     g->setAcceleration(qreal(1));
     QGestureRecognizer::reset(gesture);
 }
-#endif // QT_MAC_USE_COCOA
 
 QT_END_NAMESPACE
 
index f6f2073..8d1bd33 100644 (file)
@@ -81,7 +81,6 @@ public:
     void reset(QGesture *gesture);
 };
 
-#if defined(QT_MAC_USE_COCOA)
 
 class QMacPanGestureRecognizer : public QObject, public QGestureRecognizer
 {
@@ -97,7 +96,6 @@ private:
     bool _panCanceled;
 };
 
-#endif
 
 QT_END_NAMESPACE
 
index a98cee7..43da4a9 100644 (file)
@@ -65,21 +65,11 @@ QMacInputContext::QMacInputContext(QObject *parent)
 
 QMacInputContext::~QMacInputContext()
 {
-#ifndef QT_MAC_USE_COCOA
-    if(textDocument)
-        DeleteTSMDocument(textDocument);
-#endif
 }
 
 void
 QMacInputContext::createTextDocument()
 {
-#ifndef QT_MAC_USE_COCOA
-    if(!textDocument) {
-        InterfaceTypeList itl = { kUnicodeDocument };
-        NewTSMDocument(1, itl, &textDocument, SRefCon(this));
-    }
-#endif
 }
 
 
@@ -91,103 +81,27 @@ QString QMacInputContext::language()
 
 void QMacInputContext::mouseHandler(int pos, QMouseEvent *e)
 {
-#ifndef QT_MAC_USE_COCOA
-    if(e->type() != QEvent::MouseButtonPress)
-        return;
-
-    if (!composing)
-        return;
-    if (pos < 0 || pos > currentText.length())
-        reset();
-    // ##### handle mouse position
-#else
     Q_UNUSED(pos);
     Q_UNUSED(e);
-#endif
-}
-
-#if !defined QT_MAC_USE_COCOA
-
-static QTextFormat qt_mac_compose_format()
-{
-    QTextCharFormat ret;
-    ret.setFontUnderline(true);
-    return ret;
 }
 
-void QMacInputContext::reset()
-{
-    if (recursionGuard)
-        return;
-    if (!currentText.isEmpty()){
-        QInputMethodEvent e;
-        e.setCommitString(currentText);
-        qt_sendSpontaneousEvent(focusWidget(), &e);
-        currentText = QString();
-    }
-    recursionGuard = true;
-    createTextDocument();
-    composing = false;
-    ActivateTSMDocument(textDocument);
-    FixTSMDocument(textDocument);
-    recursionGuard = false;
-}
-
-bool QMacInputContext::isComposing() const
-{
-    return composing;
-}
-#endif
 
 void QMacInputContext::setFocusWidget(QWidget *w)
 {
     createTextDocument();
-#ifndef QT_MAC_USE_COCOA
-    if(w)
-        ActivateTSMDocument(textDocument);
-    else
-        DeactivateTSMDocument(textDocument);
-#endif
     QInputContext::setFocusWidget(w);
 }
 
 
-#ifndef QT_MAC_USE_COCOA
-static EventTypeSpec input_events[] = {
-    { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
-    { kEventClassTextInput, kEventTextInputOffsetToPos },
-    { kEventClassTextInput, kEventTextInputUpdateActiveInputArea }
-};
-static EventHandlerUPP input_proc_handlerUPP = 0;
-static EventHandlerRef input_proc_handler = 0;
-#endif
 
 void
 QMacInputContext::initialize()
 {
-#ifndef QT_MAC_USE_COCOA
-    if(!input_proc_handler) {
-        input_proc_handlerUPP = NewEventHandlerUPP(QMacInputContext::globalEventProcessor);
-        InstallEventHandler(GetApplicationEventTarget(), input_proc_handlerUPP,
-                            GetEventTypeCount(input_events), input_events,
-                            0, &input_proc_handler);
-    }
-#endif
 }
 
 void
 QMacInputContext::cleanup()
 {
-#ifndef QT_MAC_USE_COCOA
-    if(input_proc_handler) {
-        RemoveEventHandler(input_proc_handler);
-        input_proc_handler = 0;
-    }
-    if(input_proc_handlerUPP) {
-        DisposeEventHandlerUPP(input_proc_handlerUPP);
-        input_proc_handlerUPP = 0;
-    }
-#endif
 }
 
 void QMacInputContext::setLastKeydownEvent(EventRef event)
@@ -203,175 +117,7 @@ void QMacInputContext::setLastKeydownEvent(EventRef event)
 OSStatus
 QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
 {
-#ifndef QT_MAC_USE_COCOA
-    QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData);
-
-    SRefCon refcon = 0;
-    GetEventParameter(event, kEventParamTextInputSendRefCon, typeRefCon, 0,
-                      sizeof(refcon), 0, &refcon);
-    QMacInputContext *context = reinterpret_cast<QMacInputContext*>(refcon);
-
-    bool handled_event=true;
-    UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
-    switch(eclass) {
-    case kEventClassTextInput: {
-        handled_event = false;
-        QWidget *widget = QApplicationPrivate::focus_widget;
-        bool canCompose = widget && (!context || widget->inputContext() == context)
-                && !(widget->inputMethodHints() & Qt::ImhDigitsOnly
-                || widget->inputMethodHints() & Qt::ImhFormattedNumbersOnly
-                || widget->inputMethodHints() & Qt::ImhHiddenText);
-        if(!canCompose) {
-            handled_event = false;
-        } else if(ekind == kEventTextInputOffsetToPos) {
-            if(!widget->testAttribute(Qt::WA_InputMethodEnabled)) {
-                handled_event = false;
-                break;
-            }
-
-            QRect mr(widget->inputMethodQuery(Qt::ImMicroFocus).toRect());
-            QPoint mp(widget->mapToGlobal(QPoint(mr.topLeft())));
-            Point pt;
-            pt.h = mp.x();
-            pt.v = mp.y() + mr.height();
-            SetEventParameter(event, kEventParamTextInputReplyPoint, typeQDPoint,
-                              sizeof(pt), &pt);
-            handled_event = true;
-        } else if(ekind == kEventTextInputUpdateActiveInputArea) {
-            if(!widget->testAttribute(Qt::WA_InputMethodEnabled)) {
-                handled_event = false;
-                break;
-            }
-
-            if (context->recursionGuard)
-                break;
-
-            ByteCount unilen = 0;
-            GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
-                              0, 0, &unilen, 0);
-            UniChar *unicode = (UniChar*)NewPtr(unilen);
-            GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
-                              0, unilen, 0, unicode);
-            QString text((QChar*)unicode, unilen / sizeof(UniChar));
-            DisposePtr((char*)unicode);
-
-            ByteCount fixed_length = 0;
-            GetEventParameter(event, kEventParamTextInputSendFixLen, typeByteCount, 0,
-                              sizeof(fixed_length), 0, &fixed_length);
-            if(fixed_length == ULONG_MAX || fixed_length == unilen) {
-                QInputMethodEvent e;
-                e.setCommitString(text);
-                context->currentText = QString();
-                qt_sendSpontaneousEvent(context->focusWidget(), &e);
-                handled_event = true;
-                context->reset();
-            } else {
-                ByteCount rngSize = 0;
-                OSStatus err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
-                                                 0, &rngSize, 0);
-                QVarLengthArray<TextRangeArray> highlight(rngSize);
-                if (noErr == err) {
-                    err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
-                                            rngSize, &rngSize, highlight.data());
-                }
-                context->composing = true;
-                if(fixed_length > 0) {
-                    const int qFixedLength = fixed_length / sizeof(UniChar);
-                    QList<QInputMethodEvent::Attribute> attrs;
-                    attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
-                                                          qFixedLength, text.length()-qFixedLength,
-                                                          qt_mac_compose_format());
-                    QInputMethodEvent e(text, attrs);
-                    context->currentText = text;
-                    e.setCommitString(text.left(qFixedLength), 0, qFixedLength);
-                    qt_sendSpontaneousEvent(widget, &e);
-                    handled_event = true;
-                } else {
-                    /* Apple's enums that they have removed from Tiger :(
-                    enum {
-                        kCaretPosition = 1,
-                        kRawText = 2,
-                        kSelectedRawText = 3,
-                        kConvertedText = 4,
-                        kSelectedConvertedText = 5,
-                        kBlockFillText = 6,
-                        kOutlineText = 7,
-                        kSelectedText = 8
-                    };
-                    */
-#ifndef kConvertedText
-#define kConvertedText 4
-#endif
-#ifndef kCaretPosition
-#define kCaretPosition 1
-#endif
-                    QList<QInputMethodEvent::Attribute> attrs;
-                    if (!highlight.isEmpty()) {
-                        TextRangeArray *data = highlight.data();
-                        for (int i = 0; i < data->fNumOfRanges; ++i) {
-                            int start = data->fRange[i].fStart / sizeof(UniChar);
-                            int len = (data->fRange[i].fEnd - data->fRange[i].fStart) / sizeof(UniChar);
-                            if (data->fRange[i].fHiliteStyle == kCaretPosition) {
-                                attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, start, 0, QVariant());
-                                continue;
-                            }
-                            QTextCharFormat format;
-                            format.setFontUnderline(true);
-                            if (data->fRange[i].fHiliteStyle == kConvertedText)
-                                format.setUnderlineColor(Qt::gray);
-                            else
-                                format.setUnderlineColor(Qt::black);
-                            attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, start, len, format);
-                        }
-                    } else {
-                        attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
-                                0, text.length(), qt_mac_compose_format());
-                    }
-                    context->currentText = text;
-                    QInputMethodEvent e(text, attrs);
-                    qt_sendSpontaneousEvent(widget, &e);
-                    handled_event = true;
-                }
-            }
-#if 0
-            if(!context->composing)
-                handled_event = false;
-#endif
-
-            extern bool qt_mac_eat_unicode_key; //qapplication_mac.cpp
-            qt_mac_eat_unicode_key = handled_event;
-        } else if(ekind == kEventTextInputUnicodeForKeyEvent) {
-            EventRef key_ev = 0;
-            GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0,
-                              sizeof(key_ev), 0, &key_ev);
-            QString text;
-            ByteCount unilen = 0;
-            if(GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, 0, &unilen, 0) == noErr) {
-                UniChar *unicode = (UniChar*)NewPtr(unilen);
-                GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, unilen, 0, unicode);
-                text = QString((QChar*)unicode, unilen / sizeof(UniChar));
-                DisposePtr((char*)unicode);
-            }
-            unsigned char chr = 0;
-            GetEventParameter(key_ev, kEventParamKeyMacCharCodes, typeChar, 0, sizeof(chr), 0, &chr);
-            if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr))))
-                handled_event = !widget->testAttribute(Qt::WA_InputMethodEnabled);
-            QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
-            if (context && context->lastKeydownEvent()) {
-                qt_keymapper_private()->translateKeyEvent(widget, 0, context->lastKeydownEvent(),
-                                                          0, false);
-                context->setLastKeydownEvent(0);
-            }
-        }
-        break; }
-    default:
-        break;
-    }
-    if(!handled_event) //let the event go through
-        return eventNotHandledErr;
-#else
     Q_UNUSED(event);
-#endif
     return noErr; //we eat the event
 }
 
index 3def016..af8e0e3 100644 (file)
@@ -556,11 +556,7 @@ QCoreGraphicsPaintEngine::end()
     Q_D(QCoreGraphicsPaintEngine);
     setActive(false);
     if(d->pdev->devType() == QInternal::Widget && static_cast<QWidget*>(d->pdev)->windowType() == Qt::Desktop) {
-#ifndef QT_MAC_USE_COCOA
-        HideWindow(qt_mac_window_for(static_cast<QWidget*>(d->pdev)));
-#else
 //        // ### need to do [qt_mac_window_for(static_cast<QWidget *>(d->pdev)) orderOut]; (need to rename)
-#endif
 
        }
     if(d->shading) {
@@ -1045,11 +1041,7 @@ void QCoreGraphicsPaintEngine::drawTextItem(const QPointF &pos, const QTextItem
     if (ti.glyphs.numGlyphs) {
         switch (fe->type()) {
         case QFontEngine::Mac:
-#ifdef QT_MAC_USE_COCOA
             static_cast<QCoreTextFontEngine *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
-#else
-            static_cast<QFontEngineMac *>(fe)->draw(d->hd, pos.x(), pos.y(), ti, paintDevice()->height());
-#endif
             break;
         case QFontEngine::Box:
             d->drawBoxTextItem(pos, ti);
index a375eda..48835c7 100644 (file)
@@ -860,28 +860,6 @@ static QPixmap qt_mac_grabScreenRect(const QRect &rect)
     return QPixmap::fromMacCGImageRef(image);
 }
 
-#ifndef QT_MAC_USE_COCOA // no QuickDraw in 64-bit mode
-static QPixmap qt_mac_grabScreenRect_10_3(int x, int y, int w, int h, QWidget *widget)
-{
-    QPixmap pm = QPixmap(w, h);
-    extern WindowPtr qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
-    const BitMap *windowPort = 0;
-    if((widget->windowType() == Qt::Desktop)) {
-        GDHandle gdh;
-          if(!(gdh=GetMainDevice()))
-              qDebug("Qt: internal: Unexpected condition reached: %s:%d", __FILE__, __LINE__);
-          windowPort = (BitMap*)(*(*gdh)->gdPMap);
-    } else {
-        windowPort = GetPortBitMapForCopyBits(GetWindowPort(qt_mac_window_for(widget)));
-    }
-    const BitMap *pixmapPort = GetPortBitMapForCopyBits(static_cast<GWorldPtr>(pm.macQDHandle()));
-    Rect macSrcRect, macDstRect;
-    SetRect(&macSrcRect, x, y, x + w, y + h);
-    SetRect(&macDstRect, 0, 0, w, h);
-    CopyBits(windowPort, pixmapPort, &macSrcRect, &macDstRect, srcCopy, 0);
-    return pm;
-}
-#endif
 
 QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
 {
@@ -898,18 +876,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
     globalCoord = widget->mapToGlobal(globalCoord);
     QRect rect(globalCoord.x() + x, globalCoord.y() + y, w, h);
 
-#ifdef QT_MAC_USE_COCOA
     return qt_mac_grabScreenRect(rect);
-#else
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
-    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
-        return qt_mac_grabScreenRect(rect);
-    } else
-#endif
-   {
-        return qt_mac_grabScreenRect_10_3(x, y, w, h, widget);
-   }
-#endif // ifdef Q_WS_MAC64
 }
 
 /*! \internal
@@ -1005,85 +972,6 @@ CGImageRef qt_mac_create_imagemask(const QPixmap &pixmap, const QRectF &sr)
     return px->cg_mask;
 }
 
-#ifndef QT_MAC_USE_COCOA
-IconRef qt_mac_create_iconref(const QPixmap &px)
-{
-    if (px.isNull())
-        return 0;
-
-    //create icon
-    IconFamilyHandle iconFamily = reinterpret_cast<IconFamilyHandle>(NewHandle(0));
-    //create data
-    {
-        struct {
-            OSType mac_type;
-            int width, height, depth;
-            bool mask;
-        } images[] = {
-            { kThumbnail32BitData, 128, 128, 32, false },
-            { kThumbnail8BitMask, 128, 128, 8, true },
-            { 0, 0, 0, 0, false } //end marker
-        };
-        for(int i = 0; images[i].mac_type; i++) {
-            //get QPixmap data
-            QImage scaled_px = px.toImage().scaled(images[i].width, images[i].height);
-
-            quint32 *sptr = (quint32 *) scaled_px.bits();
-            quint32 *srow;
-            uint sbpr = scaled_px.bytesPerLine();
-
-            //get Handle data
-            const int dbpr = images[i].width * (images[i].depth/8);
-            Handle hdl = NewHandle(dbpr*images[i].height);
-            if(!sptr) { //handle null pixmap
-                memset((*hdl), '\0', dbpr*images[i].height);
-            } else if(images[i].mask) {
-                if(images[i].mac_type == kThumbnail8BitMask) {
-                    for(int y = 0, hindex = 0; y < images[i].height; ++y) {
-                        srow = sptr + (y * (sbpr/4));
-                        for(int x = 0; x < images[i].width; ++x)
-                            *((*hdl)+(hindex++)) = qAlpha(*(srow+x));
-                    }
-                }
-            } else {
-                char *dest = (*hdl);
-#if defined(__i386__)
-                if(images[i].depth == 32) {
-                    for(int y = 0; y < images[i].height; ++y) {
-                        uint *source = (uint*)((const uchar*)sptr+(sbpr*y));
-                        for(int x = 0; x < images[i].width; ++x, dest += 4)
-                            *((uint*)dest) = CFSwapInt32(*(source + x));
-                    }
-                } else
-#endif
-                {
-                    for(int y = 0; y < images[i].height; ++y)
-                        memcpy(dest+(y*dbpr), ((const uchar*)sptr+(sbpr*y)), dbpr);
-                }
-            }
-
-            //set the family data to the Handle
-            OSStatus set = SetIconFamilyData(iconFamily, images[i].mac_type, hdl);
-            if(set != noErr)
-                qWarning("%s: %d -- Unable to create icon data[%d]!! %ld",
-                         __FILE__, __LINE__, i, long(set));
-            DisposeHandle(hdl);
-        }
-    }
-
-    //acquire and cleanup
-    IconRef ret;
-    static int counter = 0;
-    const OSType kQtCreator = 'CUTE';
-    RegisterIconRefFromIconFamily(kQtCreator, (OSType)counter, iconFamily, &ret);
-    AcquireIconRef(ret);
-    UnregisterIconRef(kQtCreator, (OSType)counter);
-    DisposeHandle(reinterpret_cast<Handle>(iconFamily));
-    counter++;
-    return ret;
-
-}
-#endif
 
 /*! \internal */
 QPaintEngine* QMacPlatformPixmap::paintEngine() const
index fb40677..b01d7a5 100644 (file)
@@ -90,12 +90,7 @@ bool QMacPrintEngine::begin(QPaintDevice *dev)
         }
     }
     OSStatus status = noErr;
-#ifndef QT_MAC_USE_COCOA
-    status = d->shouldSuppressStatus() ? PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format)
-                                       : PMSessionBeginCGDocument(d->session, d->settings, d->format);
-#else
     status = PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format);
-#endif
 
     if (status != noErr) {
         d->state = QPrinter::Error;
@@ -139,9 +134,7 @@ Qt::HANDLE QMacPrintEngine::handle() const
 
 QMacPrintEnginePrivate::~QMacPrintEnginePrivate()
 {
-#ifdef QT_MAC_USE_COCOA
     [printInfo release];
-#endif
     delete paintEngine;
 }
 
@@ -250,12 +243,7 @@ bool QMacPrintEngine::newPage()
     Q_D(QMacPrintEngine);
     Q_ASSERT(d->state == QPrinter::Active);
     OSStatus err =
-#ifndef QT_MAC_USE_COCOA
-    d->shouldSuppressStatus() ? PMSessionEndPageNoDialog(d->session)
-                              : PMSessionEndPage(d->session);
-#else
     PMSessionEndPageNoDialog(d->session);
-#endif
     if (err != noErr)  {
         if (err == kPMCancel) {
             // User canceled, we need to abort!
@@ -357,18 +345,7 @@ int QMacPrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const
         PMPrinter printer;
         if(PMSessionGetCurrentPrinter(d->session, &printer) == noErr) {
             PMResolution resolution;
-#ifndef QT_MAC_USE_COCOA
-#  if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
-            if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
-                PMPrinterGetOutputResolution(printer, d->settings, &resolution);
-            } else
-#  endif
-            {
-                PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &resolution);
-            }
-#else
             PMPrinterGetOutputResolution(printer, d->settings, &resolution);
-#endif
             val = (int)resolution.vRes;
             break;
         }
@@ -397,11 +374,7 @@ void QMacPrintEnginePrivate::initialize()
 {
     Q_Q(QMacPrintEngine);
 
-#ifndef QT_MAC_USE_COCOA
-    Q_ASSERT(!session);
-#else
     Q_ASSERT(!printInfo);
-#endif
 
     if (!paintEngine)
         paintEngine = new QCoreGraphicsPaintEngine();
@@ -410,14 +383,9 @@ void QMacPrintEnginePrivate::initialize()
 
     fullPage = false;
 
-#ifndef QT_MAC_USE_COCOA
-    if (PMCreateSession(&session) != 0)
-        session = 0;
-#else
     QMacCocoaAutoReleasePool pool;
     printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
     session = static_cast<PMPrintSession>([printInfo PMPrintSession]);
-#endif
 
     PMPrinter printer;
     if (session && PMSessionGetCurrentPrinter(session, &printer) == noErr) {
@@ -441,32 +409,9 @@ void QMacPrintEnginePrivate::initialize()
         }
     }
 
-#ifndef QT_MAC_USE_COCOA
-    bool settingsInitialized = (settings != 0);
-    bool settingsOK = !settingsInitialized ? PMCreatePrintSettings(&settings) == noErr : true;
-    if (settingsOK && !settingsInitialized)
-        settingsOK = PMSessionDefaultPrintSettings(session, settings) == noErr;
-
-
-    bool formatInitialized = (format != 0);
-    bool formatOK = !formatInitialized ? PMCreatePageFormat(&format) == noErr : true;
-    if (formatOK) {
-        if (!formatInitialized) {
-            formatOK = PMSessionDefaultPageFormat(session, format) == noErr;
-        }
-        formatOK = PMSessionValidatePageFormat(session, format, kPMDontWantBoolean) == noErr;
-    }
-#else
     settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]);
     format = static_cast<PMPageFormat>([printInfo PMPageFormat]);
-#endif
 
-#ifndef QT_MAC_USE_COCOA
-    if (!settingsOK || !formatOK) {
-        qWarning("QMacPrintEngine::initialize: Unable to initialize QPainter");
-        state = QPrinter::Error;
-    }
-#endif
 
     QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant>::const_iterator propC;
     for (propC = valueCache.constBegin(); propC != valueCache.constEnd(); propC++) {
@@ -476,20 +421,9 @@ void QMacPrintEnginePrivate::initialize()
 
 void QMacPrintEnginePrivate::releaseSession()
 {
-#ifndef QT_MAC_USE_COCOA
-    if (shouldSuppressStatus()) {
-       PMSessionEndPageNoDialog(session);
-       PMSessionEndDocumentNoDialog(session);
-    } else {
-       PMSessionEndPage(session);
-       PMSessionEndDocument(session);
-    }
-    PMRelease(session);
-#else
     PMSessionEndPageNoDialog(session);
     PMSessionEndDocumentNoDialog(session);
     [printInfo release];
-#endif
     printInfo = 0;
     session = 0;
 }
@@ -512,12 +446,7 @@ bool QMacPrintEnginePrivate::newPage_helper()
         cgEngine->d_func()->restoreGraphicsState();
 
     OSStatus status =
-#ifndef QT_MAC_USE_COCOA
-        shouldSuppressStatus() ? PMSessionBeginPageNoDialog(session, format, 0)
-                               : PMSessionBeginPage(session, format, 0);
-#else
         PMSessionBeginPageNoDialog(session, format, 0);
-#endif
     if(status != noErr) {
         state = QPrinter::Error;
         return false;
index 5c4fe94..6c17818 100644 (file)
@@ -150,11 +150,7 @@ public:
     QList<QVariant> supportedResolutions() const;
     inline bool isPrintSessionInitialized() const
     {
-#ifndef QT_MAC_USE_COCOA
-        return session != 0;
-#else
         return printInfo != 0;
-#endif
     }
     bool shouldSuppressStatus() const;
 };
index 94805a7..b929d9c 100644 (file)
@@ -47,152 +47,6 @@ QT_BEGIN_NAMESPACE
 
 QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0 };
 
-#if defined(Q_WS_MAC32) && !defined(QT_MAC_USE_COCOA)
-#define RGN_CACHE_SIZE 200
-#ifdef RGN_CACHE_SIZE
-static bool rgncache_init = false;
-static int rgncache_used;
-static RgnHandle rgncache[RGN_CACHE_SIZE];
-static void qt_mac_cleanup_rgncache()
-{
-    rgncache_init = false;
-    for(int i = 0; i < RGN_CACHE_SIZE; ++i) {
-        if(rgncache[i]) {
-            --rgncache_used;
-            DisposeRgn(rgncache[i]);
-            rgncache[i] = 0;
-        }
-    }
-}
-#endif
-
-Q_WIDGETS_EXPORT RgnHandle qt_mac_get_rgn()
-{
-#ifdef RGN_CACHE_SIZE
-    if(!rgncache_init) {
-        rgncache_used = 0;
-        rgncache_init = true;
-        for(int i = 0; i < RGN_CACHE_SIZE; ++i)
-            rgncache[i] = 0;
-        qAddPostRoutine(qt_mac_cleanup_rgncache);
-    } else if(rgncache_used) {
-        for(int i = 0; i < RGN_CACHE_SIZE; ++i) {
-            if(rgncache[i]) {
-                RgnHandle ret = rgncache[i];
-                SetEmptyRgn(ret);
-                rgncache[i] = 0;
-                --rgncache_used;
-                return ret;
-            }
-        }
-    }
-#endif
-    return NewRgn();
-}
-
-Q_WIDGETS_EXPORT void qt_mac_dispose_rgn(RgnHandle r)
-{
-#ifdef RGN_CACHE_SIZE
-    if(rgncache_init && rgncache_used < RGN_CACHE_SIZE) {
-        for(int i = 0; i < RGN_CACHE_SIZE; ++i) {
-            if(!rgncache[i]) {
-                ++rgncache_used;
-                rgncache[i] = r;
-                return;
-            }
-        }
-    }
-#endif
-    DisposeRgn(r);
-}
-
-static OSStatus qt_mac_get_rgn_rect(UInt16 msg, RgnHandle, const Rect *rect, void *reg)
-{
-    if(msg == kQDRegionToRectsMsgParse) {
-        QRect rct(rect->left, rect->top, (rect->right - rect->left), (rect->bottom - rect->top));
-        if(!rct.isEmpty())
-            *((QRegion *)reg) += rct;
-    }
-    return noErr;
-}
-
-Q_WIDGETS_EXPORT QRegion qt_mac_convert_mac_region(RgnHandle rgn)
-{
-    return QRegion::fromQDRgn(rgn);
-}
-
-QRegion QRegion::fromQDRgn(RgnHandle rgn)
-{
-    QRegion ret;
-    ret.detach();
-    OSStatus oss = QDRegionToRects(rgn, kQDParseRegionFromTopLeft, qt_mac_get_rgn_rect, (void *)&ret);
-    if(oss != noErr)
-        return QRegion();
-    return ret;
-}
-
-/*!
-    \internal
-     Create's a RegionHandle, it's the caller's responsibility to release.
-*/
-RgnHandle QRegion::toQDRgn() const
-{
-    RgnHandle rgnHandle = qt_mac_get_rgn();
-    if(d->qt_rgn && d->qt_rgn->numRects) {
-        RgnHandle tmp_rgn = qt_mac_get_rgn();
-        int n = d->qt_rgn->numRects;
-        const QRect *qt_r = (n == 1) ? &d->qt_rgn->extents : d->qt_rgn->rects.constData();
-        while (n--) {
-            SetRectRgn(tmp_rgn,
-                       qMax(SHRT_MIN, qt_r->x()),
-                       qMax(SHRT_MIN, qt_r->y()),
-                       qMin(SHRT_MAX, qt_r->right() + 1),
-                       qMin(SHRT_MAX, qt_r->bottom() + 1));
-            UnionRgn(rgnHandle, tmp_rgn, rgnHandle);
-            ++qt_r;
-        }
-        qt_mac_dispose_rgn(tmp_rgn);
-    }
-    return rgnHandle;
-}
-
-/*!
-    \internal
-     Create's a RegionHandle, it's the caller's responsibility to release.
-     Returns 0 if the QRegion overflows.
-*/
-RgnHandle QRegion::toQDRgnForUpdate_sys() const
-{
-    RgnHandle rgnHandle = qt_mac_get_rgn();
-    if(d->qt_rgn && d->qt_rgn->numRects) {
-        RgnHandle tmp_rgn = qt_mac_get_rgn();
-        int n = d->qt_rgn->numRects;
-        const QRect *qt_r = (n == 1) ? &d->qt_rgn->extents : d->qt_rgn->rects.constData();
-        while (n--) {
-
-            // detect overflow. Tested for use with HIViewSetNeedsDisplayInRegion
-            // in QWidgetPrivate::update_sys().
-            enum { HIViewSetNeedsDisplayInRegionOverflow = 10000 }; // empirically determined conservative value
-            if (qt_r->right() > HIViewSetNeedsDisplayInRegionOverflow || qt_r->bottom() > HIViewSetNeedsDisplayInRegionOverflow) {
-                qt_mac_dispose_rgn(tmp_rgn);
-                qt_mac_dispose_rgn(rgnHandle);
-                return 0;
-            }
-
-            SetRectRgn(tmp_rgn,
-                       qMax(SHRT_MIN, qt_r->x()),
-                       qMax(SHRT_MIN, qt_r->y()),
-                       qMin(SHRT_MAX, qt_r->right() + 1),
-                       qMin(SHRT_MAX, qt_r->bottom() + 1));
-            UnionRgn(rgnHandle, tmp_rgn, rgnHandle);
-            ++qt_r;
-        }
-        qt_mac_dispose_rgn(tmp_rgn);
-    }
-    return rgnHandle;
-}
-
-#endif
 
 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
 OSStatus QRegion::shape2QRegionHelper(int inMessage, HIShapeRef,
@@ -239,18 +93,10 @@ HIMutableShapeRef QRegion::toHIMutableShape() const
     } else
 #endif
     {
-#ifndef QT_MAC_USE_COCOA
-        QCFType<HIShapeRef> qdShape = HIShapeCreateWithQDRgn(QMacSmartQuickDrawRegion(toQDRgn()));
-        HIShapeUnion(qdShape, shape, shape);
-#endif
     }
     return shape;
 }
 
-#if !defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA)
-typedef OSStatus (*PtrHIShapeGetAsQDRgn)(HIShapeRef, RgnHandle);
-static PtrHIShapeGetAsQDRgn ptrHIShapeGetAsQDRgn = 0;
-#endif
 
 
 QRegion QRegion::fromHIShapeRef(HIShapeRef shape)
@@ -268,17 +114,6 @@ QRegion QRegion::fromHIShapeRef(HIShapeRef shape)
 # endif
 #endif
     {
-#if !defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA)
-        if (ptrHIShapeGetAsQDRgn == 0) {
-            QLibrary library(QLatin1String("/System/Library/Frameworks/Carbon.framework/Carbon"));
-            library.setLoadHints(QLibrary::ExportExternalSymbolsHint);
-                    ptrHIShapeGetAsQDRgn = reinterpret_cast<PtrHIShapeGetAsQDRgn>(library.resolve("HIShapeGetAsQDRgn"));
-        }
-        RgnHandle rgn = qt_mac_get_rgn();
-        ptrHIShapeGetAsQDRgn(shape, rgn);
-        returnRegion = QRegion::fromQDRgn(rgn);
-        qt_mac_dispose_rgn(rgn);
-#endif
     }
     return returnRegion;
 }
index d1620b1..20bb6bf 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-#ifdef QT_MAC_USE_COCOA
 // Cmd + left mousebutton should produce a right button
 //  press (mainly for mac users with one-button mice):
 static bool qt_leftButtonIsRightButton = false;
-#endif
 
 Q_GLOBAL_STATIC(QMacWindowFader, macwindowFader);
 
@@ -120,27 +118,17 @@ void QMacWindowFader::performFade()
 {
     const QWidgetList myWidgetsToFade = m_windowsToFade;
     const int widgetCount = myWidgetsToFade.count();
-#if QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     [NSAnimationContext beginGrouping];
     [[NSAnimationContext currentContext] setDuration:NSTimeInterval(m_duration)];
-#endif
 
     for (int i = 0; i < widgetCount; ++i) {
         QWidget *widget = m_windowsToFade.at(i);
         OSWindowRef window = qt_mac_window_for(widget);
-#if QT_MAC_USE_COCOA
         [[window animator] setAlphaValue:0.0];
         QTimer::singleShot(qRound(m_duration * 1000), widget, SLOT(hide()));
-#else
-        TransitionWindowOptions options = {0, m_duration, 0, 0};
-        TransitionWindowWithOptions(window, kWindowFadeTransitionEffect, kWindowHideTransitionAction,
-                                    0, 1, &options);
-#endif
     }
-#if QT_MAC_USE_COCOA
     [NSAnimationContext endGrouping];
-#endif
     m_duration = 0.250;
     m_windowsToFade.clear();
 }
@@ -154,22 +142,11 @@ extern void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse);
 
 void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
 {
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
-#endif
     OSWindowRef wnd = static_cast<OSWindowRef>(window);
     if (wnd) {
         QWidget *widget;
-#if QT_MAC_USE_COCOA
         widget = [wnd QT_MANGLE_NAMESPACE(qt_qwidget)];
-#else
-    const UInt32 kWidgetCreatorQt = kEventClassQt;
-    enum {
-        kWidgetPropertyQWidget = 'QWId' //QWidget *
-    };
-        if (GetWindowProperty(static_cast<WindowRef>(window), kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(widget), 0, &widget) != noErr)
-            widget = 0;
-#endif
         if (widget) {
             QMacWindowFader::currentFader()->setFadeDuration(durationSeconds);
             QMacWindowFader::currentFader()->registerWindowToFade(widget);
@@ -184,7 +161,7 @@ struct dndenum_mapper
     bool Qt2Mac;
 };
 
-#if defined(QT_MAC_USE_COCOA) && defined(__OBJC__)
+#ifdef __OBJC__
 
 static dndenum_mapper dnd_enums[] = {
     { NSDragOperationLink,  Qt::LinkAction, true },
@@ -245,19 +222,12 @@ DnDParams *macCurrentDnDParameters()
 bool macWindowIsTextured( void * /*OSWindowRef*/ window )
 {
     OSWindowRef wnd = static_cast<OSWindowRef>(window);
-#if QT_MAC_USE_COCOA
        return ( [wnd styleMask] & NSTexturedBackgroundWindowMask ) ? true : false;
-#else
-       WindowAttributes currentAttributes;
-       GetWindowAttributes(wnd, &currentAttributes);
-       return (currentAttributes & kWindowMetalAttribute) ? true : false;
-#endif
 }
 
 void macWindowToolbarShow(const QWidget *widget, bool show )
 {
     OSWindowRef wnd = qt_mac_window_for(widget);
-#if QT_MAC_USE_COCOA
     if (NSToolbar *toolbar = [wnd toolbar]) {
         QMacCocoaAutoReleasePool pool;
         if (show != [toolbar isVisible]) {
@@ -267,65 +237,38 @@ void macWindowToolbarShow(const QWidget *widget, bool show )
             qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
         }
     }
-#else
-    qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
-    ShowHideWindowToolbar(wnd, show, false);
-#endif
 }
 
 
 void macWindowToolbarSet( void * /*OSWindowRef*/ window, void *toolbarRef  )
 {
     OSWindowRef wnd = static_cast<OSWindowRef>(window);
-#if QT_MAC_USE_COCOA
     [wnd setToolbar:static_cast<NSToolbar *>(toolbarRef)];
-#else
-    SetWindowToolbar(wnd, static_cast<HIToolbarRef>(toolbarRef));
-#endif
 }
 
 bool macWindowToolbarIsVisible( void * /*OSWindowRef*/ window )
 {
     OSWindowRef wnd = static_cast<OSWindowRef>(window);
-#if QT_MAC_USE_COCOA
     if (NSToolbar *toolbar = [wnd toolbar])
         return [toolbar isVisible];
     return false;
-#else
-    return IsWindowToolbarVisible(wnd);
-#endif
 }
 
 void macWindowSetHasShadow( void * /*OSWindowRef*/ window, bool hasShadow  )
 {
     OSWindowRef wnd = static_cast<OSWindowRef>(window);
-#if QT_MAC_USE_COCOA
     [wnd setHasShadow:BOOL(hasShadow)];
-#else
-    if (hasShadow)
-        ChangeWindowAttributes(wnd, 0, kWindowNoShadowAttribute);
-    else
-        ChangeWindowAttributes(wnd, kWindowNoShadowAttribute, 0);
-#endif
 }
 
 void macWindowFlush(void * /*OSWindowRef*/ window)
 {
     OSWindowRef wnd = static_cast<OSWindowRef>(window);
-#if QT_MAC_USE_COCOA
     [wnd flushWindowIfNeeded];
-#else
-    HIWindowFlush(wnd);
-#endif
 }
 
 void qt_mac_update_mouseTracking(QWidget *widget)
 {
-#ifdef QT_MAC_USE_COCOA
     [qt_mac_nativeview_for(widget) updateTrackingAreas];
-#else
-    Q_UNUSED(widget);
-#endif
 }
 
 OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
@@ -352,13 +295,7 @@ InvalidContext:
 
 bool qt_mac_checkForNativeSizeGrip(const QWidget *widget)
 {
-#ifndef QT_MAC_USE_COCOA
-    OSViewRef nativeSizeGrip = 0;
-    HIViewFindByID(HIViewGetRoot(HIViewGetWindow(HIViewRef(widget->winId()))), kHIViewWindowGrowBoxID, &nativeSizeGrip);
-    return (nativeSizeGrip != 0);
-#else
     return [[reinterpret_cast<NSView *>(widget->effectiveWinId()) window] showsResizeIndicator];
-#endif
 }
 struct qt_mac_enum_mapper
 {
@@ -426,7 +363,6 @@ QMacTabletHash *qt_mac_tablet_hash()
     return tablet_hash();
 }
 
-#ifdef QT_MAC_USE_COCOA
 
 // Clears the QWidget pointer that each QCocoaView holds.
 void qt_mac_clearCocoaViewQWidgetPointers(QWidget *widget)
@@ -454,7 +390,6 @@ void qt_dispatchTabletProximityEvent(void * /*NSEvent * */ tabletEvent)
                                               [proximityEvent isEnteringProximity] };
     qt_dispatchTabletProximityEvent(carbonProximityRec);
 }
-#endif // QT_MAC_USE_COCOA
 
 void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec)
 {
@@ -527,7 +462,6 @@ void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec)
     qt_sendSpontaneousEvent(qApp, &qtabletProximity);
 }
 
-#ifdef QT_MAC_USE_COCOA
 
 Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags)
 {
@@ -621,7 +555,6 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
                    macScanCode, [event keyCode], [event modifierFlags]);
     return qt_sendSpontaneousEvent(widgetToGetEvent, &ke) && ke.isAccepted();
 }
-#endif
 
 Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
 {
@@ -640,11 +573,6 @@ Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
 
 bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent)
 {
-#ifndef QT_MAC_USE_COCOA
-    Q_UNUSED(keyEvent);
-    Q_UNUSED(widgetToGetEvent);
-    return false;
-#else
     NSEvent *event = static_cast<NSEvent *>(keyEvent);
     EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef]));
     Q_ASSERT(key_event);
@@ -667,15 +595,10 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve
 
     bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true);
     return consumed && (info != 0);
-#endif
 }
 
 void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget *widgetToGetEvent)
 {
-#ifndef QT_MAC_USE_COCOA
-    Q_UNUSED(flagsChangedEvent);
-    Q_UNUSED(widgetToGetEvent);
-#else
     UInt32 modifiers = 0;
     // Sync modifiers with Qt
     NSEvent *event = static_cast<NSEvent *>(flagsChangedEvent);
@@ -685,7 +608,6 @@ void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget
                       sizeof(modifiers), 0, &modifiers);
     extern void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object);
     qt_mac_send_modifiers_changed(modifiers, widgetToGetEvent);
-#endif
 }
 
 QPointF flipPoint(const NSPoint &p)
@@ -703,7 +625,7 @@ NSPoint flipPoint(const QPointF &p)
     return NSMakePoint(p.x(), flipYCoordinate(p.y()));
 }
 
-#if QT_MAC_USE_COCOA && __OBJC__
+#ifdef __OBJC__
 
 void qt_mac_handleNonClientAreaMouseEvent(NSWindow *window, NSEvent *event)
 {
@@ -1116,11 +1038,6 @@ bool qt_mac_handleMouseEvent(NSEvent *event, QEvent::Type eventType, Qt::MouseBu
 
 bool qt_mac_handleTabletEvent(void * /*QCocoaView * */view, void * /*NSEvent * */tabletEvent)
 {
-#ifndef QT_MAC_USE_COCOA
-    Q_UNUSED(view);
-    Q_UNUSED(tabletEvent);
-    return false;
-#else
     QT_MANGLE_NAMESPACE(QCocoaView) *theView = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view);
     NSView *theNSView = static_cast<NSView *>(view);
     NSEvent *theTabletEvent = static_cast<NSEvent *>(tabletEvent);
@@ -1209,29 +1126,16 @@ bool qt_mac_handleTabletEvent(void * /*QCocoaView * */view, void * /*NSEvent * *
 
     qt_sendSpontaneousEvent(widgetToGetMouse, &qtabletEvent);
     return qtabletEvent.isAccepted();
-#endif
 }
 
 void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::HIContentBorderMetrics &metrics)
 {
     OSWindowRef theWindow = static_cast<OSWindowRef>(window);
-#if !defined(QT_MAC_USE_COCOA)
-#  if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
-        ::HIWindowSetContentBorderThickness(theWindow, &metrics);
-    }
-#  else
-    Q_UNUSED(window);
-    Q_UNUSED(metrics);
-#  endif
-#else
     if ([theWindow styleMask] & NSTexturedBackgroundWindowMask)
         [theWindow setContentBorderThickness:metrics.top forEdge:NSMaxYEdge];
     [theWindow setContentBorderThickness:metrics.bottom forEdge:NSMinYEdge];
-#endif
 }
 
-#if QT_MAC_USE_COCOA
 void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widget)
 {
     QMacCocoaAutoReleasePool pool;
@@ -1294,9 +1198,7 @@ void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivat
     widget->originalDrawMethod = true;
     [theWindow display];
 }
-#endif // QT_MAC_USE_COCOA
 
-#if QT_MAC_USE_COCOA
 void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show)
 {
     if(!window)
@@ -1306,7 +1208,6 @@ void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show)
     NSToolbar *macToolbar = [theWindow toolbar];
     [macToolbar setShowsBaselineSeparator:show];
 }
-#endif // QT_MAC_USE_COCOA
 
 QStringList qt_mac_NSArrayToQStringList(void *nsarray)
 {
@@ -1326,7 +1227,6 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
     return result;
 }
 
-#if QT_MAC_USE_COCOA
 void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow)
 {
     if (!widgetForWindow)
@@ -1351,7 +1251,6 @@ void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow)
 
     [window setShowsToolbarButton:uint(flags & Qt::MacWindowToolBarButtonHint) != 0];
 }
-#endif // QT_MAC_USE_COCOA
 
 // Carbon: Make sure you call QDEndContext on the context when done with it.
 CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
@@ -1359,13 +1258,7 @@ CGContextRef qt_mac_graphicsContextFor(QWidget *widget)
     if (!widget)
         return 0;
 
-#ifndef QT_MAC_USE_COCOA
-    CGContextRef context;
-    CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
-    QDBeginCGContext(port, &context);
-#else
     CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithWindow:qt_mac_window_for(widget)] graphicsPort];
-#endif
     return context;
 }
 
@@ -1373,20 +1266,12 @@ void qt_mac_dispatchPendingUpdateRequests(QWidget *widget)
 {
     if (!widget)
         return;
-#ifndef QT_MAC_USE_COCOA
-    HIViewRender(qt_mac_nativeview_for(widget));
-#else
     [qt_mac_nativeview_for(widget) displayIfNeeded];
-#endif
 }
 
 CGFloat qt_mac_get_scalefactor()
 {
-#ifndef QT_MAC_USE_COCOA
-    return HIGetScaleFactor();
-#else
     return [[NSScreen mainScreen] userSpaceScaleFactor];
-#endif
 }
 
 QString qt_mac_get_pasteboardString(OSPasteboardRef paste)
@@ -1455,10 +1340,8 @@ void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayI
 
 void qt_mac_post_retranslateAppMenu()
 {
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu));
-#endif
 }
 
 QWidgetPrivate *QMacScrollOptimization::_target = 0;
@@ -1467,7 +1350,6 @@ int QMacScrollOptimization::_dx = 0;
 int QMacScrollOptimization::_dy = 0;
 QRect QMacScrollOptimization::_scrollRect = QRect(0, 0, -1, -1);
 
-#ifdef QT_MAC_USE_COCOA
 // This method implements the magic for the drawRectSpecial method.
 // We draw a line at the upper edge of the content view in order to
 // override the title baseline.
@@ -1558,6 +1440,5 @@ void qt_mac_setNeedsDisplayInRect(QWidget *widget, QRegion region)
 
 }
 
-#endif // QT_MAC_USE_COCOA
 
 QT_END_NAMESPACE
index 339bc82..b3c9371 100644 (file)
 #include <qdebug.h>
 
 QT_BEGIN_NAMESPACE
-#ifdef QT_MAC_USE_COCOA
 static CTFontRef CopyCTThemeFont(ThemeFontID themeID)
 {
     CTFontUIFontType ctID = HIThemeGetUIFontType(themeID);
     return CTFontCreateUIFontForLanguage(ctID, 0, 0);
 }
-#endif
 
 QFont qfontForThemeFont(ThemeFontID themeID)
 {
-#ifndef QT_MAC_USE_COCOA
-    static const ScriptCode Script = smRoman;
-    Str255 f_name;
-    SInt16 f_size;
-    Style f_style;
-    GetThemeFont(themeID, Script, f_name, &f_size, &f_style);
-    extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp
-    return QFont(qt_mac_from_pascal_string(f_name), f_size,
-                 (f_style & ::bold) ? QFont::Bold : QFont::Normal,
-                 (bool)(f_style & ::italic));
-#else
     QCFType<CTFontRef> ctfont = CopyCTThemeFont(themeID);
     QString familyName = QCFString(CTFontCopyFamilyName(ctfont));
     QCFType<CFDictionaryRef> dict = CTFontCopyTraits(ctfont);
@@ -77,7 +64,6 @@ QFont qfontForThemeFont(ThemeFontID themeID)
     CFNumberGetValue(num, kCFNumberFloatType, &fW);
     bool italic = (fW != 0.0);
     return QFont(familyName, CTFontGetSize(ctfont), wght, italic);
-#endif
 }
 
 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
@@ -110,20 +96,7 @@ static inline QColor leopardBrush(ThemeBrush brush)
 
 QColor qcolorForTheme(ThemeBrush brush)
 {
-#ifndef QT_MAC_USE_COCOA
-#  if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
-    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
-        return leopardBrush(brush);
-    } else
-#  endif
-    {
-        RGBColor rgbcolor;
-        GetThemeBrushAsColor(brush, 32, true, &rgbcolor);
-        return QColor(rgbcolor.red / 256, rgbcolor.green / 256, rgbcolor.blue / 256);
-    }
-#else
     return leopardBrush(brush);
-#endif
 }
 
 QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
index 80328c3..5a1d4ee 100644 (file)
@@ -57,9 +57,7 @@
 
 #ifdef __OBJC__
 #include <Cocoa/Cocoa.h>
-#ifdef QT_MAC_USE_COCOA
 #include <objc/runtime.h>
-#endif // QT_MAC_USE_COCOA
 #endif
 
 #include <CoreServices/CoreServices.h>
index 251d9b5..8ac58bb 100644 (file)
@@ -566,11 +566,7 @@ void QTextEngine::shapeTextMac(int item) const
         return;
     }
     
-#ifndef QT_MAC_USE_COCOA
-    QFontEngineMacMulti *fe = static_cast<QFontEngineMacMulti *>(font);
-#else
     QCoreTextFontEngineMulti *fe = static_cast<QCoreTextFontEngineMulti *>(font);
-#endif
     QTextEngine::ShaperFlags flags;
     if (si.analysis.bidiLevel % 2)
         flags |= RightToLeft;
index 39a4895..dd95876 100644 (file)
@@ -120,15 +120,6 @@ extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
 #define XCOORD_MAX 16383
 #define WRECT_MAX 8191
 
-#ifndef QT_MAC_USE_COCOA
-
-extern "C" {
-    extern OSStatus _HIViewScrollRectWithOptions(HIViewRef, const HIRect *, CGFloat, CGFloat,
-                                                 OptionBits) __attribute__ ((weak));
-}
-#define kHIViewScrollRectAdjustInvalid 1
-#define kHIViewScrollRectDontInvalidateRevealedArea 2
-#endif
 
 
 /*****************************************************************************
@@ -142,38 +133,12 @@ extern "C" {
 /*****************************************************************************
   QWidget globals
  *****************************************************************************/
-#ifndef QT_MAC_USE_COCOA
-typedef QHash<Qt::WindowFlags, WindowGroupRef> WindowGroupHash;
-Q_GLOBAL_STATIC(WindowGroupHash, qt_mac_window_groups)
-const UInt32 kWidgetCreatorQt = kEventClassQt;
-enum {
-    kWidgetPropertyQWidget = 'QWId' //QWidget *
-};
-#endif
 
 static bool qt_mac_raise_process = true;
 static OSWindowRef qt_root_win = 0;
 QWidget *mac_mouse_grabber = 0;
 QWidget *mac_keyboard_grabber = 0;
 
-#ifndef QT_MAC_USE_COCOA
-#ifdef QT_NAMESPACE
-
-// produce the string "com.trolltech.qt-namespace.widget", where "namespace" is the contents of QT_NAMESPACE.
-#define SS(x) #x
-#define S0(x) SS(x)
-#define S "com.trolltech.qt-" S0(QT_NAMESPACE) ".widget"
-
-static CFStringRef kObjectQWidget = CFSTR(S);
-
-#undef SS
-#undef S0
-#undef S
-
-#else
-static CFStringRef kObjectQWidget = CFSTR("com.trolltech.qt.widget");
-#endif // QT_NAMESPACE
-#endif // QT_MAC_USE_COCOA
 
 /*****************************************************************************
   Externals
@@ -216,7 +181,6 @@ static QSize qt_mac_desktopSize()
     return QSize(w, h);
 }
 
-#ifdef QT_MAC_USE_COCOA
 static NSDrawer *qt_mac_drawer_for(const QWidget *widget)
 {
     NSView *widgetView = reinterpret_cast<NSView *>(widget->window()->effectiveWinId());
@@ -230,25 +194,18 @@ static NSDrawer *qt_mac_drawer_for(const QWidget *widget)
     }
     return 0;
 }
-#endif
 
 static void qt_mac_destructView(OSViewRef view)
 {
-#ifdef QT_MAC_USE_COCOA
     NSWindow *window = [view window];
     if ([window contentView] == view)
         [window setContentView:[[NSView alloc] initWithFrame:[view bounds]]];
     [view removeFromSuperview];
     [view release];
-#else
-    HIViewRemoveFromSuperview(view);
-    CFRelease(view);
-#endif
 }
 
 static void qt_mac_destructWindow(OSWindowRef window)
 {
-#ifdef QT_MAC_USE_COCOA
     if ([window isVisible] && [window isSheet]){
         [NSApp endSheet:window];
         [window orderOut:window];
@@ -256,21 +213,12 @@ static void qt_mac_destructWindow(OSWindowRef window)
 
     [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] resignDelegateForWindow:window];
     [window release];
-#else
-    // Remove property to clean up memory:
-    RemoveWindowProperty(window, kWidgetCreatorQt, kWidgetPropertyQWidget);
-    CFRelease(window);
-#endif
 }
 
 static void qt_mac_destructDrawer(NSDrawer *drawer)
 {
-#ifdef QT_MAC_USE_COCOA
     [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] resignDelegateForDrawer:drawer];
     [drawer release];
-#else
-    Q_UNUSED(drawer);
-#endif
 }
 
 bool qt_mac_can_clickThrough(const QWidget *w)
@@ -306,11 +254,7 @@ bool qt_mac_is_macdrawer(const QWidget *w)
 
 bool qt_mac_insideKeyWindow(const QWidget *w)
 {
-#ifdef QT_MAC_USE_COCOA
     return [[reinterpret_cast<NSView *>(w->effectiveWinId()) window] isKeyWindow];
-#else
-    Q_UNUSED(w);
-#endif
     return false;
 }
 
@@ -319,7 +263,6 @@ bool qt_mac_set_drawer_preferred_edge(QWidget *w, Qt::DockWidgetArea where) //us
     if(!qt_mac_is_macdrawer(w))
         return false;
 
-#if QT_MAC_USE_COCOA
     NSDrawer *drawer = qt_mac_drawer_for(w);
     if (!drawer)
         return false;
@@ -343,36 +286,9 @@ bool qt_mac_set_drawer_preferred_edge(QWidget *w, Qt::DockWidgetArea where) //us
            [drawer openOnEdge:edge];
        }
        [drawer setPreferredEdge:edge];
-#else
-    OSWindowRef window = qt_mac_window_for(w);
-    OptionBits edge;
-    if(where & Qt::LeftDockWidgetArea)
-        edge = kWindowEdgeLeft;
-    else if(where & Qt::RightDockWidgetArea)
-        edge = kWindowEdgeRight;
-    else if(where & Qt::TopDockWidgetArea)
-        edge = kWindowEdgeTop;
-    else if(where & Qt::BottomDockWidgetArea)
-        edge = kWindowEdgeBottom;
-    else
-        return false;
-
-    if(edge == GetDrawerPreferredEdge(window)) //no-op
-        return false;
-
-    //do it
-    SetDrawerPreferredEdge(window, edge);
-    if(w->isVisible()) {
-        CloseDrawer(window, false);
-        OpenDrawer(window, edge, true);
-    }
-#endif
     return true;
 }
 
-#ifndef QT_MAC_USE_COCOA
-Q_GUI_EXPORT
-#endif
 QPoint qt_mac_posInWindow(const QWidget *w)
 {
     QPoint ret = w->data->wrect.topLeft();
@@ -386,17 +302,7 @@ QPoint qt_mac_posInWindow(const QWidget *w)
 //find a QWidget from a OSWindowRef
 QWidget *qt_mac_find_window(OSWindowRef window)
 {
-#ifdef QT_MAC_USE_COCOA
     return [window QT_MANGLE_NAMESPACE(qt_qwidget)];
-#else
-    if(!window)
-        return 0;
-
-    QWidget *ret;
-    if(GetWindowProperty(window, kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(ret), 0, &ret) == noErr)
-        return ret;
-    return 0;
-#endif
 }
 
 inline static void qt_mac_set_fullscreen_mode(bool b)
@@ -426,19 +332,7 @@ Q_GUI_EXPORT OSViewRef qt_mac_effectiveview_for(const QWidget *w)
 
 Q_GUI_EXPORT OSViewRef qt_mac_get_contentview_for(OSWindowRef w)
 {
-#ifdef QT_MAC_USE_COCOA
     return [w contentView];
-#else
-    HIViewRef contentView = 0;
-    OSStatus err = GetRootControl(w, &contentView);  // Returns the window's content view (Apple QA1214)
-    if (err == errUnknownControl) {
-        contentView = HIViewGetRoot(w);
-    } else if (err != noErr) {
-        qWarning("Qt:Could not get content or root view of window! %s:%d [%ld]",
-                 __FILE__, __LINE__, err);
-    }
-    return contentView;
-#endif
 }
 
 bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref)
@@ -448,22 +342,14 @@ bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref)
 
 Q_GUI_EXPORT OSWindowRef qt_mac_window_for(OSViewRef view)
 {
-#ifdef QT_MAC_USE_COCOA
     if (view)
         return [view window];
     return 0;
-#else
-    return HIViewGetWindow(view);
-#endif
 }
 
 static bool qt_isGenuineQWidget(OSViewRef ref)
 {
-#ifdef QT_MAC_USE_COCOA
     return [ref isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]];
-#else
-    return HIObjectIsOfClass(HIObjectRef(ref), kObjectQWidget);
-#endif
 }
 
 bool qt_isGenuineQWidget(const QWidget *window)
@@ -508,82 +394,7 @@ Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w)
     return 0;
 }
 
-#ifndef QT_MAC_USE_COCOA
-/*  Checks if the current group is a 'stay on top' group. If so, the
-    group gets removed from the hash table */
-static void qt_mac_release_stays_on_top_group(WindowGroupRef group)
-{
-    for (WindowGroupHash::iterator it = qt_mac_window_groups()->begin(); it != qt_mac_window_groups()->end(); ++it) {
-        if (it.value() == group) {
-            qt_mac_window_groups()->remove(it.key());
-            return;
-        }
-    }
-}
 
-/* Use this function instead of ReleaseWindowGroup, this will be sure to release the
-   stays on top window group (created with qt_mac_get_stays_on_top_group below) */
-static void qt_mac_release_window_group(WindowGroupRef group)
-{
-    ReleaseWindowGroup(group);
-    if (GetWindowGroupRetainCount(group) == 0)
-        qt_mac_release_stays_on_top_group(group);
-}
-#define ReleaseWindowGroup(x) Are you sure you wanted to do that? (you wanted qt_mac_release_window_group)
-
-SInt32 qt_mac_get_group_level(WindowClass wclass)
-{
-    SInt32 group_level;
-    CGWindowLevel tmpLevel;
-    GetWindowGroupLevelOfType(GetWindowGroupOfClass(wclass), kWindowGroupLevelActive, &tmpLevel);
-    group_level = tmpLevel;
-    return group_level;
-}
-#endif
-
-#ifndef QT_MAC_USE_COCOA
-static void qt_mac_set_window_group(OSWindowRef window, Qt::WindowFlags flags, int level)
-{
-    WindowGroupRef group = 0;
-    if (qt_mac_window_groups()->contains(flags)) {
-        group = qt_mac_window_groups()->value(flags);
-        RetainWindowGroup(group);
-    } else {
-        CreateWindowGroup(kWindowActivationScopeNone, &group);
-        SetWindowGroupLevel(group, level);
-        SetWindowGroupParent(group, GetWindowGroupOfClass(kAllWindowClasses));
-        qt_mac_window_groups()->insert(flags, group);
-    }
-    SetWindowGroup(window, group);
-}
-
-inline static void qt_mac_set_window_group_to_stays_on_top(OSWindowRef window, Qt::WindowType type)
-{
-    // We create one static stays on top window group so that
-    // all stays on top (aka popups) will fall into the same
-    // group and be able to be raise()'d with releation to one another (from
-    // within the same window group).
-    qt_mac_set_window_group(window, type|Qt::WindowStaysOnTopHint, qt_mac_get_group_level(kOverlayWindowClass));
-}
-
-inline static void qt_mac_set_window_group_to_tooltip(OSWindowRef window)
-{
-    // Since new groups are created for 'stays on top' windows, the
-    // same must be done for tooltips. Otherwise, tooltips would be drawn
-    // below 'stays on top' widgets even tough they are on the same level.
-    // Also, add 'two' to the group level to make sure they also get on top of popups.
-    qt_mac_set_window_group(window, Qt::ToolTip, qt_mac_get_group_level(kHelpWindowClass)+2);
-}
-
-inline static void qt_mac_set_window_group_to_popup(OSWindowRef window)
-{
-    // In Qt, a popup is seen as a 'stay on top' window.
-    // Since new groups are created for 'stays on top' windows, the
-    // same must be done for popups. Otherwise, popups would be drawn
-    // below 'stays on top' windows. Add 1 to get above pure stay-on-top windows.
-    qt_mac_set_window_group(window, Qt::Popup, qt_mac_get_group_level(kOverlayWindowClass)+1);
-}
-#endif
 
 inline static bool updateRedirectedToGraphicsProxyWidget(QWidget *widget, const QRect &rect)
 {
@@ -625,14 +436,6 @@ inline static bool updateRedirectedToGraphicsProxyWidget(QWidget *widget, const
 void QWidgetPrivate::macSetNeedsDisplay(QRegion region)
 {
     Q_Q(QWidget);
-#ifndef QT_MAC_USE_COCOA
-    if (region.isEmpty())
-        HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true);
-    else if (RgnHandle rgnHandle = region.toQDRgnForUpdate_sys())
-        HIViewSetNeedsDisplayInRegion(qt_mac_nativeview_for(q), QMacSmartQuickDrawRegion(rgnHandle), true);
-    else
-        HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow.
-#else
     if (NSView *nativeView = qt_mac_nativeview_for(q)) {
         // INVARIANT: q is _not_ alien. So we can optimize a little:
         if (region.isEmpty()) {
@@ -664,7 +467,6 @@ void QWidgetPrivate::macSetNeedsDisplay(QRegion region)
             }
         }
     }
-#endif
 }
 
 void QWidgetPrivate::macUpdateIsOpaque()
@@ -672,29 +474,13 @@ void QWidgetPrivate::macUpdateIsOpaque()
     Q_Q(QWidget);
     if (!q->testAttribute(Qt::WA_WState_Created))
         return;
-#ifndef QT_MAC_USE_COCOA
-    HIViewFeatures bits;
-    HIViewRef hiview = qt_mac_nativeview_for(q);
-    HIViewGetFeatures(hiview, &bits);
-    if ((bits & kHIViewIsOpaque) == isOpaque)
-        return;
-    if (isOpaque) {
-        HIViewChangeFeatures(hiview, kHIViewIsOpaque, 0);
-    } else {
-        HIViewChangeFeatures(hiview, 0, kHIViewIsOpaque);
-    }
-    if (q->isVisible())
-        HIViewReshapeStructure(qt_mac_nativeview_for(q));
-#else
     if (isRealWindow() && !q->testAttribute(Qt::WA_MacBrushedMetal)) {
         bool opaque = isOpaque;
         if (extra && extra->imageMask)
             opaque = false; // we are never opaque when we have a mask.
         [qt_mac_window_for(q) setOpaque:opaque];
     }
-#endif
 }
-#ifdef QT_MAC_USE_COCOA
 static OSWindowRef qt_mac_create_window(QWidget *widget, WindowClass wclass,
                                         NSUInteger wattr, const QRect &crect)
 {
@@ -770,831 +556,9 @@ static OSWindowRef qt_mac_create_window(QWidget *widget, WindowClass wclass,
     qt_syncCocoaTitleBarButtons(window, widget);
     return window;
 }
-#else
-static OSWindowRef qt_mac_create_window(QWidget *, WindowClass wclass, WindowAttributes wattr,
-                                        const QRect &crect)
-{
-    OSWindowRef window;
-    Rect geo;
-    SetRect(&geo, crect.left(), crect.top(), crect.right() + 1, crect.bottom() + 1);
-    OSStatus err;
-    if(geo.right <= geo.left)          geo.right = geo.left + 1;
-    if(geo.bottom <= geo.top)          geo.bottom = geo.top + 1;
-    Rect null_rect;
-       SetRect(&null_rect, 0, 0, 1, 1);
-    err = CreateNewWindow(wclass, wattr, &null_rect, &window);
-    if(err == noErr) {
-        err = SetWindowBounds(window, kWindowContentRgn, &geo);
-        if(err != noErr)
-            qWarning("QWidget: Internal error (%s:%d)", __FILE__, __LINE__);
-    }
-    return window;
-}
-
-#ifndef QT_NO_GESTURES
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
-/* We build the release package against the 10.4 SDK.
-   So, to enable gestures for applications running on
-   10.6+, we define the missing constants here: */
-enum {
-    kEventClassGesture              = 'gest',
-    kEventGestureStarted            = 1,
-    kEventGestureEnded              = 2,
-    kEventGestureMagnify            = 4,
-    kEventGestureSwipe              = 5,
-    kEventGestureRotate             = 6,
-    kEventParamRotationAmount       = 'rota',
-    kEventParamSwipeDirection       = 'swip',
-    kEventParamMagnificationAmount  = 'magn'
-};
-#endif
-#endif // QT_NO_GESTURES
-
-// window events
-static EventTypeSpec window_events[] = {
-    { kEventClassWindow, kEventWindowClose },
-    { kEventClassWindow, kEventWindowExpanded },
-    { kEventClassWindow, kEventWindowHidden },
-    { kEventClassWindow, kEventWindowZoom },
-    { kEventClassWindow, kEventWindowZoomed },
-    { kEventClassWindow, kEventWindowCollapsed },
-    { kEventClassWindow, kEventWindowToolbarSwitchMode },
-    { kEventClassWindow, kEventWindowProxyBeginDrag },
-    { kEventClassWindow, kEventWindowProxyEndDrag },
-    { kEventClassWindow, kEventWindowResizeCompleted },
-    { kEventClassWindow, kEventWindowBoundsChanging },
-    { kEventClassWindow, kEventWindowGetRegion },
-    { kEventClassWindow, kEventWindowGetClickModality },
-    { kEventClassWindow, kEventWindowTransitionCompleted },
-    { kEventClassGesture, kEventGestureStarted },
-    { kEventClassGesture, kEventGestureEnded },
-    { kEventClassGesture, kEventGestureMagnify },
-    { kEventClassGesture, kEventGestureSwipe },
-    { kEventClassGesture, kEventGestureRotate },
-    { kEventClassMouse, kEventMouseDown }
-};
-static EventHandlerUPP mac_win_eventUPP = 0;
-static void cleanup_win_eventUPP()
-{
-    DisposeEventHandlerUPP(mac_win_eventUPP);
-    mac_win_eventUPP = 0;
-}
-static const EventHandlerUPP make_win_eventUPP()
-{
-    if(mac_win_eventUPP)
-        return mac_win_eventUPP;
-    qAddPostRoutine(cleanup_win_eventUPP);
-    return mac_win_eventUPP = NewEventHandlerUPP(QWidgetPrivate::qt_window_event);
-}
-OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event, void *)
-{
-    QScopedLoopLevelCounter loopLevelCounter(qApp->d_func()->threadData);
-    bool handled_event = true;
-    UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
-    switch(eclass) {
-    case kEventClassWindow: {
-        WindowRef wid = 0;
-        GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 0,
-                          sizeof(WindowRef), 0, &wid);
-        QWidget *widget = qt_mac_find_window(wid);
-        if(!widget) {
-            handled_event = false;
-        } else if(ekind == kEventWindowGetClickModality) {
-            // Carbon will send us kEventWindowGetClickModality before every
-            // mouse press / release event. By returning 'true', we tell Carbon
-            // that we would like the event target to receive the mouse event even
-            // if the target is modally shaddowed. In Qt, this makes sense when we
-            // e.g. have a popup showing, as the popup will grab the event
-            // and perhaps use it to close itself.
-            // By also setting the current modal window back into the event, we
-            // help Carbon determining which window is supposed to be raised.
-            handled_event = qApp->activePopupWidget() ? true : false;
-        } else if(ekind == kEventWindowClose) {
-            widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
-            QMenuBar::macUpdateMenuBar();
-        } else if (ekind == kEventWindowTransitionCompleted) {
-            WindowTransitionAction transitionAction;
-            GetEventParameter(event, kEventParamWindowTransitionAction, typeWindowTransitionAction,
-                              0, sizeof(transitionAction), 0, &transitionAction);
-            if (transitionAction == kWindowHideTransitionAction)
-                widget->hide();
-        } else if(ekind == kEventWindowExpanded) {
-            Qt::WindowStates currState = Qt::WindowStates(widget->data->window_state);
-            Qt::WindowStates newState = currState;
-            if (currState & Qt::WindowMinimized)
-                newState &= ~Qt::WindowMinimized;
-            if (!(currState & Qt::WindowActive))
-                newState |= Qt::WindowActive;
-            if (newState != currState) {
-                // newState will differ from currState if the window
-                // was expanded after clicking on the jewels (as opposed
-                // to calling QWidget::setWindowState)
-                widget->data->window_state = newState;
-                QWindowStateChangeEvent e(currState);
-                QApplication::sendSpontaneousEvent(widget, &e);
-            }
-
-            QShowEvent qse;
-            QApplication::sendSpontaneousEvent(widget, &qse);
-        } else if(ekind == kEventWindowZoom) {
-            widget->d_func()->topData()->normalGeometry = widget->geometry();
-            handled_event = false;
-        } else if(ekind == kEventWindowZoomed) {
-            WindowPartCode windowPart;
-            GetEventParameter(event, kEventParamWindowPartCode,
-                              typeWindowPartCode, 0, sizeof(windowPart), 0, &windowPart);
-            if(windowPart == inZoomIn && widget->isMaximized()) {
-
-                widget->data->window_state = widget->data->window_state & ~Qt::WindowMaximized;
-                QWindowStateChangeEvent e(Qt::WindowStates(widget->data->window_state | Qt::WindowMaximized));
-                QApplication::sendSpontaneousEvent(widget, &e);
-            } else if(windowPart == inZoomOut && !widget->isMaximized()) {
-                widget->data->window_state = widget->data->window_state | Qt::WindowMaximized;
-                QWindowStateChangeEvent e(Qt::WindowStates(widget->data->window_state
-                                                           & ~Qt::WindowMaximized));
-                QApplication::sendSpontaneousEvent(widget, &e);
-            }
-            qt_button_down = 0;
-        } else if(ekind == kEventWindowCollapsed) {
-            if (!widget->isMinimized()) {
-                widget->data->window_state = widget->data->window_state | Qt::WindowMinimized;
-                QWindowStateChangeEvent e(Qt::WindowStates(widget->data->window_state & ~Qt::WindowMinimized));
-                QApplication::sendSpontaneousEvent(widget, &e);
-            }
-
-            // Deactivate this window:
-            if (widget->isActiveWindow() && !(widget->windowType() == Qt::Popup)) {
-                QWidget *w = 0;
-                if (widget->parentWidget())
-                    w = widget->parentWidget()->window();
-                if (!w || (!w->isVisible() && !w->isMinimized())) {
-                    for (WindowPtr wp = GetFrontWindowOfClass(kDocumentWindowClass, true);
-                        wp; wp = GetNextWindowOfClass(wp, kDocumentWindowClass, true)) {
-                        if ((w = qt_mac_find_window(wp)))
-                            break;
-                    }
-                }
-                if(!(w && w->isVisible() && !w->isMinimized()))
-                    qApp->setActiveWindow(0);
-            }
-
-            //we send a hide to be like X11/Windows
-            QEvent e(QEvent::Hide);
-            QApplication::sendSpontaneousEvent(widget, &e);
-            qt_button_down = 0;
-        } else if(ekind == kEventWindowToolbarSwitchMode) {
-            macSendToolbarChangeEvent(widget);
-            HIToolbarRef toolbar;
-            if (GetWindowToolbar(wid, &toolbar) == noErr) {
-                if (toolbar) {
-                    // Let HIToolbar do its thang, but things like the OpenGL context
-                    // needs to know about it.
-                    CallNextEventHandler(er, event);
-                    qt_event_request_window_change(widget);
-                    widget->data->fstrut_dirty = true;
-                }
-            }
-        } else if(ekind == kEventWindowGetRegion) {
-            WindowRef window;
-            GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 0,
-                              sizeof(window), 0, &window);
-            WindowRegionCode wcode;
-            GetEventParameter(event, kEventParamWindowRegionCode, typeWindowRegionCode, 0,
-                              sizeof(wcode), 0, &wcode);
-            if (wcode != kWindowOpaqueRgn){
-                // If the region is kWindowOpaqueRgn, don't call next
-                // event handler cause this will make the shadow of
-                // masked windows become offset. Unfortunately, we're not sure why.
-                CallNextEventHandler(er, event);
-            }
-                       RgnHandle rgn;
-            GetEventParameter(event, kEventParamRgnHandle, typeQDRgnHandle, 0,
-                              sizeof(rgn), 0, &rgn);
-
-            if(QWidgetPrivate::qt_widget_rgn(qt_mac_find_window(window), wcode, rgn, false))
-                SetEventParameter(event, kEventParamRgnHandle, typeQDRgnHandle, sizeof(rgn), &rgn);
-        } else if(ekind == kEventWindowProxyBeginDrag) {
-            QIconDragEvent e;
-            QApplication::sendSpontaneousEvent(widget, &e);
-        } else if(ekind == kEventWindowResizeCompleted) {
-            // Create a mouse up event, since such an event is not send by carbon to the
-            // application event handler (while a mouse down <b>is</b> on kEventWindowResizeStarted)
-            EventRef mouseUpEvent;
-            CreateEvent(0, kEventClassMouse, kEventMouseUp, 0, kEventAttributeUserEvent, &mouseUpEvent);
-            UInt16 mbutton = kEventMouseButtonPrimary;
-            SetEventParameter(mouseUpEvent, kEventParamMouseButton, typeMouseButton, sizeof(mbutton), &mbutton);
-            WindowRef window;
-            GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 0, sizeof(window), 0, &window);
-            Rect dragRect;
-            GetWindowBounds(window, kWindowGrowRgn, &dragRect);
-            Point pos = {dragRect.bottom, dragRect.right};
-            SetEventParameter(mouseUpEvent, kEventParamMouseLocation, typeQDPoint, sizeof(pos), &pos);
-            SendEventToApplication(mouseUpEvent);
-            ReleaseEvent(mouseUpEvent);
-        } else if(ekind == kEventWindowBoundsChanging) {
-            UInt32 flags = 0;
-            GetEventParameter(event, kEventParamAttributes, typeUInt32, 0,
-                                  sizeof(flags), 0, &flags);
-            Rect nr;
-            GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, 0,
-                                  sizeof(nr), 0, &nr);
-
-            QRect newRect(nr.left, nr.top, nr.right - nr.left, nr.bottom - nr.top);
-
-            QTLWExtra * const tlwExtra = widget->d_func()->maybeTopData();
-            if (tlwExtra && tlwExtra->isSetGeometry == 1) {
-                widget->d_func()->setGeometry_sys_helper(newRect.left(), newRect.top(), newRect.width(), newRect.height(), tlwExtra->isMove);
-            } else {
-                //implicitly removes the maximized bit
-                if((widget->data->window_state & Qt::WindowMaximized) &&
-                   IsWindowInStandardState(wid, 0, 0)) {
-                    widget->data->window_state &= ~Qt::WindowMaximized;
-                    QWindowStateChangeEvent e(Qt::WindowStates(widget->data->window_state
-                                                | Qt::WindowMaximized));
-                    QApplication::sendSpontaneousEvent(widget, &e);
-
-                }
-
-                handled_event = false;
-                const QRect oldRect = widget->data->crect;
-                if((flags & kWindowBoundsChangeOriginChanged)) {
-                    if(nr.left != oldRect.x() || nr.top != oldRect.y()) {
-                        widget->data->crect.moveTo(nr.left, nr.top);
-                        QMoveEvent qme(widget->data->crect.topLeft(), oldRect.topLeft());
-                        QApplication::sendSpontaneousEvent(widget, &qme);
-                    }
-                }
-                if((flags & kWindowBoundsChangeSizeChanged)) {
-                    if (widget->isWindow()) {
-                        QSize newSize = QLayout::closestAcceptableSize(widget, newRect.size());
-                        int dh = newSize.height() - newRect.height();
-                        int dw = newSize.width() - newRect.width();
-                        if (dw != 0 || dh != 0) {
-                            handled_event = true;  // We want to change the bounds, so we handle the event
-
-                            // set the rect, so we can also do the resize down below (yes, we need to resize).
-                            newRect.setBottom(newRect.bottom() + dh);
-                            newRect.setRight(newRect.right() + dw);
-
-                            nr.left = newRect.x();
-                            nr.top = newRect.y();
-                            nr.right = nr.left + newRect.width();
-                            nr.bottom = nr.top + newRect.height();
-                            SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), &nr);
-                        }
-                    }
-
-                    if (oldRect.width() != newRect.width() || oldRect.height() != newRect.height()) {
-                        widget->data->crect.setSize(newRect.size());
-                        HIRect bounds = CGRectMake(0, 0, newRect.width(), newRect.height());
-
-                        // If the WA_StaticContents attribute is set we can optimize the resize
-                        // by only repainting the newly exposed area. We do this by disabling
-                        // painting when setting the size of the view. The OS will invalidate
-                        // the newly exposed area for us.
-                        const bool staticContents = widget->testAttribute(Qt::WA_StaticContents);
-                        const HIViewRef view = qt_mac_nativeview_for(widget);
-                        if (staticContents)
-                            HIViewSetDrawingEnabled(view, false);
-                        HIViewSetFrame(view, &bounds);
-                        if (staticContents)
-                            HIViewSetDrawingEnabled(view, true);
-
-                        QResizeEvent qre(newRect.size(), oldRect.size());
-                        QApplication::sendSpontaneousEvent(widget, &qre);
-                        qt_event_request_window_change(widget);
-                    }
-                }
-            }
-        } else if (ekind == kEventWindowHidden) {
-            // Make sure that we also hide any visible sheets on our window.
-            // Cocoa does the right thing for us.
-            const QObjectList children = widget->children();
-            const int childCount = children.count();
-            for (int i = 0; i < childCount; ++i) {
-                QObject *obj = children.at(i);
-                if (obj->isWidgetType()) {
-                    QWidget *widget = static_cast<QWidget *>(obj);
-                    if (qt_mac_is_macsheet(widget) && widget->isVisible())
-                        widget->hide();
-                }
-            }
-        } else {
-            handled_event = false;
-        }
-        break; }
-    case kEventClassMouse: {
-#if 0
-        return SendEventToApplication(event);
-#endif
-
-        bool send_to_app = false;
-        {
-            WindowPartCode wpc;
-            if (GetEventParameter(event, kEventParamWindowPartCode, typeWindowPartCode, 0,
-                                  sizeof(wpc), 0, &wpc) == noErr && wpc != inContent)
-                send_to_app = true;
-        }
-        if(!send_to_app) {
-            WindowRef window;
-            if(GetEventParameter(event, kEventParamWindowRef, typeWindowRef, 0,
-                                 sizeof(window), 0, &window) == noErr) {
-                HIViewRef hiview;
-                if(HIViewGetViewForMouseEvent(HIViewGetRoot(window), event, &hiview) == noErr) {
-                    if(QWidget *w = QWidget::find((WId)hiview)) {
-#if 0
-                        send_to_app = !w->isActiveWindow();
-#else
-                        Q_UNUSED(w);
-                        send_to_app = true;
-#endif
-                    }
-                }
-            }
-        }
-        if(send_to_app)
-            return SendEventToApplication(event);
-        handled_event = false;
-        break; }
-
-#ifndef QT_NO_GESTURES
-    case kEventClassGesture: {
-        // First, find the widget that was under
-        // the mouse when the gesture happened:
-        HIPoint screenLocation;
-        if (GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, 0,
-                    sizeof(screenLocation), 0, &screenLocation) != noErr) {
-            handled_event = false;
-            break;
-        }
-        QWidget *widget = QApplication::widgetAt(screenLocation.x, screenLocation.y);
-        if (!widget) {
-            handled_event = false;
-            break;
-        }
-
-        QNativeGestureEvent qNGEvent;
-        qNGEvent.position = QPoint(screenLocation.x, screenLocation.y);
-
-        switch (ekind) {
-            case kEventGestureStarted:
-                qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
-                break;
-            case kEventGestureEnded:
-                qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
-                break;
-            case kEventGestureRotate: {
-                CGFloat amount;
-                if (GetEventParameter(event, kEventParamRotationAmount, 'cgfl', 0,
-                            sizeof(amount), 0, &amount) != noErr) {
-                    handled_event = false;
-                    break;
-                }
-                qNGEvent.gestureType = QNativeGestureEvent::Rotate;
-                qNGEvent.percentage = float(-amount);
-                break; }
-            case kEventGestureSwipe: {
-                HIPoint swipeDirection;
-                if (GetEventParameter(event, kEventParamSwipeDirection, typeHIPoint, 0,
-                            sizeof(swipeDirection), 0, &swipeDirection) != noErr) {
-                    handled_event = false;
-                    break;
-                }
-                qNGEvent.gestureType = QNativeGestureEvent::Swipe;
-                if (swipeDirection.x == 1)
-                    qNGEvent.angle = 180.0f;
-                else if (swipeDirection.x == -1)
-                    qNGEvent.angle = 0.0f;
-                else if (swipeDirection.y == 1)
-                    qNGEvent.angle = 90.0f;
-                else if (swipeDirection.y == -1)
-                    qNGEvent.angle = 270.0f;
-                break; }
-            case kEventGestureMagnify: {
-                CGFloat amount;
-                if (GetEventParameter(event, kEventParamMagnificationAmount, 'cgfl', 0,
-                            sizeof(amount), 0, &amount) != noErr) {
-                    handled_event = false;
-                    break;
-                }
-                qNGEvent.gestureType = QNativeGestureEvent::Zoom;
-                qNGEvent.percentage = float(amount);
-                break; }
-        }
-
-        QApplication::sendSpontaneousEvent(widget, &qNGEvent);
-    break; }
-#endif // QT_NO_GESTURES
-
-    default:
-        handled_event = false;
-    }
-    if(!handled_event) //let the event go through
-        return eventNotHandledErr;
-    return noErr; //we eat the event
-}
-
-// widget events
-static HIObjectClassRef widget_class = 0;
-static EventTypeSpec widget_events[] = {
-    { kEventClassHIObject, kEventHIObjectConstruct },
-    { kEventClassHIObject, kEventHIObjectDestruct },
-
-    { kEventClassControl, kEventControlDraw },
-    { kEventClassControl, kEventControlInitialize },
-    { kEventClassControl, kEventControlGetPartRegion },
-    { kEventClassControl, kEventControlGetClickActivation },
-    { kEventClassControl, kEventControlSetFocusPart },
-    { kEventClassControl, kEventControlDragEnter },
-    { kEventClassControl, kEventControlDragWithin },
-    { kEventClassControl, kEventControlDragLeave },
-    { kEventClassControl, kEventControlDragReceive },
-    { kEventClassControl, kEventControlOwningWindowChanged },
-    { kEventClassControl, kEventControlBoundsChanged },
-    { kEventClassControl, kEventControlGetSizeConstraints },
-    { kEventClassControl, kEventControlVisibilityChanged },
-
-    { kEventClassMouse, kEventMouseDown },
-    { kEventClassMouse, kEventMouseUp },
-    { kEventClassMouse, kEventMouseMoved },
-    { kEventClassMouse, kEventMouseDragged }
-};
-static EventHandlerUPP mac_widget_eventUPP = 0;
-static void cleanup_widget_eventUPP()
-{
-    DisposeEventHandlerUPP(mac_widget_eventUPP);
-    mac_widget_eventUPP = 0;
-}
-static const EventHandlerUPP make_widget_eventUPP()
-{
-    if(mac_widget_eventUPP)
-        return mac_widget_eventUPP;
-    qAddPostRoutine(cleanup_widget_eventUPP);
-    return mac_widget_eventUPP = NewEventHandlerUPP(QWidgetPrivate::qt_widget_event);
-}
-OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event, void *)
-{
-    QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData);
-
-    bool handled_event = true;
-    UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
-    switch(eclass) {
-    case kEventClassHIObject: {
-        HIViewRef view = 0;
-        GetEventParameter(event, kEventParamHIObjectInstance, typeHIObjectRef,
-                          0, sizeof(view), 0, &view);
-        if(ekind == kEventHIObjectConstruct) {
-            if(view) {
-                HIViewChangeFeatures(view, kHIViewAllowsSubviews, 0);
-                SetEventParameter(event, kEventParamHIObjectInstance,
-                                  typeVoidPtr, sizeof(view), &view);
-            }
-        } else if(ekind == kEventHIObjectDestruct) {
-            //nothing to really do.. or is there?
-        } else {
-            handled_event = false;
-        }
-        break; }
-    case kEventClassControl: {
-        QWidget *widget = 0;
-        HIViewRef hiview = 0;
-        if(GetEventParameter(event, kEventParamDirectObject, typeControlRef,
-                             0, sizeof(hiview), 0, &hiview) == noErr)
-            widget = QWidget::find((WId)hiview);
-        if (widget && widget->macEvent(er, event))
-            return noErr;
-        if(ekind == kEventControlDraw) {
-            if(widget && qt_isGenuineQWidget(hiview)) {
-
-                // if there is a window change event pending for any gl child wigets,
-                // send it immediately. (required for flicker-free resizing)
-                extern void qt_mac_send_posted_gl_updates(QWidget *widget);
-                qt_mac_send_posted_gl_updates(widget);
-
-                if (QApplicationPrivate::graphicsSystem() && !widget->d_func()->paintOnScreen()) {
-                    widget->d_func()->syncBackingStore();
-                    widget->d_func()->dirtyOnWidget = QRegion();
-                    return noErr;
-                }
-
-                //requested rgn
-                RgnHandle rgn;
-                GetEventParameter(event, kEventParamRgnHandle, typeQDRgnHandle, 0, sizeof(rgn), 0, &rgn);
-                QRegion qrgn(qt_mac_convert_mac_region(rgn));
-
-                //update handles
-                GrafPtr qd = 0;
-                CGContextRef cg = 0;
-                if(GetEventParameter(event, kEventParamCGContextRef, typeCGContextRef, 0, sizeof(cg), 0, &cg) != noErr) {
-                    Q_ASSERT(false);
-                }
-                widget->d_func()->hd = cg;
-                widget->d_func()->qd_hd = qd;
-                CGContextSaveGState(cg);
-
-#ifdef DEBUG_WIDGET_PAINT
-                const bool doDebug = true;
-                if(doDebug)  {
-                    qDebug("asked to draw %p[%p] [%s::%s] %p[%p] [%d] [%dx%d]", widget, hiview, widget->metaObject()->className(),
-                           widget->objectName().local8Bit().data(), widget->parentWidget(),
-                           (HIViewRef)(widget->parentWidget() ? qt_mac_nativeview_for(widget->parentWidget()) : (HIViewRef)0),
-                           HIViewIsCompositingEnabled(hiview), qt_mac_posInWindow(widget).x(), qt_mac_posInWindow(widget).y());
-#if 0
-                    QVector<QRect> region_rects = qrgn.rects();
-                    qDebug("Region! %d", region_rects.count());
-                    for(int i = 0; i < region_rects.count(); i++)
-                        qDebug("%d %d %d %d", region_rects[i].x(), region_rects[i].y(),
-                               region_rects[i].width(), region_rects[i].height());
-                    region_rects = widget->d_func()->clp.rects();
-                    qDebug("Widget Region! %d", region_rects.count());
-                    for(int i = 0; i < region_rects.count(); i++)
-                        qDebug("%d %d %d %d", region_rects[i].x(), region_rects[i].y(),
-                               region_rects[i].width(), region_rects[i].height());
-#endif
-                }
-#endif
-                if (widget->isVisible() && widget->updatesEnabled()) { //process the actual paint event.
-                    if(widget->testAttribute(Qt::WA_WState_InPaintEvent))
-                        qWarning("QWidget::repaint: Recursive repaint detected");
-                    if (widget->isWindow() && !widget->d_func()->isOpaque
-                        && !widget->testAttribute(Qt::WA_MacBrushedMetal)) {
-                        QRect qrgnRect = qrgn.boundingRect();
-                        CGContextClearRect(cg, CGRectMake(qrgnRect.x(), qrgnRect.y(), qrgnRect.width(), qrgnRect.height()));
-                    }
-
-                    QPoint redirectionOffset(0, 0);
-                    QWidget *tl = widget->window();
-                    if (tl) {
-                        Qt::WindowFlags flags = tl->windowFlags();
-                        if (flags & Qt::FramelessWindowHint
-                            || (flags & Qt::CustomizeWindowHint && !(flags & Qt::WindowTitleHint))) {
-                            if(tl->d_func()->extra && !tl->d_func()->extra->mask.isEmpty())
-                                redirectionOffset += tl->d_func()->extra->mask.boundingRect().topLeft();
-                        }
-                    }
-
-                    //setup the context
-                    widget->setAttribute(Qt::WA_WState_InPaintEvent);
-                    QPaintEngine *engine = widget->paintEngine();
-                    if (engine)
-                        engine->setSystemClip(qrgn);
-
-                    //handle the erase
-                    if (engine && (!widget->testAttribute(Qt::WA_NoSystemBackground)
-                        && (widget->isWindow() || widget->autoFillBackground())
-                        || widget->testAttribute(Qt::WA_TintedBackground)
-                        || widget->testAttribute(Qt::WA_StyledBackground))) {
-#ifdef DEBUG_WIDGET_PAINT
-                        if(doDebug)
-                            qDebug(" Handling erase for [%s::%s]", widget->metaObject()->className(),
-                                   widget->objectName().local8Bit().data());
-#endif
-                        if (!redirectionOffset.isNull())
-                            widget->d_func()->setRedirected(widget, redirectionOffset);
-
-                        bool was_unclipped = widget->testAttribute(Qt::WA_PaintUnclipped);
-                        widget->setAttribute(Qt::WA_PaintUnclipped, false);
-                        QPainter p(widget);
-                        p.setClipping(false);
-                        if(was_unclipped)
-                            widget->setAttribute(Qt::WA_PaintUnclipped);
-                        widget->d_func()->paintBackground(&p, qrgn, widget->isWindow() ? DrawAsRoot : 0);
-                        if (widget->testAttribute(Qt::WA_TintedBackground)) {
-                            QColor tint = widget->palette().window().color();
-                            tint.setAlphaF(.6);
-                            const QVector<QRect> &rects = qrgn.rects();
-                            for (int i = 0; i < rects.size(); ++i)
-                                p.fillRect(rects.at(i), tint);
-                        }
-                        p.end();
-                        if (!redirectionOffset.isNull())
-                            widget->d_func()->restoreRedirected();
-                    }
-
-                    if(!HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget))
-                        CallNextEventHandler(er, event);
-
-                    //send the paint
-                    redirectionOffset += widget->data->wrect.topLeft(); // Map from system to qt coordinates
-                    if (!redirectionOffset.isNull())
-                        widget->d_func()->setRedirected(widget, redirectionOffset);
-                    qrgn.translate(redirectionOffset);
-                    QPaintEvent e(qrgn);
-                    widget->d_func()->dirtyOnWidget = QRegion();
-                    QApplication::sendSpontaneousEvent(widget, &e);
-                    if (!redirectionOffset.isNull())
-                        widget->d_func()->restoreRedirected();
-
-                    //cleanup
-                    if (engine)
-                        engine->setSystemClip(QRegion());
-
-                    widget->setAttribute(Qt::WA_WState_InPaintEvent, false);
-                    if(!widget->testAttribute(Qt::WA_PaintOutsidePaintEvent) && widget->paintingActive())
-                        qWarning("QWidget: It is dangerous to leave painters active on a widget outside of the PaintEvent");
-                }
-
-                widget->d_func()->hd = 0;
-                widget->d_func()->qd_hd = 0;
-                CGContextRestoreGState(cg);
-            } else if(!HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget)) {
-                CallNextEventHandler(er, event);
-            }
-        } else if(ekind == kEventControlInitialize) {
-            if(HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget)) {
-                UInt32 features = kControlSupportsDragAndDrop | kControlSupportsClickActivation | kControlSupportsFocus;
-                SetEventParameter(event, kEventParamControlFeatures, typeUInt32, sizeof(features), &features);
-            } else {
-                handled_event = false;
-            }
-        } else if(ekind == kEventControlSetFocusPart) {
-            if(widget) {
-                ControlPartCode part;
-                GetEventParameter(event, kEventParamControlPart, typeControlPartCode, 0,
-                                  sizeof(part), 0, &part);
-                if(part == kControlFocusNoPart){
-                    if (widget->hasFocus())
-                        QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
-                } else
-                    widget->setFocus();
-            }
-            if(!HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget))
-                CallNextEventHandler(er, event);
-        } else if(ekind == kEventControlGetClickActivation) {
-            ClickActivationResult clickT = kActivateAndIgnoreClick;
-            SetEventParameter(event, kEventParamClickActivation, typeClickActivationResult,
-                              sizeof(clickT), &clickT);
-        } else if(ekind == kEventControlGetPartRegion) {
-            handled_event = false;
-            if(!HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget) && CallNextEventHandler(er, event) == noErr) {
-                handled_event = true;
-                break;
-            }
-            if(widget && !widget->isWindow()) {
-                ControlPartCode part;
-                GetEventParameter(event, kEventParamControlPart, typeControlPartCode, 0,
-                                  sizeof(part), 0, &part);
-                if(part == kControlClickableMetaPart && widget->testAttribute(Qt::WA_TransparentForMouseEvents)) {
-                    RgnHandle rgn;
-                    GetEventParameter(event, kEventParamControlRegion, typeQDRgnHandle, 0,
-                                      sizeof(rgn), 0, &rgn);
-                    SetEmptyRgn(rgn);
-                    handled_event = true;
-                } else if(part == kControlStructureMetaPart || part == kControlClickableMetaPart) {
-                    RgnHandle rgn;
-                    GetEventParameter(event, kEventParamControlRegion, typeQDRgnHandle, 0,
-                                      sizeof(rgn), 0, &rgn);
-                    SetRectRgn(rgn, 0, 0, widget->width(), widget->height());
-                    if(QWidgetPrivate::qt_widget_rgn(widget, kWindowStructureRgn, rgn, false))
-                        handled_event = true;
-                } else if(part == kControlOpaqueMetaPart) {
-                    if(widget->d_func()->isOpaque) {
-                        RgnHandle rgn;
-                        GetEventParameter(event, kEventParamControlRegion, typeQDRgnHandle, 0,
-                                          sizeof(RgnHandle), 0, &rgn);
-                        SetRectRgn(rgn, 0, 0, widget->width(), widget->height());
-                        QWidgetPrivate::qt_widget_rgn(widget, kWindowStructureRgn, rgn, false);
-                        SetEventParameter(event, kEventParamControlRegion, typeQDRgnHandle,
-                                sizeof(RgnHandle), &rgn);
-                        handled_event = true;
-                    }
-                }
-            }
-        } else if(ekind == kEventControlOwningWindowChanged) {
-            if(!HIObjectIsOfClass((HIObjectRef)hiview, kObjectQWidget))
-                CallNextEventHandler(er, event);
-            if(widget && qt_mac_window_for(hiview)) {
-                WindowRef foo = 0;
-                GetEventParameter(event, kEventParamControlCurrentOwningWindow, typeWindowRef, 0,
-                                  sizeof(foo), 0, &foo);
-                widget->d_func()->initWindowPtr();
-            }
-            if (widget)
-                qt_event_request_window_change(widget);
-        } else if(ekind == kEventControlDragEnter || ekind == kEventControlDragWithin ||
-                  ekind == kEventControlDragLeave || ekind == kEventControlDragReceive) {
-            // dnd are really handled in qdnd_mac.cpp,
-            // just modularize the code a little...
-            DragRef drag;
-            GetEventParameter(event, kEventParamDragRef, typeDragRef, 0, sizeof(drag), 0, &drag);
-            handled_event = false;
-            bool drag_allowed = false;
-
-            QWidget *dropWidget = widget;
-            if (qobject_cast<QFocusFrame *>(widget)){
-                // We might shadow widgets underneath the focus
-                // frame, so stay interrested, and let the dnd through
-                drag_allowed = true;
-                handled_event = true;
-                Point where;
-                GetDragMouse(drag, &where, 0);
-                dropWidget = QApplication::widgetAt(QPoint(where.h, where.v));
-
-                if (dropWidget != QDragManager::self()->currentTarget()) {
-                    // We have to 'fake' enter and leave events for the shaddowed widgets:
-                    if (ekind == kEventControlDragEnter) {
-                        if (QDragManager::self()->currentTarget())
-                            QDragManager::self()->currentTarget()->d_func()->qt_mac_dnd_event(kEventControlDragLeave, drag);
-                        if (dropWidget) {
-                            dropWidget->d_func()->qt_mac_dnd_event(kEventControlDragEnter, drag);
-                        }
-                        // Set dropWidget to zero, so qt_mac_dnd_event
-                        // doesn't get called a second time below:
-                        dropWidget = 0;
-                    } else if (ekind == kEventControlDragLeave) {
-                        dropWidget = QDragManager::self()->currentTarget();
-                        if (dropWidget) {
-                            dropWidget->d_func()->qt_mac_dnd_event(kEventControlDragLeave, drag);
-                        }
-                        // Set dropWidget to zero, so qt_mac_dnd_event
-                        // doesn't get called a second time below:
-                        dropWidget = 0;
-                    }
-                }
-            }
-
-            // Send the dnd event to the widget:
-            if (dropWidget && dropWidget->d_func()->qt_mac_dnd_event(ekind, drag)) {
-                drag_allowed = true;
-                handled_event = true;
-            }
-
-            if (ekind == kEventControlDragEnter) {
-                // If we don't accept the enter event, we will
-                // receive no more drag events for this widget
-                const Boolean wouldAccept = drag_allowed ? true : false;
-                SetEventParameter(event, kEventParamControlWouldAcceptDrop, typeBoolean,
-                        sizeof(wouldAccept), &wouldAccept);
-            }
-        } else if (ekind == kEventControlBoundsChanged) {
-            if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_Moved) || widget->testAttribute(Qt::WA_Resized)) {
-                handled_event = false;
-            } else {
-                // Sync our view in case some other (non-Qt) view is controlling us.
-                handled_event = true;
-                Rect newBounds;
-                GetEventParameter(event, kEventParamCurrentBounds,
-                                  typeQDRectangle, 0, sizeof(Rect), 0, &newBounds);
-                QRect rect(newBounds.left, newBounds.top,
-                            newBounds.right - newBounds.left, newBounds.bottom - newBounds.top);
-
-                bool moved = widget->testAttribute(Qt::WA_Moved);
-                bool resized = widget->testAttribute(Qt::WA_Resized);
-                widget->setGeometry(rect);
-                widget->setAttribute(Qt::WA_Moved, moved);
-                widget->setAttribute(Qt::WA_Resized, resized);
-                qt_event_request_window_change(widget);
-            }
-        } else if (ekind == kEventControlGetSizeConstraints) {
-            if (!widget || !qt_isGenuineQWidget(widget)) {
-                handled_event = false;
-            } else {
-                handled_event = true;
-                QWidgetItem item(widget);
-                QSize size = item.minimumSize();
-                HISize hisize = { size.width(), size.height() };
-                SetEventParameter(event, kEventParamMinimumSize, typeHISize, sizeof(HISize), &hisize);
-                size = item.maximumSize();
-                hisize.width = size.width() + 2; // ### shouldn't have to add 2 (but it works).
-                hisize.height = size.height();
-                SetEventParameter(event, kEventParamMaximumSize, typeHISize, sizeof(HISize), &hisize);
-            }
-        } else if (ekind == kEventControlVisibilityChanged) {
-            handled_event = false;
-            if (widget) {
-                qt_event_request_window_change(widget);
-                if (!HIViewIsVisible(HIViewRef(widget->winId()))) {
-                    if (widget == qt_button_down)
-                        qt_button_down = 0;
-                }
-            }
-        }
-        break; }
-    case kEventClassMouse: {
-        bool send_to_app = false;
-        if(qt_button_down)
-            send_to_app = true;
-        if(send_to_app) {
-            OSStatus err = SendEventToApplication(event);
-            if(err != noErr)
-                handled_event = false;
-        } else {
-            CallNextEventHandler(er, event);
-        }
-        break; }
-    default:
-        handled_event = false;
-        break;
-    }
-    if(!handled_event) //let the event go through
-        return eventNotHandledErr;
-    return noErr; //we eat the event
-}
-#endif
 
 OSViewRef qt_mac_create_widget(QWidget *widget, QWidgetPrivate *widgetPrivate, OSViewRef parent)
 {
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     QT_MANGLE_NAMESPACE(QCocoaView) *view = [[QT_MANGLE_NAMESPACE(QCocoaView) alloc] initWithQWidget:widget widgetPrivate:widgetPrivate];
 
@@ -1605,31 +569,10 @@ OSViewRef qt_mac_create_widget(QWidget *widget, QWidgetPrivate *widgetPrivate, O
     if (view && parent)
         [parent addSubview:view];
     return view;
-#else
-    Q_UNUSED(widget);
-    Q_UNUSED(widgetPrivate);
-    if(!widget_class) {
-        OSStatus err = HIObjectRegisterSubclass(kObjectQWidget, kHIViewClassID, 0, make_widget_eventUPP(),
-                                                GetEventTypeCount(widget_events), widget_events,
-                                                0, &widget_class);
-        if (err && err != hiObjectClassExistsErr)
-            qWarning("QWidget: Internal error (%d)", __LINE__);
-    }
-    HIViewRef ret = 0;
-    if(HIObjectCreate(kObjectQWidget, 0, (HIObjectRef*)&ret) != noErr)
-        qWarning("QWidget: Internal error (%d)", __LINE__);
-    if(ret && parent)
-        HIViewAddSubview(parent, ret);
-    return ret;
-#endif
 }
 
 void qt_mac_unregister_widget()
 {
-#ifndef QT_MAC_USE_COCOA
-    HIObjectUnregisterClass(widget_class);
-    widget_class = 0;
-#endif
 }
 
 void QWidgetPrivate::toggleDrawers(bool visible)
@@ -1670,46 +613,18 @@ bool QWidgetPrivate::qt_mac_update_sizer(QWidget *w, int up)
         topData->resizer += up;
     OSWindowRef windowRef = qt_mac_window_for(OSViewRef(w->effectiveWinId()));
     {
-#ifndef QT_MAC_USE_COCOA
-        WindowClass wclass;
-        GetWindowClass(windowRef, &wclass);
-        if(!(GetAvailableWindowAttributes(wclass) & kWindowResizableAttribute))
-            return true;
-#endif
     }
     bool remove_grip = (topData->resizer || (w->windowFlags() & Qt::FramelessWindowHint)
                         || (extraData->maxw && extraData->maxh &&
                             extraData->maxw == extraData->minw && extraData->maxh == extraData->minh));
-#ifndef QT_MAC_USE_COCOA
-    WindowAttributes attr;
-    GetWindowAttributes(windowRef, &attr);
-    if(remove_grip) {
-        if(attr & kWindowResizableAttribute) {
-            ChangeWindowAttributes(qt_mac_window_for(w), kWindowNoAttributes,
-                                   kWindowResizableAttribute);
-            ReshapeCustomWindow(qt_mac_window_for(w));
-        }
-    } else if(!(attr & kWindowResizableAttribute)) {
-        ChangeWindowAttributes(windowRef, kWindowResizableAttribute,
-                               kWindowNoAttributes);
-        ReshapeCustomWindow(windowRef);
-    }
-#else
     [windowRef setShowsResizeIndicator:!remove_grip];
-#endif
     return true;
 }
 
 void QWidgetPrivate::qt_clean_root_win()
 {
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     [qt_root_win release];
-#else
-    if(!qt_root_win)
-        return;
-    CFRelease(qt_root_win);
-#endif
     qt_root_win = 0;
 }
 
@@ -1719,12 +634,7 @@ bool QWidgetPrivate::qt_create_root_win()
         return false;
     const QSize desktopSize = qt_mac_desktopSize();
     QRect desktopRect(QPoint(0, 0), desktopSize);
-#ifdef QT_MAC_USE_COCOA
     qt_root_win = qt_mac_create_window(0, kOverlayWindowClass, NSBorderlessWindowMask, desktopRect);
-#else
-    WindowAttributes wattr = (kWindowCompositingAttribute | kWindowStandardHandlerAttribute);
-    qt_root_win = qt_mac_create_window(0, kOverlayWindowClass, wattr, desktopRect);
-#endif
     if(!qt_root_win)
         return false;
     qAddPostRoutine(qt_clean_root_win);
@@ -1734,53 +644,10 @@ bool QWidgetPrivate::qt_create_root_win()
 bool QWidgetPrivate::qt_widget_rgn(QWidget *widget, short wcode, RgnHandle rgn, bool force = false)
 {
     bool ret = false;
-#ifndef QT_MAC_USE_COCOA
-    switch(wcode) {
-    case kWindowStructureRgn: {
-        if(widget) {
-            if(widget->d_func()->extra && !widget->d_func()->extra->mask.isEmpty()) {
-                QRegion rin = qt_mac_convert_mac_region(rgn);
-                if(!rin.isEmpty()) {
-                    QPoint rin_tl = rin.boundingRect().topLeft(); //in offset
-                    rin.translate(-rin_tl.x(), -rin_tl.y()); //bring into same space as below
-                    QRegion mask = widget->d_func()->extra->mask;
-                    Qt::WindowFlags flags = widget->windowFlags();
-                    if(widget->isWindow()
-                       && !(flags & Qt::FramelessWindowHint
-                            || (flags & Qt::CustomizeWindowHint && !(flags & Qt::WindowTitleHint)))) {
-                        QRegion title;
-                        {
-                            QMacSmartQuickDrawRegion rgn(qt_mac_get_rgn());
-                            GetWindowRegion(qt_mac_window_for(widget), kWindowTitleBarRgn, rgn);
-                            title = qt_mac_convert_mac_region(rgn);
-                        }
-                        QRect br = title.boundingRect();
-                        mask.translate(0, br.height()); //put the mask 'under' the title bar..
-                        title.translate(-br.x(), -br.y());
-                        mask += title;
-                    }
-
-                    QRegion cr = rin & mask;
-                    cr.translate(rin_tl.x(), rin_tl.y()); //translate back to incoming space
-                    CopyRgn(QMacSmartQuickDrawRegion(cr.toQDRgn()), rgn);
-                }
-                ret = true;
-            } else if(force) {
-                QRegion cr(widget->geometry());
-                CopyRgn(QMacSmartQuickDrawRegion(cr.toQDRgn()), rgn);
-                ret = true;
-            }
-        }
-        break; }
-    default: break;
-    }
-    //qDebug() << widget << ret << wcode << qt_mac_convert_mac_region(rgn);
-#else
     Q_UNUSED(widget);
     Q_UNUSED(wcode);
     Q_UNUSED(rgn);
     Q_UNUSED(force);
-#endif
     return ret;
 }
 
@@ -1799,160 +666,7 @@ void QWidgetPrivate::determineWindowClass()
         data.window_flags |= Qt::MacWindowToolBarButtonHint;
     }
 #endif
-#ifndef QT_MAC_USE_COCOA
-// ### COCOA:Interleave these better!
-
-    const Qt::WindowType type = q->windowType();
-    Qt::WindowFlags &flags = data.window_flags;
-    const bool popup = (type == Qt::Popup);
-    if (type == Qt::ToolTip || type == Qt::SplashScreen || popup)
-        flags |= Qt::FramelessWindowHint;
-
-    WindowClass wclass = kSheetWindowClass;
-    if(qt_mac_is_macdrawer(q))
-        wclass = kDrawerWindowClass;
-    else if (q->testAttribute(Qt::WA_ShowModal) && flags & Qt::CustomizeWindowHint)
-        wclass = kDocumentWindowClass;
-    else if(popup || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 && type == Qt::SplashScreen))
-        wclass = kModalWindowClass;
-    else if(q->testAttribute(Qt::WA_ShowModal))
-        wclass = kMovableModalWindowClass;
-    else if(type == Qt::ToolTip)
-        wclass = kHelpWindowClass;
-    else if(type == Qt::Tool || (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5
-                                 && type == Qt::SplashScreen))
-        wclass = kFloatingWindowClass;
-    else
-        wclass = kDocumentWindowClass;
-
-    WindowGroupRef grp = 0;
-    WindowAttributes wattr = (kWindowCompositingAttribute | kWindowStandardHandlerAttribute);
-    if (q->testAttribute(Qt::WA_MacFrameworkScaled))
-        wattr |= kWindowFrameworkScaledAttribute;
-    if(qt_mac_is_macsheet(q)) {
-        //grp = GetWindowGroupOfClass(kMovableModalWindowClass);
-        wclass = kSheetWindowClass;
-    } else {
-        grp = GetWindowGroupOfClass(wclass);
-        // Shift things around a bit to get the correct window class based on the presence
-        // (or lack) of the border.
-       bool customize = flags & Qt::CustomizeWindowHint;
-        bool framelessWindow = (flags & Qt::FramelessWindowHint || (customize && !(flags & Qt::WindowTitleHint)));
-        if (framelessWindow) {
-            if(wclass == kDocumentWindowClass) {
-                wattr |= kWindowNoTitleBarAttribute;
-            } else if(wclass == kFloatingWindowClass) {
-                wattr |= kWindowNoTitleBarAttribute;
-            } else if (wclass  == kMovableModalWindowClass) {
-                wclass = kModalWindowClass;
-            }
-        } else {
-            if(wclass != kModalWindowClass)
-                wattr |= kWindowResizableAttribute;
-        }
-        // Only add extra decorations (well, buttons) for widgets that can have them
-        // and have an actual border we can put them on.
-        if(wclass != kModalWindowClass && wclass != kMovableModalWindowClass
-                && wclass != kSheetWindowClass && wclass != kPlainWindowClass
-                && !framelessWindow && wclass != kDrawerWindowClass
-                && wclass != kHelpWindowClass) {
-            if (flags & Qt::WindowMaximizeButtonHint)
-                wattr |= kWindowFullZoomAttribute;
-            if (flags & Qt::WindowMinimizeButtonHint)
-                wattr |= kWindowCollapseBoxAttribute;
-            if (flags & Qt::WindowSystemMenuHint || flags & Qt::WindowCloseButtonHint)
-                wattr |= kWindowCloseBoxAttribute;
-            if (flags & Qt::MacWindowToolBarButtonHint)
-                wattr |= kWindowToolbarButtonAttribute;
-        } else {
-            // Clear these hints so that we aren't call them on invalid windows
-            flags &= ~(Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint
-                       | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint);
-        }
-    }
-    if((popup || type == Qt::Tool) && !q->isModal())
-        wattr |= kWindowHideOnSuspendAttribute;
-    wattr |= kWindowLiveResizeAttribute;
-
-#ifdef DEBUG_WINDOW_CREATE
-#define ADD_DEBUG_WINDOW_NAME(x) { x, #x }
-    struct {
-        UInt32 tag;
-        const char *name;
-    } known_attribs[] = {
-        ADD_DEBUG_WINDOW_NAME(kWindowCompositingAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowStandardHandlerAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowMetalAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowHideOnSuspendAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowStandardHandlerAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowCollapseBoxAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowHorizontalZoomAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowVerticalZoomAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowResizableAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowNoActivatesAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowNoUpdatesAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowOpaqueForEventsAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowLiveResizeAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowCloseBoxAttribute),
-        ADD_DEBUG_WINDOW_NAME(kWindowHideOnSuspendAttribute),
-        { 0, 0 }
-    }, known_classes[] = {
-        ADD_DEBUG_WINDOW_NAME(kHelpWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kPlainWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kDrawerWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kUtilityWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kToolbarWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kSheetWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kFloatingWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kUtilityWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kDocumentWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kToolbarWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kMovableModalWindowClass),
-        ADD_DEBUG_WINDOW_NAME(kModalWindowClass),
-        { 0, 0 }
-    };
-    qDebug("Qt: internal: ************* Creating new window %p (%s::%s)", q, q->metaObject()->className(),
-            q->objectName().toLocal8Bit().constData());
-    bool found_class = false;
-    for(int i = 0; known_classes[i].name; i++) {
-        if(wclass == known_classes[i].tag) {
-            found_class = true;
-            qDebug("Qt: internal: ** Class: %s", known_classes[i].name);
-            break;
-        }
-    }
-    if(!found_class)
-        qDebug("Qt: internal: !! Class: Unknown! (%d)", (int)wclass);
-    if(wattr) {
-        WindowAttributes tmp_wattr = wattr;
-        qDebug("Qt: internal: ** Attributes:");
-        for(int i = 0; tmp_wattr && known_attribs[i].name; i++) {
-            if((tmp_wattr & known_attribs[i].tag) == known_attribs[i].tag) {
-                tmp_wattr ^= known_attribs[i].tag;
-                qDebug("Qt: internal: * %s %s", known_attribs[i].name,
-                        (GetAvailableWindowAttributes(wclass) & known_attribs[i].tag) ? "" : "(*)");
-            }
-        }
-        if(tmp_wattr)
-            qDebug("Qt: internal: !! Attributes: Unknown (%d)", (int)tmp_wattr);
-    }
-#endif
 
-    /* Just to be extra careful we will change to the kUtilityWindowClass if the
-       requested attributes cannot be used */
-    if((GetAvailableWindowAttributes(wclass) & wattr) != wattr) {
-        WindowClass tmp_class = wclass;
-        if(wclass == kToolbarWindowClass || wclass == kUtilityWindowClass)
-            wclass = kFloatingWindowClass;
-        if(tmp_class != wclass) {
-            if(!grp)
-                grp = GetWindowGroupOfClass(wclass);
-            wclass = tmp_class;
-        }
-    }
-    topData()->wclass = wclass;
-    topData()->wattr = wattr;
-#else
     const Qt::WindowType type = q->windowType();
     Qt::WindowFlags &flags = data.window_flags;
     const bool popup = (type == Qt::Popup);
@@ -1984,9 +698,6 @@ void QWidgetPrivate::determineWindowClass()
         wclass = kSheetWindowClass;
         wattr = NSTitledWindowMask | NSResizableWindowMask;
     } else {
-#ifndef QT_MAC_USE_COCOA
-        grp = GetWindowGroupOfClass(wclass);
-#endif
         // Shift things around a bit to get the correct window class based on the presence
         // (or lack) of the border.
        bool customize = flags & Qt::CustomizeWindowHint;
@@ -2078,200 +789,18 @@ void QWidgetPrivate::determineWindowClass()
         for(int i = 0; tmp_wattr && known_attribs[i].name; i++) {
             if((tmp_wattr & known_attribs[i].tag) == known_attribs[i].tag) {
                 tmp_wattr ^= known_attribs[i].tag;
-            }
-        }
-        if(tmp_wattr)
-            qDebug("Qt: internal: !! Attributes: Unknown (%d)", (int)tmp_wattr);
-    }
-#endif
-
-#ifndef QT_MAC_USE_COCOA
-    /* Just to be extra careful we will change to the kUtilityWindowClass if the
-       requested attributes cannot be used */
-    if((GetAvailableWindowAttributes(wclass) & wattr) != wattr) {
-        WindowClass tmp_class = wclass;
-        if(wclass == kToolbarWindowClass || wclass == kUtilityWindowClass)
-            wclass = kFloatingWindowClass;
-        if(tmp_class != wclass) {
-            if(!grp)
-                grp = GetWindowGroupOfClass(wclass);
-            wclass = tmp_class;
-        }
-    }
-#endif
-#endif
-    topData()->wclass = wclass;
-    topData()->wattr = wattr;
-}
-
-#ifndef QT_MAC_USE_COCOA  // This is handled in Cocoa via our category.
-void QWidgetPrivate::initWindowPtr()
-{
-    Q_Q(QWidget);
-    OSWindowRef windowRef = qt_mac_window_for(qt_mac_nativeview_for(q)); //do not create!
-    if(!windowRef)
-        return;
-    QWidget *window = q->window(), *oldWindow = 0;
-    if(GetWindowProperty(windowRef, kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(oldWindow), 0, &oldWindow) == noErr) {
-        Q_ASSERT(window == oldWindow);
-        return;
-    }
-
-    if(SetWindowProperty(windowRef, kWidgetCreatorQt, kWidgetPropertyQWidget, sizeof(window), &window) != noErr)
-        qWarning("Qt:Internal error (%s:%d)", __FILE__, __LINE__); //no real way to recover
-    if(!q->windowType() != Qt::Desktop) { //setup an event callback handler on the window
-        InstallWindowEventHandler(windowRef, make_win_eventUPP(), GetEventTypeCount(window_events),
-                window_events, static_cast<void *>(qApp), &window_event);
-    }
-}
-
-void QWidgetPrivate::finishCreateWindow_sys_Carbon(OSWindowRef windowRef)
-{
-    Q_Q(QWidget);
-    const Qt::WindowType type = q->windowType();
-    Qt::WindowFlags &flags = data.window_flags;
-    QWidget *parentWidget = q->parentWidget();
-
-    const bool desktop = (type == Qt::Desktop);
-    const bool dialog = (type == Qt::Dialog
-                         || type == Qt::Sheet
-                         || type == Qt::Drawer
-                         || (flags & Qt::MSWindowsFixedSizeDialogHint));
-    QTLWExtra *topExtra = topData();
-    quint32 wattr = topExtra->wattr;
-    if (!desktop)
-        SetAutomaticControlDragTrackingEnabledForWindow(windowRef, true);
-    HIWindowChangeFeatures(windowRef, kWindowCanCollapse, 0);
-    if (wattr & kWindowHideOnSuspendAttribute)
-        HIWindowChangeAvailability(windowRef, kHIWindowExposeHidden, 0);
-    else
-        HIWindowChangeAvailability(windowRef, 0, kHIWindowExposeHidden);
-    if ((flags & Qt::WindowStaysOnTopHint))
-        ChangeWindowAttributes(windowRef, kWindowNoAttributes, kWindowHideOnSuspendAttribute);
-    if (qt_mac_is_macdrawer(q) && parentWidget)
-        SetDrawerParent(windowRef, qt_mac_window_for (parentWidget));
-    if (topExtra->group) {
-        qt_mac_release_window_group(topExtra->group);
-        topExtra->group = 0;
-    }
-    if (type == Qt::ToolTip)
-        qt_mac_set_window_group_to_tooltip(windowRef);
-    else if (type == Qt::Popup && (flags & Qt::WindowStaysOnTopHint))
-        qt_mac_set_window_group_to_popup(windowRef);
-    else if (flags & Qt::WindowStaysOnTopHint)
-        qt_mac_set_window_group_to_stays_on_top(windowRef, type);
-    else if (dialog)
-        SetWindowGroup(windowRef, GetWindowGroupOfClass(kMovableModalWindowClass));
-
-#ifdef DEBUG_WINDOW_CREATE
-    if (WindowGroupRef grpf = GetWindowGroup(windowRef)) {
-        QCFString cfname;
-        CopyWindowGroupName(grpf, &cfname);
-        SInt32 lvl;
-        GetWindowGroupLevel(grpf, &lvl);
-        const char *from = "Default";
-        if (topExtra && grpf == topData()->group)
-            from = "Created";
-        else if (grpf == grp)
-            from = "Copied";
-        qDebug("Qt: internal: With window group '%s' [%p] @ %d: %s",
-                static_cast<QString>(cfname).toLatin1().constData(), grpf, (int)lvl, from);
-    } else {
-        qDebug("Qt: internal: No window group!!!");
-    }
-    HIWindowAvailability hi_avail = 0;
-    if (HIWindowGetAvailability(windowRef, &hi_avail) == noErr) {
-        struct {
-            UInt32 tag;
-            const char *name;
-        } known_avail[] = {
-            ADD_DEBUG_WINDOW_NAME(kHIWindowExposeHidden),
-            { 0, 0 }
-        };
-        qDebug("Qt: internal: ** HIWindowAvailibility:");
-        for (int i = 0; hi_avail && known_avail[i].name; i++) {
-            if ((hi_avail & known_avail[i].tag) == known_avail[i].tag) {
-                hi_avail ^= known_avail[i].tag;
-                qDebug("Qt: internal: * %s", known_avail[i].name);
-            }
-        }
-        if (hi_avail)
-            qDebug("Qt: internal: !! Attributes: Unknown (%d)", (int)hi_avail);
-    }
-#undef ADD_DEBUG_WINDOW_NAME
-#endif
-    if (extra && !extra->mask.isEmpty())
-        ReshapeCustomWindow(windowRef);
-    SetWindowModality(windowRef, kWindowModalityNone, 0);
-    if (qt_mac_is_macdrawer(q))
-        SetDrawerOffsets(windowRef, 0.0, 25.0);
-    data.fstrut_dirty = true; // when we create a toplevel widget, the frame strut should be dirty
-    HIViewRef hiview = (HIViewRef)data.winid;
-    HIViewRef window_hiview = qt_mac_get_contentview_for(windowRef);
-    if(!hiview) {
-        hiview = qt_mac_create_widget(q, this, window_hiview);
-        setWinId((WId)hiview);
-    } else {
-        HIViewAddSubview(window_hiview, hiview);
-    }
-    if (hiview) {
-        Rect win_rect;
-        GetWindowBounds(qt_mac_window_for (window_hiview), kWindowContentRgn, &win_rect);
-        HIRect bounds = CGRectMake(0, 0, win_rect.right-win_rect.left, win_rect.bottom-win_rect.top);
-        HIViewSetFrame(hiview, &bounds);
-        HIViewSetVisible(hiview, true);
-        if (q->testAttribute(Qt::WA_DropSiteRegistered))
-            registerDropSite(true);
-        transferChildren();
-    }
-    initWindowPtr();
-
-    if (topExtra->posFromMove) {
-        updateFrameStrut();
-        const QRect &fStrut = frameStrut();
-        Rect r;
-        SetRect(&r, data.crect.left(), data.crect.top(), data.crect.right() + 1, data.crect.bottom() + 1);
-        SetRect(&r, r.left + fStrut.left(), r.top + fStrut.top(),
-                    (r.left + fStrut.left() + data.crect.width()) - fStrut.right(),
-                    (r.top + fStrut.top() + data.crect.height()) - fStrut.bottom());
-        SetWindowBounds(windowRef, kWindowContentRgn, &r);
-        topExtra->posFromMove = false;
-    }
-
-    if (q->testAttribute(Qt::WA_WState_WindowOpacitySet)){
-        q->setWindowOpacity(topExtra->opacity / 255.0f);
-    } else if (qt_mac_is_macsheet(q)){
-        SetThemeWindowBackground(qt_mac_window_for(q), kThemeBrushSheetBackgroundTransparent, true);
-        CGFloat alpha = 0;
-        GetWindowAlpha(qt_mac_window_for(q), &alpha);
-        if (alpha == 1){
-            // For some reason the 'SetThemeWindowBackground' does not seem
-            // to work. So we do this little hack until it hopefully starts to
-            // work in newer versions of mac OS.
-            q->setWindowOpacity(0.95f);
-            q->setAttribute(Qt::WA_WState_WindowOpacitySet, false);
+            }
         }
-    } else{
-        // If the window has been recreated after beeing e.g. a sheet,
-        // make sure that we don't report a faulty opacity:
-        q->setWindowOpacity(1.0f);
-        q->setAttribute(Qt::WA_WState_WindowOpacitySet, false);
+        if(tmp_wattr)
+            qDebug("Qt: internal: !! Attributes: Unknown (%d)", (int)tmp_wattr);
     }
+#endif
 
-    // Since we only now have a window, sync our state.
-    macUpdateHideOnSuspend();
-    macUpdateOpaqueSizeGrip();
-    macUpdateMetalAttribute();
-    macUpdateIgnoreMouseEvents();
-    setWindowTitle_helper(extra->topextra->caption);
-    setWindowIconText_helper(extra->topextra->iconText);
-    setWindowFilePath_helper(extra->topextra->filePath);
-    setWindowModified_sys(q->isWindowModified());
-    updateFrameStrut();
-    qt_mac_update_sizer(q);
-    applyMaxAndMinSizeOnWindow();
+    topData()->wclass = wclass;
+    topData()->wattr = wattr;
 }
-#else  // QT_MAC_USE_COCOA
+
+#undef ADD_DEBUG_WINDOW_NAME
 
 void QWidgetPrivate::setWindowLevel()
 {
@@ -2398,7 +927,6 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
     applyMaxAndMinSizeOnWindow();
 }
 
-#endif // QT_MAC_USE_COCOA
 
 /*
  Recreates widget window. Useful if immutable
@@ -2409,18 +937,6 @@ void QWidgetPrivate::recreateMacWindow()
     Q_Q(QWidget);
     OSViewRef myView = qt_mac_nativeview_for(q);
     OSWindowRef oldWindow = qt_mac_window_for(myView);
-#ifndef QT_MAC_USE_COCOA
-    HIViewRemoveFromSuperview(myView);
-    determineWindowClass();
-    createWindow_sys();
-
-    if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) {
-        mwl->updateHIToolBarStatus();
-    }
-
-    if (IsWindowVisible(oldWindow))
-        show_sys();
-#else
     QMacCocoaAutoReleasePool pool;
     [myView removeFromSuperview];
     determineWindowClass();
@@ -2436,7 +952,6 @@ void QWidgetPrivate::recreateMacWindow()
         [oldWindow orderOut:oldWindow];
         show_sys();
     }
-#endif // QT_MAC_USE_COCOA
 
     // Release the window after creating the new window, because releasing it early
     // may cause the app to quit ("close on last window closed attribute")
@@ -2463,11 +978,7 @@ void QWidgetPrivate::createWindow_sys()
     if (windowRef == 0)
         qWarning("QWidget: Internal error: %s:%d: If you reach this error please contact Qt Support and include the\n"
                 "      WidgetFlags used in creating the widget.", __FILE__, __LINE__);
-#ifndef QT_MAC_USE_COCOA
-    finishCreateWindow_sys_Carbon(windowRef);
-#else
     finishCreateWindow_sys_Cocoa(windowRef);
-#endif
 }
 
 void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
@@ -2476,9 +987,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
     QMacCocoaAutoReleasePool pool;
 
     OSViewRef destroyid = 0;
-#ifndef QT_MAC_USE_COCOA
-    window_event = 0;
-#endif
 
     Qt::WindowType type = q->windowType();
     Qt::WindowFlags flags = data.window_flags;
@@ -2511,15 +1019,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
                     deskn = dsk->screenNumber(parentWidget);
                 QRect screenGeo = dsk->screenGeometry(deskn);
                 if (!wasResized) {
-#ifndef QT_MAC_USE_COCOA
-                    data.crect.setSize(QSize(screenGeo.width()/2, 4*screenGeo.height()/10));
-#else
                     NSRect newRect = [NSWindow frameRectForContentRect:NSMakeRect(0, 0,
                                                                   screenGeo.width() / 2.,
                                                                   4 * screenGeo.height() / 10.)
                                         styleMask:topData()->wattr];
                     data.crect.setSize(QSize(newRect.size.width, newRect.size.height));
-#endif
                     // Constrain to minimums and maximums we've set
                     if (extra->minw > 0)
                         data.crect.setWidth(qMax(extra->minw, data.crect.width()));
@@ -2545,23 +1049,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
     if(window) {                                // override the old window (with a new NSView)
         OSViewRef nativeView = OSViewRef(window);
         OSViewRef parent = 0;
-#ifndef QT_MAC_USE_COCOA
-        CFRetain(nativeView);
-#else
         [nativeView retain];
-#endif
         if (destroyOldWindow)
             destroyid = qt_mac_nativeview_for(q);
         bool transfer = false;
         setWinId((WId)nativeView);
-#ifndef QT_MAC_USE_COCOA
-#ifndef HIViewInstallEventHandler
-        // Macro taken from the CarbonEvents Header on Tiger
-#define HIViewInstallEventHandler( target, handler, numTypes, list, userData, outHandlerRef ) \
-               InstallEventHandler( HIObjectGetEventTarget( (HIObjectRef) (target) ), (handler), (numTypes), (list), (userData), (outHandlerRef) )
-#endif
-        HIViewInstallEventHandler(nativeView, make_widget_eventUPP(), GetEventTypeCount(widget_events), widget_events, 0, 0);
-#endif
         if(topLevel) {
             for(int i = 0; i < 2; ++i) {
                 if(i == 1) {
@@ -2570,19 +1062,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
                     createWindow_sys();
                 }
                 if(OSWindowRef windowref = qt_mac_window_for(nativeView)) {
-#ifndef QT_MAC_USE_COCOA
-                    CFRetain(windowref);
-#else
                     [windowref retain];
-#endif
                     if (initializeWindow) {
                         parent = qt_mac_get_contentview_for(windowref);
                     } else {
-#ifndef QT_MAC_USE_COCOA
-                        parent = HIViewGetSuperview(nativeView);
-#else
                         parent = [nativeView superview];
-#endif
                     }
                     break;
                 }
@@ -2597,83 +1081,45 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
             parent = qt_mac_nativeview_for(parentWidget);
         }
         if(parent != nativeView && parent) {
-#ifndef QT_MAC_USE_COCOA
-            HIViewAddSubview(parent, nativeView);
-#else
             [parent addSubview:nativeView];
-#endif
         }
         if(transfer)
             transferChildren();
         data.fstrut_dirty = true; // we'll re calculate this later
         q->setAttribute(Qt::WA_WState_Visible,
-#ifndef QT_MAC_USE_COCOA
-                        HIViewIsVisible(nativeView)
-#else
                         ![nativeView isHidden]
-#endif
                         );
         if(initializeWindow) {
-#ifndef QT_MAC_USE_COCOA
-            HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height());
-            HIViewSetFrame(nativeView, &bounds);
-            q->setAttribute(Qt::WA_WState_Visible, HIViewIsVisible(nativeView));
-#else
             NSRect bounds = NSMakeRect(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height());
             [nativeView setFrame:bounds];
             q->setAttribute(Qt::WA_WState_Visible, [nativeView isHidden]);
-#endif
         }
-#ifndef QT_MAC_USE_COCOA
-        initWindowPtr();
-#endif
     } else if (desktop) {                        // desktop widget
         if (!qt_root_win)
             QWidgetPrivate::qt_create_root_win();
         Q_ASSERT(qt_root_win);
         WId rootWinID = 0;
-#ifndef QT_MAC_USE_COCOA
-        CFRetain(qt_root_win);
-        if(HIViewRef rootContentView = HIViewGetRoot(qt_root_win)) {
-            rootWinID = (WId)rootContentView;
-            CFRetain(rootContentView);
-        }
-#else
         [qt_root_win retain];
         if (OSViewRef rootContentView = [qt_root_win contentView]) {
             rootWinID = (WId)rootContentView;
             [rootContentView retain];
         }
-#endif
         setWinId(rootWinID);
     } else if (topLevel) {
         determineWindowClass();
         if(OSViewRef osview = qt_mac_create_widget(q, this, 0)) {
-#ifndef QT_MAC_USE_COCOA
-            HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(),
-                                       data.crect.width(), data.crect.height());
-            HIViewSetFrame(osview, &bounds);
-#else
             NSRect bounds = NSMakeRect(data.crect.x(), flipYCoordinate(data.crect.y()),
                                        data.crect.width(), data.crect.height());
             [osview setFrame:bounds];
-#endif
             setWinId((WId)osview);
         }
     } else {
         data.fstrut_dirty = false; // non-toplevel widgets don't have a frame, so no need to update the strut
 
-#ifdef QT_MAC_USE_COCOA
         if (q->testAttribute(Qt::WA_NativeWindow) == false || q->internalWinId() != 0) {
             // INVARIANT: q is Alien, and we should not create an NSView to back it up.
         } else
-#endif
         if (OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) {
-#ifndef QT_MAC_USE_COCOA
-            HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height());
-            HIViewSetFrame(osview, &bounds);
-            setWinId((WId)osview);
-#else
             NSRect bounds = NSMakeRect(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height());
             [osview setFrame:bounds];
             setWinId((WId)osview);
@@ -2683,7 +1129,6 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
                 QMacCocoaAutoReleasePool pool;
                 [osview setHidden:NO];
             }
-#endif
         }
     }
 
@@ -2710,11 +1155,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
 Qt::HANDLE
 QWidget::macQDHandle() const
 {
-#ifndef QT_MAC_USE_COCOA
-    return d_func()->qd_hd;
-#else
     return 0;
-#endif
 }
 
 /*!
@@ -2773,21 +1214,15 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
             if(OSViewRef hiview = qt_mac_nativeview_for(this)) {
                 OSWindowRef window = 0;
                 NSDrawer *drawer = nil;
-#ifdef QT_MAC_USE_COCOA
                 if (qt_mac_is_macdrawer(this)) {
                     drawer = qt_mac_drawer_for(this);
                 } else
-#endif
                 if (isWindow())
                     window = qt_mac_window_for(hiview);
 
                 // Because of how "destruct" works, we have to do just a normal release for the root_win.
                 if (window && window == qt_root_win) {
-#ifndef QT_MAC_USE_COCOA
-                    CFRelease(hiview);
-#else
                     [hiview release];
-#endif
                 } else {
                     qt_mac_destructView(hiview);
                 }
@@ -2821,9 +1256,6 @@ void QWidgetPrivate::transferChildren()
                 if (!topData()->caption.isEmpty())
                     setWindowTitle_helper(extra->topextra->caption);
                 if (w->internalWinId()) {
-#ifndef QT_MAC_USE_COCOA
-                    HIViewAddSubview(qt_mac_nativeview_for(q), qt_mac_nativeview_for(w));
-#else
                     // New NSWindows get an extra reference when drops are
                     // registered (at least in 10.5) which means that we may
                     // access the window later and get a crash (becasue our
@@ -2836,14 +1268,12 @@ void QWidgetPrivate::transferChildren()
                     [qt_mac_nativeview_for(q) addSubview:qt_mac_nativeview_for(w)];
                     [qt_mac_nativeview_for(w) release];
                     w->setAttribute(Qt::WA_DropSiteRegistered, oldRegistered);
-#endif
                 }
             }
         }
     }
 }
 
-#ifdef QT_MAC_USE_COCOA
 void QWidgetPrivate::setSubWindowStacking(bool set)
 {
     // After hitting too many unforeseen bugs trying to put Qt on top of the cocoa child
@@ -2918,7 +1348,6 @@ void QWidgetPrivate::setSubWindowStacking(bool set)
         }
     }
 }
-#endif
 
 void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
 {
@@ -2926,9 +1355,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
     QMacCocoaAutoReleasePool pool;
     QTLWExtra *topData = maybeTopData();
     bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
-#ifdef QT_MAC_USE_COCOA
     bool wasWindow = q->isWindow();
-#endif
     OSViewRef old_id = 0;
 
     if (q->isVisible() && q->parentWidget() && parent != q->parentWidget())
@@ -2949,18 +1376,11 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
         }
     }
 
-#ifndef QT_MAC_USE_COCOA
-    EventHandlerRef old_window_event = 0;
-#else
     bool oldToolbarVisible = false;
     NSDrawer *oldDrawer = nil;
     NSToolbar *oldToolbar = 0;
-#endif
     if (wasCreated && !(q->windowType() == Qt::Desktop)) {
         old_id = qt_mac_nativeview_for(q);
-#ifndef QT_MAC_USE_COCOA
-        old_window_event = window_event;
-#else
         if (qt_mac_is_macdrawer(q)) {
             oldDrawer = qt_mac_drawer_for(q);
         }
@@ -2973,7 +1393,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
                 [oldWindow setToolbar:nil];
             }
         }
-#endif
     }
     QWidget* oldtlw = q->window();
 
@@ -3006,15 +1425,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
     if (wasCreated || (nativeWidget && nonWindowWithCreatedParent)) {
         createWinId();
         if (q->isWindow()) {
-#ifndef QT_MAC_USE_COCOA
-            // We do this down below for wasCreated, so avoid doing this twice
-            // (only for performance, it gets called a lot anyway).
-            if (!wasCreated) {
-                if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) {
-                    mwl->updateHIToolBarStatus();
-                }
-            }
-#else
             // Simply transfer our toolbar over. Everything should stay put, unlike in Carbon.
             if (oldToolbar && !(f & Qt::FramelessWindowHint)) {
                 OSWindowRef newWindow = qt_mac_window_for(q);
@@ -3022,7 +1432,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
                 [oldToolbar release];
                 [oldToolbar setVisible:oldToolbarVisible];
             }
-#endif
         }
     }
     if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden)
@@ -3031,15 +1440,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
 
     if (wasCreated) {
         transferChildren();
-#ifndef QT_MAC_USE_COCOA
-        // If we were a unified window, We just transfered our toolbars out of the unified toolbar.
-        // So redo the status one more time. It apparently is not an issue with Cocoa.
-        if (q->isWindow()) {
-            if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) {
-                mwl->updateHIToolBarStatus();
-            }
-        }
-#endif
 
         if (topData &&
                 (!topData->caption.isEmpty() || !topData->filePath.isEmpty()))
@@ -3052,19 +1452,13 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
         q->setAttribute(Qt::WA_DropSiteRegistered, true);
 
     //cleanup
-#ifndef QT_MAC_USE_COCOA
-    if (old_window_event)
-        RemoveEventHandler(old_window_event);
-#endif
     if (old_id) { //don't need old window anymore
         OSWindowRef window = (oldtlw == q) ? qt_mac_window_for(old_id) : 0;
         qt_mac_destructView(old_id);
 
-#ifdef QT_MAC_USE_COCOA
         if (oldDrawer) {
             qt_mac_destructDrawer(oldDrawer);
         } else
-#endif
         if (window)
             qt_mac_destructWindow(window);
     }
@@ -3091,14 +1485,6 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
         QPoint p = pos + data->crect.topLeft();
         return isWindow() ?  p : parentWidget()->mapToGlobal(p);
     }
-#ifndef QT_MAC_USE_COCOA
-    QPoint tmp = d->mapToWS(pos);
-    HIPoint hi_pos = CGPointMake(tmp.x(), tmp.y());
-    HIViewConvertPoint(&hi_pos, qt_mac_nativeview_for(this), 0);
-    Rect win_rect;
-    GetWindowBounds(qt_mac_window_for(this), kWindowStructureRgn, &win_rect);
-    return QPoint((int)hi_pos.x+win_rect.left, (int)hi_pos.y+win_rect.top);
-#else
     QPoint tmp = d->mapToWS(pos);
     NSPoint hi_pos = NSMakePoint(tmp.x(), tmp.y());
     hi_pos = [qt_mac_nativeview_for(this) convertPoint:hi_pos toView:nil];
@@ -3108,7 +1494,6 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
     // If we aren't the desktop we need to flip, if you flip the desktop on itself, you get the other problem.
     return ((window()->windowFlags() & Qt::Desktop) == Qt::Desktop) ? QPointF(hi_pos.x, hi_pos.y).toPoint()
                                                                     : flipPoint(hi_pos).toPoint();
-#endif
 }
 
 QPoint QWidget::mapFromGlobal(const QPoint &pos) const
@@ -3118,13 +1503,6 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const
         QPoint p = isWindow() ?  pos : parentWidget()->mapFromGlobal(pos);
         return p - data->crect.topLeft();
     }
-#ifndef QT_MAC_USE_COCOA
-    Rect win_rect;
-    GetWindowBounds(qt_mac_window_for(this), kWindowStructureRgn, &win_rect);
-    HIPoint hi_pos = CGPointMake(pos.x()-win_rect.left, pos.y()-win_rect.top);
-    HIViewConvertPoint(&hi_pos, 0, qt_mac_nativeview_for(this));
-    return d->mapFromWS(QPoint((int)hi_pos.x, (int)hi_pos.y));
-#else
     NSRect win_rect = [qt_mac_window_for(this) frame];
     // The Window point is in "Cocoa coordinates," but the view is in "Qt coordinates"
     // so make sure to keep them in sync.
@@ -3132,7 +1510,6 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const
                                  flipYCoordinate(pos.y())-win_rect.origin.y);
     hi_pos = [qt_mac_nativeview_for(this) convertPoint:hi_pos fromView:0];
     return d->mapFromWS(QPoint(qRound(hi_pos.x), qRound(hi_pos.y)));
-#endif
 }
 
 void QWidgetPrivate::updateSystemBackground()
@@ -3153,12 +1530,8 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
 {
     Q_Q(QWidget);
     if (q->isWindow()) {
-#ifndef QT_MAC_USE_COCOA
-        SetWindowTitleWithCFString(qt_mac_window_for(q), QCFString(caption));
-#else
         QMacCocoaAutoReleasePool pool;
         [qt_mac_window_for(q) setTitle:qt_mac_QStringToNSString(caption)];
-#endif
     }
 }
 
@@ -3166,42 +1539,16 @@ void QWidgetPrivate::setWindowModified_sys(bool mod)
 {
     Q_Q(QWidget);
     if (q->isWindow() && q->testAttribute(Qt::WA_WState_Created)) {
-#ifndef QT_MAC_USE_COCOA
-        SetWindowModified(qt_mac_window_for(q), mod);
-#else
         [qt_mac_window_for(q) setDocumentEdited:mod];
-#endif
     }
 }
 
 void QWidgetPrivate::setWindowFilePath_sys(const QString &filePath)
 {
     Q_Q(QWidget);
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     QFileInfo fi(filePath);
     [qt_mac_window_for(q) setRepresentedFilename:fi.exists() ? qt_mac_QStringToNSString(filePath) : @""];
-#else
-    bool validRef = false;
-    FSRef ref;
-    bzero(&ref, sizeof(ref));
-    OSStatus status;
-
-    if (!filePath.isEmpty()) {
-        status = FSPathMakeRef(reinterpret_cast<const UInt8 *>(filePath.toUtf8().constData()), &ref, 0);
-        validRef = (status == noErr);
-    }
-    // Set the proxy regardless, since this is our way of clearing it as well, but ignore the
-    // return value as well.
-    if (validRef) {
-        status = HIWindowSetProxyFSRef(qt_mac_window_for(q), &ref);
-    } else {
-        status = RemoveWindowProxy(qt_mac_window_for(q));
-    }
-    if (status != noErr)
-        qWarning("QWidget::setWindowFilePath: Error setting proxyicon for path (%s):%ld",
-                qPrintable(filePath), status);
-#endif
 }
 
 void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
@@ -3227,28 +1574,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
         }
     }
     if (q->isWindow()) {
-#ifndef QT_MAC_USE_COCOA
-        IconRef previousIcon = 0;
-        if (icon.isNull()) {
-            RemoveWindowProxy(qt_mac_window_for(q));
-            previousIcon = topData->windowIcon;
-            topData->windowIcon = 0;
-        } else {
-            WindowClass wclass;
-            GetWindowClass(qt_mac_window_for(q), &wclass);
-
-            if (wclass == kDocumentWindowClass) {
-                IconRef newIcon = qt_mac_create_iconref(*pm);
-                previousIcon = topData->windowIcon;
-                topData->windowIcon = newIcon;
-                SetWindowProxyIcon(qt_mac_window_for(q), newIcon);
-            }
-        }
-
-        // Release the previous icon if it was set by this function.
-        if (previousIcon != 0)
-            ReleaseIconRef(previousIcon);
-#else
         QMacCocoaAutoReleasePool pool;
         if (icon.isNull())
             return;
@@ -3267,7 +1592,6 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
             [iconButton setImage:image];
             [image release];
         }
-#endif
     }
 }
 
@@ -3275,12 +1599,8 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
 {
     Q_Q(QWidget);
     if(q->isWindow() && !iconText.isEmpty()) {
-#ifndef QT_MAC_USE_COCOA
-        SetWindowAlternateTitle(qt_mac_window_for(q), QCFString(iconText));
-#else
         QMacCocoaAutoReleasePool pool;
         [qt_mac_window_for(q) setMiniwindowTitle:qt_mac_QStringToNSString(iconText)];
-#endif
     }
 }
 
@@ -3363,28 +1683,15 @@ void QWidget::activateWindow()
 
     bool windowActive;
     OSWindowRef win = qt_mac_window_for(tlw);
-#ifndef QT_MAC_USE_COCOA
-    windowActive = IsWindowActive(win);
-#else
     QMacCocoaAutoReleasePool pool;
     windowActive = [win isKeyWindow];
-#endif
     if ((tlw->windowType() == Qt::Popup)
             || (tlw->windowType() == Qt::Tool)
             || qt_mac_is_macdrawer(tlw)
             || windowActive) {
-#ifndef QT_MAC_USE_COCOA
-        ActivateWindow(win, true);
-        qApp->setActiveWindow(tlw);
-#else
         [win makeKeyWindow];
-#endif
     } else if(!isMinimized()) {
-#ifndef QT_MAC_USE_COCOA
-        SelectWindow(win);
-#else
         [win makeKeyAndOrderFront:win];
-#endif
     }
 }
 
@@ -3431,47 +1738,22 @@ void QWidgetPrivate::show_sys()
         return;
 
     bool realWindow = isRealWindow();
-#ifndef QT_MAC_USE_COCOA
-    if (realWindow && !q->testAttribute(Qt::WA_Moved)) {
-        if (qt_mac_is_macsheet(q))
-            recreateMacWindow();
-        q->createWinId();
-        if (QWidget *p = q->parentWidget()) {
-            p->createWinId();
-            RepositionWindow(qt_mac_window_for(q), qt_mac_window_for(p), kWindowCenterOnParentWindow);
-        } else {
-            RepositionWindow(qt_mac_window_for(q), 0, kWindowCenterOnMainScreen);
-        }
-    }
-#endif
 
     data.fstrut_dirty = true;
     if (realWindow) {
         bool isCurrentlyMinimized = (q->windowState() & Qt::WindowMinimized);
         setModal_sys();
         OSWindowRef window = qt_mac_window_for(q);
-#ifndef QT_MAC_USE_COCOA
-        SizeWindow(window, q->width(), q->height(), true);
-#endif
 
-#ifdef QT_MAC_USE_COCOA
         // Make sure that we end up sending a repaint event to
         // the widget if the window has been visible one before:
         [qt_mac_get_contentview_for(window) setNeedsDisplay:YES];
-#endif
         if(qt_mac_is_macsheet(q)) {
             qt_event_request_showsheet(q);
         } else if(qt_mac_is_macdrawer(q)) {
-#ifndef QT_MAC_USE_COCOA
-            OpenDrawer(window, kWindowEdgeDefault, false);
-#else
             NSDrawer *drawer = qt_mac_drawer_for(q);
             [drawer openOnEdge:[drawer preferredEdge]];
-#endif
         } else {
-#ifndef QT_MAC_USE_COCOA
-            ShowHide(window, true);
-#else
             // sync the opacity value back (in case of a fade).
             [window setAlphaValue:q->windowOpacity()];
 
@@ -3494,7 +1776,6 @@ void QWidgetPrivate::show_sys()
             }
             setSubWindowStacking(true);
             qt_mac_update_cursor();
-#endif
             if (q->windowType() == Qt::Popup) {
                 qt_button_down = 0;
                 if (q->focusWidget())
@@ -3505,20 +1786,10 @@ void QWidgetPrivate::show_sys()
             toggleDrawers(true);
         }
         if (isCurrentlyMinimized) { //show in collapsed state
-#ifndef QT_MAC_USE_COCOA
-            CollapseWindow(window, true);
-#else
             [window miniaturize:window];
-#endif
         } else if (!q->testAttribute(Qt::WA_ShowWithoutActivating)) {
-#ifndef QT_MAC_USE_COCOA
-            qt_event_request_activate(q);
-#endif
         }
     } else if(topData()->embedded || !q->parentWidget() || q->parentWidget()->isVisible()) {
-#ifndef QT_MAC_USE_COCOA
-        HIViewSetVisible(qt_mac_nativeview_for(q), true);
-#else
         if (NSView *view = qt_mac_nativeview_for(q)) {
             // INVARIANT: q is native. Just show the view:
             [view setHidden:NO];
@@ -3526,10 +1797,8 @@ void QWidgetPrivate::show_sys()
             // INVARIANT: q is alien. Update q instead:
             q->update();
         }
-#endif
     }
 
-#ifdef QT_MAC_USE_COCOA
     if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
         // Update enter/leave immidiatly, don't wait for a move event. But only
         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
@@ -3541,7 +1810,6 @@ void QWidgetPrivate::show_sys()
         qt_last_native_mouse_receiver = widgetUnderMouse ?
             (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0;
     }
-#endif
 
     topLevelAt_cache = 0;
     qt_event_request_window_change(q);
@@ -3549,13 +1817,7 @@ void QWidgetPrivate::show_sys()
 
 QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt)
 {
-#ifndef QT_MAC_USE_COCOA
-    CGPoint nativePoint = CGPointMake(pt.x(), pt.y());
-    HIViewConvertPoint(&nativePoint, qt_mac_nativeview_for(child->parentWidget()),
-                       qt_mac_nativeview_for(child));
-#else
     NSPoint nativePoint = [qt_mac_nativeview_for(child) convertPoint:NSMakePoint(pt.x(), pt.y()) fromView:qt_mac_nativeview_for(child->parentWidget())];
-#endif
     return QPoint(nativePoint.x, nativePoint.y);
 }
 
@@ -3567,31 +1829,14 @@ void QWidgetPrivate::hide_sys()
         return;
     QMacCocoaAutoReleasePool pool;
     if(q->isWindow()) {
-#ifdef QT_MAC_USE_COCOA
         setSubWindowStacking(false);
-#endif
         OSWindowRef window = qt_mac_window_for(q);
         if(qt_mac_is_macsheet(q)) {
-#ifndef QT_MAC_USE_COCOA
-            WindowRef parent = 0;
-            if(GetSheetWindowParent(window, &parent) != noErr || !parent)
-                ShowHide(window, false);
-            else
-                HideSheetWindow(window);
-#else
             [NSApp endSheet:window];
             [window orderOut:window];
-#endif
         } else if(qt_mac_is_macdrawer(q)) {
-#ifndef QT_MAC_USE_COCOA
-            CloseDrawer(window, false);
-#else
             [qt_mac_drawer_for(q) close];
-#endif
         } else {
-#ifndef QT_MAC_USE_COCOA
-            ShowHide(window, false);
-#else
             [window orderOut:window];
             // Unfortunately it is not as easy as just hiding the window, we need
             // to find out if we were in full screen mode. If we were and this is
@@ -3625,56 +1870,11 @@ void QWidgetPrivate::hide_sys()
                 if(!keepFullScreen)
                     qt_mac_set_fullscreen_mode(false);
             }
-#endif
             toggleDrawers(false);
             qt_mac_update_cursor();
-#ifndef QT_MAC_USE_COCOA
-            // Clear modality (because it seems something that we've always done).
-            if (data.window_modality != Qt::NonModal) {
-                SetWindowModality(window, kWindowModalityNone,
-                          q->parentWidget() ? qt_mac_window_for(q->parentWidget()->window()) : 0);
-            }
-#endif
-        }
-#ifndef QT_MAC_USE_COCOA
-        // If the window we now hide was the active window, we need
-        // to find, and activate another window on screen. NB: Cocoa takes care of this
-        // logic for us (and distinquishes between main windows and key windows)
-        if (q->isActiveWindow() && !(q->windowType() == Qt::Popup)) {
-            QWidget *w = 0;
-            if(q->parentWidget())
-                w = q->parentWidget()->window();
-            if(!w || (!w->isVisible() && !w->isMinimized())) {
-                for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true);
-                    wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) {
-                    if((w = qt_mac_find_window(wp)))
-                        break;
-                }
-                if (!w){
-                    for (WindowPtr wp = GetFrontWindowOfClass(kDocumentWindowClass, true);
-                            wp; wp = GetNextWindowOfClass(wp, kDocumentWindowClass, true)) {
-                        if((w = qt_mac_find_window(wp)))
-                            break;
-                    }
-                }
-                if (!w){
-                    for(WindowPtr wp = GetFrontWindowOfClass(kSimpleWindowClass, true);
-                        wp; wp = GetNextWindowOfClass(wp, kSimpleWindowClass, true)) {
-                        if((w = qt_mac_find_window(wp)))
-                            break;
-                    }
-                }
-            }
-            if(w && w->isVisible() && !w->isMinimized()) {
-                qt_event_request_activate(w);
-            }
         }
-#endif
     } else {
          invalidateBuffer(q->rect());
-#ifndef QT_MAC_USE_COCOA
-        HIViewSetVisible(qt_mac_nativeview_for(q), false);
-#else
         if (NSView *view = qt_mac_nativeview_for(q)) {
             // INVARIANT: q is native. Just hide the view:
             [view setHidden:YES];
@@ -3682,10 +1882,8 @@ void QWidgetPrivate::hide_sys()
             // INVARIANT: q is alien. Repaint where q is placed instead:
             qt_mac_updateParentUnderAlienWidget(q);
         }
-#endif
     }
 
-#ifdef QT_MAC_USE_COCOA
     if ([NSApp isActive] && !qt_button_down && !QWidget::mouseGrabber()){
         // Update enter/leave immidiatly, don't wait for a move event. But only
         // if no grab exists (even if the grab points to this widget, it seems, ref X11)
@@ -3697,7 +1895,6 @@ void QWidgetPrivate::hide_sys()
         qt_last_native_mouse_receiver = widgetUnderMouse ?
             (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0;
      }
-#endif
 
     topLevelAt_cache = 0;
     qt_event_request_window_change(q);
@@ -3713,9 +1910,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
     if (oldstate == newstate)
         return;
 
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
-#endif
     bool needSendStateChange = true;
     if(isWindow()) {
         if((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {
@@ -3749,17 +1944,9 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
         OSWindowRef window = qt_mac_window_for(this);
         if((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
             if (newstate & Qt::WindowMinimized) {
-#ifndef QT_MAC_USE_COCOA
-                CollapseWindow(window, true);
-#else
                 [window miniaturize:window];
-#endif
             } else {
-#ifndef QT_MAC_USE_COCOA
-                CollapseWindow(window, false);
-#else
                 [window deminiaturize:window];
-#endif
             }
             needSendStateChange = oldstate == windowState(); // Collapse didn't change our flags.
         }
@@ -3788,45 +1975,6 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
             (oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized))) {
             if(newstate & Qt::WindowMaximized) {
                 data->fstrut_dirty = true;
-#ifndef QT_MAC_USE_COCOA
-                HIToolbarRef toolbarRef;
-                if (GetWindowToolbar(window, &toolbarRef) == noErr && toolbarRef
-                        && !isVisible() && !IsWindowToolbarVisible(window)) {
-                    // HIToolbar, needs to be shown so that it's in the structure window
-                    // Typically this is part of a main window and will get shown
-                    // during the show, but it's will make the maximize all wrong.
-                    ShowHideWindowToolbar(window, true, false);
-                    d->updateFrameStrut();  // In theory the dirty would work, but it's optimized out if the window is not visible :(
-                }
-                Rect bounds;
-                QDesktopWidget *dsk = QApplication::desktop();
-                QRect avail = dsk->availableGeometry(dsk->screenNumber(this));
-                SetRect(&bounds, avail.x(), avail.y(), avail.x() + avail.width(), avail.y() + avail.height());
-                if(QWExtra *extra = d->extraData()) {
-                    if(bounds.right - bounds.left > extra->maxw)
-                        bounds.right = bounds.left + extra->maxw;
-                    if(bounds.bottom - bounds.top > extra->maxh)
-                        bounds.bottom = bounds.top + extra->maxh;
-                }
-                if(d->topData()) {
-                    QRect fs = d->frameStrut();
-                    bounds.left += fs.left();
-                    if(bounds.right < avail.x()+avail.width())
-                        bounds.right = qMin<short>((uint)avail.x()+avail.width(), bounds.right+fs.left());
-                    if(bounds.bottom < avail.y()+avail.height())
-                        bounds.bottom = qMin<short>((uint)avail.y()+avail.height(), bounds.bottom+fs.top());
-                    bounds.top += fs.top();
-                    bounds.right -= fs.right();
-                    bounds.bottom -= fs.bottom();
-                }
-                QRect orect(geometry().x(), geometry().y(), width(), height()),
-                      nrect(bounds.left, bounds.top, bounds.right - bounds.left,
-                            bounds.bottom - bounds.top);
-                if(orect != nrect) { // the new rect differ from the old
-                    Point idealSize  = { nrect.height(), nrect.width() };
-                    ZoomWindowIdeal(window, inZoomOut, &idealSize);
-                }
-#else
                 NSToolbar *toolbarRef = [window toolbar];
                 if (toolbarRef && !isVisible() && ![toolbarRef isVisible]) {
                     // HIToolbar, needs to be shown so that it's in the structure window
@@ -3839,15 +1987,9 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
                 }
                 // Everything should be handled by Cocoa.
                 [window zoom:window];
-#endif
                 needSendStateChange = oldstate == windowState(); // Zoom didn't change flags.
             } else if(oldstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen)) {
-#ifndef QT_MAC_USE_COCOA
-                Point idealSize;
-                ZoomWindowIdeal(window, inZoomIn, &idealSize);
-#else
                 [window zoom:window];
-#endif
                 if(QTLWExtra *tlextra = d->topData()) {
                     setGeometry(tlextra->normalGeometry);
                     tlextra->normalGeometry.setRect(0, 0, -1, -1);
@@ -3875,13 +2017,9 @@ void QWidgetPrivate::setFocus_sys()
 {
     Q_Q(QWidget);
     if (q->testAttribute(Qt::WA_WState_Created)) {
-#ifdef QT_MAC_USE_COCOA
         QMacCocoaAutoReleasePool pool;
         NSView *view = qt_mac_nativeview_for(q);
         [[view window] makeFirstResponder:view];
-#else
-        SetKeyboardFocus(qt_mac_window_for(q), qt_mac_nativeview_for(q), 1);
-#endif
     }
 }
 
@@ -3901,7 +2039,6 @@ void QWidgetPrivate::raise_sys()
     if((q->windowType() == Qt::Desktop))
         return;
 
-#if QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     if (isRealWindow()) {
         // With the introduction of spaces it is not as simple as just raising the window.
@@ -3947,20 +2084,6 @@ void QWidgetPrivate::raise_sys()
         [parentView sortSubviewsUsingFunction:compareViews2Raise context:reinterpret_cast<void *>(view)];
     }
     topLevelAt_cache = 0;
-#else
-    if(q->isWindow()) {
-        //raise this window
-        BringToFront(qt_mac_window_for(q));
-        if(qt_mac_raise_process) { //we get to be the active process now
-            ProcessSerialNumber psn;
-            GetCurrentProcess(&psn);
-            SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
-        }
-    } else if(q->parentWidget()) {
-        HIViewSetZOrder(qt_mac_nativeview_for(q), kHIViewZOrderAbove, 0);
-        qt_event_request_window_change(q);
-    }
-#endif
 }
 
 NSComparisonResult compareViews2Lower(id view1, id view2, void *context)
@@ -3978,7 +2101,6 @@ void QWidgetPrivate::lower_sys()
     Q_Q(QWidget);
     if((q->windowType() == Qt::Desktop))
         return;
-#ifdef QT_MAC_USE_COCOA
     if (isRealWindow()) {
         OSWindowRef window = qt_mac_window_for(q);
         [window orderBack:window];
@@ -3988,15 +2110,6 @@ void QWidgetPrivate::lower_sys()
         [parentView sortSubviewsUsingFunction:compareViews2Lower context:reinterpret_cast<void *>(view)];
     }
     topLevelAt_cache = 0;
-#else
-    if(q->isWindow()) {
-        SendBehind(qt_mac_window_for(q), 0);
-    } else if(q->parentWidget()) {
-        invalidateBuffer(q->rect());
-        HIViewSetZOrder(qt_mac_nativeview_for(q), kHIViewZOrderBelow, 0);
-        qt_event_request_window_change(q);
-    }
-#endif
 }
 
 NSComparisonResult compareViews2StackUnder(id view1, id view2, void *context)
@@ -4015,7 +2128,6 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w)
     Q_Q(QWidget);
     if(!w || q->isWindow() || (q->windowType() == Qt::Desktop))
         return;
-#ifdef QT_MAC_USE_COCOA
     // Do the same trick as lower_sys() and put this widget before the widget passed in.
     NSView *myView = qt_mac_nativeview_for(q);
     NSView *wView = qt_mac_nativeview_for(w);
@@ -4034,117 +2146,8 @@ void QWidgetPrivate::stackUnder_sys(QWidget *w)
     viewOrder[myView] = viewOrder[wView] - 1;
 
     [parentView sortSubviewsUsingFunction:compareViews2StackUnder context:reinterpret_cast<void *>(&viewOrder)];
-#else
-    QWidget *p = q->parentWidget();
-    if(!p || p != w->parentWidget())
-        return;
-    invalidateBuffer(q->rect());
-    HIViewSetZOrder(qt_mac_nativeview_for(q), kHIViewZOrderBelow, qt_mac_nativeview_for(w));
-    qt_event_request_window_change(q);
-#endif
 }
 
-#ifndef QT_MAC_USE_COCOA
-/*
-    Modifies the bounds for a widgets backing HIView during moves and resizes. Also updates the
-    widget, either by scrolling its contents or repainting, depending on the WA_StaticContents
-    flag
-*/
-static void qt_mac_update_widget_position(QWidget *q, QRect oldRect, QRect newRect)
-{
-    HIRect bounds = CGRectMake(newRect.x(), newRect.y(),
-                               newRect.width(), newRect.height());
-
-    const HIViewRef view = qt_mac_nativeview_for(q);
-    const bool isMove = (oldRect.topLeft() != newRect.topLeft());
-    const bool isResize = (oldRect.size() != newRect.size());
-
-//    qDebug() << oldRect << newRect << isMove << isResize << q->testAttribute(Qt::WA_OpaquePaintEvent) << q->testAttribute(Qt::WA_StaticContents);
-    QWidgetPrivate *qd = qt_widget_private(q);
-
-    // Perform a normal (complete repaint) update in some cases:
-    if (
-        // always repaint on move.
-        (isMove) ||
-
-        // limited update on resize requires WA_StaticContents.
-        (isResize && q->testAttribute(Qt::WA_StaticContents) == false) ||
-
-        // one of the rects are invalid
-        (oldRect.isValid() == false || newRect.isValid() == false)  ||
-
-        // the position update is a part of a drag-and-drop operation
-        QDragManager::self()->object ||
-
-        // we are on Panther (no HIViewSetNeedsDisplayInRect)
-        QSysInfo::MacintoshVersion < QSysInfo::MV_10_4
-    ){
-        HIViewSetFrame(view, &bounds);
-        return;
-    }
-
-    const int dx = newRect.x() - oldRect.x();
-    const int dy = newRect.y() - oldRect.y();
-
-    if (isMove) {
-        // HIViewScrollRect silently fails if we try to scroll anything under the grow box.
-        // Check if there's one present within the widget rect, and if there is fall back
-        // to repainting the entire widget.
-        QWidget const * const parentWidget = q->parentWidget();
-        const HIViewRef parentView = qt_mac_nativeview_for(parentWidget);
-        HIViewRef nativeSizeGrip = 0;
-        if (q->testAttribute(Qt::WA_WState_Created))
-            HIViewFindByID(HIViewGetRoot(HIViewGetWindow(HIViewRef(q->winId()))), kHIViewWindowGrowBoxID, &nativeSizeGrip);
-        if (nativeSizeGrip) {
-            QWidget * const window = q->window();
-
-            const int sizeGripSize = 20;
-            const QRect oldWidgetRect = QRect(q->mapTo(window, QPoint(0, 0)), QSize(oldRect.width(), oldRect.height()));
-            const QRect newWidgetRect = QRect(q->mapTo(window, QPoint(0, 0)), QSize(newRect.width(), newRect.height()));
-            const QRect sizeGripRect = QRect(window->rect().bottomRight() - QPoint(sizeGripSize, sizeGripSize),
-                                             window->rect().bottomRight());
-
-            if (sizeGripRect.intersects(oldWidgetRect) || sizeGripRect.intersects(newWidgetRect)) {
-                HIViewSetFrame(view, &bounds);
-                return;
-            }
-        }
-
-        // Don't scroll anything outside the parent widget rect.
-        const QRect scrollRect = (oldRect | newRect) & parentWidget->rect();
-        const HIRect scrollBounds =
-            CGRectMake(scrollRect.x(), scrollRect.y(), scrollRect.width(), scrollRect.height());
-
-        // We cannot scroll when the widget has a mask as that would
-        // scroll the masked out areas too
-        if (qd->extra && qd->extra->hasMask) {
-            HIViewMoveBy(view, dx, dy);
-            return;
-        }
-
-        OSStatus err = HIViewScrollRect(parentView, &scrollBounds, dx, dy);
-        if (err != noErr) {
-            HIViewSetNeedsDisplay(view, true);
-            qWarning("QWidget: Internal error (%s:%d)", __FILE__, __LINE__);
-        }
-    }
-    // Set the view bounds with drawing disabled to prevent repaints.
-    HIViewSetDrawingEnabled(view, false);
-    HIViewSetFrame(view, &bounds);
-    HIViewSetDrawingEnabled(view, true);
-
-    // Update any newly exposed areas due to resizing.
-    const int startx = oldRect.width();
-    const int stopx = newRect.width();
-    const int starty = oldRect.height();
-    const int stopy = newRect.height();
-
-    const HIRect verticalSlice = CGRectMake(startx, 0, stopx , stopy);
-    HIViewSetNeedsDisplayInRect(view, &verticalSlice, true);
-    const HIRect horizontalSlice = CGRectMake(0, starty, startx, stopy);
-    HIViewSetNeedsDisplayInRect(view, &horizontalSlice, true);
-}
-#endif
 
 /*
   Helper function for non-toplevel widgets. Helps to map Qt's 32bit
@@ -4198,26 +2201,15 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
     // Embedded have different meaning on each platform, and on
     // Mac, it means that q is a QMacNativeWidget.
     bool isEmbeddedWindow = (q->isWindow() && topData()->embedded);
-#ifdef QT_MAC_USE_COCOA
     NSView *nsview = qt_mac_nativeview_for(q);
-#endif
     if (!isEmbeddedWindow) {
         parentWRect = q->parentWidget()->data->wrect;
     } else {
         // INVARIANT: q's parent view is not owned by Qt. So we need to
         // do some extra calls to get the clipped rect of the parent view:
-#ifndef QT_MAC_USE_COCOA
-        HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q));
-#else
         NSView *parentView = [qt_mac_nativeview_for(q) superview];
-#endif
         if (parentView) {
-#ifndef QT_MAC_USE_COCOA
-            HIRect tmpRect;
-            HIViewGetFrame(parentView, &tmpRect);
-#else
             NSRect tmpRect = [parentView frame];
-#endif
             parentWRect = QRect(tmpRect.origin.x, tmpRect.origin.y,
                                 tmpRect.size.width, tmpRect.size.height);
         } else {
@@ -4255,11 +2247,6 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
             if (data.wrect.contains(vrect)) {
                 wrectInParentCoordSys = data.wrect;
                 wrectInParentCoordSys.translate(data.crect.topLeft());
-#ifndef QT_MAC_USE_COCOA
-                HIRect bounds = CGRectMake(wrectInParentCoordSys.x(), wrectInParentCoordSys.y(),
-                                           wrectInParentCoordSys.width(), wrectInParentCoordSys.height());
-                HIViewSetFrame(qt_mac_nativeview_for(q), &bounds);
-#else
                 if (nsview) {
                     // INVARIANT: q is native. Set view frame:
                     NSRect bounds = NSMakeRect(wrectInParentCoordSys.x(), wrectInParentCoordSys.y(),
@@ -4275,43 +2262,18 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
 
                     nativeParent->update(dirtyWRect);
                 }
-#endif
                 if (q->testAttribute(Qt::WA_OutsideWSRange)) {
                     q->setAttribute(Qt::WA_OutsideWSRange, false);
                     if (!dontShow) {
                         q->setAttribute(Qt::WA_Mapped);
-#ifndef QT_MAC_USE_COCOA
-                        HIViewSetVisible(qt_mac_nativeview_for(q), true);
-#else
                         // If q is Alien, the following call does nothing:
                         [nsview setHidden:NO];
-#endif
                     }
                 }
                 return;
             }
         }
 
-#ifndef QT_MAC_USE_COCOA
-        const QRect validRange(-XCOORD_MAX,-XCOORD_MAX, 2*XCOORD_MAX, 2*XCOORD_MAX);
-        if (!validRange.contains(wrectInParentCoordSys)) {
-            // We're too big, and must clip:
-            QPoint screenOffset(0, 0); // offset of the part being on screen
-            const QWidget *parentWidget = q->parentWidget();
-            while (parentWidget && !parentWidget->isWindow()) {
-                screenOffset -= parentWidget->data->crect.topLeft();
-                parentWidget = parentWidget->parentWidget();
-            }
-            QRect cropRect(screenOffset.x() - WRECT_MAX,
-                           screenOffset.y() - WRECT_MAX,
-                           2*WRECT_MAX,
-                           2*WRECT_MAX);
-
-            wrectInParentCoordSys &=cropRect;
-            wrect = wrectInParentCoordSys;
-            wrect.translate(-data.crect.topLeft());
-        }
-#endif //QT_MAC_USE_COCOA
     }
 
     // unmap if we are outside the valid window system coord system
@@ -4320,12 +2282,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
     if (q->testAttribute(Qt::WA_OutsideWSRange) != outsideRange) {
         q->setAttribute(Qt::WA_OutsideWSRange, outsideRange);
         if (outsideRange) {
-#ifndef QT_MAC_USE_COCOA
-            HIViewSetVisible(qt_mac_nativeview_for(q), false);
-#else
             // If q is Alien, the following call does nothing:
             [nsview setHidden:YES];
-#endif
             q->setAttribute(Qt::WA_Mapped, false);
         } else if (!q->isHidden()) {
             mapWindow = true;
@@ -4350,12 +2308,6 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
         }
     }
 
-#ifndef QT_MAC_USE_COCOA
-    // Move the actual HIView:
-    qt_mac_update_widget_position(q, oldRect, wrectInParentCoordSys);
-    if (jump)
-        q->update();
-#else
     if (nsview) {
         // INVARIANT: q is native. Move the actual NSView:
         NSRect bounds = NSMakeRect(
@@ -4391,16 +2343,11 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
             nativeParent->update(dirtyOldWRect | dirtyNewWRect);
         }
     }
-#endif
 
     if (mapWindow && !dontShow) {
         q->setAttribute(Qt::WA_Mapped);
-#ifndef QT_MAC_USE_COCOA
-        HIViewSetVisible(qt_mac_nativeview_for(q), true);
-#else
         // If q is Alien, the following call does nothing:
         [nsview setHidden:NO];
-#endif
     }
 }
 
@@ -4437,20 +2384,12 @@ void QWidgetPrivate::applyMaxAndMinSizeOnWindow()
     QMacCocoaAutoReleasePool pool;
 
     const float max_f(20000);
-#ifndef QT_MAC_USE_COCOA
-#define SF(x) ((x > max_f) ? max_f : x)
-    HISize max = CGSizeMake(SF(extra->maxw), SF(extra->maxh));
-    HISize min = CGSizeMake(SF(extra->minw), SF(extra->minh));
-#undef SF
-    SetWindowResizeLimits(qt_mac_window_for(q), &min, &max);
-#else
 #define SF(x) ((x > max_f) ? max_f : x)
     NSSize max = NSMakeSize(SF(extra->maxw), SF(extra->maxh));
     NSSize min = NSMakeSize(SF(extra->minw), SF(extra->minh));
 #undef SF
     [qt_mac_window_for(q) setContentMinSize:min];
     [qt_mac_window_for(q) setContentMaxSize:max];
-#endif
 }
 
 void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
@@ -4466,17 +2405,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
 
     if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){
         adjustWithinMaxAndMinSize(w, h);
-#ifndef QT_MAC_USE_COCOA
-        if (w != 0 && h != 0) {
-            topData()->isSetGeometry = 1;
-            topData()->isMove = isMove;
-            Rect r; SetRect(&r, x, y, x + w, y + h);
-            SetWindowBounds(qt_mac_window_for(q), kWindowContentRgn, &r);
-            topData()->isSetGeometry = 0;
-        } else {
-            setGeometry_sys_helper(x, y, w, h, isMove);
-        }
-#else
         if (!isMove && !q->testAttribute(Qt::WA_Moved) && !q->isVisible()) {
             // INVARIANT: The location of the window has not yet been set. The default will
             // instead be to center it on the desktop, or over the parent, if any. Since we now
@@ -4523,7 +2451,6 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
             cocoaFrameRect.origin.y -= 1;
             [window setFrameOrigin:cocoaFrameRect.origin];
         }
-#endif
     } else {
         setGeometry_sys_helper(x, y, w, h, isMove);
     }
@@ -4558,21 +2485,7 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
         adjustWithinMaxAndMinSize(w, h);
         qt_mac_update_sizer(q);
 
-#ifndef QT_MAC_USE_COCOA
-        if (q->windowFlags() & Qt::WindowMaximizeButtonHint) {
-            OSWindowRef window = qt_mac_window_for(q);
-            if (extra->maxw && extra->maxh && extra->maxw == extra->minw
-                    && extra->maxh == extra->minh) {
-                ChangeWindowAttributes(window, kWindowNoAttributes, kWindowFullZoomAttribute);
-            } else {
-                ChangeWindowAttributes(window, kWindowFullZoomAttribute, kWindowNoAttributes);
-            }
-        }
-        HIRect bounds = CGRectMake(0, 0, w, h);
-        HIViewSetFrame(qt_mac_nativeview_for(q), &bounds);
-#else
         [qt_mac_nativeview_for(q) setFrame:NSMakeRect(0, 0, w, h)];
-#endif
     } else {
         const QRect oldRect(oldp, olds);
         if (!isResize && QApplicationPrivate::graphicsSystem())
@@ -4618,39 +2531,21 @@ void QWidgetPrivate::updateMaximizeButton_sys()
 
     OSWindowRef window = qt_mac_window_for(q);
     QTLWExtra * tlwExtra = topData();
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     NSButton *maximizeButton = [window standardWindowButton:NSWindowZoomButton];
-#endif
     if (extra->maxw && extra->maxh
         && extra->maxw == extra->minw
         && extra->maxh == extra->minh) {
         // The window has a fixed size, so gray out the maximize button:
         if (!tlwExtra->savedWindowAttributesFromMaximized) {
-#ifndef QT_MAC_USE_COCOA
-            GetWindowAttributes(window,
-                                (WindowAttributes*)&extra->topextra->savedWindowAttributesFromMaximized);
-
-#else
             tlwExtra->savedWindowAttributesFromMaximized = (![maximizeButton isHidden] && [maximizeButton isEnabled]);
-#endif
         }
-#ifndef QT_MAC_USE_COCOA
-        ChangeWindowAttributes(window, kWindowNoAttributes, kWindowFullZoomAttribute);
-#else
        [maximizeButton setEnabled:NO];
-#endif
 
 
     } else {
         if (tlwExtra->savedWindowAttributesFromMaximized) {
-#ifndef QT_MAC_USE_COCOA
-            ChangeWindowAttributes(window,
-                                   extra->topextra->savedWindowAttributesFromMaximized,
-                                   kWindowNoAttributes);
-#else
             [maximizeButton setEnabled:YES];
-#endif
             tlwExtra->savedWindowAttributesFromMaximized = 0;
         }
     }
@@ -4720,15 +2615,7 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect)
         return;
     }
 
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
-#else
-    Q_UNUSED(isAlien);
-    // We're not sure what the following call is supposed to achive
-    // but until we see what it breaks, we don't bring it into the
-    // Cocoa port:
-    qt_event_request_window_change(q);
-#endif
 
     // First move all native children. Alien children will indirectly be
     // moved when the parent is scrolled. All directly or indirectly moved
@@ -4742,27 +2629,12 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect)
             if (QWidget *w = qobject_cast<QWidget*>(obj)) {
                 if (!w->isWindow()) {
                     w->data->crect = QRect(w->pos() + scrollDelta, w->size());
-#ifndef QT_MAC_USE_COCOA
-                    if (w->testAttribute(Qt::WA_WState_Created)) {
-                        HIRect bounds = CGRectMake(w->data->crect.x(), w->data->crect.y(),
-                                                   w->data->crect.width(), w->data->crect.height());
-                        HIViewRef hiview = qt_mac_nativeview_for(w);
-                        const bool opaque = q->testAttribute(Qt::WA_OpaquePaintEvent);
-
-                        if (opaque)
-                            HIViewSetDrawingEnabled(hiview,  false);
-                        HIViewSetFrame(hiview, &bounds);
-                        if (opaque)
-                            HIViewSetDrawingEnabled(hiview,  true);
-                    }
-#else
                     if (NSView *view = qt_mac_nativeview_for(w)) {
                         // INVARIANT: w is not alien
                         [view setFrame:NSMakeRect(
                             w->data->crect.x(), w->data->crect.y(),
                             w->data->crect.width(), w->data->crect.height())];
                     }
-#endif
                     movedChildren.append(w);
                 }
             }
@@ -4773,18 +2645,6 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect)
         // Scroll q itself according to the qscrollRect, and
         // call update on any exposed areas so that they get redrawn:
 
-#ifndef QT_MAC_USE_COCOA
-        OSViewRef view = qt_mac_nativeview_for(q);
-        HIRect scrollrect = CGRectMake(qscrollRect.x(), qscrollRect.y(), qscrollRect.width(), qscrollRect.height());
-        OSStatus err = _HIViewScrollRectWithOptions(view, qscrollRect.isValid() ? &scrollrect : 0, dx, dy, kHIViewScrollRectAdjustInvalid);
-        if (err) {
-           // The only parameter that can go wrong, is the rect.
-           qWarning("QWidget::scroll: Your rectangle was too big for the widget, clipping rect");
-           scrollrect = CGRectMake(qMax(qscrollRect.x(), 0), qMax(qscrollRect.y(), 0),
-                                   qMin(qscrollRect.width(), q->width()), qMin(qscrollRect.height(), q->height()));
-           _HIViewScrollRectWithOptions(view, qscrollRect.isValid() ? &scrollrect : 0, dx, dy, kHIViewScrollRectAdjustInvalid);
-        }
-#else
 
         QWidget *nativeWidget = isAlien ? q->nativeParentWidget() : q;
         if (!nativeWidget)
@@ -4858,7 +2718,6 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect)
         if (dy != 0)
             update_sys(deltaYRect);
 
-#endif // QT_MAC_USE_COCOA
     }
 
     for (int i=0; i<movedChildren.size(); i++) {
@@ -4877,18 +2736,10 @@ int QWidget::metric(PaintDeviceMetric m) const
         return qRound(metric(PdmWidth) * 25.4 / qreal(metric(PdmDpiX)));
     case PdmHeight:
     case PdmWidth:
-#ifndef QT_MAC_USE_COCOA
-        { HIRect rect;
-        HIViewGetFrame(qt_mac_nativeview_for(this), &rect);
-        if(m == PdmWidth)
-            return (int)rect.size.width;
-        return (int)rect.size.height; }
-#else
         if (m == PdmWidth)
             return data->crect.width();
         else
             return data->crect.height();
-#endif
     case PdmDepth:
         return 32;
     case PdmNumColors:
@@ -4920,17 +2771,13 @@ int QWidget::metric(PaintDeviceMetric m) const
 
 void QWidgetPrivate::createSysExtra()
 {
-#ifdef QT_MAC_USE_COCOA
     extra->imageMask = 0;
-#endif
 }
 
 void QWidgetPrivate::deleteSysExtra()
 {
-#ifdef QT_MAC_USE_COCOA
     if (extra->imageMask)
         CFRelease(extra->imageMask);
-#endif
 }
 
 void QWidgetPrivate::createTLSysExtra()
@@ -4947,16 +2794,6 @@ void QWidgetPrivate::createTLSysExtra()
 
 void QWidgetPrivate::deleteTLSysExtra()
 {
-#ifndef QT_MAC_USE_COCOA
-    if (extra->topextra->group) {
-        qt_mac_release_window_group(extra->topextra->group);
-        extra->topextra->group = 0;
-    }
-    if (extra->topextra->windowIcon) {
-        ReleaseIconRef(extra->topextra->windowIcon);
-        extra->topextra->windowIcon = 0;
-    }
-#endif
 }
 
 void QWidgetPrivate::updateFrameStrut()
@@ -4968,7 +2805,6 @@ void QWidgetPrivate::updateFrameStrut()
     that->data.fstrut_dirty = false;
     QTLWExtra *top = that->topData();
 
-#if QT_MAC_USE_COCOA
     // 1 Get the window frame
     OSWindowRef oswnd = qt_mac_window_for(q);
     NSRect frameW = [oswnd frame];
@@ -4978,11 +2814,6 @@ void QWidgetPrivate::updateFrameStrut()
                               (frameW.origin.y + frameW.size.height) - (frameC.origin.y + frameC.size.height),
                               (frameW.origin.x + frameW.size.width) - (frameC.origin.x + frameC.size.width),
                               frameC.origin.y - frameW.origin.y);
-#else
-    Rect window_r;
-    GetWindowStructureWidths(qt_mac_window_for(q), &window_r);
-    top->frameStrut.setCoords(window_r.left, window_r.top, window_r.right, window_r.bottom);
-#endif
 }
 
 void QWidgetPrivate::registerDropSite(bool on)
@@ -4990,9 +2821,6 @@ void QWidgetPrivate::registerDropSite(bool on)
     Q_Q(QWidget);
     if (!q->testAttribute(Qt::WA_WState_Created))
         return;
-#ifndef QT_MAC_USE_COCOA
-    SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on);
-#else
     NSWindow *win = qt_mac_window_for(q);
     if (on) {
         if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaWindow) class]])
@@ -5000,13 +2828,11 @@ void QWidgetPrivate::registerDropSite(bool on)
         else if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaPanel) class]])
             [static_cast<QT_MANGLE_NAMESPACE(QCocoaPanel) *>(win) registerDragTypes];
     }
-#endif
 }
 
 void QWidgetPrivate::registerTouchWindow(bool enable)
 {
     Q_UNUSED(enable);
-#ifdef QT_MAC_USE_COCOA
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
     if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6)
         return;
@@ -5033,7 +2859,6 @@ void QWidgetPrivate::registerTouchWindow(bool enable)
         }
     }
 #endif
-#endif
 }
 
 void QWidgetPrivate::setMask_sys(const QRegion &region)
@@ -5041,12 +2866,6 @@ void QWidgetPrivate::setMask_sys(const QRegion &region)
     Q_UNUSED(region);
     Q_Q(QWidget);
 
-#ifndef QT_MAC_USE_COCOA
-    if (q->isWindow())
-        ReshapeCustomWindow(qt_mac_window_for(q));
-    else
-        HIViewReshapeStructure(qt_mac_nativeview_for(q));
-#else
     if (!q->internalWinId())
         return;
 
@@ -5058,7 +2877,6 @@ void QWidgetPrivate::setMask_sys(const QRegion &region)
     }
 
     topLevelAt_cache = 0;
-#endif
 }
 
 void QWidgetPrivate::setWindowOpacity_sys(qreal level)
@@ -5074,14 +2892,9 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
         return;
 
     OSWindowRef oswindow = qt_mac_window_for(q);
-#if QT_MAC_USE_COCOA
     [oswindow setAlphaValue:level];
-#else
-    SetWindowAlpha(oswindow, level);
-#endif
 }
 
-#ifdef QT_MAC_USE_COCOA
 void QWidgetPrivate::syncCocoaMask()
 {
     Q_Q(QWidget);
@@ -5137,7 +2950,6 @@ void QWidgetPrivate::finishCocoaMaskSetup()
     }
     macSetNeedsDisplay(QRegion());
 }
-#endif
 
 struct QPaintEngineCleanupHandler
 {
@@ -5170,7 +2982,6 @@ void QWidgetPrivate::setModal_sys()
     const QWidget * const primaryWindow = windowParent ? windowParent->window() : 0;
     OSWindowRef windowRef = qt_mac_window_for(q);
 
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
     bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask;
 
@@ -5208,87 +3019,6 @@ void QWidgetPrivate::setModal_sys()
         }
     }
 
-#else
-    const bool primaryWindowModal = primaryWindow ? primaryWindow->testAttribute(Qt::WA_ShowModal) : false;
-    const bool modal = q->testAttribute(Qt::WA_ShowModal);
-
-    WindowClass old_wclass;
-    GetWindowClass(windowRef, &old_wclass);
-
-    if (modal || primaryWindowModal) {
-        if (q->windowModality() == Qt::WindowModal
-                || (primaryWindow && primaryWindow->windowModality() == Qt::WindowModal)){
-            // Window should be window-modal (which implies a sheet).
-            if (old_wclass != kSheetWindowClass){
-                // We cannot convert a created window to a sheet.
-                // So we recreate the window:
-                recreateMacWindow();
-                return;
-            }
-        } else {
-            // Window should be application-modal (which implies NOT using a sheet).
-            if (old_wclass == kSheetWindowClass){
-                // We cannot convert a sheet to a window.
-                // So we recreate the window:
-                recreateMacWindow();
-                return;
-            } else if (!(q->data->window_flags & Qt::CustomizeWindowHint)) {
-                if (old_wclass == kDocumentWindowClass || old_wclass == kFloatingWindowClass || old_wclass == kUtilityWindowClass){
-                    // Only change the class to kMovableModalWindowClass if the no explicit jewels
-                    // are set (kMovableModalWindowClass can't contain them), and the current window class
-                    // can be converted to modal (according to carbon doc). Mind the order of
-                    // HIWindowChangeClass and ChangeWindowAttributes.
-                    WindowGroupRef group = GetWindowGroup(windowRef);
-                    HIWindowChangeClass(windowRef, kMovableModalWindowClass);
-                    quint32 tmpWattr = kWindowCloseBoxAttribute | kWindowHorizontalZoomAttribute;
-                    ChangeWindowAttributes(windowRef, tmpWattr, kWindowNoAttributes);
-                    ChangeWindowAttributes(windowRef, kWindowNoAttributes, tmpWattr);
-                    // If the window belongs to a qt-created group, set that group once more:
-                    if (data.window_flags & Qt::WindowStaysOnTopHint
-                            || q->windowType() == Qt::Popup
-                            || q->windowType() == Qt::ToolTip)
-                        SetWindowGroup(windowRef, group);
-                }
-                // Popups are usually handled "special" and are never modal.
-                Qt::WindowType winType = q->windowType();
-                if (winType != Qt::Popup && winType != Qt::ToolTip)
-                    SetWindowModality(windowRef, kWindowModalityAppModal, 0);
-            }
-        }
-    } else if (windowRef) {
-        if (old_wclass == kSheetWindowClass){
-            // Converting a sheet to a window is complex. It's easier to recreate:
-            recreateMacWindow();
-            return;
-        }
-
-        SetWindowModality(windowRef, kWindowModalityNone, 0);
-       if (!(q->data->window_flags & Qt::CustomizeWindowHint)) {
-           if (q->window()->d_func()->topData()->wattr |= kWindowCloseBoxAttribute)
-               ChangeWindowAttributes(windowRef, kWindowCloseBoxAttribute, kWindowNoAttributes);
-           if (q->window()->d_func()->topData()->wattr |= kWindowHorizontalZoomAttribute)
-               ChangeWindowAttributes(windowRef, kWindowHorizontalZoomAttribute, kWindowNoAttributes);
-           if (q->window()->d_func()->topData()->wattr |= kWindowCollapseBoxAttribute)
-                ChangeWindowAttributes(windowRef, kWindowCollapseBoxAttribute, kWindowNoAttributes);
-       }
-
-        WindowClass newClass = q->window()->d_func()->topData()->wclass;
-        if (old_wclass != newClass && newClass != 0){
-            WindowGroupRef group = GetWindowGroup(windowRef);
-            HIWindowChangeClass(windowRef, newClass);
-            // If the window belongs to a qt-created group, set that group once more:
-            if (data.window_flags & Qt::WindowStaysOnTopHint
-                || q->windowType() == Qt::Popup
-                || q->windowType() == Qt::ToolTip)
-                SetWindowGroup(windowRef, group);
-        }
-    }
-
-    // Make sure that HIWindowChangeClass didn't remove drag support
-    // or reset the opaque size grip setting:
-    SetAutomaticControlDragTrackingEnabledForWindow(windowRef, true);
-    macUpdateOpaqueSizeGrip();
-#endif
 }
 
 void QWidgetPrivate::macUpdateHideOnSuspend()
@@ -5296,17 +3026,10 @@ void QWidgetPrivate::macUpdateHideOnSuspend()
     Q_Q(QWidget);
     if (!q->testAttribute(Qt::WA_WState_Created) || !q->isWindow() || q->windowType() != Qt::Tool)
         return;
-#ifndef QT_MAC_USE_COCOA
-    if(q->testAttribute(Qt::WA_MacAlwaysShowToolWindow))
-        ChangeWindowAttributes(qt_mac_window_for(q), 0, kWindowHideOnSuspendAttribute);
-    else
-        ChangeWindowAttributes(qt_mac_window_for(q), kWindowHideOnSuspendAttribute, 0);
-#else
     if(q->testAttribute(Qt::WA_MacAlwaysShowToolWindow))
         [qt_mac_window_for(q) setHidesOnDeactivate:NO];
     else
         [qt_mac_window_for(q) setHidesOnDeactivate:YES];
-#endif
 }
 
 void QWidgetPrivate::macUpdateOpaqueSizeGrip()
@@ -5316,13 +3039,6 @@ void QWidgetPrivate::macUpdateOpaqueSizeGrip()
     if (!q->testAttribute(Qt::WA_WState_Created) || !q->isWindow())
         return;
 
-#ifndef QT_MAC_USE_COCOA       // Growbox is always transparent on Cocoa. Can emulate with setting a QSizeGrip
-    HIViewRef growBox;
-    HIViewFindByID(HIViewGetRoot(qt_mac_window_for(q)), kHIViewWindowGrowBoxID, &growBox);
-    if (!growBox)
-        return;
-    HIGrowBoxViewSetTransparent(growBox, !q->testAttribute(Qt::WA_MacOpaqueSizeGrip));
-#endif
 }
 
 void QWidgetPrivate::macUpdateSizeAttribute()
@@ -5343,29 +3059,6 @@ void QWidgetPrivate::macUpdateSizeAttribute()
 
 void QWidgetPrivate::macUpdateIgnoreMouseEvents()
 {
-#ifndef QT_MAC_USE_COCOA  // This is handled inside the mouse handler on Cocoa.
-    Q_Q(QWidget);
-    if (!q->testAttribute(Qt::WA_WState_Created))
-        return;
-
-    if(q->isWindow())
-       {
-        if(q->testAttribute(Qt::WA_TransparentForMouseEvents))
-            ChangeWindowAttributes(qt_mac_window_for(q), kWindowIgnoreClicksAttribute, 0);
-        else
-            ChangeWindowAttributes(qt_mac_window_for(q), 0, kWindowIgnoreClicksAttribute);
-        ReshapeCustomWindow(qt_mac_window_for(q));
-    } else {
-#ifndef kHIViewFeatureIgnoresClicks
-#define kHIViewFeatureIgnoresClicks kHIViewIgnoresClicks
-#endif
-        if(q->testAttribute(Qt::WA_TransparentForMouseEvents))
-            HIViewChangeFeatures(qt_mac_nativeview_for(q), kHIViewFeatureIgnoresClicks, 0);
-        else
-            HIViewChangeFeatures(qt_mac_nativeview_for(q), 0, kHIViewFeatureIgnoresClicks);
-        HIViewReshapeStructure(qt_mac_nativeview_for(q));
-    }
-#endif
 }
 
 void QWidgetPrivate::macUpdateMetalAttribute()
@@ -5376,40 +3069,21 @@ void QWidgetPrivate::macUpdateMetalAttribute()
         return;
 
     if (realWindow) {
-#if QT_MAC_USE_COCOA
         // Cocoa doesn't let us change the style mask once it's been changed
         // So, that means we need to recreate the window.
         OSWindowRef cocoaWindow = qt_mac_window_for(q);
         if ([cocoaWindow styleMask] & NSTexturedBackgroundWindowMask)
             return;
         recreateMacWindow();
-#else
-        QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q));
-        if (q->testAttribute(Qt::WA_MacBrushedMetal)) {
-            if (layout)
-                layout->updateHIToolBarStatus();
-            ChangeWindowAttributes(qt_mac_window_for(q), kWindowMetalAttribute, 0);
-            ChangeWindowAttributes(qt_mac_window_for(q), kWindowMetalNoContentSeparatorAttribute, 0);
-        } else {
-            ChangeWindowAttributes(qt_mac_window_for(q), 0, kWindowMetalNoContentSeparatorAttribute);
-            ChangeWindowAttributes(qt_mac_window_for(q), 0, kWindowMetalAttribute);
-            if (layout)
-                layout->updateHIToolBarStatus();
-        }
-#endif
     }
 }
 
 void QWidgetPrivate::setEnabled_helper_sys(bool enable)
 {
-#ifdef QT_MAC_USE_COCOA
     Q_Q(QWidget);
     NSView *view = qt_mac_nativeview_for(q);
     if ([view isKindOfClass:[NSControl class]])
         [static_cast<NSControl *>(view) setEnabled:enable];
-#else
-    Q_UNUSED(enable);
-#endif
 }
 
 QT_END_NAMESPACE
index 6629ec0..8b40d1e 100644 (file)
@@ -741,11 +741,6 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
         break;
     case QStyle::CT_MenuBar:
         if (sz == QAquaSizeLarge) {
-#ifndef QT_MAC_USE_COCOA
-            SInt16 size;
-            if (!GetThemeMenuBarHeight(&size))
-                ret = QSize(-1, size);
-#else
             ret = QSize(-1, [[NSApp mainMenu] menuBarHeight]);
             // In the qt_mac_set_native_menubar(false) case,
             // we come it here with a zero-height main menu,
@@ -753,7 +748,6 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
             // Use 22 pixels for the height, by observation.
             if (ret.height() <= 0)
                 ret.setHeight(22);
-#endif
         }
         break;
     default:
index 39b7faf..358ecf0 100644 (file)
@@ -1133,11 +1133,7 @@ void QCompleter::setPopup(QAbstractItemView *popup)
         delete d->popup;
     if (popup->model() != d->proxy)
         popup->setModel(d->proxy);
-#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
-     popup->show();
-#else
      popup->hide();
-#endif
 
     Qt::FocusPolicy origPolicy = Qt::NoFocus;
     if (d->widget)
index 4186ac3..5553c63 100644 (file)
@@ -188,12 +188,8 @@ void QSystemTrayIconPrivate::updateIcon_sys()
 {
     if(sys && !icon.isNull()) {
         QMacCocoaAutoReleasePool pool;
-#ifndef QT_MAC_USE_COCOA
-        const short scale = GetMBarHeight()-4;
-#else
         CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
         const short scale = hgt - 4;
-#endif
         NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
         [(NSImageView*)[[sys->item item] view] setImage: nsimage];
         [nsimage release];
@@ -321,12 +317,8 @@ QT_END_NAMESPACE
     down = NO;
 
     if( ![self icon]->icon().isNull() ) {
-#ifndef QT_MAC_USE_COCOA
-        const short scale = GetMBarHeight()-4;
-#else
         CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
         const short scale = hgt - 4;
-#endif
         NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale))));
         [self setImage: nsimage];
         [nsimage release];
@@ -344,12 +336,8 @@ QT_END_NAMESPACE
     int clickCount = [mouseEvent clickCount];  
     [self setNeedsDisplay:YES];
 
-#ifndef QT_MAC_USE_COCOA
-    const short scale = GetMBarHeight()-4;
-#else
     CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
     const short scale = hgt - 4;
-#endif
 
     if (![self icon]->icon().isNull() ) {
         NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected)));
@@ -453,10 +441,6 @@ QT_END_NAMESPACE
         qtsystray_sendActivated(icon, QSystemTrayIcon::Trigger);
 
     if (icon->contextMenu()) {
-#ifndef QT_MAC_USE_COCOA
-        [[[self item] view] removeAllToolTips];
-        iconPrivate->updateToolTip_sys();
-#endif
         NSMenu *m = [[QT_MANGLE_NAMESPACE(QNSMenu) alloc] initWithQMenu:icon->contextMenu()];
         [m setAutoenablesItems: NO];
         [[NSNotificationCenter defaultCenter] addObserver:imageCell
@@ -533,11 +517,7 @@ private:
             [item setToolTip:(NSString*)QCFString::toCFStringRef(action->toolTip())];
             const QIcon icon = action->icon();
             if(!icon.isNull()) {
-#ifndef QT_MAC_USE_COCOA
-                const short scale = GetMBarHeight();
-#else
                 const short scale = [[NSApp mainMenu] menuBarHeight];
-#endif
                 NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(icon.pixmap(QSize(scale, scale))));
                 [item setImage: nsimage];
                 [nsimage release];
index 2ced5b3..c6be7f1 100644 (file)
@@ -40,7 +40,6 @@
 ****************************************************************************/
 
 #import <private/qcocoatoolbardelegate_mac_p.h>
-#ifdef QT_MAC_USE_COCOA
 #include <private/qmainwindowlayout_p.h>
 #include <private/qt_mac_p.h>
 #include <private/qt_cocoa_helpers_mac_p.h>
@@ -150,4 +149,3 @@ QT_FORWARD_DECLARE_CLASS(QCFString);
 }
 
 @end
-#endif // QT_MAC_USE_COCOA
index 813d278..846c693 100644 (file)
@@ -51,7 +51,6 @@
 //
 
 #include "qmacdefines_mac.h"
-#ifdef QT_MAC_USE_COCOA
 #import <Cocoa/Cocoa.h>
 
 QT_BEGIN_NAMESPACE
@@ -68,4 +67,3 @@ QT_END_NAMESPACE
 
 - (id)initWithMainWindowLayout:(QT_PREPEND_NAMESPACE(QMainWindowLayout) *)layout;
 @end
-#endif
index aa627ef..1a1f16a 100644 (file)
@@ -2064,7 +2064,7 @@ void QDockAreaLayoutInfo::updateSeparatorWidgets() const
         }
         j++;
 
-#ifndef QT_MAC_USE_COCOA
+#ifndef Q_WS_MAC
         sepWidget->raise();
 #endif
         QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
@@ -3178,7 +3178,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const
         }
         j++;
 
-#ifndef QT_MAC_USE_COCOA
+#ifndef Q_WS_MAC
         sepWidget->raise();
 #endif
         QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
index 5fcc474..c02c13f 100644 (file)
@@ -1034,11 +1034,6 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
 
     q->setWindowFlags(flags);
 
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) {
-        ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
-    }
-#endif
 
     if (!rect.isNull())
         q->setGeometry(rect);
index 8e64e3b..b79ee3d 100644 (file)
@@ -96,28 +96,18 @@ class QMacCocoaViewContainerPrivate : public QWidgetPrivate
     Q_DECLARE_PUBLIC(QMacCocoaViewContainer)
 public:
     NSView *nsview;
-#ifndef QT_MAC_USE_COCOA
-    HIViewRef wrapperView;
-#endif
     QMacCocoaViewContainerPrivate();
     ~QMacCocoaViewContainerPrivate();
 };
 
 QMacCocoaViewContainerPrivate::QMacCocoaViewContainerPrivate()
      : nsview(0)
-#ifndef QT_MAC_USE_COCOA
-       , wrapperView(0)
-#endif
 {
 }
 
 QMacCocoaViewContainerPrivate::~QMacCocoaViewContainerPrivate()
 {
     [nsview release];
-#ifndef QT_MAC_USE_COCOA
-    if (wrapperView)
-        CFRelease(wrapperView);
-#endif
 }
 
 /*!
@@ -168,20 +158,7 @@ void QMacCocoaViewContainer::setCocoaView(void *cocoaViewToWrap)
     destroy(true, true);
     [view retain];
     d->nsview = view;
-#ifndef QT_MAC_USE_COCOA
-    if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5) {
-        qWarning("QMacCocoaViewContainer::setCocoaView: You cannot use this class with Carbon on versions of Mac OS X less than 10.5.");
-        return;
-    }
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-    if (d->wrapperView)
-        CFRelease(d->wrapperView);
-    HICocoaViewCreate(d->nsview, 0, &d->wrapperView);
-    create(WId(d->wrapperView), false, true);
-#endif
-#else
     create(WId(d->nsview), false, true);
-#endif
     [oldView release];
 }
 
index 238b8d5..014700f 100644 (file)
@@ -1442,13 +1442,11 @@ bool QMainWindow::event(QEvent *event)
                     // We are coming out of a minimize, leave things as is.
                     d->layout->blockVisiblityCheck = true;
                 }
-#  ifdef QT_MAC_USE_COCOA
                 // We need to update the HIToolbar status when we go out of or into fullscreen.
                 QWindowStateChangeEvent *wce = static_cast<QWindowStateChangeEvent *>(event);
                 if ((windowState() & Qt::WindowFullScreen) || (wce->oldState() & Qt::WindowFullScreen)) {
                     d->layout->updateHIToolBarStatus();
                 }
-#  endif // Cocoa
             }
             break;
 #endif // Q_WS_MAC
@@ -1506,16 +1504,13 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
     d->useHIToolBar = set;
     createWinId(); // We need the hiview for down below.
 
-#ifdef QT_MAC_USE_COCOA
     // Activate the unified toolbar with the raster engine.
     if (windowSurface() && set) {
         d->layout->unifiedSurface = new QUnifiedToolbarSurface(this);
     }
-#endif // QT_MAC_USE_COCOA
 
     d->layout->updateHIToolBarStatus();
 
-#ifdef QT_MAC_USE_COCOA
     // Deactivate the unified toolbar with the raster engine.
     if (windowSurface() && !set) {
         if (d->layout->unifiedSurface) {
@@ -1523,7 +1518,6 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
             d->layout->unifiedSurface = 0;
         }
     }
-#endif // QT_MAC_USE_COCOA
 
     // Enabling the unified toolbar clears the opaque size grip setting, update it.
     d->macUpdateOpaqueSizeGrip();
index 28e8764..ba5d1d5 100644 (file)
 #include <private/qt_cocoa_helpers_mac_p.h>
 #include <private/qtoolbar_p.h>
 
-#ifndef QT_MAC_USE_COCOA
-#include <Carbon/Carbon.h>
-#else
 #include <private/qcocoatoolbardelegate_mac_p.h>
 #import  <private/qcocoawindowdelegate_mac_p.h>
-#endif
 
 QT_BEGIN_NAMESPACE
 #ifdef QT_NAMESPACE
@@ -63,12 +59,7 @@ QT_BEGIN_NAMESPACE
 #define SNSToolbar "com.trolltech.qt-" S0(QT_NAMESPACE) ".qtoolbarInNSToolbar"
 #define MacToolbar "com.trolltech.qt-" S0(QT_NAMESPACE) ".qmainwindow.mactoolbar"
 
-#ifndef QT_MAC_USE_COCOA
-static CFStringRef kQToolBarHIToolbarItemClassID = CFSTR(S);
-static CFStringRef kQToolBarHIToolbarIdentifier = CFSTR(SToolbar);
-#else
 static NSString *kQToolBarNSToolbarIdentifier = @SNSToolbar;
-#endif
 static CFStringRef kQMainWindowMacToolbarID = CFSTR(MacToolbar);
 #undef SS
 #undef S0
@@ -78,248 +69,10 @@ static CFStringRef kQMainWindowMacToolbarID = CFSTR(MacToolbar);
 #undef MacToolbar
 
 #else
-#ifndef QT_MAC_USE_COCOA
-static CFStringRef kQToolBarHIToolbarItemClassID = CFSTR("com.trolltech.qt.qmainwindow.qtoolbarInHIToolbar");
-static CFStringRef kQToolBarHIToolbarIdentifier = CFSTR("com.trolltech.qt.hitoolbar-qtoolbar");
-#else
 static NSString *kQToolBarNSToolbarIdentifier = @"com.trolltech.qt.qmainwindow.qtoolbarInNSToolbar";
-#endif
 static CFStringRef kQMainWindowMacToolbarID = CFSTR("com.trolltech.qt.qmainwindow.mactoolbar");
 #endif // QT_NAMESPACE
 
-#ifndef QT_MAC_USE_COCOA
-
-static const int kEventParamQToolBar = 'QTBR';
-static const int kEventParamQMainWindowLayout = 'QMWL';
-
-const EventTypeSpec qtoolbarEvents[] =
-{
-    { kEventClassHIObject, kEventHIObjectConstruct },
-    { kEventClassHIObject, kEventHIObjectDestruct },
-    { kEventClassHIObject, kEventHIObjectInitialize },
-    { kEventClassToolbarItem, kEventToolbarItemCreateCustomView }
-};
-
-struct QToolBarInHIToolbarInfo
-{
-    QToolBarInHIToolbarInfo(HIToolbarItemRef item)
-        : toolbarItem(item), mainWindowLayout(0)
-    {}
-    HIToolbarItemRef toolbarItem;
-    QMainWindowLayout *mainWindowLayout;
-};
-
-OSStatus QMainWindowLayout::qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef,
-                                                       EventRef event, void *data)
-{
-    OSStatus result = eventNotHandledErr;
-    QToolBarInHIToolbarInfo *object = static_cast<QToolBarInHIToolbarInfo *>(data);
-
-    switch (GetEventClass(event)) {
-        case kEventClassHIObject:
-            switch (GetEventKind(event)) {
-                case kEventHIObjectConstruct:
-                {
-                    HIObjectRef toolbarItem;
-                    GetEventParameter(event, kEventParamHIObjectInstance, typeHIObjectRef,
-                                      0, sizeof( HIObjectRef ), 0, &toolbarItem);
-
-                    QToolBarInHIToolbarInfo *item = new QToolBarInHIToolbarInfo(toolbarItem);
-                    SetEventParameter(event, kEventParamHIObjectInstance, typeVoidPtr,
-                                      sizeof(void *), &item);
-                    result = noErr;
-                }
-                    break;
-                case kEventHIObjectInitialize:
-                    result = CallNextEventHandler(inCallRef, event);
-                    if (result == noErr) {
-                        QToolBar *toolbar = 0;
-                        QMainWindowLayout *layout = 0;
-                        GetEventParameter(event, kEventParamQToolBar, typeVoidPtr,
-                                          0, sizeof(void *), 0, &toolbar);
-                        GetEventParameter(event, kEventParamQMainWindowLayout, typeVoidPtr,
-                                          0, sizeof(void *), 0, &layout);
-                        object->mainWindowLayout = layout;
-                        object->mainWindowLayout->unifiedToolbarHash.insert(object->toolbarItem, toolbar);
-                        HIToolbarItemChangeAttributes(object->toolbarItem,
-                                                      kHIToolbarItemLabelDisabled, 0);
-                    }
-                    break;
-
-                case kEventHIObjectDestruct:
-                    delete object;
-                    result = noErr;
-                    break;
-            }
-            break;
-
-        case kEventClassToolbarItem:
-            switch (GetEventKind(event))
-        {
-            case kEventToolbarItemCreateCustomView:
-            {
-                QToolBar *toolbar
-                = object->mainWindowLayout->unifiedToolbarHash.value(object->toolbarItem);
-                if (toolbar) {
-                    HIViewRef hiview = HIViewRef(toolbar->winId());
-                    SetEventParameter(event, kEventParamControlRef, typeControlRef,
-                                      sizeof(HIViewRef), &hiview);
-                    result = noErr;
-                }
-            }
-                break;
-        }
-            break;
-    }
-    return result;
-}
-
-void QMainWindowLayout::qtMacHIToolbarRegisterQToolBarInHIToolborItemClass()
-{
-    static bool registered = false;
-
-    if (!registered) {
-        HIObjectRegisterSubclass( kQToolBarHIToolbarItemClassID,
-                                 kHIToolbarItemClassID, 0, QMainWindowLayout::qtoolbarInHIToolbarHandler,
-                                 GetEventTypeCount(qtoolbarEvents), qtoolbarEvents, 0, 0 );
-        registered = true;
-    }
-}
-
-static void GetToolbarAllowedItems(CFMutableArrayRef array)
-{
-    CFArrayAppendValue(array, kQToolBarHIToolbarIdentifier);
-}
-
-HIToolbarItemRef QMainWindowLayout::createQToolBarInHIToolbarItem(QToolBar *toolbar,
-                                                                  QMainWindowLayout *layout)
-{
-    QMainWindowLayout::qtMacHIToolbarRegisterQToolBarInHIToolborItemClass();
-
-    EventRef event;
-    HIToolbarItemRef result = 0;
-
-    CFStringRef identifier = kQToolBarHIToolbarIdentifier;
-    UInt32 options = kHIToolbarItemAllowDuplicates;
-
-    CreateEvent(0, kEventClassHIObject, kEventHIObjectInitialize,
-                GetCurrentEventTime(), 0, &event);
-    SetEventParameter(event, kEventParamToolbarItemIdentifier, typeCFStringRef,
-                      sizeof(CFStringRef), &identifier);
-    SetEventParameter(event, kEventParamAttributes, typeUInt32, sizeof(UInt32), &options);
-    SetEventParameter(event, kEventParamQToolBar, typeVoidPtr, sizeof(void *), &toolbar);
-    SetEventParameter(event, kEventParamQMainWindowLayout, typeVoidPtr, sizeof(void *), &layout);
-
-    HIObjectCreate(kQToolBarHIToolbarItemClassID, event,
-                   static_cast<HIObjectRef *>(&result));
-
-    ReleaseEvent(event);
-    return result;
-
-}
-
-HIToolbarItemRef QMainWindowLayout::CreateToolbarItemForIdentifier(CFStringRef identifier,
-                                                                   CFTypeRef data)
-{
-    HIToolbarItemRef item = 0;
-    if (CFStringCompare(kQToolBarHIToolbarIdentifier, identifier,
-                        kCFCompareBackwards) == kCFCompareEqualTo) {
-        if (data && CFGetTypeID(data) == CFArrayGetTypeID()) {
-            CFArrayRef array = static_cast<CFArrayRef>(data);
-            QToolBar *toolbar = static_cast<QToolBar *>(const_cast<void *>(CFArrayGetValueAtIndex(array, 0)));
-            QMainWindowLayout *layout = static_cast<QMainWindowLayout *>(const_cast<void *>(CFArrayGetValueAtIndex(array, 1)));
-            item = createQToolBarInHIToolbarItem(toolbar, layout);
-        }
-    }
-    return item;
-}
-
-static const EventTypeSpec kToolbarEvents[] = {
-{ kEventClassToolbar, kEventToolbarGetDefaultIdentifiers },
-{ kEventClassToolbar, kEventToolbarGetAllowedIdentifiers },
-{ kEventClassToolbar, kEventToolbarCreateItemWithIdentifier },
-{ kEventClassToolbar, kEventToolbarItemAdded },
-{ kEventClassToolbar, kEventToolbarItemRemoved }
-};
-
-OSStatus QMainWindowLayout::qtmacToolbarDelegate(EventHandlerCallRef, EventRef event, void *data)
-{
-    QMainWindowLayout *mainWindowLayout = static_cast<QMainWindowLayout *>(data);
-    OSStatus            result = eventNotHandledErr;
-    CFMutableArrayRef   array;
-    CFStringRef         identifier;
-    switch (GetEventKind(event)) {
-        case kEventToolbarGetDefaultIdentifiers:
-        case kEventToolbarGetAllowedIdentifiers:
-            GetEventParameter(event, kEventParamMutableArray, typeCFMutableArrayRef, 0,
-                              sizeof(CFMutableArrayRef), 0, &array);
-            GetToolbarAllowedItems(array);
-            result = noErr;
-            break;
-        case kEventToolbarCreateItemWithIdentifier: {
-            HIToolbarItemRef item;
-            CFTypeRef data = 0;
-            OSStatus err = GetEventParameter(event, kEventParamToolbarItemIdentifier, typeCFStringRef,
-                                             0, sizeof(CFStringRef), 0, &identifier);
-            err = GetEventParameter(event, kEventParamToolbarItemConfigData, typeCFTypeRef,
-                                    0, sizeof(CFTypeRef), 0, &data);
-            item = CreateToolbarItemForIdentifier(identifier, data);
-            if (item) {
-                result = SetEventParameter(event, kEventParamToolbarItem, typeHIToolbarItemRef,
-                                           sizeof(HIToolbarItemRef), &item );
-            }
-            break;
-        }
-        case kEventToolbarItemAdded: {
-            // Double check that our "view" of the toolbar is similar.
-            HIToolbarItemRef item;
-            CFIndex index;
-            if (GetEventParameter(event, kEventParamToolbarItem, typeHIToolbarItemRef,
-                                  0, sizeof(HIToolbarItemRef), 0, &item) == noErr
-                && GetEventParameter(event, kEventParamIndex, typeCFIndex, 0,
-                                     sizeof(CFIndex), 0, &index) == noErr) {
-                CFRetain(item); // We will watch this until it's removed from the list (or bust).
-                mainWindowLayout->toolbarItemsCopy.insert(index, item);
-                QToolBar *toolbar = mainWindowLayout->unifiedToolbarHash.value(item);
-                if (toolbar) {
-                    int toolbarIndex = mainWindowLayout->qtoolbarsInUnifiedToolbarList.indexOf(toolbar);
-                    if (index != toolbarIndex) {
-                        // Dang, we must be out of sync, rebuild it from the "toolbarItemsCopy"
-                        mainWindowLayout->qtoolbarsInUnifiedToolbarList.clear();
-                        for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) {
-                            // This will either append the correct toolbar or an
-                            // null toolbar. This is fine because this list
-                            // is really only kept to make sure that things are but in the right order.
-                            mainWindowLayout->qtoolbarsInUnifiedToolbarList.append(
-                                                                                   mainWindowLayout->unifiedToolbarHash.value(mainWindowLayout->
-                                                                                                                              toolbarItemsCopy.at(i)));
-                        }
-                    }
-                }
-            }
-            break;
-        }
-        case kEventToolbarItemRemoved: {
-            HIToolbarItemRef item;
-            if (GetEventParameter(event, kEventParamToolbarItem, typeHIToolbarItemRef,
-                                  0, sizeof(HIToolbarItemRef), 0, &item) == noErr) {
-                mainWindowLayout->unifiedToolbarHash.remove(item);
-                for (int i = 0; i < mainWindowLayout->toolbarItemsCopy.size(); ++i) {
-                    if (mainWindowLayout->toolbarItemsCopy.at(i) == item) {
-                        // I know about it, so release it.
-                        mainWindowLayout->toolbarItemsCopy.removeAt(i);
-                        mainWindowLayout->qtoolbarsInUnifiedToolbarList.removeAt(i);
-                        CFRelease(item);
-                        break;
-                    }
-                }
-            }
-            break;
-        }
-    }
-    return result;
-}
-#endif // ! QT_MAC_USE_COCOA
 
 #ifndef kWindowUnifiedTitleAndToolbarAttribute
 #define kWindowUnifiedTitleAndToolbarAttribute (1 << 7)
@@ -328,18 +81,8 @@ OSStatus QMainWindowLayout::qtmacToolbarDelegate(EventHandlerCallRef, EventRef e
 void QMainWindowLayout::updateHIToolBarStatus()
 {
     bool useMacToolbar = layoutState.mainWindow->unifiedTitleAndToolBarOnMac();
-#ifndef QT_MAC_USE_COCOA
-    if (useMacToolbar) {
-        ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
-                               kWindowUnifiedTitleAndToolbarAttribute, 0);
-    } else {
-        ChangeWindowAttributes(qt_mac_window_for(layoutState.mainWindow),
-                               0, kWindowUnifiedTitleAndToolbarAttribute);
-    }
-#endif
 
     layoutState.mainWindow->setUpdatesEnabled(false);  // reduces a little bit of flicker, not all though
-#if defined(QT_MAC_USE_COCOA)
     QMacCocoaAutoReleasePool pool;
     NSView *cView = [qt_mac_window_for(layoutState.mainWindow) contentView];
     if (useMacToolbar) {
@@ -349,16 +92,13 @@ void QMainWindowLayout::updateHIToolBarStatus()
                                                      name: NSViewFrameDidChangeNotification
                                                    object: cView];
     }
-#endif
     if (!useMacToolbar) {
         macWindowToolbarShow(layoutState.mainWindow, false);
         // Move everything out of the HIToolbar into the main toolbar.
         while (!qtoolbarsInUnifiedToolbarList.isEmpty()) {
             // Should shrink the list by one every time.
             QToolBar *toolbar = qtoolbarsInUnifiedToolbarList.first();
-#if defined(QT_MAC_USE_COCOA)
             unifiedSurface->removeToolbar(toolbar);
-#endif
             layoutState.mainWindow->addToolBar(Qt::TopToolBarArea, toolbar);
         }
         macWindowToolbarSet(qt_mac_window_for(layoutState.mainWindow), 0);
@@ -374,14 +114,12 @@ void QMainWindowLayout::updateHIToolBarStatus()
         }
         syncUnifiedToolbarVisibility();
     }
-#if defined(QT_MAC_USE_COCOA)
     if (!useMacToolbar) {
         [cView setPostsFrameChangedNotifications:NO];
         [[NSNotificationCenter defaultCenter] removeObserver: [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate]
                                                         name: NSViewFrameDidChangeNotification
                                                       object: cView];
     }
-#endif
     layoutState.mainWindow->setUpdatesEnabled(true);
 }
 
@@ -392,7 +130,6 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
     if (toolbar == 0)
         return;
 
-#if defined(QT_MAC_USE_COCOA)
     // toolbar will now become native (if not already) since we need
     // an nsview for it inside the corresponding NSToolbarItem.
     // Setting isInUnifiedToolbar will (among other things) stop alien
@@ -402,7 +139,6 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
     // that either the menubar must be alien again, or the sibling must
     // be backed by an nsview to protect from overlapping issues:
     toolbar->d_func()->isInUnifiedToolbar = true;
-#endif
 
     QToolBarLayout *toolbarLayout = static_cast<QToolBarLayout *>(toolbar->layout());
     toolbarSaveState.insert(toolbar, ToolBarSaveState(toolbar->isMovable(), toolbar->maximumSize()));
@@ -425,22 +161,6 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
 
     int toolbarIndex = qtoolbarsInUnifiedToolbarList.indexOf(toolbar);
 
-#ifndef QT_MAC_USE_COCOA
-    HIToolbarRef macToolbar = NULL;
-    if ((GetWindowToolbar(window, &macToolbar) == noErr) && !macToolbar) {
-        HIToolbarCreate(kQMainWindowMacToolbarID,
-                        kHIToolbarItemAllowDuplicates, &macToolbar);
-        InstallEventHandler(HIObjectGetEventTarget(static_cast<HIToolbarRef>(macToolbar)),
-                            QMainWindowLayout::qtmacToolbarDelegate, GetEventTypeCount(kToolbarEvents),
-                            kToolbarEvents, this, 0);
-        HIToolbarSetDisplaySize(macToolbar, kHIToolbarDisplaySizeNormal);
-        HIToolbarSetDisplayMode(macToolbar, kHIToolbarDisplayModeIconOnly);
-        macWindowToolbarSet(window, macToolbar);
-        if (layoutState.mainWindow->isVisible())
-            macWindowToolbarShow(layoutState.mainWindow, true);
-        CFRelease(macToolbar);
-    }
-#else
     QMacCocoaAutoReleasePool pool;
     NSToolbar *macToolbar = [window toolbar];
     if (macToolbar == nil) {
@@ -451,14 +171,9 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
         [window setToolbar:macToolbar];
         [macToolbar release];
     }
-#endif
     if (toolbarIndex != -1) {
         qtoolbarsInUnifiedToolbarList.removeAt(toolbarIndex);
-#ifndef QT_MAC_USE_COCOA
-        HIToolbarRemoveItemAtIndex(macToolbar, toolbarIndex);
-#else
         [macToolbar removeItemAtIndex:toolbarIndex];
-#endif
     }
     qtoolbarsInUnifiedToolbarList.insert(beforeIndex, toolbar);
 
@@ -468,28 +183,15 @@ void QMainWindowLayout::insertIntoMacToolbar(QToolBar *before, QToolBar *toolbar
         for (int i = 0; i < beforeIndex; ++i) {
             offset.setX(offset.x() + qtoolbarsInUnifiedToolbarList.at(i)->size().width());
         }
-#ifdef QT_MAC_USE_COCOA
         unifiedSurface->insertToolbar(toolbar, offset);
-#endif // QT_MAC_USE_COCOA
     }
 
-#ifndef QT_MAC_USE_COCOA
-    QCFType<HIToolbarItemRef> outItem;
-    const QObject *stupidArray[] = { toolbar, this };
-    QCFType<CFArrayRef> array = CFArrayCreate(0, reinterpret_cast<const void **>(&stupidArray),
-                                              2, 0);
-    HIToolbarCreateItemWithIdentifier(macToolbar, kQToolBarHIToolbarIdentifier,
-                                      array, &outItem);
-    HIToolbarInsertItemAtIndex(macToolbar, outItem, beforeIndex);
-#else
     NSString *toolbarID = kQToolBarNSToolbarIdentifier;
     toolbarID = [toolbarID stringByAppendingFormat:@"%p", toolbar];
     cocoaItemIDToToolbarHash.insert(qt_mac_NSStringToQString(toolbarID), toolbar);
     [macToolbar insertItemWithItemIdentifier:toolbarID atIndex:beforeIndex];
-#endif
 }
 
-#ifdef QT_MAC_USE_COCOA
 void QMainWindowLayout::updateUnifiedToolbarOffset()
 {
     QPoint offset(0, 0);
@@ -499,7 +201,6 @@ void QMainWindowLayout::updateUnifiedToolbarOffset()
         qtoolbarsInUnifiedToolbarList.at(i)->d_func()->toolbar_offset = offset;
     }
 }
-#endif // QT_MAC_USE_COCOA
 
 
 void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
@@ -517,17 +218,11 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
             toolbar->setMovable(saveState.movable);
             toolbar->setMaximumSize(saveState.maximumSize);
             toolbarSaveState.remove(toolbar);
-#ifndef QT_MAC_USE_COCOA
-            HIToolbarItemRef item = static_cast<HIToolbarItemRef>(it.key());
-            HIToolbarRemoveItemAtIndex(HIToolbarItemGetToolbar(item),
-                                       toolbarItemsCopy.indexOf(item));
-#else
             NSToolbarItem *item = static_cast<NSToolbarItem *>(it.key());
             [[qt_mac_window_for(layoutState.mainWindow->window()) toolbar]
                 removeItemAtIndex:toolbarItemsCopy.indexOf(item)];
              unifiedToolbarHash.remove(item);
              qtoolbarsInUnifiedToolbarList.removeAll(toolbar);
-#endif
             break;
         }
         ++it;
@@ -536,32 +231,25 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar)
 
 void QMainWindowLayout::cleanUpMacToolbarItems()
 {
-#ifdef QT_MAC_USE_COCOA
     QMacCocoaAutoReleasePool pool;
-#endif
     for (int i = 0; i < toolbarItemsCopy.size(); ++i) {
-#ifdef QT_MAC_USE_COCOA
         NSToolbarItem *item = static_cast<NSToolbarItem *>(toolbarItemsCopy.at(i));
         [item setView:0];
-#endif
         CFRelease(toolbarItemsCopy.at(i));
     }
     toolbarItemsCopy.clear();
     unifiedToolbarHash.clear();
 
-#ifdef QT_MAC_USE_COCOA
     OSWindowRef window = qt_mac_window_for(layoutState.mainWindow);
     NSToolbar *macToolbar = [window toolbar];
     if (macToolbar) {
       [[macToolbar delegate] release];
       [macToolbar setDelegate:nil];
     }
-#endif
 }
 
 void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const
 {
-#ifdef QT_MAC_USE_COCOA
     QHash<void *, QToolBar *>::const_iterator it = unifiedToolbarHash.constBegin();
     NSToolbarItem *item = nil;
     while (it != unifiedToolbarHash.constEnd()) {
@@ -582,9 +270,6 @@ void QMainWindowLayout::fixSizeInUnifiedToolbar(QToolBar *tb) const
         nssize.height = size.height();
         [item setMinSize:nssize];
     }
-#else
-    Q_UNUSED(tb);
-#endif
 }
 
 void QMainWindowLayout::syncUnifiedToolbarVisibility()
index f811609..9d3f127 100644 (file)
@@ -85,9 +85,7 @@ typedef HIObjectRef                     HIToolbarItemRef;
 typedef const void * CFTypeRef;
 typedef const struct __CFString * CFStringRef;
 
-#  ifdef QT_MAC_USE_COCOA
 #include <private/qunifiedtoolbarsurface_mac_p.h>
-# endif // QT_MAC_USE_COCOA
 
 #endif // Q_WS_MAC
 
@@ -312,7 +310,6 @@ private:
     void updateTabBarShapes();
 #endif
 #ifdef Q_WS_MAC
-#  ifndef QT_MAC_USE_COCOA
     static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *);
     static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event,
                                                void *data);
@@ -320,7 +317,6 @@ private:
     static HIToolbarItemRef CreateToolbarItemForIdentifier(CFStringRef identifier, CFTypeRef data);
     static HIToolbarItemRef createQToolBarInHIToolbarItem(QToolBar *toolbar,
                                                           QMainWindowLayout *layout);
-#  endif
 public:
     struct ToolBarSaveState {
         ToolBarSaveState() : movable(false) { }
@@ -343,10 +339,8 @@ public:
     void syncUnifiedToolbarVisibility();
     bool blockVisiblityCheck;
 
-#ifdef QT_MAC_USE_COCOA
     QUnifiedToolbarSurface *unifiedSurface;
     void updateUnifiedToolbarOffset();
-#endif // QT_MAC_USE_COCOA
 
 #endif // Q_WS_MAC
 };
index b20df0b..4fd7a31 100644 (file)
@@ -100,7 +100,6 @@ void QTabBarPrivate::updateMacBorderMetrics()
         metrics.left = 0;
         metrics.right = 0;
         qt_mac_updateContentBorderMetricts(window, metrics);
-#if QT_MAC_USE_COCOA
         // In Cocoa we need to keep track of the drawRect method.
         // If documentMode is enabled we need to change it, unless
         // a toolbar is present.
@@ -113,7 +112,6 @@ void QTabBarPrivate::updateMacBorderMetrics()
         // Since in Cocoa there is no simple way to remove the baseline, so we just ask the
         // top level to do the magic for us.
         privateWidget->syncUnifiedMode();
-#endif // QT_MAC_USE_COCOA
     }
 #endif
 }
index 6fc4dc9..3d3ef4f 100644 (file)
@@ -231,11 +231,6 @@ void QToolBarPrivate::startDrag(bool moving)
 
     if (!moving) {
         state->widgetItem = layout->unplug(q);
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-        if (q->isWindow()) {
-           setWindowState(true, true); //set it to floating
-        }
-#endif
         Q_ASSERT(state->widgetItem != 0);
     }
     state->dragging = !moving;
@@ -1129,36 +1124,6 @@ bool QToolBar::event(QEvent *event)
             mwLayout->fixSizeInUnifiedToolbar(this);
             mwLayout->syncUnifiedToolbarVisibility();
         }
-#  if !defined(QT_MAC_USE_COCOA)
-        // Fall through
-    case QEvent::LayoutRequest: {
-        // There's currently no way to invalidate the size and let
-        // HIToolbar know about it. This forces a re-check.
-        int earlyResult = -1;
-        if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget())) {
-            bool needUpdate = true;
-            if (event->type() == QEvent::LayoutRequest) {
-                QSize oldSizeHint = sizeHint();
-                earlyResult = QWidget::event(event) ? 1 : 0;
-                needUpdate = oldSizeHint != sizeHint();
-            }
-
-            if (needUpdate) {
-                OSWindowRef windowRef = qt_mac_window_for(mainWindow);
-                if (toolbarInUnifiedToolBar(this)
-                        && macWindowToolbarIsVisible(windowRef))   {
-                    DisableScreenUpdates();
-                    macWindowToolbarShow(this, false);
-                    macWindowToolbarShow(this, true);
-                    EnableScreenUpdates();
-                }
-            }
-
-            if (earlyResult != -1)
-                return earlyResult;
-        }
-    }
-#  endif // !QT_MAC_USE_COCOA
 #endif // Q_WS_MAC
         break;
     case QEvent::ParentChange:
index 971fdda..ac9be12 100644 (file)
@@ -402,15 +402,12 @@ void QToolBarLayout::setGeometry(const QRect &rect)
             extension->hide();
     }
 #ifdef Q_WS_MAC
-    // Nothing to do for Carbon... probably   
-#  ifdef QT_MAC_USE_COCOA
     if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) {
         Qt::ToolBarArea area = win->toolBarArea(tb);
         if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) {
             qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb);
         }
     }
-#  endif
 #endif
     
 }
index a56894f..17a3982 100644 (file)
@@ -223,7 +223,7 @@ private slots:
     void drawRect_task215378();
     void drawRect_task247505();
 
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_OS_MAC)
     void drawText_subPixelPositionsInRaster_qtbug5053();
 #endif
 
@@ -4528,11 +4528,11 @@ void tst_QPainter::clipBoundingRect()
 
 }
 
-// Only Mac/Cocoa supports sub pixel positions in raster engine currently
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+//Only Mac/Cocoa supports sub pixel positions in raster engine currently
+#ifdef Q_OS_MAC
 void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
 {
-    QFontMetricsF fm(qApp->font());
+       QFontMetricsF fm(qApp->font());
 
     QImage baseLine(fm.width(QChar::fromLatin1('e')), fm.height(), QImage::Format_RGB32);
     baseLine.fill(Qt::white);
index 5404b0f..f922ba3 100644 (file)
@@ -96,7 +96,7 @@ private slots:
     void rawFontSetPixelSize_data();
     void rawFontSetPixelSize();
 
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_X11) || defined(Q_WS_MAC)
     void multipleRawFontsFromData();
 #endif
 
@@ -854,7 +854,7 @@ void tst_QRawFont::rawFontSetPixelSize()
     QCOMPARE(rawFont.pixelSize(), 24.0);
 }
 
-#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_X11) || defined(Q_WS_MAC)
 void tst_QRawFont::multipleRawFontsFromData()
 {
     QFile file(QString::fromLatin1(SRCDIR "testfont.ttf"));
index 7f30009..4f9beb6 100644 (file)
@@ -1178,7 +1178,7 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204()
 #if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11)
 void tst_QTextScriptEngine::combiningMarks_qtbug15675()
 {
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_MAC)
     QString s;
     s.append(QChar(0x0061));
     s.append(QChar(0x0062));
index 66807fc..0c0934e 100644 (file)
@@ -68,11 +68,9 @@ private slots:
     void testDragWindow();
     void testMouseEnter();
     void testChildDialogInFrontOfModalParent();
-#ifdef QT_MAC_USE_COCOA
 //    void testChildWindowInFrontOfParentWindow();
 //    void testChildToolWindowInFrontOfChildNormalWindow();
     void testChildWindowInFrontOfStaysOnTopParentWindow();
-#endif
     void testKeyPressOnToplevel();
     void testModifierShift();
     void testModifierAlt();
@@ -318,7 +316,6 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent()
     QVERIFY(!child.isVisible());
 }
 
-#ifdef QT_MAC_USE_COCOA
 #if 0
 // This test is disabled as of Qt-4.7.4 because we cannot do it
 // unless we use the Cocoa sub window API. But using that opens up
@@ -398,7 +395,6 @@ void tst_MacNativeEvents::testChildWindowInFrontOfStaysOnTopParentWindow()
     QTest::qWait(100);
     QVERIFY(!button.isVisible());
 }
-#endif
 
 void tst_MacNativeEvents::testKeyPressOnToplevel()
 {
index b76ee1b..c3a0e32 100644 (file)
 ****************************************************************************/
 #include <QtTest/QtTest>
 
-#if defined(Q_WS_MAC) && !defined (QT_MAC_USE_COCOA)
-
-#include <private/qt_mac_p.h>
-#undef verify // yes, lets reserve the word "verify"
-
-#include <QApplication>
-#include <QDebug>
-#include <QTimer>
-#include <QString>
-#include <QFile>
-#include <QVariant>
-#include <QPushButton>
-#include <QToolBar>
-#include <QSlider>
-#include <QListWidget>
-#include <QTableWidget>
-#include <QScrollArea>
-#include <QLabel>
-#include <QScrollBar>
-#include <QTextEdit>
-#include <QAccessibleInterface>
-#include <QAccessible>
-#include <QPluginLoader>
-#include <private/qaccessible_mac_p.h>
-#include <quiloader.h>
-
-#include <sys/types.h> // for getpid()
-#include <unistd.h>
-
-Q_DECLARE_METATYPE(AXUIElementRef);
-
-typedef QCFType<CFArrayRef> QCFArrayRef;
-
-class tst_qaccessibility_mac : public QObject
-{
-Q_OBJECT
-public slots:
-    void printInfo();
-    void testForm();
-    void testButtons();
-    void testLineEdit();
-    void testLabel();
-    void testGroups();
-    void testTabWidget();
-    void testTabBar();
-    void testComboBox();
-    void testDeleteWidget();
-    void testDeleteWidgets();
-    void testMultipleWindows();
-    void testHiddenWidgets();
-    void testActions();
-    void testChangeState();
-    void testSlider();
-    void testScrollArea();
-    void testListView();
-    void testTableView();
-    void testScrollBar();
-    void testSplitter();
-    void testTextEdit();
-    void testItemViewsWithoutModel();
-private slots:
-    void testQAElement();
-    void testQAInterface();
-
-    // ui tests load an .ui file.
-    void uitests_data();
-    void uitests();
-    
-    void tests_data();
-    void tests();
-private:
-    void runTest(const QString &testSlot);
-};
-
-/*
-    VERIFYs that there is no error and prints an error message if there is.
-*/
-void testError(AXError error, const QString &text)
-{
-    if (error)
-        qDebug() << "Error" << error << text;
-    QVERIFY(error == 0);
-}
-
-/*
-    Prints an CFArray holding CFStrings.
-*/
-void printCFStringArray(CFArrayRef array, const QString &title)
-{
-    const int numElements = CFArrayGetCount(array);
-    qDebug() << "num" << title << " " <<  numElements;
-
-    for (int i = 0; i < numElements; ++i) {
-       CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(array, i);
-       qDebug() << QCFString::toQString(str);
-    }
-}
-
-QStringList toQStringList(const CFArrayRef array)
-{
-    const int numElements = CFArrayGetCount(array);
-    QStringList qtStrings;
-    
-    for (int i = 0; i < numElements; ++i) {
-        CFStringRef str = (CFStringRef)CFArrayGetValueAtIndex(array, i);
-        qtStrings.append(QCFString::toQString(str));
-    }
-    
-    return qtStrings;
-}
-
-QVariant AXValueToQVariant(AXValueRef value)
-{
-    QVariant var;
-    const AXValueType type = AXValueGetType(value);
-    switch (type) {
-        case kAXValueCGPointType : {
-            CGPoint point;
-            if (AXValueGetValue(value, type, &point))
-                var = QPointF(point.x, point.y);
-        } break;
-        case kAXValueCGSizeType : {
-            CGSize size;
-            if (AXValueGetValue(value, type, &size))
-                var = QSizeF(size.width, size.height);
-        } break;
-        case kAXValueCGRectType :  {
-            CGRect rect;
-            if (AXValueGetValue(value, type, &rect))
-                var = QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-        } break;
-        case kAXValueCFRangeType :
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
-        case kAXValueAXErrorType :
-#endif
-        case kAXValueIllegalType :
-        default:
-        qDebug() << "Illegal/Unsuported AXValue:" << type;
-        break;
-    };
-    return var;
-}
-
-/*
-    Converts a CFTypeRef to a QVariant, for certain selected types. Prints
-    an error message and returns QVariant() if the type is not supported.
-*/
-QVariant CFTypeToQVariant(CFTypeRef value)
-{
-    QVariant var;
-    if (value == 0)
-        return var;
-    const uint typeID = CFGetTypeID(value);
-    if (typeID == CFStringGetTypeID()) {
-        var.setValue(QCFString::toQString((CFStringRef)value));
-    } else if (typeID == CFBooleanGetTypeID()) {
-        var.setValue((bool)CFBooleanGetValue((CFBooleanRef)value));
-    } else if (typeID == AXUIElementGetTypeID()) {
-        var.setValue((AXUIElementRef)value);
-    } else if (typeID == AXValueGetTypeID()) {
-        var = AXValueToQVariant((AXValueRef)value);
-    } else if (typeID == CFNumberGetTypeID()) {
-        CFNumberRef number = (CFNumberRef)value;
-        if (CFNumberGetType(number) != kCFNumberSInt32Type)
-            qDebug() << "unsupported number type" << CFNumberGetType(number);
-        int theNumber;
-        CFNumberGetValue(number, kCFNumberSInt32Type, &theNumber);
-        var.setValue(theNumber);
-    } else if (typeID == CFArrayGetTypeID()) {
-        CFArrayRef cfarray = static_cast<CFArrayRef>(value);
-        QVariantList list;
-        CFIndex size = CFArrayGetCount(cfarray);
-        for (CFIndex i = 0; i < size; ++i)
-            list << CFTypeToQVariant(CFArrayGetValueAtIndex(cfarray, i));
-        var.setValue(list);
-    } else {
-        QCFString str = CFCopyTypeIDDescription(typeID);
-        qDebug() << "Unknown CFType: " << typeID << (QString)str;
-    }
-    return var;
-}
-
-/*
-    Tests if a given attribute is supported by an element. Expects either
-    no error or error -25205 (Not supported). Causes a test failure
-    on other error values.
-*/
-bool supportsAttribute(AXUIElementRef element, CFStringRef attribute)
-{
-    CFArrayRef array;
-    AXError err = AXUIElementCopyAttributeNames(element, &array);
-    if (err) {
-        testError(err, QLatin1String("unexpected error when testing for supported attribute") + QCFString::toQString(attribute));
-        return false;
-    }
-    CFRange range;
-    range.location = 0;
-    range.length = CFArrayGetCount(array);
-    return CFArrayContainsValue(array, range, attribute);
-}
-
-/*
-    Returns the accessibility attribute specified with attribute in a QVariant
-*/
-QVariant attribute(AXUIElementRef element, CFStringRef attribute)
-{
-    CFTypeRef value = 0;
-    AXError err = AXUIElementCopyAttributeValue(element, attribute, &value);
-
-    testError(err, QString("Error getting element attribute ") + QCFString::toQString(attribute));
-
-    if (err)
-        return QVariant();
-
-    return CFTypeToQVariant(value);
-}
-
-/*
-    Returns the title for an element.
-*/
-QString title(AXUIElementRef element)
-{
-    return attribute(element, kAXTitleAttribute).toString();
-}
-
-/*
-    Returns the role for an element.
-*/
-QString role(AXUIElementRef element)
-{
-    return attribute(element, kAXRoleAttribute).toString();
-}
-
-/*
-    Returns the subrole for an element.
-*/
-QString subrole(AXUIElementRef element)
-{
-    return attribute(element, kAXSubroleAttribute).toString();
-}
-
-/*
-    Returns the role description for an element.
-*/
-QString roleDescription(AXUIElementRef element)
-{
-    return attribute(element, kAXRoleDescriptionAttribute).toString();
-}
-
-/*
-    Returns the enabled attribute for an element.
-*/
-bool enabled(AXUIElementRef element)
-{
-    return attribute(element, kAXEnabledAttribute).toBool();
-}
-
-/*
-    Returns the value attribute for an element as an QVariant.
-*/
-QVariant value(AXUIElementRef element)
-{
-    return attribute(element, kAXValueAttribute);
-}
-
-QVariant value(QAElement element)
-{
-    return value(element.element());
-}
-
-/*
-    Returns the description attribute for an element as an QVariant.
-*/
-QVariant description(AXUIElementRef element)
-{
-    return attribute(element, kAXDescriptionAttribute);
-}
-
-/*
-    Returns the value attribute for an element as an bool.
-*/
-bool boolValue(AXUIElementRef element)
-{
-    return attribute(element, kAXValueAttribute).toBool();
-}
-
-/*
-    Returns the parent for an element
-*/
-AXUIElementRef parent(AXUIElementRef element)
-{
-    return attribute(element, kAXParentAttribute).value<AXUIElementRef>();
-}
-
-/*
-    Returns the (top-level) window(not a sheet or a drawer) for an element
-*/
-AXUIElementRef window(AXUIElementRef element)
-{
-    return attribute(element, kAXWindowAttribute).value<AXUIElementRef>();
-}
-
-/*
-    Returns the (top-level) UI element(can also be a sheet or drawer) for an element
-*/
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
-AXUIElementRef topLevelUIElement(AXUIElementRef element)
-{
-    return attribute(element, kAXTopLevelUIElementAttribute).value<AXUIElementRef>();
-}
-#endif
-
-/*
-    Returns thie size of the element.
-*/
-QSizeF size(AXUIElementRef element)
-{
-    return attribute(element, kAXSizeAttribute).value<QSizeF>();
-}
-
-/*
-    Returns the position of the element.
-*/
-QPointF position(AXUIElementRef element)
-{
-    return attribute(element, kAXPositionAttribute).value<QPointF>();
-}
-
-/*
-    Returns the rect of the element.
-*/
-QRectF rect(AXUIElementRef element)
-{
-    return QRectF(position(element), size(element));
-}
-
-bool above(AXUIElementRef a, AXUIElementRef b)
-{
-    return (position(a).y() + size(a).height() <= position(b).y());
-}
-
-bool contains(AXUIElementRef a, AXUIElementRef b)
-{
-    return rect(a).contains(rect(b));
-}
-
-QList<AXUIElementRef> tabs(AXUIElementRef element)
-{
-    CFTypeRef value;
-    AXError err = AXUIElementCopyAttributeValue(element, kAXTabsAttribute, &value);
-    if (err)
-        return QList<AXUIElementRef>();
-        
-    CFArrayRef array = (CFArrayRef)value;
-    QList<AXUIElementRef> elements;
-    const int count = CFArrayGetCount(array);
-    for (int i = 0; i < count; ++i)
-        elements.append((AXUIElementRef)CFArrayGetValueAtIndex(array, i));
-   
-    return elements;
-}
-
-QList<AXUIElementRef> elementListAttribute(AXUIElementRef element, CFStringRef attributeName)
-{
-    QList<AXUIElementRef> elementList;
-    QVariantList variants = attribute(element, attributeName).value<QVariantList>();
-    foreach(QVariant variant, variants)
-        elementList.append(variant.value<AXUIElementRef>());
-    return elementList;
-}
-
-AXUIElementRef elementAttribute(AXUIElementRef element, CFStringRef attributeName)
-{
-    return attribute(element, attributeName).value<AXUIElementRef>();
-}
-
-QString stringAttribute(AXUIElementRef element, CFStringRef attributeName)
-{
-    return attribute(element, attributeName).value<QString>();
-}
-
-
-/*
-    Returns the UIElement at the given position.
-*/
-AXUIElementRef childAtPoint(QPointF position)
-{
-    AXUIElementRef element = 0;
-    const AXError err = AXUIElementCopyElementAtPosition(AXUIElementCreateApplication(getpid()), position.x(), position.y(), &element);
-    if (err) {
-        qDebug() << "Error getting element at " << position;
-        return 0;
-    }
-
-    return element;
-}
-
-/*
-    Returns a QStringList containing the names of the actions the ui element supports
-*/
-QStringList actionNames(AXUIElementRef element)
-{
-    CFArrayRef cfStrings;
-    const AXError err = AXUIElementCopyActionNames(element, &cfStrings);
-    testError(err, "Unable to get action names");
-    return toQStringList(cfStrings);
-}
-
-bool supportsAction(const AXUIElementRef element, const QString &actionName)
-{
-    const QStringList actions = actionNames(element);
-    return actions.contains(actionName);
-}
-
-bool performAction(const AXUIElementRef element, const QString &actionName)
-{
-    const AXError err = AXUIElementPerformAction(element, QCFString(actionName));
-    return (err == 0);
-}
-
-/*
-    Om 10.4 and up, verifyes the AXRoleDescription attribute for an element,
-    on 10.3 and below this test always passes.
-
-    The reason for this is that the HICopyAccessibilityRoleDescription call
-    used to implement this functionality was introduced in 10.4.
-*/
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
-    #define VERIFY_ROLE_DESCRIPTION(ELEMENT,  TEXT) \
-            QCOMPARE(roleDescription(ELEMENT), QString(TEXT))
-#else
-    #define VERIFY_ROLE_DESCRIPTION(ELEMENT,  TEXT) QVERIFY(true)
-#endif
-
-
-CFArrayRef childrenArray(AXUIElementRef element)
-{
-    CFTypeRef value = 0;
-    AXError err = AXUIElementCopyAttributeValue(element, kAXChildrenAttribute, &value);
-    if (!err && CFGetTypeID(value) == CFArrayGetTypeID()) {
-        return (CFArrayRef)value;
-    }
-   
-    return CFArrayCreate(0,0,0,0);
-}
-
-/*
-    Gest the child count from an element.
-*/
-int numChildren(AXUIElementRef element)
-{
-    return CFArrayGetCount(childrenArray(element));
-}
-
-/*
-    Gets the child with index childIndex from element. Returns 0 if not found.
-*/
-AXUIElementRef child(AXUIElementRef element, int childIndex)
-{
-    CFArrayRef children = childrenArray(element);
-    if (childIndex >= CFArrayGetCount(children))
-        return 0;
-
-    const void *data  = CFArrayGetValueAtIndex(children, childIndex);
-    return (AXUIElementRef)data;
-}
-
-/*
-    Gets the child titled childTitle from element. Returns 0 if not found.
-*/
-AXUIElementRef childByTitle(AXUIElementRef element, const QString &childTitle)
-{
-    CFArrayRef children  = childrenArray(element);
-    const int numChildren = CFArrayGetCount(children);
-    for (int i = 0; i < numChildren; ++i) {
-        const AXUIElementRef childElement = (AXUIElementRef)CFArrayGetValueAtIndex(children, i);
-        // Test for support for title attribute before getting it to avoid test fail.
-        if (supportsAttribute(childElement, kAXTitleAttribute) && title(childElement) == childTitle)
-            return childElement;
-    }
-    return 0;
-}
-
-/*
-    Gets the child with the given value from element. Returns 0 if not found.
-*/
-AXUIElementRef childByValue(AXUIElementRef element, const QVariant &testValue)
-{
-    CFArrayRef children  = childrenArray(element);
-    const int numChildren = CFArrayGetCount(children);
-    for (int i = 0; i < numChildren; ++i) {
-        const AXUIElementRef childElement = (AXUIElementRef)CFArrayGetValueAtIndex(children, i);
-        // Test for support for value attribute before getting it to avoid test fail.
-        if (supportsAttribute(childElement, kAXValueAttribute) && value(childElement) == testValue)
-            return childElement;
-    }
-    return 0;
-}
-
-/*
-    Gets the child by role from element. Returns 0 if not found.
-*/
-AXUIElementRef childByRole(AXUIElementRef element, const QString &macRole)
-{
-    CFArrayRef children  = childrenArray(element);
-    const int numChildren = CFArrayGetCount(children);
-    for (int i = 0; i < numChildren; ++i) {
-        const AXUIElementRef childElement = (AXUIElementRef)CFArrayGetValueAtIndex(children, i);
-        if (role(childElement) == macRole)
-            return childElement;
-    }
-    return 0;
-}
-
-void printTypeForAttribute(AXUIElementRef element, CFStringRef attribute)
-{
-    CFTypeRef value = 0;
-    AXError err = AXUIElementCopyAttributeValue(element, attribute, &value);
-    if (!err) {
-        qDebug() << "type id" << CFGetTypeID(value);
-        QCFString str = CFCopyTypeIDDescription(CFGetTypeID(value));
-        qDebug() << (QString)str;
-    } else {
-        qDebug() << "Attribute Get error" << endl;
-    }
-}
-
-int indent = 0;
-QString space()
-{
-    QString space;
-    for (int i = 0; i < indent; ++i) {
-        space += " ";
-    }
-    return space;
-}
-
-
-/*
-    Recursively prints acccesibility info for currentElement and all its children.
-*/
-void printElementInfo(AXUIElementRef currentElement)
-{
-    if (HIObjectIsAccessibilityIgnored(AXUIElementGetHIObject(currentElement))) {
-        qDebug() << space() << "Ignoring element with role" << role(currentElement);
-        return;
-    }
-    
-    qDebug() << space() <<"Role" << role(currentElement);
-    if (supportsAttribute(currentElement, kAXTitleAttribute))
-        qDebug() << space() << "Title" << title(currentElement);
-    else
-        qDebug() << space() << "Title not supported";
-    
-    if (supportsAttribute(currentElement, kAXValueAttribute))
-        qDebug() << space() << "Value" << attribute(currentElement, kAXValueAttribute);
-    else
-        qDebug() << space() << "Value not supported";
-    
-    qDebug() << space() << "Number of children" << numChildren(currentElement);
-    for (int i = 0; i < numChildren(currentElement); ++i) {
-        AXUIElementRef childElement = child(currentElement, i);
-        // Skip the menu bar.
-        if (role(childElement) != "AXMenuBar") {
-            indent+= 4;
-            printElementInfo(childElement);
-            indent-= 4;
-        }
-    }
-    qDebug() << " ";
-}
-
-/*
-    Recursively prints the child interfaces belonging to interface.
-*/
-
-void printChildren(const QAInterface &interface)
-{
-    if (interface.isValid() == false)
-        return;
-        
-    QList<QAInterface> children = interface.children();
-    if (children.isEmpty())
-        return;
-
-    qDebug() << "## Children for" << interface;
-    foreach (const QAInterface &child, children) {
-        qDebug() << child << "index in parent" << interface.indexOfChild(child);
-    }
-    foreach (const QAInterface &child, children) {
-        printChildren(child);
-    }
-}
-
-bool isIgnored(AXUIElementRef currentElement)
-{
-    return HIObjectIsAccessibilityIgnored(AXUIElementGetHIObject(currentElement));
-}
-
-bool equal(CFTypeRef o1, CFTypeRef o2)
-{
-    if (o1 == 0 || o2 == 0)
-        return false;
-    return CFEqual(o1, o2);
-}
-
-/*
-    Verifies basic element info.
-*/
-#define VERIFY_ELEMENT(element, _parent, _role) \
-    QVERIFY(element != 0); \
-    QVERIFY(role(element) == _role); \
-    QVERIFY(equal(::parent(element), _parent));
-/*
-    Verifies that the application and the main form is there has the right info.
-*/
-void testAppAndForm(AXUIElementRef application)
-{
-    QVERIFY(title(application) == "tst_qaccessibility_mac");
-    QVERIFY(role(application) == "AXApplication");
-
-    AXUIElementRef form = childByTitle(application, "Form");
-    VERIFY_ELEMENT(form, application, "AXWindow");
-}
-
-void tst_qaccessibility_mac::printInfo()
-{
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    printElementInfo(currentApplication);
-}
-
-/*
-    Tests for form.ui
-*/
-void tst_qaccessibility_mac::testForm()
-{
-    // Get reference to the current application.
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    testAppAndForm(currentApplication);
-    childByTitle(currentApplication, "Form");
-}
-
-/*
-    Tests for buttons.ui
-*/
-void tst_qaccessibility_mac::testButtons()
-{
-    // Get reference to the current application.
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    testAppAndForm(currentApplication);
-    AXUIElementRef form = childByTitle(currentApplication, "Form");
-
-    AXUIElementRef ren = childByTitle(form, "Ren");
-    VERIFY_ELEMENT(ren, form, "AXButton");
-    QVERIFY(enabled(ren) == true);
-    VERIFY_ROLE_DESCRIPTION(ren, "button");
-
-    AXUIElementRef stimpy = childByTitle(form, "Stimpy");
-    VERIFY_ELEMENT(stimpy, form, "AXRadioButton");
-    QVERIFY(enabled(stimpy) == true);
-    QVERIFY(value(stimpy).toInt() == 1); // checked;
-    VERIFY_ROLE_DESCRIPTION(stimpy, "radio button");
-
-    AXUIElementRef pinky = childByTitle(form, "Pinky");
-    VERIFY_ELEMENT(pinky, form, "AXCheckBox");
-    QVERIFY(enabled(pinky) == false);
-    QVERIFY(value(pinky).toInt() == 0); // unchecked;
-    VERIFY_ROLE_DESCRIPTION(pinky, "check box");
-
-    AXUIElementRef brain = childByTitle(form, "Brain");
-    VERIFY_ELEMENT(brain, form, "AXButton");
-    VERIFY_ROLE_DESCRIPTION(brain, "button");
-}
-
-void tst_qaccessibility_mac::testLabel()
-{
-    // Get reference to the current application.
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-
-    testAppAndForm(currentApplication);
-    AXUIElementRef form = childByTitle(currentApplication, "Form");
-    AXUIElementRef label = childByValue(form, "This is a Text Label");
-    QVERIFY(label);
-    VERIFY_ELEMENT(label, form, "AXStaticText");
-    VERIFY_ROLE_DESCRIPTION(label, "text");
-    QCOMPARE(supportsAttribute(label, kAXDescriptionAttribute), false);
-}
-
-/*
-    Tests for lineedit.ui
-*/
-void tst_qaccessibility_mac::testLineEdit()
-{
-    // Get reference to the current application.
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-
-    testAppAndForm(currentApplication);
-    AXUIElementRef form = childByTitle(currentApplication, "Form");
-    AXUIElementRef lineEdit = childByValue(form, "Line edit");
-    VERIFY_ELEMENT(lineEdit, form, "AXTextField");
-    VERIFY_ROLE_DESCRIPTION(lineEdit, "text field");
-}
-
-/*
-    Tests for groups.ui
-*/
-void tst_qaccessibility_mac::testGroups()
-{
-    // Get reference to the current application.
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-
-    testAppAndForm(currentApplication);
-    AXUIElementRef form = childByTitle(currentApplication, "Form");
-
-    AXUIElementRef groupA = childByTitle(form, "Group A");
-    VERIFY_ELEMENT(groupA, form, "AXGroup");
-    AXUIElementRef button1 = childByTitle(groupA, "PushButton 1");
-    VERIFY_ELEMENT(button1, groupA, "AXButton");
-    VERIFY_ROLE_DESCRIPTION(groupA, "group");
-
-    AXUIElementRef groupB = childByTitle(form, "Group B");
-    VERIFY_ELEMENT(groupB, form, "AXGroup");
-    AXUIElementRef button3 = childByTitle(groupB, "PushButton 3");
-    VERIFY_ELEMENT(button3, groupB, "AXButton");
-}
-
-/*
-    Tests for tabs.ui
-*/
-void tst_qaccessibility_mac::testTabWidget()
-{
-    {   // Test that the QTabWidget hierarchy is what we expect it to be.
-        QTabWidget tabWidget;
-        tabWidget.show();
-        QAInterface interface = QAccessible::queryAccessibleInterface(&tabWidget);
-        tabWidget.addTab(new QPushButton("Foo"), "FooTab");
-        tabWidget.addTab(new QPushButton("Bar"), "BarTab");
-        QCOMPARE(interface.childCount(), 2);
-        const QList<QAInterface> children = interface.children();
-        QVERIFY(children.at(0).object()->inherits("QStackedWidget"));
-        QVERIFY(children.at(1).object()->inherits("QTabBar"));
-        
-        const QList<QAInterface> tabBarChildren = children.at(1).children();
-        QCOMPARE(tabBarChildren.count(), 4);
-        QCOMPARE(tabBarChildren.at(0).text(QAccessible::Name), QLatin1String("FooTab"));
-        QCOMPARE(tabBarChildren.at(1).text(QAccessible::Name), QLatin1String("BarTab"));
-        QCOMPARE(tabBarChildren.at(0).role(), QAccessible::PageTab);
-        QCOMPARE(tabBarChildren.at(1).role(), QAccessible::PageTab);
-
-        // Check that the hierarchy manager is able to register the tab bar children.
-        QAccessibleHierarchyManager *manager = QAccessibleHierarchyManager::instance();
-        QAInterface tabBarInterface = children.at(1);
-        QAElement tabBarElement = manager->registerInterface(tabBarInterface);
-        QCOMPARE(manager->lookup(tabBarElement).childCount(), 4);
-        manager->registerChildren(tabBarInterface);
-        QAElement tabButtonElement = manager->lookup(tabBarChildren.at(1));
-        QAInterface tabButtonInterface = manager->lookup(tabButtonElement);
-        QCOMPARE(tabButtonInterface.text(QAccessible::Name), QLatin1String("BarTab"));
-        QVERIFY(isItInteresting(tabButtonInterface) == true);
-    }
-
-    // Get reference to the current application.
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-
-    testAppAndForm(currentApplication);
-    const QString formTitle = "Form";
-    AXUIElementRef form = childByTitle(currentApplication, formTitle);
-    QVERIFY(form);
-
-    const QString tabRole = "AXTabGroup";
-    AXUIElementRef tabGroup = childByRole(form, tabRole);
-    QVERIFY(tabGroup);
-
-    // Test that we have three child buttons (the tab buttons + plus the contents of the first tab)
-    const int numChildren = ::numChildren(tabGroup);
-    QCOMPARE(numChildren, 3);
-    
-    const QString tab1Title = "Tab 1";
-    AXUIElementRef tabButton1 = childByTitle(tabGroup, tab1Title);
-    QVERIFY (tabButton1);
-    VERIFY_ELEMENT(tabButton1, tabGroup, "AXRadioButton");
-    QCOMPARE(title(tabButton1), tab1Title);
-
-    const QString tab2Title = "Tab 2";
-    const AXUIElementRef tabButton2 = childByTitle(tabGroup, tab2Title);
-    QVERIFY(tabButton2);
-    VERIFY_ELEMENT(tabButton2, tabGroup, "AXRadioButton");
-    QCOMPARE(title(tabButton2), tab2Title);
-    
-    // Test that the window and top-level-ui-elment is the form.
-    // Window is not reported properly on 10.5
-    if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5) {
-        QVERIFY(equal(window(tabGroup), form));
-
-    //   ### hangs on 10.4
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
-    QVERIFY(equal(window(tabButton1), form));
-#endif
-    }
-//   ### hangs on 10.4
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
-    QVERIFY(equal(topLevelUIElement(tabGroup), form));
-    QVERIFY(equal(topLevelUIElement(tabButton1), form));    
-#endif
-    // Test the bounding rectangles for the tab group and buttons.
-    const QRectF groupRect(position(tabGroup), size(tabGroup));
-    const QRectF tabButton1Rect(position(tabButton1), size(tabButton1));
-    const QRectF tabButton2Rect(position(tabButton2), size(tabButton2));
-    
-    QVERIFY(groupRect.isNull() == false);
-    QVERIFY(tabButton1Rect.isNull() == false);
-    QVERIFY(tabButton1Rect.isNull() == false);
-        
-    QVERIFY(groupRect.contains(tabButton1Rect));
-    QVERIFY(groupRect.contains(tabButton2Rect));
-    QVERIFY(tabButton2Rect.contains(tabButton1Rect) == false);
-    
-    // Test the childAtPoint event.
-    const AXUIElementRef childAtTab1Position = childAtPoint(position(tabButton1) + QPointF(5,5));
-    QVERIFY(equal(childAtTab1Position, tabButton1));
-    const AXUIElementRef childAtOtherPosition = childAtPoint(position(tabButton1) - QPointF(5,5));
-    QVERIFY(equal(childAtOtherPosition, tabButton1) == false);
-
-    // Test AXTabs attribute
-    QVERIFY(supportsAttribute(tabGroup, kAXTabsAttribute));
-    QList<AXUIElementRef> tabElements = tabs(tabGroup);
-    QCOMPARE(tabElements.count(), 2);
-    QVERIFY(equal(tabElements.at(0), tabButton1));
-    QVERIFY(equal(tabElements.at(1), tabButton2));
-    
-    // Perform the press action on each child.
-    for (int i = 0; i < numChildren; ++i) {
-        const AXUIElementRef child = ::child(tabGroup, i);
-        QVERIFY(supportsAction(child, "AXPress"));
-        QVERIFY(performAction(child, "AXPress"));
-    }
-}
-
-void tst_qaccessibility_mac::testTabBar()
-{
-    QTabBar tabBar;
-    tabBar.addTab("Tab A");
-    tabBar.addTab("Tab B");
-    tabBar.show();
-
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    AXUIElementRef window = childByRole(currentApplication, "AXWindow");
-    QVERIFY(window);
-
-    const QString tabRole = "AXTabGroup";
-    AXUIElementRef tabGroup = childByRole(window, tabRole);
-    QVERIFY(tabGroup);
-
-    const int numChildren = ::numChildren(tabGroup);
-    QCOMPARE(numChildren, 2);
-    
-    const QString tab1Title = "Tab A";
-    AXUIElementRef tabButton1 = childByTitle(tabGroup, tab1Title);
-    QVERIFY (tabButton1);
-    VERIFY_ELEMENT(tabButton1, tabGroup, "AXRadioButton");
-    QCOMPARE(title(tabButton1), tab1Title);
-
-    const QString tab2Title = "Tab B";
-    const AXUIElementRef tabButton2 = childByTitle(tabGroup, tab2Title);
-    QVERIFY(tabButton2);
-    VERIFY_ELEMENT(tabButton2, tabGroup, "AXRadioButton");
-    QCOMPARE(title(tabButton2), tab2Title);
-
-    // Test the childAtPoint event.
-    const AXUIElementRef childAtTab1Position = childAtPoint(position(tabButton1) + QPointF(5,5));
-    QVERIFY(equal(childAtTab1Position, tabButton1));
-    const AXUIElementRef childAtOtherPosition = childAtPoint(position(tabButton1) - QPointF(5,5));
-    QVERIFY(equal(childAtOtherPosition, tabButton1) == false);
-
-    // Test AXTabs attribute
-    QVERIFY(supportsAttribute(tabGroup, kAXTabsAttribute));
-    QList<AXUIElementRef> tabElements = tabs(tabGroup);
-    QCOMPARE(tabElements.count(), 2);
-    QVERIFY(equal(tabElements.at(0), tabButton1));
-    QVERIFY(equal(tabElements.at(1), tabButton2));
-    
-    // Perform the press action on each child.
-    for (int i = 0; i < numChildren; ++i) {
-        const AXUIElementRef child = ::child(tabGroup, i);
-        QVERIFY(supportsAction(child, "AXPress"));
-        QVERIFY(performAction(child, "AXPress"));
-    }
-}
-
-void tst_qaccessibility_mac::testComboBox()
-{
-    // Get reference to the current application.
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-
-    testAppAndForm(currentApplication);
-    const QString formTitle = "Form";
-    AXUIElementRef form = childByTitle(currentApplication, formTitle);
-    
-    const QString comboBoxRole = "AXPopUpButton";
-    AXUIElementRef comboBox = childByRole(form, comboBoxRole);
-    QVERIFY(comboBox != 0);
-    QVERIFY(supportsAction(comboBox, "AXPress"));
-    QVERIFY(performAction(comboBox, "AXPress"));
-}
-
-void tst_qaccessibility_mac::testDeleteWidget()
-{
-    const QString buttonTitle = "Hi there";
-    QWidget *form = new QWidget(0, Qt::Window);
-    form->setWindowTitle("Form");
-    form->show();
-    QPushButton *button = new QPushButton(buttonTitle, form);
-    button->show();
-
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    testAppAndForm(currentApplication);
-    AXUIElementRef formElement = childByTitle(currentApplication, "Form");
-
-    AXUIElementRef buttonElement = childByTitle(formElement, buttonTitle);
-    QVERIFY(buttonElement);
-
-    button->hide();
-    delete button;
-
-    buttonElement = childByTitle(formElement, buttonTitle);
-    QVERIFY(!buttonElement);
-    delete form;
-}
-
-void tst_qaccessibility_mac::testDeleteWidgets()
-{
-    const QString buttonTitle = "Hi there";
-    const int repeats = 10;
-
-    for (int i = 0; i < repeats; ++i) {
-
-        QWidget *form = new QWidget(0, Qt::Window);
-        form->setWindowTitle("Form");
-        form->show();
-    
-        QPushButton *button = new QPushButton(buttonTitle, form);
-        button->show();
-    
-        AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-        testAppAndForm(currentApplication);
-        AXUIElementRef formElement = childByTitle(currentApplication, "Form");
-        AXUIElementRef buttonElement = childByTitle(formElement, buttonTitle);
-        QVERIFY(buttonElement);
-        delete form;
-
-        {
-            AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-            QVERIFY(currentApplication);
-            AXUIElementRef formElement = childByTitle(currentApplication, "Form");
-            QVERIFY(!formElement);
-        }
-    }
-
-    for (int i = 0; i < repeats; ++i) {
-        QWidget *form = new QWidget(0, Qt::Window);
-        form->setWindowTitle("Form");
-
-    
-        new QScrollBar(form);
-        form->show();
-    
-        AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-        testAppAndForm(currentApplication);
-        AXUIElementRef formElement = childByTitle(currentApplication, "Form");
-        
-        const AXUIElementRef scrollBarElement = childByRole(formElement, "AXScrollBar");
-        QVERIFY(scrollBarElement);
-        delete form;
-
-        {
-            AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-            QVERIFY(currentApplication);
-            AXUIElementRef formElement = childByTitle(currentApplication, "Form");
-            QVERIFY(!formElement);
-        }
-    }
-
-    for (int i = 0; i < repeats; ++i) {
-        QWidget *form = new QWidget(0, Qt::Window);
-        form->setWindowTitle("Form");
-    
-        QListWidget *listWidget = new QListWidget(form);
-        listWidget->addItem("Foo");
-        listWidget->addItem("Bar");
-        form->show();
-    
-        AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-        testAppAndForm(currentApplication);
-        AXUIElementRef formElement = childByTitle(currentApplication, "Form");
-
-        const AXUIElementRef scrollAreaElement = childByRole(formElement, "AXScrollArea");
-        QVERIFY(scrollAreaElement);
-
-        const AXUIElementRef listElement = childByRole(scrollAreaElement, "AXList");
-        QVERIFY(listElement);
-        delete form;
-
-        {
-            AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-            QVERIFY(currentApplication);
-            AXUIElementRef formElement = childByTitle(currentApplication, "Form");
-            QVERIFY(!formElement);
-        }
-    }
-
-}
-
-void tst_qaccessibility_mac::testMultipleWindows()
-{
-    const QString formATitle("FormA");
-    const QString formBTitle("FormB");
-
-    // Create a window
-    QWidget *formA = new QWidget(0, Qt::Window);
-    formA->setWindowTitle(formATitle);
-    formA->show();
-
-    // Test if we can access the window
-    AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    AXUIElementRef formAElement = childByTitle(currentApplication, formATitle);
-    QVERIFY(formAElement);
-
-    // Create another window
-    QWidget *formB = new QWidget(0, Qt::Window);
-    formB->setWindowTitle(formBTitle);
-    formB->show();
-
-    // Test if we can access both windows
-    formAElement = childByTitle(currentApplication, formATitle);
-    QVERIFY(formAElement);
-
-    AXUIElementRef formBElement = childByTitle(currentApplication, formBTitle);
-    QVERIFY(formBElement);
-    
-    delete formA;
-}
-
-void tst_qaccessibility_mac::testHiddenWidgets()
-{
-    const QString windowTitle ="a widget";
-    QWidget * const window = new QWidget(0);
-    window->setWindowTitle(windowTitle);
-    window->show();
-
-    const AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    const AXUIElementRef windowElement = childByTitle(currentApplication, windowTitle);
-    QVERIFY(windowElement);
-    QCOMPARE(isIgnored(windowElement), false);
-    
-    const QString buttonTitle = "a button";
-    QPushButton * const button = new QPushButton(window);    
-    button->setText(buttonTitle);
-    button->show();
-    
-    const AXUIElementRef buttonElement = childByTitle(windowElement, buttonTitle);
-    QVERIFY(buttonElement);
-    QCOMPARE(isIgnored(buttonElement), false);
-
-    const QString toolbarTitle = "a toolbar";
-    QToolBar * const toolbar = new QToolBar(toolbarTitle, window);
-    toolbar->show();
-    
-    const AXUIElementRef toolBarElement = childByTitle(windowElement, toolbarTitle);
-    QVERIFY(toolBarElement == 0);
-
-    delete window;
-};
-
-void tst_qaccessibility_mac::testActions()
-{
-    // create a window with a push button
-    const QString windowTitle ="a widget";
-    QWidget * const window = new QWidget();
-    window->setWindowTitle(windowTitle);
-    window->show();
-
-    const AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    const AXUIElementRef windowElement = childByTitle(currentApplication, windowTitle);
-    QVERIFY(windowElement);
-
-    const QString buttonTitle = "a button";
-    QPushButton * const button = new QPushButton(window);    
-    button->setText(buttonTitle);
-    button->show();
-    
-    const AXUIElementRef buttonElement = childByTitle(windowElement, buttonTitle);
-    QVERIFY(buttonElement);
-
-    // Verify that the button has the Press action.
-    const QStringList actions = actionNames(buttonElement);
-    const QString pressActionName("AXPress");
-    QVERIFY(actions.contains(pressActionName));
-    
-    // Press button and check the pressed signal
-    QSignalSpy pressed(button, SIGNAL(pressed()));
-    QVERIFY(performAction(buttonElement, pressActionName));
-    QCOMPARE(pressed.count(), 1);
-    
-    pressed.clear();
-    QVERIFY(performAction(buttonElement, QString("does not exist")));
-    QCOMPARE(pressed.count(), 0);
-
-    delete window;
-};
-
-void tst_qaccessibility_mac::testChangeState()
-{
-    const QString windowTitle ="a widget";
-    QWidget * const window = new QWidget();
-    window->setWindowTitle(windowTitle);
-    window->show();
-    const AXUIElementRef applicationElement = AXUIElementCreateApplication(getpid());
-    const AXUIElementRef windowElement = childByTitle(applicationElement, windowTitle);
-    QVERIFY(windowElement);
-    const int otherChildren = numChildren(windowElement);
-    
-    const QString buttonTitle = "Button";
-    QPushButton * const button = new QPushButton(buttonTitle, window);
-    button->setText(buttonTitle);  
-
-    // Test that show/hide adds/removes the button from the hierachy.
-    QVERIFY(childByTitle(windowElement, buttonTitle) == 0);
-    QCOMPARE(numChildren(windowElement), otherChildren);
-    button->show();
-    QVERIFY(childByTitle(windowElement, buttonTitle) != 0);
-    QCOMPARE(numChildren(windowElement), otherChildren + 1);
-    button->hide();
-    QVERIFY(childByTitle(windowElement, buttonTitle) == 0);
-    QCOMPARE(numChildren(windowElement), otherChildren);
-    button->show();
-    QVERIFY(childByTitle(windowElement, buttonTitle) != 0);
-    QCOMPARE(numChildren(windowElement), otherChildren + 1);
-
-    // Test that hiding and showing a widget also removes and adds all its children.
-    {
-        QWidget * const parent = new QWidget(window);
-        const int otherChildren = numChildren(windowElement);
-        
-        QPushButton * const child = new QPushButton(parent);
-        const QString childButtonTitle = "child button";
-        child->setText(childButtonTitle);
-        
-        parent->show();
-        QVERIFY(childByTitle(windowElement, childButtonTitle) != 0);
-        QCOMPARE(numChildren(windowElement), otherChildren + 1);
-
-        parent->hide();
-        QVERIFY(childByTitle(windowElement, childButtonTitle) == 0);
-        QCOMPARE(numChildren(windowElement), otherChildren );
-
-        parent->show();
-        QVERIFY(childByTitle(windowElement, childButtonTitle) != 0);
-        QCOMPARE(numChildren(windowElement), otherChildren + 1);
-        
-        delete parent;
-    }
-
-    // Test that the enabled attribute is updated after a call to setEnabled.
-    const AXUIElementRef buttonElement = childByTitle(windowElement, buttonTitle);
-    QVERIFY(enabled(buttonElement));
-    button->setEnabled(false);
-    QVERIFY(enabled(buttonElement) == false);
-    button->setEnabled(true);
-    QVERIFY(enabled(buttonElement));
-
-    // Test that changing the title updates the accessibility information.
-    const QString buttonTitle2 = "Button 2";    
-    button->setText(buttonTitle2);
-    QVERIFY(childByTitle(windowElement, buttonTitle2) != 0);
-    QVERIFY(childByTitle(windowElement, buttonTitle) == 0);
-
-    delete window;
-}
-
-void tst_qaccessibility_mac::testSlider()
-{
-    const QString windowTitle = "a widget";
-    QWidget * const window = new QWidget();
-    window->setWindowTitle(windowTitle);
-    window->show();
-    const AXUIElementRef applicationElement = AXUIElementCreateApplication(getpid());
-    QVERIFY(applicationElement);
-    const AXUIElementRef windowElement = childByTitle(applicationElement, windowTitle);
-    QVERIFY(windowElement);
-    const int windowChildren = numChildren(windowElement);
-    
-    QSlider * const slider = new QSlider(window);
-    slider->show();
-    const AXUIElementRef sliderElement = childByRole(windowElement, "AXSlider");
-    QVERIFY(sliderElement);
-
-    // Test that the slider and its children are removed from the hierachy when we call hide().
-    QCOMPARE(numChildren(windowElement), windowChildren + 1);
-    slider->hide();
-    QCOMPARE(numChildren(windowElement), windowChildren);
-    
-    delete slider;
-}
-
-void tst_qaccessibility_mac::testScrollArea()
-{
-    QWidget window;
-    const QString windowTitle = "window";
-    window.setWindowTitle(windowTitle);
-    window.resize(300, 300);
-
-    QScrollArea scrollArea(&window);
-    scrollArea.resize(300, 300);
-    scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-    scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-
-    QLabel label;
-    label.setText("Foo"); 
-    scrollArea.setWidget(&label);
-
-    window.show();
-
-    // Verify that the QAinterface returns the correct children
-    QAInterface interface = QAccessible::queryAccessibleInterface(&scrollArea);
-    QCOMPARE(interface.childCount(), 3);
-    
-    QAInterface viewport = interface.navigate(QAccessible::Child, 1);
-    QVERIFY(viewport.isValid());
-
-    QAInterface scrollBarContainer1 = interface.navigate(QAccessible::Child, 2);
-    QVERIFY(scrollBarContainer1.isValid());
-
-    QAInterface scrollBar1 = scrollBarContainer1.navigate(QAccessible::Child, 1);
-
-    QVERIFY(scrollBar1.isValid());
-    QVERIFY(scrollBar1.role() == QAccessible::ScrollBar);
-
-    QAInterface scrollBarContainer2 = interface.navigate(QAccessible::Child, 3);
-    QVERIFY(scrollBarContainer1.isValid());
-
-    QAInterface scrollBar2 = scrollBarContainer2.navigate(QAccessible::Child, 1);
-    QVERIFY(scrollBar2.isValid());
-    QVERIFY(scrollBar2.role() == QAccessible::ScrollBar);    
-
-    // Navigate to the scroll area from the application
-    const AXUIElementRef applicationElement = AXUIElementCreateApplication(getpid());
-    QVERIFY(applicationElement);
-    const AXUIElementRef windowElement = childByTitle(applicationElement, windowTitle);
-    QVERIFY(windowElement);
-    const AXUIElementRef scrollAreaElement = childByRole(windowElement, "AXScrollArea");
-    QVERIFY(scrollAreaElement);
-
-    // Get the scroll bars
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXHorizontalScrollBarAttribute));
-    const AXUIElementRef horizontalScrollBar = elementAttribute(scrollAreaElement, kAXHorizontalScrollBarAttribute);
-    QVERIFY(horizontalScrollBar);
-    QVERIFY(role(horizontalScrollBar) == "AXScrollBar");
-    QVERIFY(stringAttribute(horizontalScrollBar, kAXOrientationAttribute) == "AXHorizontalOrientation");
-
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXVerticalScrollBarAttribute));
-    const AXUIElementRef verticalScrollBar = elementAttribute(scrollAreaElement, kAXVerticalScrollBarAttribute);
-    QVERIFY(verticalScrollBar);
-    QVERIFY(role(verticalScrollBar) == "AXScrollBar");
-    QVERIFY(stringAttribute(verticalScrollBar, kAXOrientationAttribute) == "AXVerticalOrientation");
-
-    // Get the contents and verify that we get the label.
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXContentsAttribute));
-    const QList<AXUIElementRef> contents = elementListAttribute(scrollAreaElement, kAXContentsAttribute);
-    QCOMPARE(contents.count(), 1);
-    AXUIElementRef content = contents.at(0);
-    QVERIFY(role(content) == "AXStaticText");
-    QVERIFY(title(content) == "Foo");
-
-    // Turn scroll bars off
-    {
-    scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXHorizontalScrollBarAttribute) == false);
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXVerticalScrollBarAttribute) == false);
-
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXContentsAttribute));
-    const QList<AXUIElementRef> contents = elementListAttribute(scrollAreaElement, kAXContentsAttribute);
-    QCOMPARE(contents.count(), 1);
-    AXUIElementRef content = contents.at(0);
-    
-    QVERIFY(role(content) == "AXStaticText");
-    QVERIFY(title(content) == "Foo");
-    }
-
-    // Turn the horizontal scrollbar on.
-    {
-    scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-    scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXHorizontalScrollBarAttribute) == true);
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXVerticalScrollBarAttribute) == false);
-
-    const AXUIElementRef horizontalScrollBar = elementAttribute(scrollAreaElement, kAXHorizontalScrollBarAttribute);
-    QVERIFY(horizontalScrollBar);
-    QVERIFY(role(horizontalScrollBar) == "AXScrollBar");
-    QVERIFY(stringAttribute(horizontalScrollBar, kAXOrientationAttribute) == "AXHorizontalOrientation");
-
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXContentsAttribute));
-    const QList<AXUIElementRef> contents = elementListAttribute(scrollAreaElement, kAXContentsAttribute);
-    QCOMPARE(contents.count(), 1);
-    AXUIElementRef content = contents.at(0);
-    QVERIFY(role(content) == "AXStaticText");
-    QVERIFY(title(content) == "Foo");
-    }
-
-    // Turn the vertical scrollbar on.
-    {
-    scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXHorizontalScrollBarAttribute) == false);
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXVerticalScrollBarAttribute) == true);
-
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXVerticalScrollBarAttribute));
-    const AXUIElementRef verticalScrollBar = elementAttribute(scrollAreaElement, kAXVerticalScrollBarAttribute);
-    QVERIFY(verticalScrollBar);
-    QVERIFY(role(verticalScrollBar) == "AXScrollBar");
-    QVERIFY(stringAttribute(verticalScrollBar, kAXOrientationAttribute) == "AXVerticalOrientation");
-
-    QVERIFY(supportsAttribute(scrollAreaElement, kAXContentsAttribute));
-    const QList<AXUIElementRef> contents = elementListAttribute(scrollAreaElement, kAXContentsAttribute);
-    QCOMPARE(contents.count(), 1);
-    AXUIElementRef content = contents.at(0);
-    QVERIFY(role(content) == "AXStaticText");
-    QVERIFY(title(content) == "Foo");
-    }
-}
-
-void tst_qaccessibility_mac::testListView()
-{
-    QWidget window;
-    const QString windowTitle("window");
-    window.setWindowTitle(windowTitle);
-    window.resize(300, 300);
-
-    QListWidget *listWidget = new QListWidget(&window);
-    listWidget->setObjectName("listwidget");
-    listWidget->addItem("A");
-    listWidget->addItem("B");
-    listWidget->addItem("C");
-    
-    window.show();
-    QTest::qWait(1);
-        
-    {
-        // Verify that QAInterface works as expected for list views
-        QAInterface listWidgetInterface = QAccessible::queryAccessibleInterface(listWidget);
-        QCOMPARE(listWidgetInterface.role(), QAccessible::Client);
-        QCOMPARE(listWidgetInterface.childCount(), 1);
-        QAInterface viewPort = listWidgetInterface.childAt(1);
-        QCOMPARE(viewPort.role(), QAccessible::List);
-        QVERIFY(viewPort.object() != 0);
-        QCOMPARE(viewPort.childCount(), 3);
-        const QList<QAInterface> rows = viewPort.children();
-        QCOMPARE(rows.count(), 3);
-        QVERIFY(rows.at(0).object() == 0);
-        QCOMPARE(rows.at(0).parent().indexOfChild(rows.at(0)), 1);
-        QCOMPARE(rows.at(1).parent().indexOfChild(rows.at(1)), 2);
-        QCOMPARE(rows.at(2).parent().indexOfChild(rows.at(2)), 3);         
-        
-        // test the QAInterface comparison operator
-        QVERIFY(rows.at(0) == rows.at(0));
-        QVERIFY(rows.at(0) != rows.at(1));
-        QVERIFY(rows.at(0) != viewPort);
-        QVERIFY(viewPort == viewPort);
-        QVERIFY(listWidgetInterface != viewPort);
-        QVERIFY(listWidgetInterface == listWidgetInterface);
-        
-        // test QAInterface::isHIView()
-        QVERIFY(viewPort.isHIView());
-        QVERIFY(listWidgetInterface.isHIView());
-        QVERIFY(rows.at(0).isHIView() == false);
-    }
-
-    const AXUIElementRef applicationElement = AXUIElementCreateApplication(getpid());
-    QVERIFY(applicationElement);
-    const AXUIElementRef windowElement = childByTitle(applicationElement, windowTitle);
-    QVERIFY(windowElement);
-    const AXUIElementRef scrollAreaElement = childByRole(windowElement, "AXScrollArea");
-    QVERIFY(scrollAreaElement);
-    const AXUIElementRef listElement = childByRole(scrollAreaElement, "AXList");
-    QVERIFY(listElement);
-    QVERIFY(equal(::parent(listElement), scrollAreaElement));
-    // Window is not reported properly on 10.5
-    if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5) 
-        QVERIFY(equal(::window(listElement), windowElement));
-    
-    const AXUIElementRef A = childByTitle(listElement, "A");
-    QVERIFY(A);
-    const AXUIElementRef B = childByTitle(listElement, "B");
-    QVERIFY(B);
-    const AXUIElementRef C = childByTitle(listElement, "C");
-    QVERIFY(C);
-
-    QVERIFY(value(A) == "A");
-    QVERIFY(equal(::parent(A), listElement));
-    QVERIFY(enabled(A));
-
-    // Window is not reported properly on 10.5, this test
-    // hangs on 10.4. Disable it for now.
-    //    if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5) 
-    //        QVERIFY(equal(::window(A), windowElement));
-    
-    QVERIFY(above(A, B));
-    QVERIFY(!above(B, A));
-    QVERIFY(above(B, C));
-    QVERIFY(contains(listElement, A));
-    QVERIFY(!contains(A, listElement));
-    QVERIFY(contains(listElement, B));
-    QVERIFY(contains(listElement, C));
-}
-
-void tst_qaccessibility_mac::testTableView()
-{
-    QWidget window;
-    const QString windowTitle("window");
-    window.setWindowTitle(windowTitle);
-    window.resize(300, 300);
-
-    QTableWidget *tableWidget = new QTableWidget(&window);
-    tableWidget->setObjectName("tablewidget");
-    tableWidget->setRowCount(3);
-    tableWidget->setColumnCount(2);
-
-    tableWidget->setItem(0, 0, new QTableWidgetItem("A1"));
-    tableWidget->setItem(0, 1, new QTableWidgetItem("A2"));
-
-    tableWidget->setItem(1, 0, new QTableWidgetItem("B1"));
-    tableWidget->setItem(1, 1, new QTableWidgetItem("B2"));
-
-    tableWidget->setItem(2, 0, new QTableWidgetItem("C1"));
-    tableWidget->setItem(2, 1, new QTableWidgetItem("C2"));
-
-    window.show();
-    
-    {
-        // Verify that QAInterface works as expected for table view children.
-        QAInterface tableWidgetInterface = QAccessible::queryAccessibleInterface(tableWidget);
-        QCOMPARE(tableWidgetInterface.role(), QAccessible::Client);
-        QCOMPARE(tableWidgetInterface.childCount(), 1);
-        QAInterface viewPort = tableWidgetInterface.childAt(1);
-        QCOMPARE(viewPort.childCount(), 4);
-        QCOMPARE(viewPort.role(), QAccessible::Table);
-        QVERIFY(viewPort.object() != 0);
-        const QList<QAInterface> rows = viewPort.children();
-        QCOMPARE(rows.count(), 4);
-        QVERIFY(rows.at(0).object() == 0);
-        QCOMPARE(rows.at(0).parent().indexOfChild(rows.at(0)), 1);
-        QCOMPARE(rows.at(1).parent().indexOfChild(rows.at(1)), 2);
-        QCOMPARE(rows.at(2).parent().indexOfChild(rows.at(2)), 3);         
-
-        QAInterface Arow = rows.at(1);
-        QCOMPARE(Arow.role(), QAccessible::Row);
-        QAInterface Brow = rows.at(2);
-
-        QVERIFY(Arow.name() == "1");
-        QVERIFY(Brow.name() == "2");
-
-        QVERIFY(Arow == Arow);
-        QVERIFY(Brow != Arow);
-        QVERIFY(Arow.isHIView() == false);
-        QCOMPARE(Arow.childCount(), 3);
-        QList<QAInterface> Achildren = Arow.children();
-        QCOMPARE(Achildren.count(), 3);
-        QAInterface A1 = Achildren.at(1);
-        QAInterface A2 = Achildren.at(2);
-        QCOMPARE(Arow.indexOfChild(A1), 2);
-        QCOMPARE(Arow.indexOfChild(A2), 3);
-        QCOMPARE(A1.role(), QAccessible::Cell);
-
-        QList<QAInterface> Bchildren = Brow.children();
-        QCOMPARE(Bchildren.count(), 3);
-        QAInterface B1 = Bchildren.at(1);
-        QAInterface B2 = Bchildren.at(2);
-        QVERIFY(B1.parent() == Brow);
-        QVERIFY(B1.parent() != Arow);
-        QCOMPARE(Arow.indexOfChild(B1), -1);
-
-        QVERIFY(A1 == A1);
-        QVERIFY(A1 != A2);
-        QVERIFY(B1 != A1);
-        QVERIFY(B1 != A2);
-        QVERIFY(A1 != Arow);
-        QVERIFY(A1 != Brow);
-        QVERIFY(A1 != viewPort);
-        QVERIFY(A1.isHIView() == false);
-
-        QVERIFY(B1.parent() == Brow);
-        QVERIFY(A1.parent() == Arow);
-        B1 = A1;
-        QVERIFY(B1.parent() == Arow);
-    }
-    
-    const AXUIElementRef applicationElement = AXUIElementCreateApplication(getpid());
-    QVERIFY(applicationElement);
-    const AXUIElementRef windowElement = childByTitle(applicationElement, windowTitle);
-    QVERIFY(windowElement);
-    const AXUIElementRef scrollAreaElement = childByRole(windowElement, "AXScrollArea");
-    QVERIFY(scrollAreaElement);
-    const AXUIElementRef tableElement = childByRole(scrollAreaElement, "AXTable");
-    QVERIFY(tableElement);
-   
-    {
-        // Verify that QAccessibleHierarchyManager can look up table view children correctly
-        QAccessibleHierarchyManager *manager = QAccessibleHierarchyManager::instance();
-        QAInterface tableInterface = manager->lookup(tableElement);
-        QVERIFY(tableInterface.isValid());
-        QVERIFY(tableInterface.role() == QAccessible::Table);
-   
-        QAInterface ArowInterface = tableInterface.childAt(2);
-
-        QVERIFY(ArowInterface.name() == "1");
-        QVERIFY(manager->lookup(manager->lookup(ArowInterface)).name() == "1");
-
-        QCOMPARE(ArowInterface.childCount(), 3);
-        QAInterface A1Interface = ArowInterface.childAt(2);
-
-        QCOMPARE(A1Interface.value(), QString("A1"));
-        QVERIFY(value(manager->lookup(A1Interface)).toString() == "A1");
-
-        QAInterface A2Interface = ArowInterface.childAt(3);
-        QAElement A2Element = manager->lookup(A2Interface);
-        QVERIFY(manager->lookup(A2Element).value() == "A2");
-        QVERIFY(value(A2Element).toString() == "A2");
-
-        QAInterface BrowInterface = tableInterface.childAt(3);
-        QVERIFY(BrowInterface.value() == "2");
-        QVERIFY(manager->lookup(manager->lookup(BrowInterface)).value() == "2");
-
-        QCOMPARE(BrowInterface.childCount(), 3);
-        QAInterface B1Interface = BrowInterface.childAt(2);
-        QVERIFY(value(manager->lookup(B1Interface)).toString() == "B1");
-
-        QAInterface B2Interface = BrowInterface.childAt(3);
-        QAElement B2Element = manager->lookup(B2Interface);
-        QVERIFY(manager->lookup(B2Element).value() == "B2");
-        QVERIFY(value(B2Element).toString() == "B2");
-    }
-
-
-
-    const AXUIElementRef Arow = childByTitle(tableElement, "1");
-    QVERIFY(Arow);
-    const AXUIElementRef Brow = childByTitle(tableElement, "2");
-    QVERIFY(Brow);
-    const AXUIElementRef Crow = childByTitle(tableElement, "3");
-    QVERIFY(Crow);
-
-    QCOMPARE(numChildren(Arow), 3);
-    const AXUIElementRef A1cell = childByTitle(Arow, "A1");
-    QVERIFY(A1cell);
-    QVERIFY(role(A1cell) == "AXTextField");
-    const AXUIElementRef A2cell = childByTitle(Arow, "A2");
-    QVERIFY(A2cell);
-    QVERIFY(equal(::parent(A2cell), Arow));
-
-    const AXUIElementRef B2cell = childByTitle(Brow, "B2");
-    QVERIFY(B2cell);
-    QVERIFY(equal(::parent(B2cell), Brow));
-
-    {
-        QVERIFY(supportsAttribute(tableElement, kAXRowsAttribute));
-        const QList<AXUIElementRef> rows = elementListAttribute(tableElement, kAXRowsAttribute);
-        QCOMPARE(rows.count(), 3); // the header is not a row
-        QVERIFY(value(rows.at(1)) == "2");
-        QVERIFY(value(rows.at(2)) == "3");
-    }
-
-    {
-        QVERIFY(supportsAttribute(tableElement, kAXVisibleRowsAttribute));
-        const QList<AXUIElementRef> rows = elementListAttribute(tableElement, kAXVisibleRowsAttribute);
-        QCOMPARE(rows.count(), 3);
-        QVERIFY(value(rows.at(1)) == "2");
-    }
-    {
-        QVERIFY(supportsAttribute(tableElement, kAXSelectedRowsAttribute));
-        const QList<AXUIElementRef> rows = elementListAttribute(tableElement, kAXSelectedRowsAttribute);
-        QCOMPARE(rows.count(), 0);
-    }
-
-    // test row visibility
-    {
-        QTableWidget tableWidget;
-        tableWidget.setObjectName("tablewidget");
-        tableWidget.setRowCount(1000);
-        tableWidget.setColumnCount(1);
-
-        for (int i =0; i < 1000; ++i) {
-            tableWidget.setItem(i, 0, new QTableWidgetItem("item"));
-        }
-        tableWidget.show();
-        
-        QAInterface tableWidgetInterface = QAccessible::queryAccessibleInterface(&tableWidget);
-        QAInterface viewPortInterface = tableWidgetInterface.childAt(1);
-        QCOMPARE(viewPortInterface.childCount(), 1001);
-
-        QVERIFY((viewPortInterface.childAt(2).state() & QAccessible::Invisible) == false);
-        QVERIFY((viewPortInterface.childAt(2).state() & QAccessible::Offscreen) == false);
-        
-        QVERIFY(viewPortInterface.childAt(500).state() & QAccessible::Invisible);
-//        QVERIFY(viewPortInterface.childAt(500).state() & QAccessible::Offscreen);
-        tableWidget.hide();
-    }
-
-//    printElementInfo(tableElement);
-//    QTest::qWait(1000000);
-}
-
-void tst_qaccessibility_mac::testScrollBar()
-{
-    {
-        QScrollBar scrollBar;
-        scrollBar.show();
-
-        QAInterface scrollBarInterface = QAccessible::queryAccessibleInterface(&scrollBar);
-        QVERIFY(scrollBarInterface.isValid());
-        QCOMPARE(scrollBarInterface.childCount(), 5);
-        QCOMPARE(scrollBarInterface.indexOfChild(scrollBarInterface.childAt(1)), 1);
-        QCOMPARE(scrollBarInterface.indexOfChild(scrollBarInterface.childAt(2)), 2);
-        QCOMPARE(scrollBarInterface.indexOfChild(scrollBarInterface.childAt(5)), 5);
-        QCOMPARE(scrollBarInterface.indexOfChild(scrollBarInterface), -1);
-    }
-
-    const AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    testAppAndForm(currentApplication);
-    const AXUIElementRef form = childByTitle(currentApplication, "Form");
-    QVERIFY(form);
-    const AXUIElementRef scrollBarElement = childByRole(form, "AXScrollBar");
-    QVERIFY(scrollBarElement);
-    QCOMPARE(attribute(scrollBarElement, kAXOrientationAttribute).toString(), QLatin1String("AXVerticalOrientation"));
-
-    {
-        const AXUIElementRef lineUpElement = childByTitle(scrollBarElement, "Line up");
-        QVERIFY(lineUpElement);
-        QCOMPARE (subrole(lineUpElement), QLatin1String("AXDecrementArrow"));
-    }{
-        const AXUIElementRef lineDownElement = childByTitle(scrollBarElement, "Line down");
-        QVERIFY(lineDownElement);
-        QCOMPARE (subrole(lineDownElement), QLatin1String("AXIncrementArrow"));
-    }{
-        const AXUIElementRef pageUpElement = childByTitle(scrollBarElement, "Page up");
-        QVERIFY(pageUpElement);
-        QCOMPARE (subrole(pageUpElement), QLatin1String("AXDecrementPage"));
-    }{
-        const AXUIElementRef pageDownElement = childByTitle(scrollBarElement, "Page down");
-        QVERIFY(pageDownElement);
-        QCOMPARE (subrole(pageDownElement), QLatin1String("AXIncrementPage"));
-    }{
-        const AXUIElementRef valueIndicatorElement = childByTitle(scrollBarElement, "Position");
-        QVERIFY(valueIndicatorElement);
-        QCOMPARE(value(valueIndicatorElement).toInt(), 50);
-    }
-}
-
-void tst_qaccessibility_mac::testSplitter()
-{
-    const AXUIElementRef currentApplication = AXUIElementCreateApplication(getpid());
-    testAppAndForm(currentApplication);
-    const AXUIElementRef form = childByTitle(currentApplication, "Form");
-    QVERIFY(form);
-    
-    const AXUIElementRef splitGroupElement = childByRole(form, "AXSplitGroup");
-    QVERIFY(splitGroupElement);
-
-    for (int i = 0; i < numChildren(splitGroupElement); ++i)
-        QVERIFY(child(splitGroupElement, 3));
-
-    // Visual Order: Foo splitter Bar splitter Baz
-    QList<AXUIElementRef> splitterList = elementListAttribute(splitGroupElement, kAXSplittersAttribute);
-    QCOMPARE(splitterList.count(), 2); 
-    foreach (AXUIElementRef splitter, splitterList) {
-        QCOMPARE(role(splitter), QLatin1String("AXSplitter"));
-        QVERIFY(supportsAttribute(splitter, kAXPreviousContentsAttribute));
-        QVERIFY(supportsAttribute(splitter, kAXNextContentsAttribute));
-        QCOMPARE(attribute(splitter, kAXOrientationAttribute).toString(), QLatin1String("AXVerticalOrientation"));
-        QList<AXUIElementRef> prevList = elementListAttribute(splitter, kAXPreviousContentsAttribute);  
-        QCOMPARE(prevList.count(), 1); 
-        QList<AXUIElementRef> nextList = elementListAttribute(splitter, kAXNextContentsAttribute);  
-        QCOMPARE(nextList.count(), 1);
-        
-        // verify order
-        if (title(prevList.at(0)) == QLatin1String("Foo"))
-            QCOMPARE(title(nextList.at(0)), QLatin1String("Bar"));
-        else if (title(prevList.at(0)) == QLatin1String("Bar"))
-            QCOMPARE(title(nextList.at(0)), QLatin1String("Baz"));
-        else {
-            QFAIL("Splitter contents and handles are out of order"); 
-        }
-    }
-}
-
-void tst_qaccessibility_mac::testTextEdit()
-{
-    QWidget window;
-    const QString windowTitle("window");
-    window.setWindowTitle(windowTitle);
-    window.resize(300, 300);
-
-    QTextEdit *textEdit = new QTextEdit(&window);
-    textEdit->resize(300, 300);
-    const QString textLine("this is a line");
-    textEdit->setText(textLine);
-    
-    window.show();
-
-    const AXUIElementRef applicationElement = AXUIElementCreateApplication(getpid());
-    QVERIFY(applicationElement);
-    const AXUIElementRef windowElement = childByTitle(applicationElement, windowTitle);
-    QVERIFY(windowElement);
-    const AXUIElementRef scrollAreaElement = childByRole(windowElement, "AXScrollArea");
-    QVERIFY(scrollAreaElement);
-    const AXUIElementRef textElement = childByRole(scrollAreaElement, "AXTextField");
-    QVERIFY(textElement);
-    QVERIFY(value(textElement) == textLine);
-}
-
-void testModelLessItemView(QAbstractItemView *itemView, const QByteArray &role)
-{
-    const QString windowTitle("window");
-    itemView->setWindowTitle(windowTitle);
-    itemView->show();
-
-    QTest::qWait(100);
-#if defined(Q_WS_X11)
-    qt_x11_wait_for_window_manager(w);
-#endif
-
-    QAccessibleInterface *acc = QAccessible::queryAccessibleInterface(itemView);
-    QVERIFY(acc->isValid());
-    QCOMPARE(acc->childCount(), 1);
-    acc->role(0);
-    acc->rect(0);
-
-    QAccessibleInterface *accViewport = 0;
-    int entry = acc->navigate(QAccessible::Child, 1, &accViewport);
-    QVERIFY(accViewport);
-    QCOMPARE(entry, 0);
-    QVERIFY(accViewport->isValid());
-    QCOMPARE(accViewport->childCount(), 0);
-    accViewport->role(0);
-    accViewport->rect(0);
-
-    delete acc;
-    delete accViewport;
-        
-    const AXUIElementRef applicationElement = AXUIElementCreateApplication(getpid());
-    QVERIFY(applicationElement);
-    const AXUIElementRef windowElement = childByTitle(applicationElement, windowTitle);
-    QVERIFY(windowElement);
-    const AXUIElementRef scrollAreaElement = childByRole(windowElement, "AXScrollArea");
-    QVERIFY(scrollAreaElement);
-    const AXUIElementRef tableElement = childByRole(scrollAreaElement, role);
-    QVERIFY(tableElement);
-    
-    delete itemView;
-}
-
-void tst_qaccessibility_mac::testItemViewsWithoutModel()
-{
-    testModelLessItemView(new QListView(), "AXList");
-    testModelLessItemView(new QTableView(), "AXTable");
-}
-
-void tst_qaccessibility_mac::testQAElement()
-{
-    {
-        QAElement element;
-        QVERIFY(element.isValid() == false);
-    }
-    
-    {
-        QAElement element(0, 0);
-        QVERIFY(element.isValid() == false);
-    }
-
-    {
-        int argc = 0;
-        char **argv = 0;
-        QApplication app(argc, argv);
-        QWidget w;
-        QAElement element(reinterpret_cast<HIObjectRef>(w.winId()), 0);
-        QVERIFY(element.isValid() == true);
-    }
-
-}
-
-void tst_qaccessibility_mac::testQAInterface()
-{
-    {
-        QAInterface interface;
-        QVERIFY(interface.isValid() == false);
-    }
-    
-    {
-        QAInterface interface(0, 0);
-        QVERIFY(interface.isValid() == false);
-    }
-
-    {
-        int argc = 0;
-        char **argv = 0;
-        QApplication app(argc, argv);
-
-        {
-            QWidget w;
-            QAInterface element(QAccessible::queryAccessibleInterface(&w), 0);
-            QVERIFY(element.isValid() == true);
-        }
-        {
-            QWidget w;
-            QAInterface element(QAccessible::queryAccessibleInterface(&w), 100);
-            QVERIFY(element.isValid() == false);
-        }
-    }
-}
-
-void tst_qaccessibility_mac::uitests_data()
-{
-    QTest::addColumn<QString>("uiFilename");
-    QTest::addColumn<QString>("testSlot");
-
-    QTest::newRow("form") << "form.ui" << SLOT(testForm());
-    QTest::newRow("buttons") << "buttons.ui" << SLOT(testButtons());
-    QTest::newRow("label") << "label.ui" << SLOT(testLabel());
-    QTest::newRow("line edit") << "lineedit.ui" << SLOT(testLineEdit());
-    QTest::newRow("groups") << "groups.ui" << SLOT(testGroups());
-    QTest::newRow("tabs") << "tabs.ui" << SLOT(testTabWidget());
-    QTest::newRow("combobox") << "combobox.ui" << SLOT(testComboBox());
-    QTest::newRow("scrollbar") << "scrollbar.ui" << SLOT(testScrollBar());
-    QTest::newRow("splitters") << "splitters.ui" << SLOT(testSplitter());
-}
-
-void tst_qaccessibility_mac::uitests()
-{
-    QFETCH(QString, uiFilename);
-    QFETCH(QString, testSlot);
-
-    // The Accessibility interface must be enabled to run this test.
-    if (!AXAPIEnabled())
-        QSKIP("Accessibility not enabled. Check \"Enable access for assistive devices\" in the system preferences -> universal access to run this test.", SkipAll);
-
-    int argc = 0;
-    char **argv = 0;
-    QApplication app(argc, argv);
-
-    // Create and display form.
-    QUiLoader loader;
-    QFile file(":" + uiFilename);
-    QVERIFY(file.exists());
-    file.open(QFile::ReadOnly);
-    QWidget *window = loader.load(&file, 0);
-    QVERIFY(window);
-    file.close();
-    window->show();
-
-    QTimer::singleShot(50, this, qPrintable(testSlot));
-    // Quit when returning to the main event loop after running tests.
-    QTimer::singleShot(200, &app, SLOT(quit()));
-    app.exec();
-    delete window;
-}
-
-void tst_qaccessibility_mac::tests_data()
-{
-    QTest::addColumn<QString>("testSlot");
-    QTest::newRow("deleteWidget") << SLOT(testDeleteWidget());
-    QTest::newRow("deleteWidgets") << SLOT(testDeleteWidgets());
-    QTest::newRow("multipleWindows") << SLOT(testMultipleWindows());
-    QTest::newRow("hiddenWidgets") << SLOT(testHiddenWidgets());
-    QTest::newRow("actions") << SLOT(testActions());
-    QTest::newRow("changeState") << SLOT(testChangeState());
-    QTest::newRow("slider") << SLOT(testSlider());
-    QTest::newRow("scrollArea") << SLOT(testScrollArea());
-    QTest::newRow("listView") << SLOT(testListView());
-    QTest::newRow("tableView") << SLOT(testTableView());
-    QTest::newRow("textEdit") << SLOT(testTextEdit());
-    QTest::newRow("ItemViews without model") << SLOT(testItemViewsWithoutModel());
-    QTest::newRow("tabbar") << SLOT(testTabBar());
-}
-
-void tst_qaccessibility_mac::tests()
-{
-    QFETCH(QString, testSlot);
-    runTest(testSlot);
-}
-
-/*
-    Tests show that querying the accessibility interface directly does not work. (I get a
-    kAXErrorAPIDisabled error, indicating that the accessible API is disabled, which it isn't.)
-    To work around this, we run the tests in a callback slot called from the main event loop.
-*/
-void tst_qaccessibility_mac::runTest(const QString &testSlot)
-{
-    // The Accessibility interface must be enabled to run this test.
-    if (!AXAPIEnabled())
-        QSKIP("Accessibility not enabled. Check \"Enable access for assistive devices\" in the system preferences -> universal access to run this test.", SkipAll);
-
-    int argc = 0;
-    char **argv = 0;
-    QApplication app(argc, argv);
-
-    QTimer::singleShot(50, this, qPrintable(testSlot));
-    // Quit when returning to the main event loop after running tests.
-    QTimer::singleShot(200, &app, SLOT(quit()));
-    app.exec();
-
-}
-
-QTEST_APPLESS_MAIN(tst_qaccessibility_mac)
-
-#else // defined(Q_WS_MAC) && !defined (QT_MAC_USE_COCOA)
-
 QTEST_NOOP_MAIN
 
-#endif
-
 #include "tst_qaccessibility_mac.moc"
 
 
index 281aff3..f76f4c9 100644 (file)
@@ -917,7 +917,7 @@ void tst_QFiledialog::selectFiles()
     QVERIFY(listView);
     for (int i = 0; i < list.count(); ++i) {
         fd.selectFile(fd.directory().path() + "/" + list.at(i));
-#if defined(QT_MAC_USE_COCOA) || defined(Q_WS_WIN)
+#if defined(Q_WS_MAC) || defined(Q_WS_WIN)
     QEXPECT_FAIL("", "This test does not work on Mac or Windows", Abort);
 #endif
         QTRY_VERIFY(!listView->selectionModel()->selectedRows().isEmpty());
index f7bdf67..a9ba80b 100644 (file)
@@ -87,7 +87,7 @@ Q_DECLARE_METATYPE(QRectF)
 #define Q_CHECK_PAINTEVENTS
 #endif
 
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_MAC)
 // On mac (cocoa) we always get full update.
 // So check that the expected region is contained inside the actual
 #define COMPARE_REGIONS(ACTUAL, EXPECTED) QVERIFY((EXPECTED).subtracted(ACTUAL).isEmpty())
index 8e94dbc..0a0dfc2 100644 (file)
@@ -2285,7 +2285,7 @@ void tst_QGraphicsView::viewportUpdateMode()
 
     // The view gets two updates for the update scene updates.
     QTRY_VERIFY(!view.lastUpdateRegions.isEmpty());
-#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
+#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
     QCOMPARE(view.lastUpdateRegions.last().rects().size(), 2);
     QCOMPARE(view.lastUpdateRegions.last().rects().at(0).size(), QSize(14, 14));
     QCOMPARE(view.lastUpdateRegions.last().rects().at(1).size(), QSize(14, 14));
@@ -3360,9 +3360,8 @@ void tst_QGraphicsView::moveItemWhileScrolling()
     int a = adjustForAntialiasing ? 2 : 1;
     expectedRegion += QRect(40, 50, 10, 10).adjusted(-a, -a, a, a);
     expectedRegion += QRect(40, 60, 10, 10).adjusted(-a, -a, a, a);
-#ifdef QT_MAC_USE_COCOA
-    if (QApplicationPrivate::graphicsSystem() == 0)
-        QEXPECT_FAIL("", "This will fail with Cocoa because paint events are not send in the order expected by graphicsview", Continue);
+#ifdef Q_OS_MAC
+    QEXPECT_FAIL("", "This will fail with Cocoa because paint events are not send in the order expected by graphicsview", Continue);
 #endif
     COMPARE_REGIONS(view.lastPaintedRegion, expectedRegion);
 }
@@ -3712,7 +3711,7 @@ void tst_QGraphicsView::exposeRegion()
     COMPARE_REGIONS(view.lastUpdateRegions.at(0), expectedExposeRegion);
 
     // Make sure the item didn't get any repaints.
-#ifndef QT_MAC_USE_COCOA
+#ifndef Q_OS_MAC
     QCOMPARE(item->paints, 0);
 #endif
 }
@@ -3870,7 +3869,7 @@ void tst_QGraphicsView::update2()
     rect->update();
     QTRY_VERIFY(view.painted);
 
-#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
+#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
     QTRY_VERIFY(view.painted);
     QCOMPARE(view.lastUpdateRegions.size(), 1);
     QCOMPARE(view.lastUpdateRegions.at(0), expectedUpdateRegion);
@@ -3926,7 +3925,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape()
     child->update();
     QTRY_VERIFY(view.painted);
 
-#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
+#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
     QTRY_VERIFY(view.painted);
     QCOMPARE(view.lastUpdateRegions.size(), 1);
     QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
@@ -3978,7 +3977,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
     child->update();
     QTRY_VERIFY(view.painted);
 
-#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
+#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
     QTRY_VERIFY(view.painted);
     QCOMPARE(view.lastUpdateRegions.size(), 1);
     QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
@@ -3998,7 +3997,7 @@ void tst_QGraphicsView::update_ancestorClipsChildrenToShape2()
     expected = child->deviceTransform(view.viewportTransform()).mapRect(child->boundingRect());
     expected.adjust(-2, -2, 2, 2); // Antialiasing
 
-#ifndef QT_MAC_USE_COCOA //cocoa doesn't support drawing regions
+#ifndef Q_OS_MAC //cocoa doesn't support drawing regions
     QTRY_VERIFY(view.painted);
     QCOMPARE(view.lastUpdateRegions.size(), 1);
     QCOMPARE(view.lastUpdateRegions.at(0), QRegion(expected.toAlignedRect()));
index 49d324f..3629bf1 100644 (file)
@@ -419,9 +419,7 @@ private slots:
     void childAt();
 #ifdef Q_WS_MAC
     void childAt_unifiedToolBar();
-#ifdef QT_MAC_USE_COCOA
     void taskQTBUG_11373();
-#endif // QT_MAC_USE_COCOA
 #endif
     void taskQTBUG_17333_ResizeInfiniteRecursion();
 
@@ -2691,7 +2689,7 @@ void tst_QWidget::raise()
     QTest::qWaitForWindowShown(parent);
     QTest::qWait(10);
 
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_OS_MAC
     if (child1->internalWinId()) {
         QSKIP("Cocoa has no Z-Order for views, we hack it, but it results in paint events.", SkipAll);
     }
@@ -2721,7 +2719,7 @@ void tst_QWidget::raise()
     foreach (UpdateWidget *child, allChildren) {
         int expectedPaintEvents = child == child2 ? 1 : 0;
         int expectedZOrderChangeEvents = child == child2 ? 1 : 0;
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_OS_MAC
         QSKIP("Not yet sure why this fails.", SkipSingle);
 #endif
         QTRY_COMPARE(child->numPaintEvents, expectedPaintEvents);
@@ -2775,7 +2773,7 @@ void tst_QWidget::raise()
 }
 
 // Cocoa has no Z-Order for views, we hack it, but it results in paint events.
-#ifndef QT_MAC_USE_COCOA
+#ifndef QT_OS_MAC
 void tst_QWidget::lower()
 {
     QWidget *parent = new QWidget(0);
@@ -2840,7 +2838,7 @@ void tst_QWidget::lower()
 #endif
 
 // Cocoa has no Z-Order for views, we hack it, but it results in paint events.
-#ifndef QT_MAC_USE_COCOA
+#ifndef QT_OS_MAC
 void tst_QWidget::stackUnder()
 {
     QTest::qWait(10);
@@ -4242,6 +4240,9 @@ void tst_QWidget::update()
     QApplication::processEvents();
     QApplication::processEvents();
 
+#ifdef Q_OS_MAC
+    QEXPECT_FAIL(0, "Cocoa compositor says to paint this twice.", Continue);
+#endif
     QTRY_COMPARE(w.numPaintEvents, 1);
 
     QCOMPARE(w.visibleRegion(), QRegion(w.rect()));
@@ -4301,10 +4302,6 @@ void tst_QWidget::update()
                                   - child.visibleRegion().translated(childOffset);
         QCOMPARE(w.visibleRegion(), expectedVisible);
         QCOMPARE(w.paintedRegion, expectedVisible);
-#ifdef QT_MAC_USE_COCOA
-        if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
-            QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue);
-#endif
         QCOMPARE(child.numPaintEvents, 0);
 
         w.reset();
@@ -4373,7 +4370,7 @@ void tst_QWidget::update()
         QCOMPARE(sibling.numPaintEvents, 1);
         QCOMPARE(sibling.paintedRegion, sibling.visibleRegion());
 
-#ifdef QT_MAC_USE_COCOA
+#ifdef Q_OS_MAC
         if (child.internalWinId()) // child is native
             QEXPECT_FAIL(0, "Cocoa compositor paints child and sibling", Continue);
 #endif
@@ -4817,11 +4814,6 @@ void tst_QWidget::windowMoveResize()
         widget.show();
 
         QTest::qWait(10);
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-        QEXPECT_FAIL("130,50 0x0, flags 0",
-                     "Showing a window with 0x0 size shifts it up.",
-                     Continue);
-#endif
         QTRY_COMPARE(widget.pos(), rect.topLeft());
         QTRY_COMPARE(widget.size(), rect.size());
 
@@ -4863,7 +4855,7 @@ void tst_QWidget::windowMoveResize()
             widget.move(r.topLeft());
             widget.resize(r.size());
             QApplication::processEvents();
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_MAC)
             if (r.width() == 0 && r.height() > 0) {
                 widget.move(r.topLeft());
                 widget.resize(r.size());
@@ -4932,7 +4924,7 @@ void tst_QWidget::windowMoveResize()
             widget.move(r.topLeft());
             widget.resize(r.size());
             QApplication::processEvents();
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+#if defined(Q_WS_MAC)
             if (r.width() == 0 && r.height() > 0) {
                 widget.move(r.topLeft());
                 widget.resize(r.size());
@@ -5106,7 +5098,7 @@ void tst_QWidget::showAndMoveChild()
 }
 
 // Cocoa only has rect granularity.
-#ifndef QT_MAC_USE_COCOA
+#ifndef QT_OS_MAC
 void tst_QWidget::subtractOpaqueSiblings()
 {
     QWidget w;
@@ -5837,9 +5829,6 @@ void tst_QWidget::compatibilityChildInsertedEvents()
 {
     EventRecorder::EventList expected;
     bool accessibilityEnabled = false;
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    accessibilityEnabled = AXAPIEnabled();
-#endif
 
     // Move away the cursor; otherwise it might result in an enter event if it's
     // inside the widget when the widget is shown.
@@ -5893,12 +5882,10 @@ void tst_QWidget::compatibilityChildInsertedEvents()
             << qMakePair(&widget, QEvent::PolishRequest)
             << qMakePair(&widget, QEvent::Type(QEvent::User + 1));
 
-#ifndef QT_MAC_USE_CARBON
-#ifdef QT_MAC_USE_COCOA
-        if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
-#endif // QT_MAC_USE_COCOA
-            expected << qMakePair(&widget, QEvent::UpdateRequest);
-#endif // !QT_MAC_USE_CARBON
+#ifdef Q_OS_MAC
+        expected << qMakePair(&widget, QEvent::UpdateLater);
+#endif
+        expected << qMakePair(&widget, QEvent::UpdateRequest);
 
         QCOMPARE(spy.eventList(), expected);
     }
@@ -5981,12 +5968,10 @@ void tst_QWidget::compatibilityChildInsertedEvents()
             << qMakePair(&widget, QEvent::Type(QEvent::User + 1))
             << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
 
-#ifndef QT_MAC_USE_CARBON
-#ifdef QT_MAC_USE_COCOA
-        if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
-#endif // QT_MAC_USE_COCOA
-            expected << qMakePair(&widget, QEvent::UpdateRequest);
-#endif // !QT_MAC_USE_CARBON
+#ifdef Q_OS_MAC
+        expected << qMakePair(&widget, QEvent::UpdateLater);
+#endif
+        expected << qMakePair(&widget, QEvent::UpdateRequest);
 
         QCOMPARE(spy.eventList(), expected);
     }
@@ -6071,12 +6056,10 @@ void tst_QWidget::compatibilityChildInsertedEvents()
             << qMakePair(&widget, QEvent::Type(QEvent::User + 1))
             << qMakePair(&widget, QEvent::Type(QEvent::User + 2));
 
-#ifndef QT_MAC_USE_CARBON
-#ifdef QT_MAC_USE_COCOA
-        if (QApplicationPrivate::graphics_system_name == QLatin1String("raster"))
-#endif // QT_MAC_USE_COCOA
-            expected << qMakePair(&widget, QEvent::UpdateRequest);
-#endif // !QT_MAC_USE_CARBON
+#ifdef Q_OS_MAC
+        expected << qMakePair(&widget, QEvent::UpdateLater);
+#endif
+        expected << qMakePair(&widget, QEvent::UpdateRequest);
 
         QCOMPARE(spy.eventList(), expected);
     }
@@ -9425,7 +9408,6 @@ void tst_QWidget::childAt_unifiedToolBar()
     QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast<QWidget *>(label));
 }
 
-#ifdef QT_MAC_USE_COCOA
 void tst_QWidget::taskQTBUG_11373()
 {
     QMainWindow * myWindow = new QMainWindow();
@@ -9443,7 +9425,6 @@ void tst_QWidget::taskQTBUG_11373()
     // The drawer should still not be visible, since we haven't shown it.
     QCOMPARE(drawer->isVisible(), false);
 }
-#endif // QT_MAC_USE_COCOA
 #endif
 
 void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion()
index 97a3a12..d7bc3f3 100644 (file)
 QString nativeWindowTitle(QWidget *widget, Qt::WindowState state);
 bool nativeWindowModified(QWidget *widget);
 
-#ifndef QT_MAC_USE_COCOA
-typedef QPair<QWidget *, HIViewRef> WidgetViewPair;
-bool testAndRelease(const HIViewRef view);
-WidgetViewPair createAndRetain(QWidget * const parent = 0);
-#else
 typedef QPair<QWidget *, WId> WidgetViewPair;
 bool testAndRelease(const WId);
 WidgetViewPair createAndRetain(QWidget * const parent = 0);
-#endif
index 3bd5db8..10e137c 100644 (file)
@@ -49,52 +49,18 @@ QString nativeWindowTitle(QWidget *window, Qt::WindowState state)
     OSWindowRef windowRef = qt_mac_window_for(window);
     QCFString macTitle;
     if (state == Qt::WindowMinimized) {
-#ifndef QT_MAC_USE_COCOA
-        CopyWindowAlternateTitle(windowRef, &macTitle);
-#else
         macTitle = reinterpret_cast<CFStringRef>([[windowRef miniwindowTitle] retain]);
-#endif
     } else {
-#ifndef QT_MAC_USE_COCOA
-        CopyWindowTitleAsCFString(windowRef, &macTitle);
-#else
         macTitle = reinterpret_cast<CFStringRef>([[windowRef title] retain]);
-#endif
     }
     return macTitle;
 }
 
 bool nativeWindowModified(QWidget *widget)
 {
-#ifndef QT_MAC_USE_COCOA
-    return IsWindowModified(qt_mac_window_for(widget));
-#else
     return [qt_mac_window_for(widget) isDocumentEdited];
-#endif
 }
 
-#ifndef QT_MAC_USE_COCOA
-bool testAndRelease(const HIViewRef view)
-{
-//    qDebug() << CFGetRetainCount(view);
-    if (CFGetRetainCount(view) != 2)
-        return false;
-    CFRelease(view);
-    CFRelease(view);
-    return true;
-}
-
-WidgetViewPair createAndRetain(QWidget * const parent)
-{
-    QWidget * const widget = new QWidget(parent);
-    const HIViewRef view = (HIViewRef)widget->winId();
-    // Retain twice so we can safely call CFGetRetaintCount even if the retain count
-    // is off by one because of a double release.
-    CFRetain(view);
-    CFRetain(view);
-    return qMakePair(widget, view);
-}
-#else
 bool testAndRelease(const WId view)
 {
     if ([id(view) retainCount] != 2)
@@ -114,5 +80,4 @@ WidgetViewPair createAndRetain(QWidget * const parent)
     [id(view) retain];
     return qMakePair(widget, view);
 }
-#endif