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

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    105105#include "qdebug.h"
    106106#include "qtimer.h"
     107#include "qurl.h"
    107108#include "private/qmacinputcontext_p.h"
    108109#include "private/qpaintengine_mac_p.h"
     
    155156#endif
    156157
     158#define kCMDeviceUnregisteredNotification CFSTR("CMDeviceUnregisteredNotification")
     159#define kCMDefaultDeviceNotification CFSTR("CMDefaultDeviceNotification")
     160#define kCMDeviceProfilesNotification CFSTR("CMDeviceProfilesNotification")
     161#define kCMDefaultDeviceProfileNotification CFSTR("CMDefaultDeviceProfileNotification")
    157162
    158163QT_BEGIN_NAMESPACE
     
    161166QPaintDevice *qt_mac_safe_pdev = 0;
    162167QList<QMacWindowChangeEvent*> *QMacWindowChangeEvent::change_events = 0;
    163 extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp
    164168
    165169/*****************************************************************************
     
    195199static EventHandlerRef app_proc_handler = 0;
    196200static EventHandlerUPP app_proc_handlerUPP = 0;
     201#endif
    197202static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL;
    198 #endif
    199203static EventHandlerRef tablet_proximity_handler = 0;
    200204static EventHandlerUPP tablet_proximity_UPP = 0;
    201205bool QApplicationPrivate::native_modal_dialog_active;
     206
     207Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
    202208
    203209/*****************************************************************************
     
    219225void onApplicationWindowChangedActivation( QWidget*widget, bool activated );
    220226void onApplicationChangedActivation( bool activated );
     227
     228static void qt_mac_read_fontsmoothing_settings()
     229{
     230    NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"];
     231    qt_applefontsmoothing_enabled = (appleFontSmoothing > 0);
     232}
    221233
    222234Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) {
     
    524536            QFont fnt = qfontForThemeFont(mac_widget_fonts[i].font_key);
    525537            bool set_font = true;
    526             QHash<QByteArray, QFont> *hash = qt_app_fonts_hash();
     538            FontHash *hash = qt_app_fonts_hash();
    527539            if (!hash->isEmpty()) {
    528                 QHash<QByteArray, QFont>::const_iterator it
     540                FontHash::const_iterator it
    529541                                        = hash->constFind(mac_widget_fonts[i].qt_class);
    530542                if (it != hash->constEnd())
     
    625637
    626638            bool set_palette = true;
    627             extern QHash<QByteArray, QPalette> *qt_app_palettes_hash(); //qapplication.cpp
    628             QHash<QByteArray, QPalette> *phash = qt_app_palettes_hash();
     639            PaletteHash *phash = qt_app_palettes_hash();
    629640            if (!phash->isEmpty()) {
    630                 QHash<QByteArray, QPalette>::const_iterator it
     641                PaletteHash::const_iterator it
    631642                                    = phash->constFind(mac_widget_colors[i].qt_class);
    632643                if (it != phash->constEnd())
     
    952963}
    953964
    954 #ifndef QT_MAC_USE_COCOA
    955965struct QMacAppleEventTypeSpec {
    956966    AEEventClass mac_class;
     
    958968} app_apple_events[] = {
    959969    { kCoreEventClass, kAEQuitApplication },
    960     { kCoreEventClass, kAEOpenDocuments }
     970    { kCoreEventClass, kAEOpenDocuments },
     971    { kInternetEventClass, kAEGetURL },
    961972};
     973
     974#ifndef QT_MAC_USE_COCOA
     975
     976#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
     977enum
     978{
     979    kEventMouseScroll                          = 11,
     980    kEventParamMouseWheelSmoothVerticalDelta   = 'saxy',
     981    kEventParamMouseWheelSmoothHorizontalDelta = 'saxx',
     982};
     983#endif
     984
    962985/* watched events */
    963986static EventTypeSpec app_events[] = {
     
    971994    { kEventClassWindow, kEventWindowDeactivated },
    972995
     996    { kEventClassMouse, kEventMouseScroll },
    973997    { kEventClassMouse, kEventMouseWheelMoved },
    974998    { kEventClassMouse, kEventMouseDown },
     
    10411065}
    10421066
     1067void qt_color_profile_changed(CFNotificationCenterRef, void *, CFStringRef, const void *,
     1068                              CFDictionaryRef)
     1069{
     1070    QCoreGraphicsPaintEngine::cleanUpMacColorSpaces();
     1071}
    10431072/* platform specific implementations */
    10441073void qt_init(QApplicationPrivate *priv, int)
     
    10461075    if (qt_is_gui_used) {
    10471076        CGDisplayRegisterReconfigurationCallback(qt_mac_display_change_callbk, 0);
     1077        CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
     1078        CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
     1079                                        kCMDeviceUnregisteredNotification, 0,
     1080                                        CFNotificationSuspensionBehaviorDeliverImmediately);
     1081        CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
     1082                                        kCMDefaultDeviceNotification, 0,
     1083                                        CFNotificationSuspensionBehaviorDeliverImmediately);
     1084        CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
     1085                                        kCMDeviceProfilesNotification, 0,
     1086                                        CFNotificationSuspensionBehaviorDeliverImmediately);
     1087        CFNotificationCenterAddObserver(center, qApp, qt_color_profile_changed,
     1088                                        kCMDefaultDeviceProfileNotification, 0,
     1089                                        CFNotificationSuspensionBehaviorDeliverImmediately);
    10481090        ProcessSerialNumber psn;
    10491091        if (GetCurrentProcess(&psn) == noErr) {
    10501092            // Jambi needs to transform itself since most people aren't "used"
    10511093            // to putting things in bundles, but other people may actually not
    1052             // want to tranform the process (running as a helper or somethng)
     1094            // want to tranform the process (running as a helper or something)
    10531095            // so don't do that for them. This means checking both LSUIElement
    10541096            // and LSBackgroundOnly. If you set them both... well, you
     
    11571199        }
    11581200
     1201#endif
    11591202        if (!app_proc_ae_handlerUPP) {
    11601203            app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor);
    11611204            for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i)
    11621205                AEInstallEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
    1163                         app_proc_ae_handlerUPP, SRefCon(qApp), true);
    1164         }
    1165 #endif
     1206                        app_proc_ae_handlerUPP, SRefCon(qApp), false);
     1207        }
    11661208
    11671209        if (QApplicationPrivate::app_style) {
     
    11721214    if (QApplication::desktopSettingsAware())
    11731215        QApplicationPrivate::qt_mac_apply_settings();
     1216
     1217    qt_mac_read_fontsmoothing_settings();
     1218
    11741219    // Cocoa application delegate
    11751220#ifdef QT_MAC_USE_COCOA
     
    11951240        [newDelegate setMenuLoader:qtMenuLoader];
    11961241        [qtMenuLoader release];
    1197     }
    1198 #endif
    1199     if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
    1200         extern void qt_mac_set_native_menubar(bool);
    1201         qt_mac_set_native_menubar(false);
    1202     }
     1242
     1243        NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager];
     1244        [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:)
     1245          forEventClass:kInternetEventClass andEventID:kAEGetURL];
     1246    }
     1247#endif
    12031248    // Register for Carbon tablet proximity events on the event monitor target.
    12041249    // This means that we should receive proximity events even when we aren't the active application.
     
    12111256}
    12121257
     1258void qt_release_apple_event_handler()
     1259{
     1260    if(app_proc_ae_handlerUPP) {
     1261        for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i)
     1262            AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
     1263                    app_proc_ae_handlerUPP, true);
     1264        DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP);
     1265        app_proc_ae_handlerUPP = 0;
     1266    }
     1267}
     1268
    12131269/*****************************************************************************
    12141270  qt_cleanup() - cleans up when the application is finished
     
    12181274{
    12191275    CGDisplayRemoveReconfigurationCallback(qt_mac_display_change_callbk, 0);
     1276    CFNotificationCenterRef center = CFNotificationCenterGetDistributedCenter();
     1277    CFNotificationCenterRemoveObserver(center, qApp, kCMDeviceUnregisteredNotification, 0);
     1278    CFNotificationCenterRemoveObserver(center, qApp, kCMDefaultDeviceNotification, 0);
     1279    CFNotificationCenterRemoveObserver(center, qApp, kCMDeviceProfilesNotification, 0);
     1280    CFNotificationCenterRemoveObserver(center, qApp, kCMDefaultDeviceProfileNotification, 0);
     1281
    12201282#ifndef QT_MAC_USE_COCOA
    12211283    qt_release_app_proc_handler();
     
    12241286        app_proc_handlerUPP = 0;
    12251287    }
    1226     if(app_proc_ae_handlerUPP) {
    1227         for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i)
    1228             AERemoveEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id,
    1229                     app_proc_ae_handlerUPP, true);
    1230         DisposeAEEventHandlerUPP(app_proc_ae_handlerUPP);
    1231         app_proc_ae_handlerUPP = NULL;
    1232     }
    1233 #endif
    1234 
     1288#endif
     1289    qt_release_apple_event_handler();
    12351290    qt_release_tablet_proximity_handler();
    12361291    if (tablet_proximity_UPP)
     
    12911346    qApp->d_func()->cursor_list.prepend(cursor);
    12921347
     1348#ifdef QT_MAC_USE_COCOA
     1349    QMacCocoaAutoReleasePool pool;
     1350    [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) push];
     1351#else
    12931352    if (qApp && qApp->activeWindow())
    12941353        qt_mac_set_cursor(&qApp->d_func()->cursor_list.first(), QCursor::pos());
     1354#endif
    12951355}
    12961356
     
    13011361    qApp->d_func()->cursor_list.removeFirst();
    13021362
     1363#ifdef QT_MAC_USE_COCOA
     1364    QMacCocoaAutoReleasePool pool;
     1365    [NSCursor pop];
     1366#else
    13031367    if (qApp && qApp->activeWindow()) {
    13041368        const QCursor def(Qt::ArrowCursor);
    13051369        qt_mac_set_cursor(qApp->d_func()->cursor_list.isEmpty() ? &def : &qApp->d_func()->cursor_list.first(), QCursor::pos());
    13061370    }
    1307 }
    1308 #endif
     1371#endif
     1372}
     1373#endif // QT_NO_CURSOR
    13091374
    13101375QWidget *QApplication::topLevelAt(const QPoint &p)
     
    13421407}
    13431408
    1344 static QWidget *qt_mac_recursive_widgetAt(QWidget *widget, int x, int y)
    1345 {
    1346     if (!widget)
    1347         return 0;
    1348     const QObjectList kids = widget->children();
    1349     for(int i = kids.size()-1; i >= 0; --i) {
    1350         if ( QWidget *kid = qobject_cast<QWidget*>(kids.at(i)) ) {
    1351             if (kid->isVisible() && !kid->isTopLevel() &&
    1352                     !kid->testAttribute(Qt::WA_TransparentForMouseEvents)) {
    1353                 const int wx=kid->x(), wy=kid->y(),
    1354                       wx2=wx+kid->width(), wy2=wy+kid->height();
    1355                 if (x >= wx && y >= wy && x < wx2 && y < wy2) {
    1356                     const QRegion mask = kid->mask();
    1357                     if (!mask.isEmpty() && !mask.contains(QPoint(x-wx, y-wy)))
    1358                         continue;
    1359                     return qt_mac_recursive_widgetAt(kid, x-wx, y-wy);
    1360                 }
    1361             }
    1362         }
    1363     }
    1364     return widget;
    1365 }
    1366 
    13671409/*****************************************************************************
    13681410  Main event loop
     
    13971439
    13981440#ifdef QT_MAC_USE_COCOA
    1399     if (!qt_mac_is_macsheet(widget)) {
    1400         // Add a new, empty (null), NSModalSession to the stack.
    1401         // The next time we spin the event dispatcher, it will
    1402         // check the stack, and recurse into a modal session for it:
    1403         QCocoaModalSessionInfo info = {widget, 0};
    1404         QEventDispatcherMacPrivate::cocoaModalSessionStack.push(info);
    1405     }
     1441    if (!qt_mac_is_macsheet(widget))
     1442        QEventDispatcherMacPrivate::beginModalSession(widget);
    14061443#endif
    14071444}
     
    14291466#ifdef QT_MAC_USE_COCOA
    14301467        if (!qt_mac_is_macsheet(widget))
    1431             QEventDispatcherMacPrivate::rebuildModalSessionStack(true);
     1468            QEventDispatcherMacPrivate::endModalSession(widget);
    14321469#endif
    14331470    }
     
    14391476        qt_event_request_menubarupdate();
    14401477}
    1441 
    1442 #if defined(QT_MAC_USE_COCOA)
    1443 void QApplicationPrivate::_q_runAppModalWindow()
    1444 {
    1445     if (QEventDispatcherMacPrivate::blockCocoaRequestModal) {
    1446         // Just postpone the event until the event dispatcher tells
    1447         // us (by releasing the block) that it is OK to recurse into
    1448         // a new event loop for our non-execing modal window:
    1449         qApp->postEvent(qApp, new QEvent(QEvent::CocoaRequestModal));
    1450     } else {
    1451         // Recurse into a new event loop for the current app modal window:
    1452         threadData->eventDispatcher->processEvents(QEventLoop::DialogExec);
    1453     }
    1454 }
    1455 #endif
    14561478
    14571479QWidget *QApplicationPrivate::tryModalHelper_sys(QWidget *top)
     
    14681490}
    14691491
     1492#ifndef QT_MAC_USE_COCOA
    14701493static bool qt_try_modal(QWidget *widget, EventRef event)
    14711494{
     
    15011524    return !block_event;
    15021525}
     1526#endif
    15031527
    15041528OSStatus QApplicationPrivate::tabletProximityCallback(EventHandlerCallRef, EventRef carbonEvent,
     
    16391663        GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0,
    16401664                          sizeof(where), 0, &where);
    1641         if(ekind == kEventMouseMoved && qt_mac_app_fullscreen &&
    1642             QApplication::desktop()->screenNumber(QPoint(where.h, where.v)) ==
    1643             QApplication::desktop()->primaryScreen()) {
    1644             if(where.v <= 0)
    1645                 ShowMenuBar();
    1646             else if(qt_mac_window_at(where.h, where.v, 0) != inMenuBar)
    1647                 HideMenuBar();
    1648         }
    1649 
    16501665#if defined(DEBUG_MOUSE_MAPS)
    16511666        const char *edesc = 0;
     
    16541669        case kEventMouseUp: edesc = "MouseButtonRelease"; break;
    16551670        case kEventMouseDragged: case kEventMouseMoved: edesc = "MouseMove"; break;
     1671        case kEventMouseScroll: edesc = "MouseWheelScroll"; break;
    16561672        case kEventMouseWheelMoved: edesc = "MouseWheelMove"; break;
    16571673        }
     
    16721688            GetEventParameter(event, kEventParamMouseChord, typeUInt32, 0,
    16731689                              sizeof(mac_buttons), 0, &mac_buttons);
    1674             buttons = qt_mac_get_buttons(mac_buttons);
    1675         }
    1676         int wheel_delta=0;
    1677         if(ekind == kEventMouseWheelMoved) {
    1678             int mdelt = 0;
    1679             GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0,
     1690            if (ekind != kEventMouseWheelMoved)
     1691                buttons = qt_mac_get_buttons(mac_buttons);
     1692            else
     1693                buttons = QApplication::mouseButtons();
     1694        }
     1695
     1696        int wheel_deltaX = 0;
     1697        int wheel_deltaY = 0;
     1698        static EventRef compatibilityEvent = 0;
     1699
     1700        if (ekind == kEventMouseScroll) {
     1701            // kEventMouseScroll is the new way of dealing with mouse wheel
     1702            // events (kEventMouseWheelMoved was the old). kEventMouseScroll results
     1703            // in much smoother scrolling when using Mighty Mouse or TrackPad. For
     1704            // compatibility with older applications, carbon will also send us
     1705            // kEventMouseWheelMoved events if we dont eat this event
     1706            // (actually two events; one for horizontal and one for vertical).
     1707            // As a results of this, and to make sure we dont't receive duplicate events,
     1708            // we try to detect when this happend by checking the 'compatibilityEvent'.
     1709            SInt32 mdelt = 0;
     1710            GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0,
    16801711                              sizeof(mdelt), 0, &mdelt);
    1681             wheel_delta = mdelt * 120;
     1712            wheel_deltaX = mdelt;
     1713            mdelt = 0;
     1714            GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0,
     1715                              sizeof(mdelt), 0, &mdelt);
     1716            wheel_deltaY = mdelt;
     1717            GetEventParameter(event, kEventParamEventRef, typeEventRef, 0,
     1718                              sizeof(compatibilityEvent), 0, &compatibilityEvent);
     1719        } else if (ekind == kEventMouseWheelMoved) {
     1720            if (event != compatibilityEvent) {
     1721                compatibilityEvent = 0;
     1722                int mdelt = 0;
     1723                GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0,
     1724                        sizeof(mdelt), 0, &mdelt);
     1725                EventMouseWheelAxis axis;
     1726                GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, 0,
     1727                        sizeof(axis), 0, &axis);
     1728
     1729                // Remove acceleration, and use either -120 or 120 as delta:
     1730                if (axis == kEventMouseWheelAxisX)
     1731                    wheel_deltaX = qBound(-120, int(mdelt * 10000), 120);
     1732                else
     1733                    wheel_deltaY = qBound(-120, int(mdelt * 10000), 120);
     1734            }
    16821735        }
    16831736
     
    17441797                        HIViewRef hiview;
    17451798                        if(HIViewGetViewForMouseEvent(HIViewGetRoot(window), event, &hiview) == noErr) {
    1746                             widget = QWidget::find((WId)hiview);;
     1799                            widget = QWidget::find((WId)hiview);
    17471800                            if (widget) {
    17481801                                // Make sure we didn't pass over a widget with a "fake hole" in it.
     
    18611914
    18621915            QMacTabletHash *tabletHash = qt_mac_tablet_hash();
    1863             if (!tabletHash->contains(tabletPointRec.deviceID)) {
    1864                 qWarning("QCocoaView handleTabletEvent: This tablet device is unknown"
    1865                         " (received no proximity event for it). Discarding event.");
     1916            if (!tabletHash->contains(tabletPointRec.deviceID) && t != QEvent::TabletRelease) {
     1917                // Never discard TabletRelease events as they may be delivered *after* TabletLeaveProximity events
     1918                qWarning("handleTabletEvent: This tablet device is unknown"
     1919                         " (received no proximity event for it). Discarding event.");
    18661920                return false;
    18671921            }
     
    19051959                QApplication::sendSpontaneousEvent(widget, &e);
    19061960                if (e.isAccepted()) {
     1961                    if (t == QEvent::TabletPress) {
     1962                        qt_button_down = widget;
     1963                    } else if (t == QEvent::TabletRelease) {
     1964                        qt_button_down = 0;
     1965                    }
    19071966#if defined(DEBUG_MOUSE_MAPS)
    1908                     qDebug("Bail out early due to table acceptance");
     1967                    qDebug("Bail out early due to tablet acceptance");
    19091968#endif
    19101969                    break;
     
    20632122                qt_mac_dblclick.last_time = GetEventTime(event);
    20642123            }
    2065             if(wheel_delta) {
    2066                 EventMouseWheelAxis axis;
    2067                 GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, 0,
    2068                                   sizeof(axis), 0, &axis);
    2069                 QWheelEvent qwe(plocal, p, wheel_delta, buttons, modifiers,
    2070                                 axis == kEventMouseWheelAxisX ? Qt::Horizontal : Qt::Vertical);
    2071                 QApplication::sendSpontaneousEvent(widget, &qwe);
    2072                 if(!qwe.isAccepted() && QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget != widget) {
    2073                     QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(p), p,
    2074                                      wheel_delta, buttons, modifiers,
    2075                                      axis == kEventMouseWheelAxisX ? Qt::Horizontal : Qt::Vertical);
    2076                     QApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
    2077                     if(!qwe2.isAccepted())
    2078                         handled_event = false;
     2124
     2125            if (wheel_deltaX || wheel_deltaY) {
     2126                if (wheel_deltaX) {
     2127                    QWheelEvent qwe(plocal, p, wheel_deltaX, buttons, modifiers, Qt::Horizontal);
     2128                    QApplication::sendSpontaneousEvent(widget, &qwe);
     2129                    if (!qwe.isAccepted() && QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget != widget) {
     2130                        QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(p), p,
     2131                                wheel_deltaX, buttons, modifiers, Qt::Horizontal);
     2132                        QApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
     2133                        if (!qwe2.isAccepted())
     2134                            handled_event = false;
     2135                    }
     2136                }
     2137                if (wheel_deltaY) {
     2138                    QWheelEvent qwe(plocal, p, wheel_deltaY, buttons, modifiers, Qt::Vertical);
     2139                    QApplication::sendSpontaneousEvent(widget, &qwe);
     2140                    if (!qwe.isAccepted() && QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget != widget) {
     2141                        QWheelEvent qwe2(QApplicationPrivate::focus_widget->mapFromGlobal(p), p,
     2142                                wheel_deltaY, buttons, modifiers, Qt::Vertical);
     2143                        QApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, &qwe2);
     2144                        if (!qwe2.isAccepted())
     2145                            handled_event = false;
     2146                    }
    20792147                }
    20802148            } else {
     
    21392207                   widget ? widget->objectName().toLocal8Bit().constData() : "*Unknown*",
    21402208                   widget ? widget->metaObject()->className() : "*Unknown*",
    2141                    button, (int)buttons, (int)modifiers, wheel_delta);
     2209                   button, (int)buttons, (int)modifiers, wheel_deltaX);
    21422210#endif
    21432211        } else {
     
    23682436}
    23692437
     2438// In Carbon this is your one stop for apple events.
     2439// In Cocoa, it ISN'T. This is the catch-all Apple Event handler that exists
     2440// for the time between instantiating the NSApplication, but before the
     2441// NSApplication has installed it's OWN Apple Event handler. When Cocoa has
     2442// that set up, we remove this.  So, if you are debugging problems, you likely
     2443// want to check out QCocoaApplicationDelegate instead.
    23702444OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, AppleEvent *, long handlerRefcon)
    23712445{
     
    23792453        case kAEQuitApplication: {
    23802454            extern bool qt_mac_quit_menu_item_enabled; // qmenu_mac.cpp
    2381             if(!QApplicationPrivate::modalState() && qt_mac_quit_menu_item_enabled) {
     2455            if (qt_mac_quit_menu_item_enabled) {
    23822456                QCloseEvent ev;
    23832457                QApplication::sendSpontaneousEvent(app, &ev);
     
    24102484            }
    24112485            break; }
     2486        default:
     2487            break;
     2488        }
     2489    } else if (aeClass == kInternetEventClass) {
     2490        switch (aeID) {
     2491        case kAEGetURL: {
     2492            char urlData[1024];
     2493            Size actualSize;
     2494            if (AEGetParamPtr(ae, keyDirectObject, typeChar, 0, urlData,
     2495                    sizeof(urlData) - 1, &actualSize) == noErr) {
     2496                urlData[actualSize] = 0;
     2497                QFileOpenEvent ev(QUrl(QString::fromUtf8(urlData)));
     2498                QApplication::sendSpontaneousEvent(app, &ev);
     2499            }
     2500            break;
     2501        }
    24122502        default:
    24132503            break;
     
    28752965}
    28762966
    2877 void onApplicationWindowChangedActivation( QWidget*widget, bool activated )
     2967void onApplicationWindowChangedActivation(QWidget *widget, bool activated)
    28782968{
    28792969#if QT_MAC_USE_COCOA
    2880     QApplication *app = qApp;
    2881 
    2882     if ( activated )
    2883     {
    2884         if (QApplicationPrivate::app_style)
    2885         {
     2970    if (!widget)
     2971        return;
     2972
     2973    if (activated) {
     2974        if (QApplicationPrivate::app_style) {
    28862975            QEvent ev(QEvent::Style);
    28872976            qt_sendSpontaneousEvent(QApplicationPrivate::app_style, &ev);
    28882977        }
    2889 
    2890         if (widget && app_do_modal && !qt_try_modal(widget, NULL))
    2891             return;
    2892 
    2893         if (widget && widget->window()->isVisible())
    2894         {
    2895             QWidget *tlw = widget->window();
    2896 
    2897             if (tlw->isWindow() && !(tlw->windowType() == Qt::Popup)
    2898                  && !qt_mac_is_macdrawer(tlw)
    2899                 && (!tlw->parentWidget() || tlw->isModal() || !(tlw->windowType() == Qt::Tool))) {
    2900                 bool just_send_event = false;
    2901 #if 0
    2902                 WindowActivationScope    scope;
    2903                 if ( GetWindowActivationScope((OSWindowRef)wid, &scope) == noErr &&
    2904                         scope == kWindowActivationScopeIndependent)
    2905                 {
    2906                     if ( GetFrontWindowOfClass(kAllWindowClasses, true) != wid )
    2907                         just_send_event = true;
    2908                 }
    2909 #endif
    2910                 if (just_send_event) {
    2911                     QEvent e(QEvent::WindowActivate);
    2912                     qt_sendSpontaneousEvent(widget, &e);
    2913                 } else {
    2914                     app->setActiveWindow(tlw);
    2915                 }
    2916             }
    2917         }
     2978        qApp->setActiveWindow(widget);
    29182979    } else { // deactivated
    2919         if (widget && QApplicationPrivate::active_window == widget)
    2920             app->setActiveWindow(0);
    2921     }
     2980        if (QApplicationPrivate::active_window == widget)
     2981            qApp->setActiveWindow(0);
     2982    }
     2983
    29222984    QMenuBar::macUpdateMenuBar();
     2985
    29232986#else
    29242987    Q_UNUSED(widget);
     
    29743037}
    29753038
     3039void QApplicationPrivate::initializeMultitouch_sys()
     3040{ }
     3041void QApplicationPrivate::cleanupMultitouch_sys()
     3042{ }
     3043
    29763044QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.