Changeset 561 for trunk/src/gui/kernel/qapplication_mac.mm
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/kernel/qapplication_mac.mm
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 105 105 #include "qdebug.h" 106 106 #include "qtimer.h" 107 #include "qurl.h" 107 108 #include "private/qmacinputcontext_p.h" 108 109 #include "private/qpaintengine_mac_p.h" … … 155 156 #endif 156 157 158 #define kCMDeviceUnregisteredNotification CFSTR("CMDeviceUnregisteredNotification") 159 #define kCMDefaultDeviceNotification CFSTR("CMDefaultDeviceNotification") 160 #define kCMDeviceProfilesNotification CFSTR("CMDeviceProfilesNotification") 161 #define kCMDefaultDeviceProfileNotification CFSTR("CMDefaultDeviceProfileNotification") 157 162 158 163 QT_BEGIN_NAMESPACE … … 161 166 QPaintDevice *qt_mac_safe_pdev = 0; 162 167 QList<QMacWindowChangeEvent*> *QMacWindowChangeEvent::change_events = 0; 163 extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp164 168 165 169 /***************************************************************************** … … 195 199 static EventHandlerRef app_proc_handler = 0; 196 200 static EventHandlerUPP app_proc_handlerUPP = 0; 201 #endif 197 202 static AEEventHandlerUPP app_proc_ae_handlerUPP = NULL; 198 #endif199 203 static EventHandlerRef tablet_proximity_handler = 0; 200 204 static EventHandlerUPP tablet_proximity_UPP = 0; 201 205 bool QApplicationPrivate::native_modal_dialog_active; 206 207 Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; 202 208 203 209 /***************************************************************************** … … 219 225 void onApplicationWindowChangedActivation( QWidget*widget, bool activated ); 220 226 void onApplicationChangedActivation( bool activated ); 227 228 static void qt_mac_read_fontsmoothing_settings() 229 { 230 NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"]; 231 qt_applefontsmoothing_enabled = (appleFontSmoothing > 0); 232 } 221 233 222 234 Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) { … … 524 536 QFont fnt = qfontForThemeFont(mac_widget_fonts[i].font_key); 525 537 bool set_font = true; 526 QHash<QByteArray, QFont>*hash = qt_app_fonts_hash();538 FontHash *hash = qt_app_fonts_hash(); 527 539 if (!hash->isEmpty()) { 528 QHash<QByteArray, QFont>::const_iterator it540 FontHash::const_iterator it 529 541 = hash->constFind(mac_widget_fonts[i].qt_class); 530 542 if (it != hash->constEnd()) … … 625 637 626 638 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(); 629 640 if (!phash->isEmpty()) { 630 QHash<QByteArray, QPalette>::const_iterator it641 PaletteHash::const_iterator it 631 642 = phash->constFind(mac_widget_colors[i].qt_class); 632 643 if (it != phash->constEnd()) … … 952 963 } 953 964 954 #ifndef QT_MAC_USE_COCOA955 965 struct QMacAppleEventTypeSpec { 956 966 AEEventClass mac_class; … … 958 968 } app_apple_events[] = { 959 969 { kCoreEventClass, kAEQuitApplication }, 960 { kCoreEventClass, kAEOpenDocuments } 970 { kCoreEventClass, kAEOpenDocuments }, 971 { kInternetEventClass, kAEGetURL }, 961 972 }; 973 974 #ifndef QT_MAC_USE_COCOA 975 976 #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) 977 enum 978 { 979 kEventMouseScroll = 11, 980 kEventParamMouseWheelSmoothVerticalDelta = 'saxy', 981 kEventParamMouseWheelSmoothHorizontalDelta = 'saxx', 982 }; 983 #endif 984 962 985 /* watched events */ 963 986 static EventTypeSpec app_events[] = { … … 971 994 { kEventClassWindow, kEventWindowDeactivated }, 972 995 996 { kEventClassMouse, kEventMouseScroll }, 973 997 { kEventClassMouse, kEventMouseWheelMoved }, 974 998 { kEventClassMouse, kEventMouseDown }, … … 1041 1065 } 1042 1066 1067 void qt_color_profile_changed(CFNotificationCenterRef, void *, CFStringRef, const void *, 1068 CFDictionaryRef) 1069 { 1070 QCoreGraphicsPaintEngine::cleanUpMacColorSpaces(); 1071 } 1043 1072 /* platform specific implementations */ 1044 1073 void qt_init(QApplicationPrivate *priv, int) … … 1046 1075 if (qt_is_gui_used) { 1047 1076 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); 1048 1090 ProcessSerialNumber psn; 1049 1091 if (GetCurrentProcess(&psn) == noErr) { 1050 1092 // Jambi needs to transform itself since most people aren't "used" 1051 1093 // to putting things in bundles, but other people may actually not 1052 // want to tranform the process (running as a helper or someth ng)1094 // want to tranform the process (running as a helper or something) 1053 1095 // so don't do that for them. This means checking both LSUIElement 1054 1096 // and LSBackgroundOnly. If you set them both... well, you … … 1157 1199 } 1158 1200 1201 #endif 1159 1202 if (!app_proc_ae_handlerUPP) { 1160 1203 app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor); 1161 1204 for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) 1162 1205 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 } 1166 1208 1167 1209 if (QApplicationPrivate::app_style) { … … 1172 1214 if (QApplication::desktopSettingsAware()) 1173 1215 QApplicationPrivate::qt_mac_apply_settings(); 1216 1217 qt_mac_read_fontsmoothing_settings(); 1218 1174 1219 // Cocoa application delegate 1175 1220 #ifdef QT_MAC_USE_COCOA … … 1195 1240 [newDelegate setMenuLoader:qtMenuLoader]; 1196 1241 [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 1203 1248 // Register for Carbon tablet proximity events on the event monitor target. 1204 1249 // This means that we should receive proximity events even when we aren't the active application. … … 1211 1256 } 1212 1257 1258 void 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 1213 1269 /***************************************************************************** 1214 1270 qt_cleanup() - cleans up when the application is finished … … 1218 1274 { 1219 1275 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 1220 1282 #ifndef QT_MAC_USE_COCOA 1221 1283 qt_release_app_proc_handler(); … … 1224 1286 app_proc_handlerUPP = 0; 1225 1287 } 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(); 1235 1290 qt_release_tablet_proximity_handler(); 1236 1291 if (tablet_proximity_UPP) … … 1291 1346 qApp->d_func()->cursor_list.prepend(cursor); 1292 1347 1348 #ifdef QT_MAC_USE_COCOA 1349 QMacCocoaAutoReleasePool pool; 1350 [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) push]; 1351 #else 1293 1352 if (qApp && qApp->activeWindow()) 1294 1353 qt_mac_set_cursor(&qApp->d_func()->cursor_list.first(), QCursor::pos()); 1354 #endif 1295 1355 } 1296 1356 … … 1301 1361 qApp->d_func()->cursor_list.removeFirst(); 1302 1362 1363 #ifdef QT_MAC_USE_COCOA 1364 QMacCocoaAutoReleasePool pool; 1365 [NSCursor pop]; 1366 #else 1303 1367 if (qApp && qApp->activeWindow()) { 1304 1368 const QCursor def(Qt::ArrowCursor); 1305 1369 qt_mac_set_cursor(qApp->d_func()->cursor_list.isEmpty() ? &def : &qApp->d_func()->cursor_list.first(), QCursor::pos()); 1306 1370 } 1307 } 1308 #endif 1371 #endif 1372 } 1373 #endif // QT_NO_CURSOR 1309 1374 1310 1375 QWidget *QApplication::topLevelAt(const QPoint &p) … … 1342 1407 } 1343 1408 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 1367 1409 /***************************************************************************** 1368 1410 Main event loop … … 1397 1439 1398 1440 #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); 1406 1443 #endif 1407 1444 } … … 1429 1466 #ifdef QT_MAC_USE_COCOA 1430 1467 if (!qt_mac_is_macsheet(widget)) 1431 QEventDispatcherMacPrivate:: rebuildModalSessionStack(true);1468 QEventDispatcherMacPrivate::endModalSession(widget); 1432 1469 #endif 1433 1470 } … … 1439 1476 qt_event_request_menubarupdate(); 1440 1477 } 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 tells1447 // us (by releasing the block) that it is OK to recurse into1448 // 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 #endif1456 1478 1457 1479 QWidget *QApplicationPrivate::tryModalHelper_sys(QWidget *top) … … 1468 1490 } 1469 1491 1492 #ifndef QT_MAC_USE_COCOA 1470 1493 static bool qt_try_modal(QWidget *widget, EventRef event) 1471 1494 { … … 1501 1524 return !block_event; 1502 1525 } 1526 #endif 1503 1527 1504 1528 OSStatus QApplicationPrivate::tabletProximityCallback(EventHandlerCallRef, EventRef carbonEvent, … … 1639 1663 GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, 1640 1664 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 1650 1665 #if defined(DEBUG_MOUSE_MAPS) 1651 1666 const char *edesc = 0; … … 1654 1669 case kEventMouseUp: edesc = "MouseButtonRelease"; break; 1655 1670 case kEventMouseDragged: case kEventMouseMoved: edesc = "MouseMove"; break; 1671 case kEventMouseScroll: edesc = "MouseWheelScroll"; break; 1656 1672 case kEventMouseWheelMoved: edesc = "MouseWheelMove"; break; 1657 1673 } … … 1672 1688 GetEventParameter(event, kEventParamMouseChord, typeUInt32, 0, 1673 1689 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, 1680 1711 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 } 1682 1735 } 1683 1736 … … 1744 1797 HIViewRef hiview; 1745 1798 if(HIViewGetViewForMouseEvent(HIViewGetRoot(window), event, &hiview) == noErr) { 1746 widget = QWidget::find((WId)hiview); ;1799 widget = QWidget::find((WId)hiview); 1747 1800 if (widget) { 1748 1801 // Make sure we didn't pass over a widget with a "fake hole" in it. … … 1861 1914 1862 1915 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."); 1866 1920 return false; 1867 1921 } … … 1905 1959 QApplication::sendSpontaneousEvent(widget, &e); 1906 1960 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 } 1907 1966 #if defined(DEBUG_MOUSE_MAPS) 1908 qDebug("Bail out early due to table acceptance");1967 qDebug("Bail out early due to tablet acceptance"); 1909 1968 #endif 1910 1969 break; … … 2063 2122 qt_mac_dblclick.last_time = GetEventTime(event); 2064 2123 } 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 } 2079 2147 } 2080 2148 } else { … … 2139 2207 widget ? widget->objectName().toLocal8Bit().constData() : "*Unknown*", 2140 2208 widget ? widget->metaObject()->className() : "*Unknown*", 2141 button, (int)buttons, (int)modifiers, wheel_delta );2209 button, (int)buttons, (int)modifiers, wheel_deltaX); 2142 2210 #endif 2143 2211 } else { … … 2368 2436 } 2369 2437 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. 2370 2444 OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, AppleEvent *, long handlerRefcon) 2371 2445 { … … 2379 2453 case kAEQuitApplication: { 2380 2454 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) { 2382 2456 QCloseEvent ev; 2383 2457 QApplication::sendSpontaneousEvent(app, &ev); … … 2410 2484 } 2411 2485 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 } 2412 2502 default: 2413 2503 break; … … 2875 2965 } 2876 2966 2877 void onApplicationWindowChangedActivation( QWidget*widget, bool activated)2967 void onApplicationWindowChangedActivation(QWidget *widget, bool activated) 2878 2968 { 2879 2969 #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) { 2886 2975 QEvent ev(QEvent::Style); 2887 2976 qt_sendSpontaneousEvent(QApplicationPrivate::app_style, &ev); 2888 2977 } 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); 2918 2979 } 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 2922 2984 QMenuBar::macUpdateMenuBar(); 2985 2923 2986 #else 2924 2987 Q_UNUSED(widget); … … 2974 3037 } 2975 3038 3039 void QApplicationPrivate::initializeMultitouch_sys() 3040 { } 3041 void QApplicationPrivate::cleanupMultitouch_sys() 3042 { } 3043 2976 3044 QT_END_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.