Changeset 846 for trunk/src/gui/kernel
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 192 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/kernel.pri
r651 r846 121 121 kernel/qclipboard_s60.cpp\ 122 122 kernel/qdnd_s60.cpp \ 123 kernel/qsound_s60.cpp \ 124 kernel/qsoftkeymanager_s60.cpp 123 kernel/qsound_s60.cpp 125 124 126 125 HEADERS += \ 127 126 kernel/qt_s60_p.h \ 128 kernel/qeventdispatcher_s60_p.h \ 129 kernel/qsoftkeymanager_s60_p.h 127 kernel/qeventdispatcher_s60_p.h 130 128 131 129 LIBS += -lbafl -lestor … … 133 131 INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE 134 132 INCLUDEPATH += ../3rdparty/s60 133 134 contains(QT_CONFIG, s60) { 135 SOURCES += kernel/qsoftkeymanager_s60.cpp 136 HEADERS += kernel/qsoftkeymanager_s60_p.h 137 } 135 138 } 136 139 … … 219 222 OBJECTIVE_HEADERS += \ 220 223 qcocoawindow_mac_p.h \ 224 qcocoapanel_mac_p.h \ 221 225 qcocoawindowdelegate_mac_p.h \ 222 226 qcocoaview_mac_p.h \ -
trunk/src/gui/kernel/qaction.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 82 82 QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), 83 83 visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), 84 forceEnabledInSoftkeys(false), menuActionSoftkeys(false), 85 iconVisibleInMenu(-1), 84 86 menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), 85 priority(QAction::NormalPriority) , iconVisibleInMenu(-1)87 priority(QAction::NormalPriority) 86 88 { 87 89 #ifdef QT3_SUPPORT -
trunk/src/gui/kernel/qaction.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 247 247 friend class QShortcutMap; 248 248 friend class QToolButton; 249 #ifdef Q_WS_MAC 250 friend void qt_mac_clear_status_text(QAction *action); 251 #endif 249 252 }; 250 253 -
trunk/src/gui/kernel/qaction_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 76 76 ~QActionPrivate(); 77 77 78 static QActionPrivate *get(QAction *q) 79 { 80 return q->d_func(); 81 } 82 78 83 bool showStatusText(QWidget *w, const QString &str); 79 84 … … 104 109 uint separator : 1; 105 110 uint fontSet : 1; 111 112 //for soft keys management 113 uint forceEnabledInSoftkeys : 1; 114 uint menuActionSoftkeys : 1; 115 int iconVisibleInMenu : 3; // Only has values -1, 0, and 1 116 106 117 QAction::MenuRole menuRole; 107 118 QAction::SoftKeyRole softKeyRole; 108 119 QAction::Priority priority; 109 int iconVisibleInMenu : 3; // Only has values -1, 0, and 1 120 110 121 QList<QWidget *> widgets; 111 122 #ifndef QT_NO_GRAPHICSVIEW -
trunk/src/gui/kernel/qactiongroup.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qactiongroup.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qapplication.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 66 66 #include "qdebug.h" 67 67 #include "private/qgraphicssystemfactory_p.h" 68 #include "private/qgraphicssystem_p.h" 68 69 #include "private/qstylesheetstyle_p.h" 69 70 #include "private/qstyle_p.h" … … 71 72 #include <QtGui/qgraphicsproxywidget.h> 72 73 74 #ifdef QT_GRAPHICSSYSTEM_RUNTIME 75 #include "private/qgraphicssystem_runtime_p.h" 76 #endif 77 73 78 #include "qinputcontext.h" 74 79 #include "qkeymapper_p.h" … … 78 83 #endif 79 84 80 #if defined(Q_WS_X11) || defined(Q_ WS_S60)85 #if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN) 81 86 #include "qinputcontextfactory.h" 82 87 #endif … … 90 95 91 96 #include <stdlib.h> 97 98 #if defined(Q_WS_X11) && !defined(QT_NO_EGL) 99 #include <link.h> 100 #endif 92 101 93 102 #include "qapplication_p.h" … … 123 132 { 124 133 #if defined(Q_WS_WINCE) 134 Q_INIT_RESOURCE_EXTERN(qstyle_wince) 125 135 Q_INIT_RESOURCE(qstyle_wince); 126 136 #elif defined(Q_OS_SYMBIAN) 137 Q_INIT_RESOURCE_EXTERN(qstyle_s60) 127 138 Q_INIT_RESOURCE(qstyle_s60); 128 139 #else 140 Q_INIT_RESOURCE_EXTERN(qstyle) 129 141 Q_INIT_RESOURCE(qstyle); 130 142 #endif 131 143 Q_INIT_RESOURCE_EXTERN(qmessagebox) 132 144 Q_INIT_RESOURCE(qmessagebox); 133 145 #if !defined(QT_NO_PRINTDIALOG) 146 Q_INIT_RESOURCE_EXTERN(qprintdialog) 134 147 Q_INIT_RESOURCE(qprintdialog); 135 148 #endif … … 139 152 QT_BEGIN_NAMESPACE 140 153 141 Q_ DECL_IMPORT externvoid qt_call_post_routines();154 Q_CORE_EXPORT void qt_call_post_routines(); 142 155 143 156 int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0 … … 182 195 #endif 183 196 197 #ifndef QT_NO_GESTURES 184 198 gestureManager = 0; 185 199 gestureWidget = 0; 200 #endif // QT_NO_GESTURES 201 202 #if defined(Q_WS_X11) || defined(Q_WS_WIN) 203 move_cursor = 0; 204 copy_cursor = 0; 205 link_cursor = 0; 206 #endif 207 #if defined(Q_WS_WIN) 208 ignore_cursor = 0; 209 #endif 186 210 187 211 if (!self) … … 432 456 QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system 433 457 QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization 458 bool QApplicationPrivate::runtime_graphics_system = false; 434 459 435 460 Q_GLOBAL_STATIC(QMutex, applicationFontMutex) … … 455 480 int qt_antialiasing_threshold = -1; 456 481 static int drag_time = 500; 482 #ifndef QT_GUI_DRAG_DISTANCE 483 #define QT_GUI_DRAG_DISTANCE 4 484 #endif 457 485 #ifdef Q_OS_SYMBIAN 458 486 // The screens are a bit too small to for your thumb when using only 4 pixels drag distance. 459 static int drag_distance = 8;487 static int drag_distance = 12; //XXX move to qplatformdefs.h 460 488 #else 461 static int drag_distance = 4;489 static int drag_distance = QT_GUI_DRAG_DISTANCE; 462 490 #endif 463 491 static Qt::LayoutDirection layout_direction = Qt::LeftToRight; … … 472 500 bool QApplicationPrivate::widgetCount = false; 473 501 bool QApplicationPrivate::load_testability = false; 502 QString QApplicationPrivate::qmljs_debug_arguments; 474 503 #ifdef QT_KEYPAD_NAVIGATION 475 504 # ifdef Q_OS_SYMBIAN … … 488 517 if (!widget) 489 518 return false; 490 #if defined(Q_WS_MAC) // Fake alien behavior on the Mac :) 491 return !widget->isWindow() && widget->window()->testAttribute(Qt::WA_DontShowOnScreen); 492 #elif defined(Q_WS_QWS) 519 #if defined(Q_WS_QWS) 493 520 return !widget->isWindow() 494 521 # ifdef Q_BACKINGSTORE_SUBSURFACES … … 545 572 if (arg == "-qdevel" || arg == "-qdebug") { 546 573 // obsolete argument 574 } else if (arg.indexOf("-qmljsdebugger=", 0) != -1) { 575 qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15)); 547 576 } else if (arg.indexOf("-style=", 0) != -1) { 548 577 s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower()); … … 650 679 \o -graphicssystem, sets the backend to be used for on-screen widgets 651 680 and QPixmaps. Available options are \c{raster} and \c{opengl}. 681 \o -qmljsdebugger=, activates the QML/JS debugger with a specified port. 682 The value must be of format port:1234[,block], where block is optional 683 and will make the application wait until a debugger connects to it. 652 684 \endlist 653 685 … … 658 690 that is shown. 659 691 \o -fn or \c -font \e font, defines the application font. The font 660 should be specified using an X logical font description. 692 should be specified using an X logical font description. Note that 693 this option is ignored when Qt is built with fontconfig support enabled. 661 694 \o -bg or \c -background \e color, sets the default background color 662 695 and an application palette (light and dark shades are calculated). … … 684 717 \endlist 685 718 719 \section1 X11 Notes 720 721 If QApplication fails to open the X11 display, it will terminate 722 the process. This behavior is consistent with most X11 723 applications. 724 686 725 \sa arguments() 687 726 */ … … 752 791 { Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} 753 792 793 #if defined(Q_WS_X11) && !defined(QT_NO_EGL) 794 static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data) 795 { 796 const char *name = static_cast<const char *>(data); 797 return strstr(info->dlpi_name, name) != 0; 798 } 799 #endif 754 800 755 801 /*! … … 766 812 qt_is_gui_used = (qt_appType != QApplication::Tty); 767 813 process_cmdline(); 814 // the environment variable has the lowest precedence of runtime graphicssystem switches 815 if (graphics_system_name.isEmpty()) 816 graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM")); 817 818 #if defined(Q_WS_X11) && !defined(QT_NO_EGL) 819 if (graphics_system_name.isEmpty()) { 820 bool linksWithMeeGoTouch = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libmeegotouchcore")); 821 bool linksWithMeeGoGraphicsSystemHelper = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libQtMeeGoGraphicsSystemHelper")); 822 823 if (linksWithMeeGoTouch && !linksWithMeeGoGraphicsSystemHelper) { 824 qWarning("Running non-meego graphics system enabled MeeGo touch, forcing native graphicssystem\n"); 825 graphics_system_name = QLatin1String("native"); 826 } 827 } 828 #endif 829 768 830 // Must be called before initialize() 769 831 qt_init(this, qt_appType … … 778 840 extern void qt_gui_eval_init(uint); 779 841 qt_gui_eval_init(application_type); 842 #endif 843 844 #if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) 845 symbianInit(); 780 846 #endif 781 847 … … 786 852 typedef void (*TasInitialize)(void); 787 853 TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); 854 #ifdef Q_OS_SYMBIAN 855 // resolving method by name does not work on Symbian OS so need to use ordinal 856 if(!initFunction) { 857 initFunction = (TasInitialize)testLib.resolve("1"); 858 } 859 #endif 788 860 if (initFunction) { 789 861 initFunction(); … … 879 951 880 952 extern void qInitDrawhelperAsm(); 953 extern void qInitImageConversions(); 881 954 extern int qRegisterGuiVariant(); 882 955 extern int qUnregisterGuiVariant(); … … 936 1009 // Set up which span functions should be used in raster engine... 937 1010 qInitDrawhelperAsm(); 1011 // and QImage conversion functions 1012 qInitImageConversions(); 938 1013 939 1014 #ifndef QT_NO_WHEELEVENT … … 1028 1103 QApplicationPrivate::is_app_closing = true; 1029 1104 QApplicationPrivate::is_app_running = false; 1030 1031 delete qt_desktopWidget;1032 qt_desktopWidget = 0;1033 1034 #ifndef QT_NO_CLIPBOARD1035 delete qt_clipboard;1036 qt_clipboard = 0;1037 #endif1038 1105 1039 1106 delete QWidgetPrivate::mapper; … … 1052 1119 } 1053 1120 1121 delete qt_desktopWidget; 1122 qt_desktopWidget = 0; 1123 1124 #ifndef QT_NO_CLIPBOARD 1125 delete qt_clipboard; 1126 qt_clipboard = 0; 1127 #endif 1128 1129 #if defined(Q_WS_X11) || defined(Q_WS_WIN) 1130 delete d->move_cursor; d->move_cursor = 0; 1131 delete d->copy_cursor; d->copy_cursor = 0; 1132 delete d->link_cursor; d->link_cursor = 0; 1133 #endif 1134 #if defined(Q_WS_WIN) 1135 delete d->ignore_cursor; d->ignore_cursor = 0; 1136 #endif 1137 1054 1138 delete QApplicationPrivate::app_pal; 1055 1139 QApplicationPrivate::app_pal = 0; … … 1075 1159 delete QApplicationPrivate::app_icon; 1076 1160 QApplicationPrivate::app_icon = 0; 1161 delete QApplicationPrivate::graphics_system; 1162 QApplicationPrivate::graphics_system = 0; 1077 1163 #ifndef QT_NO_CURSOR 1078 1164 d->cursor_list.clear(); … … 1347 1433 // 1348 1434 QString style; 1349 if (!QApplicationPrivate::styleOverride.isEmpty()) 1435 #ifdef QT_BUILD_INTERNAL 1436 QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE")); 1437 #else 1438 QString envStyle; 1439 #endif 1440 if (!QApplicationPrivate::styleOverride.isEmpty()) { 1350 1441 style = QApplicationPrivate::styleOverride; 1351 else 1442 } else if (!envStyle.isEmpty()) { 1443 style = envStyle; 1444 } else { 1352 1445 style = QApplicationPrivate::desktopStyleKey(); 1446 } 1353 1447 1354 1448 QStyle *&app_style = QApplicationPrivate::app_style; … … 1533 1627 \c{"raster"} and \c{"opengl"}. 1534 1628 1535 This function call overrides both the application commandline 1536 \c{-graphicssystem} switch and the configure \c{-graphicssystem} switch. 1537 1538 \warning This function must be called before the QApplication constructor 1629 There are several ways to set the graphics backend, in order of decreasing 1630 precedence: 1631 \list 1632 \o the application commandline \c{-graphicssystem} switch 1633 \o QApplication::setGraphicsSystem() 1634 \o the QT_GRAPHICSSYSTEM environment variable 1635 \o the Qt configure \c{-graphicssystem} switch 1636 \endlist 1637 If the highest precedence switch sets an invalid name, the error will be 1638 ignored and the default backend will be used. 1639 1640 \warning This function is only effective before the QApplication constructor 1539 1641 is called. 1540 1642 … … 1544 1646 void QApplication::setGraphicsSystem(const QString &system) 1545 1647 { 1546 QApplicationPrivate::graphics_system_name = system; 1648 #ifdef QT_GRAPHICSSYSTEM_RUNTIME 1649 if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) { 1650 QRuntimeGraphicsSystem *r = 1651 static_cast<QRuntimeGraphicsSystem *>(QApplicationPrivate::graphics_system); 1652 r->setGraphicsSystem(system); 1653 } else 1654 #endif 1655 QApplicationPrivate::graphics_system_name = system; 1547 1656 } 1548 1657 … … 2197 2306 bool did_close = true; 2198 2307 QWidget *w; 2199 while ((w = activeModalWidget()) && did_close) {2200 if (!w->isVisible())2308 while ((w = activeModalWidget()) && did_close) { 2309 if (!w->isVisible() || w->data->is_closing) 2201 2310 break; 2202 2311 did_close = w->close(); … … 2205 2314 for (int i = 0; did_close && i < list.size(); ++i) { 2206 2315 w = list.at(i); 2207 if (w->isVisible() && w->windowType() != Qt::Desktop) { 2316 if (w->isVisible() 2317 && w->windowType() != Qt::Desktop 2318 && !w->data->is_closing) { 2208 2319 did_close = w->close(); 2209 2320 list = QApplication::topLevelWidgets(); … … 2294 2405 " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); 2295 2406 } 2407 #if defined(Q_WS_MAC) 2408 static const char *application_menu_strings[] = { 2409 QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"), 2410 QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"), 2411 QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"), 2412 QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"), 2413 QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."), 2414 QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1"), 2415 QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1") 2416 }; 2417 QString qt_mac_applicationmenu_string(int type) 2418 { 2419 QString menuString = QString::fromLatin1(application_menu_strings[type]); 2420 QString translated = qApp->translate("QMenuBar", application_menu_strings[type]); 2421 if (translated != menuString) 2422 return translated; 2423 else 2424 return qApp->translate("MAC_APPLICATION_MENU", 2425 application_menu_strings[type]); 2426 } 2427 #endif 2296 2428 #endif 2297 2429 … … 2322 2454 setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight); 2323 2455 #endif 2456 #if defined(QT_MAC_USE_COCOA) 2457 qt_mac_post_retranslateAppMenu(); 2458 #endif 2324 2459 QWidgetList list = topLevelWidgets(); 2325 2460 for (int i = 0; i < list.size(); ++i) { … … 2328 2463 postEvent(w, new QEvent(QEvent::LanguageChange)); 2329 2464 } 2465 #ifndef Q_OS_WIN 2466 } else if (e->type() == QEvent::LocaleChange) { 2467 // on Windows the event propagation is taken care by the 2468 // WM_SETTINGCHANGE event handler. 2469 QWidgetList list = topLevelWidgets(); 2470 for (int i = 0; i < list.size(); ++i) { 2471 QWidget *w = list.at(i); 2472 if (!(w->windowType() == Qt::Desktop)) { 2473 if (!w->testAttribute(Qt::WA_SetLocale)) 2474 w->d_func()->setLocale_helper(QLocale(), true); 2475 } 2476 } 2477 #endif 2330 2478 } else if (e->type() == QEvent::Timer) { 2331 2479 QTimerEvent *te = static_cast<QTimerEvent*>(e); … … 2456 2604 } 2457 2605 2606 #ifdef QT_MAC_USE_COCOA 2607 // In case the user clicked on a child window, we need to 2608 // reestablish the stacking order of the window so 2609 // it pops in front of other child windows in cocoa: 2610 qt_cocoaStackChildWindowOnTopOfOtherChildren(window); 2611 #endif 2612 2458 2613 for(int i = 0; i < toBeDeactivated.size(); ++i) { 2459 2614 QWidget *w = toBeDeactivated.at(i); … … 2690 2845 #elif defined(Q_WS_X11) 2691 2846 qt_x11_enforce_cursor(cursorWidget, true); 2692 #elif defined(Q_ WS_S60)2847 #elif defined(Q_OS_SYMBIAN) 2693 2848 qt_symbian_set_cursor(cursorWidget, true); 2694 2849 #elif defined(Q_WS_PM) … … 2998 3153 } 2999 3154 3000 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_ PM)3155 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 3001 3156 /* 3002 3157 This function should only be called when the widget changes visibility, i.e. … … 3058 3213 #endif // QT_NO_CURSOR 3059 3214 } 3060 #endif // Q_WS_WIN || Q_WS_ PM || Q_WS_X113215 #endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC || Q_WS_PM 3061 3216 3062 3217 /*! … … 3465 3620 void QApplication::setLayoutDirection(Qt::LayoutDirection direction) 3466 3621 { 3467 if (layout_direction == direction )3622 if (layout_direction == direction || direction == Qt::LayoutDirectionAuto) 3468 3623 return; 3469 3624 … … 3641 3796 } 3642 3797 3798 #ifndef QT_NO_GESTURES 3643 3799 // walk through parents and check for gestures 3644 3800 if (d->gestureManager) { … … 3685 3841 } 3686 3842 } 3687 3843 #endif // QT_NO_GESTURES 3688 3844 3689 3845 // User input and window activation makes tooltips sleep … … 4190 4346 break; 4191 4347 4348 #ifndef QT_NO_GESTURES 4192 4349 case QEvent::NativeGesture: 4193 4350 { … … 4243 4400 for (int i = 0; i < gestures.size(); ++i) { 4244 4401 QGesture *g = gestures.at(i); 4245 if ((res && eventAccepted) || (!eventAccepted && ge.isAccepted(g))) { 4402 // Ignore res [event return value] because handling of multiple gestures 4403 // packed into a single QEvent depends on not consuming the event 4404 if (eventAccepted || ge.isAccepted(g)) { 4246 4405 // if the gesture was accepted, mark the target widget for it 4247 4406 gestureEvent->d_func()->targetWidgets[g->gestureType()] = w; 4248 4407 gestureEvent->setAccepted(g, true); 4249 } else if (!eventAccepted && !ge.isAccepted(g)){4408 } else { 4250 4409 // if the gesture was explicitly ignored by the application, 4251 4410 // put it back so a parent can get it … … 4268 4427 break; 4269 4428 } 4429 #endif // QT_NO_GESTURES 4270 4430 default: 4271 4431 res = d->notify_helper(receiver, e); … … 5209 5369 */ 5210 5370 5371 #ifndef QT_NO_IM 5211 5372 // ************************************************************************ 5212 5373 // Input Method support … … 5217 5378 with \a inputContext. 5218 5379 5380 Qt takes ownership of the given \a inputContext. 5381 5219 5382 \sa inputContext() 5220 5383 */ … … 5222 5385 { 5223 5386 #ifndef QT_NO_IM 5224 Q_D(QApplication);5225 Q_UNUSED(d);// only static members being used.5387 if (inputContext == QApplicationPrivate::inputContext) 5388 return; 5226 5389 if (!inputContext) { 5227 5390 qWarning("QApplication::setInputContext: called with 0 input context"); 5228 5391 return; 5229 5392 } 5230 delete d->inputContext; 5231 d->inputContext = inputContext; 5393 delete QApplicationPrivate::inputContext; 5394 QApplicationPrivate::inputContext = inputContext; 5395 QApplicationPrivate::inputContext->setParent(this); 5232 5396 #endif 5233 5397 } … … 5256 5420 that->d_func()->inputContext = qic; 5257 5421 } 5258 #elif defined(Q_ WS_S60)5422 #elif defined(Q_OS_SYMBIAN) 5259 5423 if (!d->inputContext) { 5260 5424 QApplication *that = const_cast<QApplication *>(this); 5261 that->d_func()->inputContext = QInputContextFactory::create(QString::fromLatin1("coefep"), that); 5425 const QStringList keys = QInputContextFactory::keys(); 5426 // Try hbim and coefep first, then try others. 5427 if (keys.contains(QLatin1String("hbim"))) { 5428 that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("hbim"), that); 5429 } else if (keys.contains(QLatin1String("coefep"))) { 5430 that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("coefep"), that); 5431 } else { 5432 for (int c = 0; c < keys.size() && !d->inputContext; ++c) { 5433 that->d_func()->inputContext = QInputContextFactory::create(keys[c], that); 5434 } 5435 } 5262 5436 } 5263 5437 #endif … … 5267 5441 #endif 5268 5442 } 5443 #endif // QT_NO_IM 5269 5444 5270 5445 //Returns the current platform used by keyBindings … … 5694 5869 } 5695 5870 5871 #ifndef QT_NO_GESTURES 5696 5872 QGestureManager* QGestureManager::instance() 5697 5873 { 5698 QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); 5699 if (!qAppPriv->gestureManager) 5700 qAppPriv->gestureManager = new QGestureManager(qApp); 5701 return qAppPriv->gestureManager; 5874 if (QApplicationPrivate *qAppPriv = QApplicationPrivate::instance()) { 5875 if (!qAppPriv->gestureManager) 5876 qAppPriv->gestureManager = new QGestureManager(qApp); 5877 return qAppPriv->gestureManager; 5878 } 5879 return 0; 5880 } 5881 #endif // QT_NO_GESTURES 5882 5883 // These pixmaps approximate the images in the Windows User Interface Guidelines. 5884 5885 // XPM 5886 5887 static const char * const move_xpm[] = { 5888 "11 20 3 1", 5889 ". c None", 5890 #if defined(Q_WS_WIN) 5891 "a c #000000", 5892 "X c #FFFFFF", // Windows cursor is traditionally white 5893 #else 5894 "a c #FFFFFF", 5895 "X c #000000", // X11 cursor is traditionally black 5896 #endif 5897 "aa.........", 5898 "aXa........", 5899 "aXXa.......", 5900 "aXXXa......", 5901 "aXXXXa.....", 5902 "aXXXXXa....", 5903 "aXXXXXXa...", 5904 "aXXXXXXXa..", 5905 "aXXXXXXXXa.", 5906 "aXXXXXXXXXa", 5907 "aXXXXXXaaaa", 5908 "aXXXaXXa...", 5909 "aXXaaXXa...", 5910 "aXa..aXXa..", 5911 "aa...aXXa..", 5912 "a.....aXXa.", 5913 "......aXXa.", 5914 ".......aXXa", 5915 ".......aXXa", 5916 "........aa."}; 5917 5918 #ifdef Q_WS_WIN 5919 /* XPM */ 5920 static const char * const ignore_xpm[] = { 5921 "24 30 3 1", 5922 ". c None", 5923 "a c #000000", 5924 "X c #FFFFFF", 5925 "aa......................", 5926 "aXa.....................", 5927 "aXXa....................", 5928 "aXXXa...................", 5929 "aXXXXa..................", 5930 "aXXXXXa.................", 5931 "aXXXXXXa................", 5932 "aXXXXXXXa...............", 5933 "aXXXXXXXXa..............", 5934 "aXXXXXXXXXa.............", 5935 "aXXXXXXaaaa.............", 5936 "aXXXaXXa................", 5937 "aXXaaXXa................", 5938 "aXa..aXXa...............", 5939 "aa...aXXa...............", 5940 "a.....aXXa..............", 5941 "......aXXa.....XXXX.....", 5942 ".......aXXa..XXaaaaXX...", 5943 ".......aXXa.XaaaaaaaaX..", 5944 "........aa.XaaaXXXXaaaX.", 5945 "...........XaaaaX..XaaX.", 5946 "..........XaaXaaaX..XaaX", 5947 "..........XaaXXaaaX.XaaX", 5948 "..........XaaX.XaaaXXaaX", 5949 "..........XaaX..XaaaXaaX", 5950 "...........XaaX..XaaaaX.", 5951 "...........XaaaXXXXaaaX.", 5952 "............XaaaaaaaaX..", 5953 ".............XXaaaaXX...", 5954 "...............XXXX....."}; 5955 #endif 5956 5957 /* XPM */ 5958 static const char * const copy_xpm[] = { 5959 "24 30 3 1", 5960 ". c None", 5961 "a c #000000", 5962 "X c #FFFFFF", 5963 #if defined(Q_WS_WIN) // Windows cursor is traditionally white 5964 "aa......................", 5965 "aXa.....................", 5966 "aXXa....................", 5967 "aXXXa...................", 5968 "aXXXXa..................", 5969 "aXXXXXa.................", 5970 "aXXXXXXa................", 5971 "aXXXXXXXa...............", 5972 "aXXXXXXXXa..............", 5973 "aXXXXXXXXXa.............", 5974 "aXXXXXXaaaa.............", 5975 "aXXXaXXa................", 5976 "aXXaaXXa................", 5977 "aXa..aXXa...............", 5978 "aa...aXXa...............", 5979 "a.....aXXa..............", 5980 "......aXXa..............", 5981 ".......aXXa.............", 5982 ".......aXXa.............", 5983 "........aa...aaaaaaaaaaa", 5984 #else 5985 "XX......................", 5986 "XaX.....................", 5987 "XaaX....................", 5988 "XaaaX...................", 5989 "XaaaaX..................", 5990 "XaaaaaX.................", 5991 "XaaaaaaX................", 5992 "XaaaaaaaX...............", 5993 "XaaaaaaaaX..............", 5994 "XaaaaaaaaaX.............", 5995 "XaaaaaaXXXX.............", 5996 "XaaaXaaX................", 5997 "XaaXXaaX................", 5998 "XaX..XaaX...............", 5999 "XX...XaaX...............", 6000 "X.....XaaX..............", 6001 "......XaaX..............", 6002 ".......XaaX.............", 6003 ".......XaaX.............", 6004 "........XX...aaaaaaaaaaa", 6005 #endif 6006 ".............aXXXXXXXXXa", 6007 ".............aXXXXXXXXXa", 6008 ".............aXXXXaXXXXa", 6009 ".............aXXXXaXXXXa", 6010 ".............aXXaaaaaXXa", 6011 ".............aXXXXaXXXXa", 6012 ".............aXXXXaXXXXa", 6013 ".............aXXXXXXXXXa", 6014 ".............aXXXXXXXXXa", 6015 ".............aaaaaaaaaaa"}; 6016 6017 /* XPM */ 6018 static const char * const link_xpm[] = { 6019 "24 30 3 1", 6020 ". c None", 6021 "a c #000000", 6022 "X c #FFFFFF", 6023 #if defined(Q_WS_WIN) // Windows cursor is traditionally white 6024 "aa......................", 6025 "aXa.....................", 6026 "aXXa....................", 6027 "aXXXa...................", 6028 "aXXXXa..................", 6029 "aXXXXXa.................", 6030 "aXXXXXXa................", 6031 "aXXXXXXXa...............", 6032 "aXXXXXXXXa..............", 6033 "aXXXXXXXXXa.............", 6034 "aXXXXXXaaaa.............", 6035 "aXXXaXXa................", 6036 "aXXaaXXa................", 6037 "aXa..aXXa...............", 6038 "aa...aXXa...............", 6039 "a.....aXXa..............", 6040 "......aXXa..............", 6041 ".......aXXa.............", 6042 ".......aXXa.............", 6043 "........aa...aaaaaaaaaaa", 6044 #else 6045 "XX......................", 6046 "XaX.....................", 6047 "XaaX....................", 6048 "XaaaX...................", 6049 "XaaaaX..................", 6050 "XaaaaaX.................", 6051 "XaaaaaaX................", 6052 "XaaaaaaaX...............", 6053 "XaaaaaaaaX..............", 6054 "XaaaaaaaaaX.............", 6055 "XaaaaaaXXXX.............", 6056 "XaaaXaaX................", 6057 "XaaXXaaX................", 6058 "XaX..XaaX...............", 6059 "XX...XaaX...............", 6060 "X.....XaaX..............", 6061 "......XaaX..............", 6062 ".......XaaX.............", 6063 ".......XaaX.............", 6064 "........XX...aaaaaaaaaaa", 6065 #endif 6066 ".............aXXXXXXXXXa", 6067 ".............aXXXaaaaXXa", 6068 ".............aXXXXaaaXXa", 6069 ".............aXXXaaaaXXa", 6070 ".............aXXaaaXaXXa", 6071 ".............aXXaaXXXXXa", 6072 ".............aXXaXXXXXXa", 6073 ".............aXXXaXXXXXa", 6074 ".............aXXXXXXXXXa", 6075 ".............aaaaaaaaaaa"}; 6076 6077 QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) 6078 { 6079 #if defined(Q_WS_X11) || defined(Q_WS_WIN) 6080 if (!move_cursor) { 6081 move_cursor = new QPixmap((const char **)move_xpm); 6082 copy_cursor = new QPixmap((const char **)copy_xpm); 6083 link_cursor = new QPixmap((const char **)link_xpm); 6084 #ifdef Q_WS_WIN 6085 ignore_cursor = new QPixmap((const char **)ignore_xpm); 6086 #endif 6087 } 6088 6089 switch (cshape) { 6090 case Qt::DragMoveCursor: 6091 return *move_cursor; 6092 case Qt::DragCopyCursor: 6093 return *copy_cursor; 6094 case Qt::DragLinkCursor: 6095 return *link_cursor; 6096 #ifdef Q_WS_WIN 6097 case Qt::ForbiddenCursor: 6098 return *ignore_cursor; 6099 #endif 6100 default: 6101 break; 6102 } 6103 #endif 6104 return QPixmap(); 6105 } 6106 6107 QString QApplicationPrivate::qmljsDebugArgumentsString() 6108 { 6109 return qmljs_debug_arguments; 5702 6110 } 5703 6111 -
trunk/src/gui/kernel/qapplication.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 62 62 QT_BEGIN_HEADER 63 63 64 #if defined(Q_ WS_S60)64 #if defined(Q_OS_SYMBIAN) 65 65 class CApaApplication; 66 66 #endif … … 119 119 enum Type { Tty, GuiClient, GuiServer }; 120 120 121 #ifdef Q_ WS_S60121 #ifdef Q_OS_SYMBIAN 122 122 typedef CApaApplication * (*QS60MainApplicationFactory)(); 123 123 #endif … … 131 131 QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION); 132 132 #endif 133 #if defined(Q_ WS_S60)133 #if defined(Q_OS_SYMBIAN) 134 134 QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION); 135 135 #endif … … 272 272 virtual void saveState(QSessionManager& sm); 273 273 #endif 274 275 #ifndef QT_NO_IM 274 276 void setInputContext(QInputContext *); 275 277 QInputContext *inputContext() const; 278 #endif 276 279 277 280 static QLocale keyboardInputLocale(); … … 371 374 QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); 372 375 #endif 373 #if defined(Q_ WS_S60) || defined(qdoc)376 #if defined(Q_OS_SYMBIAN) || defined(qdoc) 374 377 QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv); 375 378 #endif … … 381 384 382 385 friend class QGraphicsWidget; 386 friend class QGraphicsItem; 383 387 friend class QGraphicsScene; 384 388 friend class QGraphicsScenePrivate; … … 403 407 friend class QDirectPainterPrivate; 404 408 #endif 409 #ifndef QT_NO_GESTURES 405 410 friend class QGestureManager; 411 #endif 406 412 407 413 #if defined(Q_WS_MAC) || defined(Q_WS_X11) … … 411 417 Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents()) 412 418 #endif 419 #if defined(Q_OS_SYMBIAN) 420 Q_PRIVATE_SLOT(d_func(), void _q_aboutToQuit()) 421 #endif 413 422 }; 414 423 -
trunk/src/gui/kernel/qapplication_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 185 185 static bool qt_mac_collapse_on_dblclick = true; 186 186 extern int qt_antialiasing_threshold; // from qapplication.cpp 187 QPointer<QWidget> qt_button_down; // widget got last button-down 187 QWidget * qt_button_down; // widget got last button-down 188 QPointer<QWidget> qt_last_mouse_receiver; 188 189 #ifndef QT_MAC_USE_COCOA 189 190 static bool qt_button_down_in_content; // whether the button_down was in the content area. … … 737 738 static void qt_mac_update_child_gl_widgets(QWidget *widget) 738 739 { 739 if (widget->isWindow())740 return;741 742 740 // Update all OpenGL child widgets for the given widget. 743 741 QList<QWidgetPrivate::GlWidgetInfo> &glWidgets = qt_widget_private(widget)->glWidgets; … … 1221 1219 1222 1220 #endif 1223 if (!app_proc_ae_handlerUPP ) {1221 if (!app_proc_ae_handlerUPP && !QApplication::testAttribute(Qt::AA_MacPluginApplication)) { 1224 1222 app_proc_ae_handlerUPP = AEEventHandlerUPP(QApplicationPrivate::globalAppleEventProcessor); 1225 for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) 1226 AEInstallEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, 1227 app_proc_ae_handlerUPP, SRefCon(qApp), false); 1223 for(uint i = 0; i < sizeof(app_apple_events) / sizeof(QMacAppleEventTypeSpec); ++i) { 1224 // Install apple event handler, but avoid overwriting an already 1225 // existing handler (it means a 3rd party application has installed one): 1226 SRefCon refCon = 0; 1227 AEEventHandlerUPP current_handler = NULL; 1228 AEGetEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, ¤t_handler, &refCon, false); 1229 if (!current_handler) 1230 AEInstallEventHandler(app_apple_events[i].mac_class, app_apple_events[i].mac_id, 1231 app_proc_ae_handlerUPP, SRefCon(qApp), false); 1232 } 1228 1233 } 1229 1234 … … 1238 1243 // Cocoa application delegate 1239 1244 #ifdef QT_MAC_USE_COCOA 1240 NSApplication *cocoaApp = [ NSApplication sharedApplication];1245 NSApplication *cocoaApp = [QNSApplication sharedApplication]; 1241 1246 QMacCocoaAutoReleasePool pool; 1242 1247 NSObject *oldDelegate = [cocoaApp delegate]; … … 1259 1264 [newDelegate setMenuLoader:qtMenuLoader]; 1260 1265 [qtMenuLoader release]; 1261 1262 NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager];1263 [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:)1264 forEventClass:kInternetEventClass andEventID:kAEGetURL];1265 1266 } 1266 1267 #endif … … 1362 1363 QApplication cursor stack 1363 1364 *****************************************************************************/ 1365 #ifdef QT_MAC_USE_COCOA 1366 void QApplicationPrivate::disableUsageOfCursorRects(bool disable) 1367 { 1368 // In Cocoa there are two competing ways of setting the cursor; either 1369 // by using cursor rects (see qcocoaview_mac.mm), or by pushing/popping 1370 // the cursor manually. When we use override cursors, it makes most sense 1371 // to use the latter. But then we need to tell cocoa to stop using the 1372 // first approach so it doesn't change the cursor back when hovering over 1373 // a cursor rect: 1374 QWidgetList topLevels = qApp->topLevelWidgets(); 1375 for (int i=0; i<topLevels.size(); ++i) { 1376 if (NSWindow *window = qt_mac_window_for(topLevels.at(i))) 1377 disable ? [window disableCursorRects] : [window enableCursorRects]; 1378 } 1379 } 1380 1381 void QApplicationPrivate::updateOverrideCursor() 1382 { 1383 // Sometimes Cocoa forgets that we have set a Cursor 1384 // manually. In those cases, remind it again: 1385 if (QCursor *override = qApp->overrideCursor()) 1386 [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(*override)) set]; 1387 } 1388 #endif 1389 1364 1390 void QApplication::setOverrideCursor(const QCursor &cursor) 1365 1391 { … … 1368 1394 #ifdef QT_MAC_USE_COCOA 1369 1395 QMacCocoaAutoReleasePool pool; 1396 if (qApp->d_func()->cursor_list.size() == 1) 1397 qApp->d_func()->disableUsageOfCursorRects(true); 1370 1398 [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) push]; 1371 1399 #else … … 1384 1412 QMacCocoaAutoReleasePool pool; 1385 1413 [NSCursor pop]; 1414 if (qApp->d_func()->cursor_list.isEmpty()) 1415 qApp->d_func()->disableUsageOfCursorRects(false); 1386 1416 #else 1387 1417 if (qApp && qApp->activeWindow()) { … … 1727 1757 // As a results of this, and to make sure we dont't receive duplicate events, 1728 1758 // we try to detect when this happend by checking the 'compatibilityEvent'. 1759 // Since delta is delivered as pixels rather than degrees, we need to 1760 // convert from pixels to degrees in a sensible manner. 1761 // It looks like 1/4 degrees per pixel behaves most native. 1762 // (NB: Qt expects the unit for delta to be 8 per degree): 1763 const int pixelsToDegrees = 2; 1729 1764 SInt32 mdelt = 0; 1730 1765 GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0, 1731 1766 sizeof(mdelt), 0, &mdelt); 1732 wheel_deltaX = mdelt ;1767 wheel_deltaX = mdelt * pixelsToDegrees; 1733 1768 mdelt = 0; 1734 1769 GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0, 1735 1770 sizeof(mdelt), 0, &mdelt); 1736 wheel_deltaY = mdelt ;1771 wheel_deltaY = mdelt * pixelsToDegrees; 1737 1772 GetEventParameter(event, kEventParamEventRef, typeEventRef, 0, 1738 1773 sizeof(compatibilityEvent), 0, &compatibilityEvent); … … 2409 2444 if(!handled_event) { 2410 2445 if(cmd.commandID == kHICommandQuit) { 2411 handled_event = true; 2412 HiliteMenu(0); 2413 bool handle_quit = true; 2414 if(QApplicationPrivate::modalState()) { 2415 int visible = 0; 2416 const QWidgetList tlws = QApplication::topLevelWidgets(); 2417 for(int i = 0; i < tlws.size(); ++i) { 2418 if(tlws.at(i)->isVisible()) 2419 ++visible; 2446 // Quitting the application is not Qt's responsibility if 2447 // used in a plugin or just embedded into a native application. 2448 // In that case, let the event pass down to the native apps event handler. 2449 if (!QApplication::testAttribute(Qt::AA_MacPluginApplication)) { 2450 handled_event = true; 2451 HiliteMenu(0); 2452 bool handle_quit = true; 2453 if(QApplicationPrivate::modalState()) { 2454 int visible = 0; 2455 const QWidgetList tlws = QApplication::topLevelWidgets(); 2456 for(int i = 0; i < tlws.size(); ++i) { 2457 if(tlws.at(i)->isVisible()) 2458 ++visible; 2459 } 2460 handle_quit = (visible <= 1); 2420 2461 } 2421 handle_quit = (visible <= 1); 2422 } 2423 if(handle_quit) { 2424 QCloseEvent ev; 2425 QApplication::sendSpontaneousEvent(app, &ev); 2426 if(ev.isAccepted()) 2427 app->quit(); 2428 } else { 2429 QApplication::beep(); 2462 if(handle_quit) { 2463 QCloseEvent ev; 2464 QApplication::sendSpontaneousEvent(app, &ev); 2465 if(ev.isAccepted()) 2466 app->quit(); 2467 } else { 2468 QApplication::beep(); 2469 } 2430 2470 } 2431 2471 } else if(cmd.commandID == kHICommandSelectWindow) { … … 2457 2497 #endif 2458 2498 } 2499 2500 #ifdef QT_MAC_USE_COCOA 2501 void QApplicationPrivate::qt_initAfterNSAppStarted() 2502 { 2503 setupAppleEvents(); 2504 updateOverrideCursor(); 2505 } 2506 2507 void QApplicationPrivate::setupAppleEvents() 2508 { 2509 // This function is called from the event dispatcher when NSApplication has 2510 // finished initialization, which appears to be just after [NSApplication run] has 2511 // started to execute. By setting up our apple events handlers this late, we override 2512 // the ones set up by NSApplication. 2513 2514 // If Qt is used as a plugin, we let the 3rd party application handle events 2515 // like quit and open file events. Otherwise, if we install our own handlers, we 2516 // easily end up breaking functionallity the 3rd party application depend on: 2517 if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) 2518 return; 2519 2520 QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]; 2521 NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager]; 2522 [eventManager setEventHandler:newDelegate andSelector:@selector(appleEventQuit:withReplyEvent:) 2523 forEventClass:kCoreEventClass andEventID:kAEQuitApplication]; 2524 [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:) 2525 forEventClass:kInternetEventClass andEventID:kAEGetURL]; 2526 } 2527 #endif 2459 2528 2460 2529 // In Carbon this is your one stop for apple events. … … 3009 3078 3010 3079 QMenuBar::macUpdateMenuBar(); 3011 3080 QApplicationPrivate::updateOverrideCursor(); 3012 3081 #else 3013 3082 Q_UNUSED(widget); -
trunk/src/gui/kernel/qapplication_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 85 85 class QWidget; 86 86 class QSocketNotifier; 87 #ifndef QT_NO_GESTURES 87 88 class QGestureManager; 89 #endif 88 90 89 91 extern bool qt_is_gui_used; … … 201 203 typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE); 202 204 205 #ifndef QT_NO_GESTURES 203 206 typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID); 204 207 typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE); … … 264 267 #endif 265 268 269 #endif // QT_NO_GESTURES 270 266 271 #endif // Q_WS_WIN 267 272 … … 414 419 static QGraphicsSystem *graphics_system; 415 420 static QString graphics_system_name; 421 static bool runtime_graphics_system; 416 422 417 423 private: … … 442 448 static bool widgetCount; // Coupled with -widgetcount switch 443 449 static bool load_testability; // Coupled with -testability switch 450 static QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging. 451 static QString qmljsDebugArgumentsString(); // access string from other libraries 452 444 453 #ifdef Q_WS_MAC 445 454 static bool native_modal_dialog_active; … … 461 470 static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long); 462 471 static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *); 472 #ifdef QT_MAC_USE_COCOA 473 static void qt_initAfterNSAppStarted(); 474 static void setupAppleEvents(); 475 static void updateOverrideCursor(); 476 static void disableUsageOfCursorRects(bool disable); 477 #endif 463 478 static bool qt_mac_apply_settings(); 464 479 #endif … … 509 524 int symbianResourceChange(const QSymbianEvent *symbianEvent); 510 525 511 #endif 512 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_PM) 526 void _q_aboutToQuit(); 527 #endif 528 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 513 529 void sendSyntheticEnterLeave(QWidget *widget); 514 530 #endif … … 517 533 #endif 518 534 535 #ifndef QT_NO_GESTURES 519 536 QGestureManager *gestureManager; 520 537 QWidget *gestureWidget; 538 #endif 539 #if defined(Q_WS_X11) || defined(Q_WS_WIN) 540 QPixmap *move_cursor; 541 QPixmap *copy_cursor; 542 QPixmap *link_cursor; 543 #endif 544 #if defined(Q_WS_WIN) 545 QPixmap *ignore_cursor; 546 #endif 547 QPixmap getPixmapCursor(Qt::CursorShape cshape); 521 548 522 549 QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId; … … 543 570 bool translateTouchEvent(const MSG &msg); 544 571 572 #ifndef QT_NO_GESTURES 545 573 PtrGetGestureInfo GetGestureInfo; 546 574 PtrGetGestureExtraArgs GetGestureExtraArgs; … … 551 579 PtrUpdatePanningFeedback UpdatePanningFeedback; 552 580 PtrEndPanningFeedback EndPanningFeedback; 581 #endif // QT_NO_GESTURES 553 582 #endif 554 583 … … 583 612 584 613 #ifdef Q_OS_SYMBIAN 585 staticQHash<TInt, TUint> scanCodeCache;614 QHash<TInt, TUint> scanCodeCache; 586 615 #endif 587 616 -
trunk/src/gui/kernel/qapplication_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qapplication_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 63 63 #include "private/qmenubar_p.h" 64 64 #include "private/qsoftkeymanager_p.h" 65 #ifdef QT_GRAPHICSSYSTEM_RUNTIME 66 #include "private/qgraphicssystem_runtime_p.h" 67 #endif 65 68 66 69 #include "apgwgnam.h" // For CApaWindowGroupName 67 70 #include <mdaaudiotoneplayer.h> // For CMdaAudioToneUtility 68 71 69 #if defined(Q_WS_S60) 70 # if !defined(QT_NO_IM) 71 # include "qinputcontext.h" 72 # include <private/qcoefepinputcontext_p.h> 73 # endif 72 #if defined(Q_OS_SYMBIAN) 74 73 # include <private/qs60mainapplication_p.h> 75 74 # include <centralrepository.h> 76 75 # include "qs60mainappui.h" 76 # include "qinputcontext.h" 77 #endif 78 79 #if defined(Q_WS_S60) 80 # if !defined(QT_NO_IM) 81 # include <private/qcoefepinputcontext_p.h> 82 # endif 77 83 #endif 78 84 … … 82 88 #include <hal_data.h> 83 89 90 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS 91 #include <graphics/wstfxconst.h> 92 #endif 93 84 94 QT_BEGIN_NAMESPACE 95 96 // Goom Events through Window Server 97 static const int KGoomMemoryLowEvent = 0x10282DBF; 98 static const int KGoomMemoryGoodEvent = 0x20026790; 85 99 86 100 #if defined(QT_DEBUG) … … 101 115 { 102 116 return qt_s60Data(); 117 } 118 119 #ifdef Q_WS_S60 120 void QS60Data::setStatusPaneAndButtonGroupVisibility(bool statusPaneVisible, bool buttonGroupVisible) 121 { 122 bool buttonGroupVisibilityChanged = false; 123 if (CEikButtonGroupContainer *const b = buttonGroupContainer()) { 124 buttonGroupVisibilityChanged = (b->IsVisible() != buttonGroupVisible); 125 b->MakeVisible(buttonGroupVisible); 126 } 127 bool statusPaneVisibilityChanged = false; 128 if (CEikStatusPane *const s = statusPane()) { 129 statusPaneVisibilityChanged = (s->IsVisible() != statusPaneVisible); 130 s->MakeVisible(statusPaneVisible); 131 } 132 if (buttonGroupVisibilityChanged || statusPaneVisibilityChanged) { 133 const QSize size = qt_TRect2QRect(static_cast<CEikAppUi*>(S60->appUi())->ClientRect()).size(); 134 const QSize oldSize; // note that QDesktopWidget::resizeEvent ignores the QResizeEvent contents 135 QResizeEvent event(size, oldSize); 136 QApplication::instance()->sendEvent(QApplication::desktop(), &event); 137 } 138 if (buttonGroupVisibilityChanged && !statusPaneVisibilityChanged && QApplication::activeWindow()) 139 // Ensure that control rectangle is updated 140 static_cast<QSymbianControl *>(QApplication::activeWindow()->winId())->handleClientAreaChange(); 141 } 142 #endif 143 144 void QS60Data::controlVisibilityChanged(CCoeControl *control, bool visible) 145 { 146 if (QWidgetPrivate::mapper && QWidgetPrivate::mapper->contains(control)) { 147 QWidget *const widget = QWidgetPrivate::mapper->value(control); 148 QWidget *const window = widget->window(); 149 if (QTLWExtra *topData = qt_widget_private(window)->maybeTopData()) { 150 QWidgetBackingStoreTracker &backingStore = topData->backingStore; 151 if (visible) { 152 if (backingStore.data()) { 153 backingStore.registerWidget(widget); 154 } else { 155 backingStore.create(window); 156 backingStore.registerWidget(widget); 157 qt_widget_private(widget)->invalidateBuffer(widget->rect()); 158 widget->repaint(); 159 } 160 } else { 161 backingStore.unregisterWidget(widget); 162 // In order to ensure that any resources used by the window surface 163 // are immediately freed, we flush the WSERV command buffer. 164 S60->wsSession().Flush(); 165 } 166 } 167 } 103 168 } 104 169 … … 198 263 199 264 200 QHash<TInt, TUint> QApplicationPrivate::scanCodeCache;201 202 265 static Qt::KeyboardModifiers mapToQtModifiers(TUint s60Modifiers) 203 266 { … … 346 409 if (!desktop) 347 410 { 348 if (isWindowOwning or!qwidget->parentWidget())411 if (isWindowOwning || !qwidget->parentWidget()) 349 412 CreateWindowL(S60->windowGroup()); 350 413 else … … 365 428 SetFocusing(true); 366 429 m_longTapDetector = QLongTapTimer::NewL(this); 430 m_doubleClickTimer.invalidate(); 367 431 368 432 DrawableWindow()->SetPointerGrab(ETrue); 369 433 } 434 435 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS 436 if (OwnsWindow()) { 437 TTfxWindowPurpose windowPurpose(ETfxPurposeNone); 438 switch (qwidget->windowType()) { 439 case Qt::Dialog: 440 windowPurpose = ETfxPurposeDialogWindow; 441 break; 442 case Qt::Popup: 443 windowPurpose = ETfxPurposePopupWindow; 444 break; 445 case Qt::Tool: 446 windowPurpose = ETfxPurposeToolWindow; 447 break; 448 case Qt::ToolTip: 449 windowPurpose = ETfxPurposeToolTipWindow; 450 break; 451 case Qt::SplashScreen: 452 windowPurpose = ETfxPurposeSplashScreenWindow; 453 break; 454 default: 455 windowPurpose = (isWindowOwning || !qwidget->parentWidget()) 456 ? ETfxPurposeWindow : ETfxPurposeChildWindow; 457 break; 458 } 459 Window().SetPurpose(windowPurpose); 460 } 461 #endif 370 462 } 371 463 372 464 QSymbianControl::~QSymbianControl() 373 465 { 466 // Ensure backing store is deleted before the top-level 467 // window is destroyed 468 qt_widget_private(qwidget)->topData()->backingStore.destroy(); 469 374 470 if (S60->curWin == this) 375 471 S60->curWin = 0; … … 408 504 { 409 505 QApplicationPrivate *d = QApplicationPrivate::instance(); 506 QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY)); 410 507 qreal pressure; 411 508 if(d->pressureSupported … … 414 511 else 415 512 pressure = qreal(1.0); 416 513 processTouchEvent(event->PointerNumber(), event->iType, screenPos, pressure); 514 } 515 #endif 516 517 void QSymbianControl::processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure) 518 { 417 519 QRect screenGeometry = qApp->desktop()->screenGeometry(qwidget); 418 520 521 QApplicationPrivate *d = QApplicationPrivate::instance(); 522 419 523 QList<QTouchEvent::TouchPoint> points = d->appAllTouchPoints; 420 while (points.count() <= event->PointerNumber())524 while (points.count() <= pointerNumber) 421 525 points.append(QTouchEvent::TouchPoint(points.count())); 422 526 … … 425 529 QTouchEvent::TouchPoint &touchPoint = points[i]; 426 530 427 if (touchPoint.id() == event->PointerNumber()) {531 if (touchPoint.id() == pointerNumber) { 428 532 Qt::TouchPointStates state; 429 switch ( event->iType) {533 switch (type) { 430 534 case TPointerEvent::EButton1Down: 535 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER 431 536 case TPointerEvent::EEnterHighPressure: 537 #endif 432 538 state = Qt::TouchPointPressed; 433 539 break; 434 540 case TPointerEvent::EButton1Up: 541 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER 435 542 case TPointerEvent::EExitCloseProximity: 543 #endif 436 544 state = Qt::TouchPointReleased; 437 545 break; … … 444 552 break; 445 553 } 446 if ( event->PointerNumber()== 0)554 if (pointerNumber == 0) 447 555 state |= Qt::TouchPointPrimary; 448 556 touchPoint.setState(state); 449 557 450 QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY));451 558 touchPoint.setScreenPos(screenPos); 452 559 touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(), … … 473 580 points); 474 581 } 475 #endif476 582 477 583 void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) … … 547 653 #endif 548 654 655 //Generate single touch event for S60 5.0 (has touchscreen, does not have advanced pointers) 656 #ifndef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER 657 if (S60->hasTouchscreen) { 658 processTouchEvent(0, pEvent.iType, QPointF(globalPos), 1.0); 659 } 660 #endif 661 549 662 sendMouseEvent(receiver, type, globalPos, button, modifiers); 550 663 } … … 594 707 TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCode type) 595 708 { 596 switch (type) { 597 //case EEventKeyDown: // <-- Intentionally left out. See below. 598 case EEventKeyUp: 599 case EEventKey: 600 { 601 // S60 has a confusing way of delivering key events. There are three types of 602 // events: EKeyEvent, EKeyEventDown and EKeyEventUp. When a key is pressed, the 603 // two first events are generated. When releasing the key, the last one is 604 // generated. 605 // Because S60 does not generate keysyms for EKeyEventDown and EKeyEventUp events, 606 // we need to do some special tricks to map it to the Qt way. First, we completely 607 // discard EKeyEventDown events, since they are redundant. Second, since 608 // EKeyEventUp does not give us a keysym, we need to cache the keysyms from 609 // the EKeyEvent events. This is what resolveS60ScanCode does. 610 611 612 // ### hackish way to send Qt application to background when pressing right softkey 613 /* 614 if( keyEvent.iScanCode == EStdKeyDevice1 ) { 615 S60->window_group->SetOrdinalPosition(-1); 616 qApp->setActiveWindow(0); 617 return EKeyWasNotConsumed; 618 } 619 */ 620 621 TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, 622 keyEvent.iCode); 623 int keyCode; 624 if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used 625 keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); 626 } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { 627 // Normal characters keys. 628 keyCode = s60Keysym; 709 /* 710 S60 has a confusing way of delivering key events. There are three types of 711 events: EEventKey, EEventKeyDown and EEventKeyUp. When a key is pressed, 712 EEventKeyDown is first generated, followed by EEventKey. Then, when the key is 713 released, EEventKeyUp is generated. 714 However, it is possible that only the EEventKey is generated alone, typically 715 in relation to virtual keyboards. In that case we need to take care to 716 generate both press and release events in Qt, since applications expect that. 717 We do this by having three states for each used scan code, depending on the 718 events received. See the switch below for what happens in each state 719 transition. 720 */ 721 722 if (type != EEventKeyDown) 723 if (handleVirtualMouse(keyEvent, type) == EKeyWasConsumed) 724 return EKeyWasConsumed; 725 726 TKeyResponse ret = EKeyWasNotConsumed; 727 #define GET_RETURN(x) (ret = ((x) == EKeyWasConsumed) ? EKeyWasConsumed : ret) 728 729 // This top level switch corresponds to the states, and the inner switches 730 // correspond to the transitions. 731 QS60Data::ScanCodeState &scanCodeState = S60->scanCodeStates[keyEvent.iScanCode]; 732 switch (scanCodeState) { 733 case QS60Data::Unpressed: 734 switch (type) { 735 case EEventKeyDown: 736 scanCodeState = QS60Data::KeyDown; 737 break; 738 case EEventKey: 739 GET_RETURN(sendSymbianKeyEvent(keyEvent, QEvent::KeyPress)); 740 GET_RETURN(sendSymbianKeyEvent(keyEvent, QEvent::KeyRelease)); 741 break; 742 case EEventKeyUp: 743 // No action. 744 break; 745 } 746 break; 747 case QS60Data::KeyDown: 748 switch (type) { 749 case EEventKeyDown: 750 // This should never happen, just stay in this state to be safe. 751 break; 752 case EEventKey: 753 GET_RETURN(sendSymbianKeyEvent(keyEvent, QEvent::KeyPress)); 754 scanCodeState = QS60Data::KeyDownAndKey; 755 break; 756 case EEventKeyUp: 757 scanCodeState = QS60Data::Unpressed; 758 break; 759 } 760 break; 761 case QS60Data::KeyDownAndKey: 762 switch (type) { 763 case EEventKeyDown: 764 // This should never happen, just stay in this state to be safe. 765 break; 766 case EEventKey: 767 GET_RETURN(sendSymbianKeyEvent(keyEvent, QEvent::KeyRelease)); 768 GET_RETURN(sendSymbianKeyEvent(keyEvent, QEvent::KeyPress)); 769 break; 770 case EEventKeyUp: 771 GET_RETURN(sendSymbianKeyEvent(keyEvent, QEvent::KeyRelease)); 772 scanCodeState = QS60Data::Unpressed; 773 break; 774 } 775 break; 776 } 777 return ret; 778 779 #undef GET_RETURN 780 } 781 782 TKeyResponse QSymbianControl::sendSymbianKeyEvent(const TKeyEvent &keyEvent, QEvent::Type type) 783 { 784 // Because S60 does not generate keysyms for EKeyEventDown and EKeyEventUp 785 // events, we need to cache the keysyms from the EKeyEvent events. This is what 786 // resolveS60ScanCode does. 787 TUint s60Keysym = QApplicationPrivate::resolveS60ScanCode(keyEvent.iScanCode, 788 keyEvent.iCode); 789 int keyCode; 790 if (s60Keysym == EKeyNull){ //some key events have 0 in iCode, for them iScanCode should be used 791 keyCode = qt_keymapper_private()->mapS60ScanCodesToQt(keyEvent.iScanCode); 792 } else if (s60Keysym >= 0x20 && s60Keysym < ENonCharacterKeyBase) { 793 // Normal characters keys. 794 keyCode = s60Keysym; 795 } else { 796 // Special S60 keys. 797 keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); 798 } 799 800 Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); 801 QKeyEventEx qKeyEvent(type, keyCode, mods, qt_keymapper_private()->translateKeyEvent(keyCode, mods), 802 (keyEvent.iRepeats != 0), 1, keyEvent.iScanCode, s60Keysym, keyEvent.iModifiers); 803 QWidget *widget; 804 widget = QWidget::keyboardGrabber(); 805 if (!widget) { 806 if (QApplicationPrivate::popupWidgets != 0) { 807 widget = QApplication::activePopupWidget()->focusWidget(); 808 if (!widget) { 809 widget = QApplication::activePopupWidget(); 810 } 629 811 } else { 630 // Special S60 keys. 631 keyCode = qt_keymapper_private()->mapS60KeyToQt(s60Keysym); 632 } 633 812 widget = QApplicationPrivate::focus_widget; 813 if (!widget) { 814 widget = qwidget; 815 } 816 } 817 } 818 819 QEventDispatcherS60 *dispatcher; 820 // It is theoretically possible for someone to install a different event dispatcher. 821 if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(widget->d_func()->threadData->eventDispatcher)) != 0) { 822 if (dispatcher->excludeUserInputEvents()) { 823 dispatcher->saveInputEvent(this, widget, new QKeyEventEx(qKeyEvent)); 824 return EKeyWasConsumed; 825 } 826 } 827 return sendKeyEvent(widget, &qKeyEvent); 828 } 829 830 TKeyResponse QSymbianControl::handleVirtualMouse(const TKeyEvent& keyEvent,TEventCode type) 831 { 634 832 #ifndef QT_NO_CURSOR 635 if (S60->mouseInteractionEnabled && S60->virtualMouseRequired) { 636 //translate keys to pointer 637 if (keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down || keyCode == Qt::Key_Select) { 638 /*Explanation about virtualMouseAccel: 639 Tapping an arrow key allows precise pixel positioning 640 Holding an arrow key down, acceleration is applied to allow cursor 641 to be quickly moved to another part of the screen by key repeats. 642 */ 643 if (S60->virtualMouseLastKey == keyCode) { 644 S60->virtualMouseAccel *= 2; 645 if (S60->virtualMouseAccel > S60->virtualMouseMaxAccel) 646 S60->virtualMouseAccel = S60->virtualMouseMaxAccel; 647 } 648 else 649 S60->virtualMouseAccel = 1; 650 S60->virtualMouseLastKey = keyCode; 651 652 QPoint pos = QCursor::pos(); 653 TPointerEvent fakeEvent; 654 fakeEvent.iType = (TPointerEvent::TType)(-1); 655 TInt x = pos.x(); 656 TInt y = pos.y(); 657 if (type == EEventKeyUp) { 658 if (keyCode == Qt::Key_Select && 659 (S60->virtualMousePressedKeys & QS60Data::Select)) 833 if (S60->mouseInteractionEnabled && S60->virtualMouseRequired) { 834 //translate keys to pointer 835 if ((keyEvent.iScanCode >= EStdKeyLeftArrow && keyEvent.iScanCode <= EStdKeyDownArrow) || 836 (keyEvent.iScanCode >= EStdKeyDevice10 && keyEvent.iScanCode <= EStdKeyDevice13) || 837 keyEvent.iScanCode == EStdKeyDevice3) { 838 QPoint pos = QCursor::pos(); 839 TPointerEvent fakeEvent; 840 fakeEvent.iType = (TPointerEvent::TType)(-1); 841 fakeEvent.iModifiers = keyEvent.iModifiers; 842 TInt x = pos.x(); 843 TInt y = pos.y(); 844 if (type == EEventKeyUp) { 845 S60->virtualMouseAccelTimeout.start(); 846 switch (keyEvent.iScanCode) { 847 case EStdKeyLeftArrow: 848 S60->virtualMousePressedKeys &= ~QS60Data::Left; 849 break; 850 case EStdKeyRightArrow: 851 S60->virtualMousePressedKeys &= ~QS60Data::Right; 852 break; 853 case EStdKeyUpArrow: 854 S60->virtualMousePressedKeys &= ~QS60Data::Up; 855 break; 856 case EStdKeyDownArrow: 857 S60->virtualMousePressedKeys &= ~QS60Data::Down; 858 break; 859 // diagonal keys (named aliases don't exist in 3.1 SDK) 860 case EStdKeyDevice10: 861 S60->virtualMousePressedKeys &= ~QS60Data::LeftUp; 862 break; 863 case EStdKeyDevice11: 864 S60->virtualMousePressedKeys &= ~QS60Data::RightUp; 865 break; 866 case EStdKeyDevice12: 867 S60->virtualMousePressedKeys &= ~QS60Data::RightDown; 868 break; 869 case EStdKeyDevice13: 870 S60->virtualMousePressedKeys &= ~QS60Data::LeftDown; 871 break; 872 case EStdKeyDevice3: //select 873 if (S60->virtualMousePressedKeys & QS60Data::Select) 660 874 fakeEvent.iType = TPointerEvent::EButton1Up; 661 S60->virtualMouseAccel = 1; 662 S60->virtualMouseLastKey = 0; 663 switch (keyCode) { 664 case Qt::Key_Left: 665 S60->virtualMousePressedKeys &= ~QS60Data::Left; 666 break; 667 case Qt::Key_Right: 668 S60->virtualMousePressedKeys &= ~QS60Data::Right; 669 break; 670 case Qt::Key_Up: 671 S60->virtualMousePressedKeys &= ~QS60Data::Up; 672 break; 673 case Qt::Key_Down: 674 S60->virtualMousePressedKeys &= ~QS60Data::Down; 675 break; 676 case Qt::Key_Select: 677 S60->virtualMousePressedKeys &= ~QS60Data::Select; 678 break; 679 } 680 } 681 else if (type == EEventKey) { 682 switch (keyCode) { 683 case Qt::Key_Left: 684 S60->virtualMousePressedKeys |= QS60Data::Left; 685 x -= S60->virtualMouseAccel; 686 fakeEvent.iType = TPointerEvent::EMove; 687 break; 688 case Qt::Key_Right: 689 S60->virtualMousePressedKeys |= QS60Data::Right; 690 x += S60->virtualMouseAccel; 691 fakeEvent.iType = TPointerEvent::EMove; 692 break; 693 case Qt::Key_Up: 694 S60->virtualMousePressedKeys |= QS60Data::Up; 695 y -= S60->virtualMouseAccel; 696 fakeEvent.iType = TPointerEvent::EMove; 697 break; 698 case Qt::Key_Down: 699 S60->virtualMousePressedKeys |= QS60Data::Down; 700 y += S60->virtualMouseAccel; 701 fakeEvent.iType = TPointerEvent::EMove; 702 break; 703 case Qt::Key_Select: 704 // Platform bug. If you start pressing several keys simultaneously (for 705 // example for drag'n'drop), Symbian starts producing spurious up and 706 // down messages for some keys. Therefore, make sure we have a clean slate 707 // of pressed keys before starting a new button press. 708 if (S60->virtualMousePressedKeys & QS60Data::Select) { 709 return EKeyWasConsumed; 710 } else { 711 S60->virtualMousePressedKeys |= QS60Data::Select; 712 fakeEvent.iType = TPointerEvent::EButton1Down; 713 } 714 break; 715 } 716 } 717 //clip to screen size (window server allows a sprite hotspot to be outside the screen) 718 if (x < 0) 719 x = 0; 720 else if (x >= S60->screenWidthInPixels) 721 x = S60->screenWidthInPixels - 1; 722 if (y < 0) 723 y = 0; 724 else if (y >= S60->screenHeightInPixels) 725 y = S60->screenHeightInPixels - 1; 726 TPoint epos(x, y); 727 TPoint cpos = epos - PositionRelativeToScreen(); 728 fakeEvent.iModifiers = keyEvent.iModifiers; 729 fakeEvent.iPosition = cpos; 730 fakeEvent.iParentPosition = epos; 731 if(fakeEvent.iType != -1) 732 HandlePointerEvent(fakeEvent); 733 return EKeyWasConsumed; 734 } 735 else { 736 S60->virtualMouseLastKey = keyCode; 737 S60->virtualMouseAccel = 1; 738 } 739 } 740 #endif 741 742 Qt::KeyboardModifiers mods = mapToQtModifiers(keyEvent.iModifiers); 743 QKeyEventEx qKeyEvent(type == EEventKeyUp ? QEvent::KeyRelease : QEvent::KeyPress, keyCode, 744 mods, qt_keymapper_private()->translateKeyEvent(keyCode, mods), 745 (keyEvent.iRepeats != 0), 1, keyEvent.iScanCode, s60Keysym, keyEvent.iModifiers); 746 // WId wid = reinterpret_cast<RWindowGroup *>(keyEvent.Handle())->Child(); 747 // if (!wid) 748 // Could happen if window isn't shown yet. 749 // return EKeyWasNotConsumed; 750 QWidget *widget; 751 widget = QWidget::keyboardGrabber(); 752 if (!widget) { 753 if (QApplicationPrivate::popupWidgets != 0) { 754 widget = QApplication::activePopupWidget()->focusWidget(); 755 if (!widget) { 756 widget = QApplication::activePopupWidget(); 757 } 758 } else { 759 widget = QApplicationPrivate::focus_widget; 760 if (!widget) { 761 widget = qwidget; 875 S60->virtualMousePressedKeys &= ~QS60Data::Select; 876 break; 762 877 } 763 878 } 764 } 765 766 QEventDispatcherS60 *dispatcher; 767 // It is theoretically possible for someone to install a different event dispatcher. 768 if ((dispatcher = qobject_cast<QEventDispatcherS60 *>(widget->d_func()->threadData->eventDispatcher)) != 0) { 769 if (dispatcher->excludeUserInputEvents()) { 770 dispatcher->saveInputEvent(this, widget, new QKeyEventEx(qKeyEvent)); 771 return EKeyWasConsumed; 879 else if (type == EEventKey) { 880 int dx = 0; 881 int dy = 0; 882 if (keyEvent.iScanCode != EStdKeyDevice3) { 883 m_doubleClickTimer.invalidate(); 884 //reset mouse accelleration after a short time with no moves 885 const int maxTimeBetweenKeyEventsMs = 500; 886 if (S60->virtualMouseAccelTimeout.isValid() && 887 S60->virtualMouseAccelTimeout.hasExpired(maxTimeBetweenKeyEventsMs)) { 888 S60->virtualMouseAccelDX = 0; 889 S60->virtualMouseAccelDY = 0; 890 } 891 S60->virtualMouseAccelTimeout.invalidate(); 892 } 893 switch (keyEvent.iScanCode) { 894 case EStdKeyLeftArrow: 895 S60->virtualMousePressedKeys |= QS60Data::Left; 896 dx = -1; 897 fakeEvent.iType = TPointerEvent::EMove; 898 break; 899 case EStdKeyRightArrow: 900 S60->virtualMousePressedKeys |= QS60Data::Right; 901 dx = 1; 902 fakeEvent.iType = TPointerEvent::EMove; 903 break; 904 case EStdKeyUpArrow: 905 S60->virtualMousePressedKeys |= QS60Data::Up; 906 dy = -1; 907 fakeEvent.iType = TPointerEvent::EMove; 908 break; 909 case EStdKeyDownArrow: 910 S60->virtualMousePressedKeys |= QS60Data::Down; 911 dy = 1; 912 fakeEvent.iType = TPointerEvent::EMove; 913 break; 914 case EStdKeyDevice10: 915 S60->virtualMousePressedKeys |= QS60Data::LeftUp; 916 dx = -1; 917 dy = -1; 918 fakeEvent.iType = TPointerEvent::EMove; 919 break; 920 case EStdKeyDevice11: 921 S60->virtualMousePressedKeys |= QS60Data::RightUp; 922 dx = 1; 923 dy = -1; 924 fakeEvent.iType = TPointerEvent::EMove; 925 break; 926 case EStdKeyDevice12: 927 S60->virtualMousePressedKeys |= QS60Data::RightDown; 928 dx = 1; 929 dy = 1; 930 fakeEvent.iType = TPointerEvent::EMove; 931 break; 932 case EStdKeyDevice13: 933 S60->virtualMousePressedKeys |= QS60Data::LeftDown; 934 dx = -1; 935 dy = 1; 936 fakeEvent.iType = TPointerEvent::EMove; 937 break; 938 case EStdKeyDevice3: 939 // Platform bug. If you start pressing several keys simultaneously (for 940 // example for drag'n'drop), Symbian starts producing spurious up and 941 // down messages for some keys. Therefore, make sure we have a clean slate 942 // of pressed keys before starting a new button press. 943 if (S60->virtualMousePressedKeys & QS60Data::Select) { 944 return EKeyWasConsumed; 945 } else { 946 S60->virtualMousePressedKeys |= QS60Data::Select; 947 fakeEvent.iType = TPointerEvent::EButton1Down; 948 if (m_doubleClickTimer.isValid() 949 && !m_doubleClickTimer.hasExpired(QApplication::doubleClickInterval())) { 950 fakeEvent.iModifiers |= EModifierDoubleClick; 951 m_doubleClickTimer.invalidate(); 952 } else { 953 m_doubleClickTimer.start(); 954 } 955 } 956 break; 957 } 958 if (dx) { 959 int cdx = S60->virtualMouseAccelDX; 960 //reset accel on change of sign, else double accel 961 if (dx * cdx <= 0) 962 cdx = dx; 963 else 964 cdx *= 4; 965 //cap accelleration 966 if (dx * cdx > S60->virtualMouseMaxAccel) 967 cdx = dx * S60->virtualMouseMaxAccel; 968 //move mouse position 969 x += cdx; 970 S60->virtualMouseAccelDX = cdx; 971 } 972 973 if (dy) { 974 int cdy = S60->virtualMouseAccelDY; 975 if (dy * cdy <= 0) 976 cdy = dy; 977 else 978 cdy *= 4; 979 if (dy * cdy > S60->virtualMouseMaxAccel) 980 cdy = dy * S60->virtualMouseMaxAccel; 981 y += cdy; 982 S60->virtualMouseAccelDY = cdy; 983 } 772 984 } 773 } 774 return sendKeyEvent(widget, &qKeyEvent); 775 } 776 } 985 //clip to screen size (window server allows a sprite hotspot to be outside the screen) 986 if (x < 0) 987 x = 0; 988 else if (x >= S60->screenWidthInPixels) 989 x = S60->screenWidthInPixels - 1; 990 if (y < 0) 991 y = 0; 992 else if (y >= S60->screenHeightInPixels) 993 y = S60->screenHeightInPixels - 1; 994 TPoint epos(x, y); 995 TPoint cpos = epos - PositionRelativeToScreen(); 996 fakeEvent.iPosition = cpos; 997 fakeEvent.iParentPosition = epos; 998 if(fakeEvent.iType != -1) 999 HandlePointerEvent(fakeEvent); 1000 return EKeyWasConsumed; 1001 } 1002 } 1003 #endif 1004 777 1005 return EKeyWasNotConsumed; 778 1006 } … … 806 1034 return EKeyWasConsumed; 807 1035 } 808 #endif // !defined(QT_NO_IM) && defined(Q_ WS_S60)1036 #endif // !defined(QT_NO_IM) && defined(Q_OS_SYMBIAN) 809 1037 810 1038 if (widget && qt_sendSpontaneousEvent(widget, keyEvent)) … … 844 1072 if (!topExtra->inExpose) { 845 1073 topExtra->inExpose = true; 1074 if (!qwidget->isWindow()) { 1075 // If we get here, then it means we have a native child window 1076 // Since no content should ever be painted to these windows, we 1077 // erase them with a transparent brush when they get an expose. 1078 CWindowGc &gc = SystemGc(); 1079 gc.SetBrushColor(TRgb(0, 0, 0, 0)); 1080 gc.Clear(controlRect); 1081 } 846 1082 QRect exposeRect = qt_TRect2QRect(controlRect); 847 1083 qwidget->d_func()->syncBackingStore(exposeRect); … … 867 1103 868 1104 if (engine->type() == QPaintEngine::Raster) { 869 QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); 1105 QS60WindowSurface *s60Surface; 1106 #ifdef QT_GRAPHICSSYSTEM_RUNTIME 1107 if (QApplicationPrivate::runtime_graphics_system) { 1108 QRuntimeWindowSurface *rtSurface = 1109 static_cast<QRuntimeWindowSurface*>(qwidget->windowSurface()); 1110 s60Surface = static_cast<QS60WindowSurface *>(rtSurface->m_windowSurface.data()); 1111 } else 1112 #endif 1113 s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); 1114 870 1115 CFbsBitmap *bitmap = s60Surface->symbianBitmap(); 871 1116 CWindowGc &gc = SystemGc(); 872 1117 873 switch(qwidget->d_func()->extraData()->nativePaintMode) { 1118 QWExtra::NativePaintMode nativePaintMode = qwidget->d_func()->extraData()->nativePaintMode; 1119 if(qwidget->d_func()->paintOnScreen()) 1120 nativePaintMode = QWExtra::Disable; 1121 1122 switch(nativePaintMode) { 874 1123 case QWExtra::Disable: 875 1124 // Do nothing 876 1125 break; 877 878 1126 case QWExtra::Blit: 879 1127 if (qwidget->d_func()->isOpaque) … … 881 1129 gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); 882 1130 break; 883 884 1131 case QWExtra::ZeroFill: 885 if (Window().DisplayMode() == EColor16MA) { 1132 if (Window().DisplayMode() == EColor16MA 1133 || Window().DisplayMode() == Q_SYMBIAN_ECOLOR16MAP) { 886 1134 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); 887 1135 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); … … 893 1141 }; 894 1142 break; 895 896 1143 default: 897 1144 Q_ASSERT(false); … … 936 1183 tlwExtra->inTopLevelResize = false; 937 1184 } else { 938 QResizeEvent *e = new QResizeEvent(newSize, oldSize); 939 QApplication::postEvent(qwidget, e); 1185 if (!qwidget->testAttribute(Qt::WA_PendingResizeEvent)) { 1186 QResizeEvent *e = new QResizeEvent(newSize, oldSize); 1187 QApplication::postEvent(qwidget, e); 1188 } 940 1189 } 941 1190 } … … 996 1245 #ifdef Q_WS_S60 997 1246 // If widget is fullscreen/minimized, hide status pane and button container otherwise show them. 998 CEikStatusPane *statusPane = S60->statusPane(); 999 CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); 1000 TBool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); 1001 if (statusPane) 1002 statusPane->MakeVisible(visible); 1003 if (buttonGroup) { 1004 // Visibility 1005 const TBool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; 1006 const TBool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; 1007 buttonGroup->MakeVisible(visible || (isFullscreen && cbaVisibilityHint)); 1247 QWidget *const window = qwidget->window(); 1248 if (!window->parentWidget()) { // Only top level native windows have control over cba/status pane 1249 const bool decorationsVisible = !(window->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); 1250 const bool statusPaneVisibility = decorationsVisible; 1251 const bool isFullscreen = window->windowState() & Qt::WindowFullScreen; 1252 const bool cbaVisibilityHint = window->windowFlags() & Qt::WindowSoftkeysVisibleHint; 1253 const bool buttonGroupVisibility = (decorationsVisible || (isFullscreen && cbaVisibilityHint)); 1254 S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); 1008 1255 } 1009 1256 #endif 1010 1257 } else if (QApplication::activeWindow() == qwidget->window()) { 1011 if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) { 1012 QWidget *fw = QApplication::focusWidget(); 1013 if (fw) { 1014 QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason); 1015 QCoreApplication::sendEvent(fw, &event); 1258 bool focusedControlFound = false; 1259 WId winId = 0; 1260 for (QWidget *w = qwidget->parentWidget(); w && (winId = w->internalWinId()); w = w->parentWidget()) { 1261 if (winId->IsFocused() && winId->IsVisible()) { 1262 focusedControlFound = true; 1263 break; 1264 } else if (w->isWindow()) 1265 break; 1266 } 1267 if (!focusedControlFound) { 1268 if (CCoeEnv::Static()->AppUi()->IsDisplayingMenuOrDialog() || S60->menuBeingConstructed) { 1269 QWidget *fw = QApplication::focusWidget(); 1270 if (fw) { 1271 QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason); 1272 QCoreApplication::sendEvent(fw, &event); 1273 } 1274 m_symbianPopupIsOpen = true; 1275 return; 1016 1276 } 1017 m_symbianPopupIsOpen = true; 1018 return; 1019 } 1020 1021 QApplication::setActiveWindow(0); 1277 1278 QApplication::setActiveWindow(0); 1279 } 1022 1280 } 1023 1281 // else { We don't touch the active window unless we were explicitly activated or deactivated } … … 1062 1320 { 1063 1321 handleClientAreaChange(); 1322 // Send resize event to trigger desktopwidget workAreaResized signal 1323 QResizeEvent e(qt_desktopWidget->size(), qt_desktopWidget->size()); 1324 QApplication::sendEvent(qt_desktopWidget, &e); 1064 1325 break; 1065 1326 } … … 1091 1352 // the top of the stack may randomly be assigned focus by Symbian, for example 1092 1353 // when creating new windows (specifically in CCoeAppUi::HandleStackChanged()). 1354 1355 // Close any popups. 1356 CEikonEnv::Static()->EikAppUi()->StopDisplayingMenuBar(); 1357 1093 1358 if (focus) { 1094 1359 S60->appUi()->RemoveFromStack(this); … … 1111 1376 } 1112 1377 1378 bool QSymbianControl::isControlActive() 1379 { 1380 return IsActivated() ? true : false; 1381 } 1382 1113 1383 /*! 1114 1384 \typedef QApplication::QS60MainApplicationFactory … … 1161 1431 TTrapHandler *origTrapHandler = User::TrapHandler(); 1162 1432 1163 // The S60 framework has not been init alized. We need to do it.1433 // The S60 framework has not been initialized. We need to do it. 1164 1434 TApaApplicationFactory factory(S60->s60ApplicationFactory ? 1165 1435 S60->s60ApplicationFactory : newS60Application); … … 1168 1438 // After this construction, CEikonEnv will be available from CEikonEnv::Static(). 1169 1439 // (much like our qApp). 1170 CEikonEnv* coe = new CEikonEnv;1440 QtEikonEnv* coe = new QtEikonEnv; 1171 1441 //not using QT_TRAP_THROWING, because coe owns the cleanupstack so it can't be pushed there. 1172 1442 if(err == KErrNone) … … 1275 1545 } 1276 1546 } 1277 #endif 1278 1547 delete repository; 1548 repository = 0; 1549 #endif 1550 1551 #ifdef QT_KEYPAD_NAVIGATION 1279 1552 if (touch) { 1280 1553 QApplicationPrivate::navigationMode = Qt::NavigationModeNone; … … 1282 1555 QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; 1283 1556 } 1557 #endif 1284 1558 1285 1559 #ifndef QT_NO_CURSOR … … 1314 1588 QApplicationPrivate::setSystemFont(systemFont); 1315 1589 1590 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS 1591 QObject::connect(qApp, SIGNAL(aboutToQuit()), qApp, SLOT(_q_aboutToQuit())); 1592 #endif 1593 1316 1594 /* 1317 1595 ### Commented out for now as parameter handling not needed in SOS(yet). Code below will break testlib with -o flag … … 1337 1615 1338 1616 // Register WId with the metatype system. This is to enable 1339 // QWidgetPrivate::create_sys to used delayed slot invo kation in order1617 // QWidgetPrivate::create_sys to used delayed slot invocation in order 1340 1618 // to destroy WId objects during reparenting. 1341 1619 qRegisterMetaType<WId>("WId"); 1342 1620 } 1621 1622 extern void qt_cleanup_symbianFontDatabase(); // qfontdatabase_s60.cpp 1343 1623 1344 1624 /***************************************************************************** … … 1352 1632 } 1353 1633 QFontCache::cleanup(); // Has to happen now, since QFontEngineS60 has FBS handles 1634 QPixmapCache::clear(); // Has to happen now, since QS60PixmapData has FBS handles 1635 1636 qt_cleanup_symbianFontDatabase(); 1354 1637 // S60 structure and window server session are freed in eventdispatcher destructor as they are needed there 1355 1638 … … 1363 1646 S60->wsSession().SetPointerCursorMode(EPointerCursorNone); 1364 1647 1648 #ifdef Q_WS_S60 1649 // Clear CBA 1650 CEikonEnv::Static()->AppUiFactory()->SwapButtonGroup(0); 1651 delete S60->buttonGroupContainer(); 1652 S60->setButtonGroupContainer(0); 1653 #endif 1654 1365 1655 if (S60->qtOwnsS60Environment) { 1366 1656 // Restore the S60 framework trap handler. See qt_init(). … … 1398 1688 void QApplicationPrivate::enterModal_sys(QWidget *widget) 1399 1689 { 1690 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS 1691 S60->wsSession().SendEffectCommand(ETfxCmdAppModalModeEnter); 1692 #endif 1400 1693 if (widget) { 1401 1694 static_cast<QSymbianControl *>(widget->effectiveWinId())->FadeBehindPopup(ETrue); … … 1413 1706 void QApplicationPrivate::leaveModal_sys(QWidget *widget) 1414 1707 { 1708 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS 1709 S60->wsSession().SendEffectCommand(ETfxCmdAppModalModeExit); 1710 #endif 1415 1711 if (widget) { 1416 1712 static_cast<QSymbianControl *>(widget->effectiveWinId())->FadeBehindPopup(EFalse); … … 1703 1999 return 1; 1704 2000 const TWsVisibilityChangedEvent *visChangedEvent = event->VisibilityChanged(); 1705 QWidget *w = QWidgetPrivate::mapper->value(control); 1706 if (!w->d_func()->maybeTopData()) 1707 break; 1708 if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) { 1709 delete w->d_func()->topData()->backingStore; 1710 w->d_func()->topData()->backingStore = 0; 1711 // In order to ensure that any resources used by the window surface 1712 // are immediately freed, we flush the WSERV command buffer. 1713 S60->wsSession().Flush(); 1714 } else if ((visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) 1715 && !w->d_func()->maybeBackingStore()) { 1716 w->d_func()->topData()->backingStore = new QWidgetBackingStore(w); 1717 w->d_func()->invalidateBuffer(w->rect()); 1718 w->repaint(); 1719 } 2001 if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::ENotVisible) 2002 S60->controlVisibilityChanged(control, false); 2003 else if (visChangedEvent->iFlags & TWsVisibilityChangedEvent::EPartiallyVisible) 2004 S60->controlVisibilityChanged(control, true); 1720 2005 return 1; 1721 2006 } … … 1735 2020 } 1736 2021 #endif 2022 #ifdef QT_SOFTKEYS_ENABLED 2023 QSoftKeyManager::updateSoftKeys(); 2024 #endif 1737 2025 break; 1738 2026 case EEventFocusLost: … … 1751 2039 #endif 1752 2040 break; 2041 case KGoomMemoryLowEvent: 2042 #ifdef QT_DEBUG 2043 qDebug() << "QApplicationPrivate::symbianProcessWsEvent - KGoomMemoryLowEvent"; 2044 #endif 2045 if (callSymbianEventFilters(symbianEvent)) 2046 return 1; 2047 #ifdef QT_GRAPHICSSYSTEM_RUNTIME 2048 if(QApplicationPrivate::runtime_graphics_system) { 2049 bool switchToSwRendering(false); 2050 2051 foreach (QWidget *w, QApplication::topLevelWidgets()) { 2052 if(w->d_func()->topData()->backingStore) { 2053 switchToSwRendering = true; 2054 break; 2055 } 2056 } 2057 2058 if (switchToSwRendering) { 2059 QRuntimeGraphicsSystem *gs = 2060 static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system); 2061 gs->setGraphicsSystem(QLatin1String("raster")); 2062 } 2063 } 2064 #endif 2065 break; 2066 case KGoomMemoryGoodEvent: 2067 #ifdef QT_DEBUG 2068 qDebug() << "QApplicationPrivate::symbianProcessWsEvent - KGoomMemoryGoodEvent"; 2069 #endif 2070 if (callSymbianEventFilters(symbianEvent)) 2071 return 1; 2072 #ifdef QT_GRAPHICSSYSTEM_RUNTIME 2073 if(QApplicationPrivate::runtime_graphics_system) { 2074 QRuntimeGraphicsSystem *gs = 2075 static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system); 2076 gs->setGraphicsSystem(QLatin1String("openvg")); 2077 } 2078 #endif 2079 break; 2080 #ifdef Q_SYMBIAN_SUPPORTS_SURFACES 2081 case EEventUser: 2082 { 2083 // GOOM is looking for candidates to kill so indicate that we are 2084 // capable of cleaning up by handling this event 2085 TInt32 *data = reinterpret_cast<TInt32 *>(event->EventData()); 2086 if (data[0] == EApaSystemEventShutdown && data[1] == KGoomMemoryLowEvent) 2087 return 1; 2088 } 2089 break; 2090 #endif 1753 2091 default: 1754 2092 break; … … 1817 2155 break; 1818 2156 default: 2157 #ifdef Q_WS_S60 1819 2158 bool handled = QSoftKeyManager::handleCommand(command); 1820 2159 if (handled) 1821 2160 ret = 1; 1822 #ifdef Q_WS_S601823 2161 else 1824 2162 ret = QMenuBarPrivate::symbianCommands(command); … … 1916 2254 TUint QApplicationPrivate::resolveS60ScanCode(TInt scanCode, TUint keysym) 1917 2255 { 2256 if (!scanCode) 2257 return keysym; 2258 2259 QApplicationPrivate *d = QApplicationPrivate::instance(); 2260 1918 2261 if (keysym) { 1919 2262 // If keysym is specified, cache it. 1920 scanCodeCache.insert(scanCode, keysym);2263 d->scanCodeCache.insert(scanCode, keysym); 1921 2264 return keysym; 1922 2265 } else { 1923 2266 // If not, retrieve the cached version. 1924 return scanCodeCache[scanCode];2267 return d->scanCodeCache[scanCode]; 1925 2268 } 1926 2269 } … … 1933 2276 if (HAL::Get(HALData::EPointer3DMaxPressure, maxTouchPressure) != KErrNone) 1934 2277 maxTouchPressure = KMaxTInt; 2278 #else 2279 pressureSupported = 0; 2280 maxTouchPressure = KMaxTInt; 1935 2281 #endif 1936 2282 } … … 2039 2385 #endif // QT_NO_CURSOR 2040 2386 2387 void QApplicationPrivate::_q_aboutToQuit() 2388 { 2389 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS 2390 // Send the shutdown tfx command 2391 S60->wsSession().SendEffectCommand(ETfxCmdAppShutDown); 2392 #endif 2393 } 2394 2395 QS60ThreadLocalData::QS60ThreadLocalData() 2396 { 2397 CCoeEnv *env = CCoeEnv::Static(); 2398 if (env) { 2399 //if this is the UI thread, share objects owned by CONE 2400 usingCONEinstances = true; 2401 wsSession = env->WsSession(); 2402 screenDevice = env->ScreenDevice(); 2403 } 2404 else { 2405 usingCONEinstances = false; 2406 qt_symbian_throwIfError(wsSession.Connect(qt_s60GetRFs())); 2407 screenDevice = new CWsScreenDevice(wsSession); 2408 screenDevice->Construct(); 2409 } 2410 } 2411 2412 QS60ThreadLocalData::~QS60ThreadLocalData() 2413 { 2414 if (!usingCONEinstances) { 2415 delete screenDevice; 2416 wsSession.Close(); 2417 } 2418 } 2419 2041 2420 QT_END_NAMESPACE -
trunk/src/gui/kernel/qapplication_win.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 53 53 #include <tpcshell.h> 54 54 #ifdef QT_WINCE_GESTURES 55 #ifndef QT_NO_GESTURES 55 56 #include <gesture.h> 57 #endif 56 58 #endif 57 59 #endif … … 67 69 #include "qpointer.h" 68 70 #include "qhash.h" 69 #include "qlibrary.h"70 71 #include "qmetaobject.h" 71 72 #include "qmime.h" … … 80 81 #include "qtooltip.h" 81 82 #include "qt_windows.h" 83 #include "qscrollbar.h" 82 84 #if defined(QT_NON_COMMERCIAL) 83 85 #include "qnc_win.h" … … 92 94 #include <private/qkeymapper_p.h> 93 95 #include <private/qlocale_p.h> 96 #include <private/qsystemlibrary_p.h> 94 97 #include "qevent_p.h" 95 98 … … 115 118 # include <winable.h> 116 119 #endif 117 118 #include "private/qwinnativepangesturerecognizer_win_p.h"119 120 120 121 #ifndef WM_TOUCH … … 198 199 #endif 199 200 201 #ifndef QT_NO_GESTURES 200 202 typedef DWORD (API *AygRecognizeGesture)(SHRGINFO*); 201 203 static AygRecognizeGesture ptrRecognizeGesture = 0; … … 205 207 if (!aygResolved) { 206 208 aygResolved = true; 207 Q Library ayglib(QLatin1String("aygshell"));209 QSystemLibrary ayglib(QLatin1String("aygshell")); 208 210 if (!ayglib.load()) 209 211 return; … … 211 213 } 212 214 } 215 #endif // QT_NO_GESTURES 213 216 214 217 #endif … … 442 445 #endif 443 446 444 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);447 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); 445 448 446 449 class QETWidget : public QWidget // event translator widget … … 463 466 bool translateCloseEvent(const MSG &msg); 464 467 bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets); 468 #ifndef QT_NO_GESTURES 465 469 bool translateGestureEvent(const MSG &msg, const GESTUREINFO &gi); 470 #endif 466 471 void repolishStyle(QStyle &style); 467 472 inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); } … … 702 707 } 703 708 709 static void qt_set_windows_updateScrollBar(QWidget *widget) 710 { 711 QList<QObject*> children = widget->children(); 712 for (int i = 0; i < children.size(); ++i) { 713 QObject *o = children.at(i); 714 if(!o->isWidgetType()) 715 continue; 716 if (QWidget *w = static_cast<QWidget *>(o)) 717 qt_set_windows_updateScrollBar(w); 718 } 719 #ifndef QT_NO_SCROLLBAR 720 if (qobject_cast<QScrollBar*>(widget)) 721 widget->updateGeometry(); 722 #endif 723 } 724 725 704 726 /***************************************************************************** 705 727 qt_init() - initializes Qt for Windows … … 812 834 #ifndef Q_OS_WINCE 813 835 ptrUpdateLayeredWindowIndirect = 814 (PtrUpdateLayeredWindowIndirect) Q Library::resolve(QLatin1String("user32"),836 (PtrUpdateLayeredWindowIndirect) QSystemLibrary::resolve(QLatin1String("user32"), 815 837 "UpdateLayeredWindowIndirect"); 816 838 ptrUpdateLayeredWindow = 817 (PtrUpdateLayeredWindow) Q Library::resolve(QLatin1String("user32"),839 (PtrUpdateLayeredWindow) QSystemLibrary::resolve(QLatin1String("user32"), 818 840 "UpdateLayeredWindow"); 819 841 … … 823 845 // Notify Vista and Windows 7 that we support highter DPI settings 824 846 ptrSetProcessDPIAware = (PtrSetProcessDPIAware) 825 Q Library::resolve(QLatin1String("user32"), "SetProcessDPIAware");847 QSystemLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware"); 826 848 if (ptrSetProcessDPIAware) 827 849 ptrSetProcessDPIAware(); 828 850 #endif 829 851 852 #ifndef QT_NO_GESTURES 830 853 priv->GetGestureInfo = 0; 831 854 priv->GetGestureExtraArgs = 0; … … 843 866 #if !defined(QT_NO_NATIVE_GESTURES) 844 867 priv->GetGestureInfo = 845 (PtrGetGestureInfo)Q Library::resolve(QLatin1String("user32"),868 (PtrGetGestureInfo)QSystemLibrary::resolve(QLatin1String("user32"), 846 869 "GetGestureInfo"); 847 870 priv->GetGestureExtraArgs = 848 (PtrGetGestureExtraArgs)Q Library::resolve(QLatin1String("user32"),871 (PtrGetGestureExtraArgs)QSystemLibrary::resolve(QLatin1String("user32"), 849 872 "GetGestureExtraArgs"); 850 873 priv->CloseGestureInfoHandle = 851 (PtrCloseGestureInfoHandle)Q Library::resolve(QLatin1String("user32"),874 (PtrCloseGestureInfoHandle)QSystemLibrary::resolve(QLatin1String("user32"), 852 875 "CloseGestureInfoHandle"); 853 876 priv->SetGestureConfig = 854 (PtrSetGestureConfig)Q Library::resolve(QLatin1String("user32"),877 (PtrSetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"), 855 878 "SetGestureConfig"); 856 879 priv->GetGestureConfig = 857 (PtrGetGestureConfig)Q Library::resolve(QLatin1String("user32"),880 (PtrGetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"), 858 881 "GetGestureConfig"); 859 882 #endif // QT_NO_NATIVE_GESTURES 883 QSystemLibrary libTheme(QLatin1String("uxtheme")); 860 884 priv->BeginPanningFeedback = 861 (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"), 862 "BeginPanningFeedback"); 885 (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback"); 863 886 priv->UpdatePanningFeedback = 864 (PtrUpdatePanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"), 865 "UpdatePanningFeedback"); 887 (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback"); 866 888 priv->EndPanningFeedback = 867 (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("uxtheme"),868 "EndPanningFeedback"); 869 #endif 889 (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback"); 890 #endif 891 #endif // QT_NO_GESTURES 870 892 } 871 893 … … 934 956 cname = QLatin1String("QGLWidget"); 935 957 style = CS_DBLCLKS; 958 #ifndef Q_WS_WINCE 959 style |= CS_OWNDC; 960 #endif 936 961 icon = true; 937 962 } else if (flags & Qt::MSWindowsOwnDC) { … … 1401 1426 } 1402 1427 1403 extern "C" 1404 LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 1428 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 1405 1429 { 1406 1430 bool result = true; … … 1476 1500 switch (message) { 1477 1501 #ifndef Q_WS_WINCE 1502 #ifndef QT_NO_SESSIONMANAGER 1478 1503 case WM_QUERYENDSESSION: { 1479 1504 if (sm_smActive) // bogus message from windows … … 1508 1533 RETURN(0); 1509 1534 } 1535 #endif 1510 1536 case WM_DISPLAYCHANGE: 1511 1537 if (QApplication::type() == QApplication::Tty) … … 1528 1554 #ifdef Q_WS_WINCE 1529 1555 // CE SIP hide/show 1530 if ( wParam == SPI_SETSIPINFO) {1556 if (qt_desktopWidget && wParam == SPI_SETSIPINFO) { 1531 1557 QResizeEvent re(QSize(0, 0), QSize(0, 0)); // Calculated by QDesktopWidget 1532 1558 QApplication::sendEvent(qt_desktopWidget, &re); … … 1580 1606 case WM_RBUTTONDOWN: 1581 1607 case WM_XBUTTONDOWN: 1608 case WM_LBUTTONDBLCLK: 1609 case WM_RBUTTONDBLCLK: 1610 case WM_MBUTTONDBLCLK: 1611 case WM_XBUTTONDBLCLK: 1582 1612 if (qt_win_ignoreNextMouseReleaseEvent) 1583 1613 qt_win_ignoreNextMouseReleaseEvent = false; … … 1649 1679 shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION; 1650 1680 resolveAygLibs(); 1681 #ifndef QT_NO_GESTURES 1651 1682 if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) { 1652 1683 if (QApplication::activePopupWidget()) … … 1655 1686 result = qt_sendSpontaneousEvent(alienWidget, &e); 1656 1687 } 1688 #endif // QT_NO_GESTURES 1657 1689 } 1658 1690 } … … 1918 1950 if (!widget->testAttribute(Qt::WA_SetLocale)) 1919 1951 widget->dptr()->setLocale_helper(QLocale(), true); 1952 QEvent e(QEvent::LocaleChange); 1953 QApplication::sendEvent(qApp, &e); 1920 1954 } 1921 1955 } … … 1928 1962 } 1929 1963 } 1964 else if (msg.wParam == SPI_SETNONCLIENTMETRICS) { 1965 widget = (QETWidget*)QWidget::find(hwnd); 1966 if (widget && !widget->parentWidget()) { 1967 qt_set_windows_updateScrollBar(widget); 1968 QEvent e(QEvent::LayoutRequest); 1969 QApplication::sendEvent(widget, &e); 1970 } 1971 } 1972 1930 1973 break; 1931 1974 … … 2196 2239 break; 2197 2240 2241 #ifndef QT_NO_CONTEXTMENU 2198 2242 case WM_CONTEXTMENU: 2199 2243 { … … 2224 2268 break; 2225 2269 #endif 2270 #endif 2226 2271 2227 2272 case WM_IME_STARTCOMPOSITION: … … 2280 2325 { 2281 2326 // Ignoring all requests while starting up 2282 if (QApplication::startingUp() || QApplication::closingDown() || ( DWORD)lParam != OBJID_CLIENT) {2327 if (QApplication::startingUp() || QApplication::closingDown() || (LONG)lParam != OBJID_CLIENT) { 2283 2328 result = false; 2284 2329 break; … … 2292 2337 oleaccChecked = true; 2293 2338 #if !defined(Q_OS_WINCE) 2294 ptrLresultFromObject = (PtrLresultFromObject)Q Library::resolve(QLatin1String("oleacc.dll"), "LresultFromObject");2339 ptrLresultFromObject = (PtrLresultFromObject)QSystemLibrary::resolve(QLatin1String("oleacc"), "LresultFromObject"); 2295 2340 #endif 2296 2341 } … … 2445 2490 QApplication::postEvent(widget, new QEvent(QEvent::OkRequest)); 2446 2491 if (CancelCommand) 2447 QApplication::postEvent(widget, new QEvent(QEvent::Close));2492 widget->showMinimized(); 2448 2493 else 2449 2494 #ifndef QT_NO_MENUBAR … … 2527 2572 result = false; 2528 2573 break; 2574 #ifndef QT_NO_GESTURES 2529 2575 #if !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES) 2530 2576 case WM_GESTURE: { … … 2561 2607 } 2562 2608 #endif // !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES) 2609 #endif // QT_NO_GESTURES 2610 #ifndef QT_NO_CURSOR 2611 case WM_SETCURSOR: { 2612 QCursor *ovr = QApplication::overrideCursor(); 2613 if (ovr) { 2614 SetCursor(ovr->handle()); 2615 RETURN(TRUE); 2616 } 2617 result = false; 2618 break; 2619 } 2620 #endif 2563 2621 default: 2564 2622 result = false; // event was not processed … … 2983 3041 msgPtr->lParam = mouseMsg.lParam; 2984 3042 msgPtr->wParam = mouseMsg.wParam; 2985 msgPtr->pt = mouseMsg.pt; 3043 // Extract the x,y coordinates from the lParam as we do in the WndProc 3044 msgPtr->pt.x = GET_X_LPARAM(mouseMsg.lParam); 3045 msgPtr->pt.y = GET_Y_LPARAM(mouseMsg.lParam); 3046 ClientToScreen(msg.hwnd, &(msgPtr->pt)); 2986 3047 // Remove the mouse move message 2987 3048 PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE, … … 3009 3070 } 3010 3071 } 3072 #ifndef Q_OS_WINCE 3073 static bool trackMouseEventLookup = false; 3074 typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT); 3075 static PtrTrackMouseEvent ptrTrackMouseEvent = 0; 3076 #endif 3011 3077 state = translateButtonState(msg.wParam, type, button); // button state 3012 3078 const QPoint widgetPos = mapFromGlobal(QPoint(msg.pt.x, msg.pt.y)); … … 3073 3139 3074 3140 if (curWin != 0) { 3075 static bool trackMouseEventLookup = false;3076 typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT);3077 static PtrTrackMouseEvent ptrTrackMouseEvent = 0;3078 3141 if (!trackMouseEventLookup) { 3079 3142 trackMouseEventLookup = true; 3080 ptrTrackMouseEvent = (PtrTrackMouseEvent)Q Library::resolve(QLatin1String("comctl32"), "_TrackMouseEvent");3143 ptrTrackMouseEvent = (PtrTrackMouseEvent)QSystemLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent"); 3081 3144 } 3082 3145 if (ptrTrackMouseEvent && !qApp->d_func()->inPopupMode()) { … … 3189 3252 } 3190 3253 3254 #ifndef Q_OS_WINCE 3255 if (type == QEvent::MouseButtonPress 3256 && QApplication::activePopupWidget() != activePopupWidget 3257 && ptrTrackMouseEvent 3258 && curWin) { 3259 // Since curWin is already the window we clicked on, 3260 // we have to setup the mouse tracking here. 3261 TRACKMOUSEEVENT tme; 3262 tme.cbSize = sizeof(TRACKMOUSEEVENT); 3263 tme.dwFlags = 0x00000002; // TME_LEAVE 3264 tme.hwndTrack = curWin; // Track on window receiving msgs 3265 tme.dwHoverTime = (DWORD)-1; // HOVER_DEFAULT 3266 ptrTrackMouseEvent(&tme); 3267 } 3268 #endif 3191 3269 if (type == QEvent::MouseButtonPress 3192 3270 && QApplication::activePopupWidget() != activePopupWidget 3193 3271 && replayPopupMouseEvent) { 3194 // the popup dis sappeared. Replay the event3272 // the popup disappeared. Replay the event 3195 3273 QWidget* w = QApplication::widgetAt(gpos.x, gpos.y); 3196 3274 if (w && !QApplicationPrivate::isBlockedByModal(w)) { … … 3429 3507 #endif // QT_NO_TABLETEVENT 3430 3508 3431 // Update the "dynamic" information sof a cursor device (pen, airbrush, etc).3509 // Update the "dynamic" information of a cursor device (pen, airbrush, etc). 3432 3510 // The dynamic information is the information of QTabletDeviceData that can change 3433 3511 // in time (eraser or pen if a device is turned around). … … 3598 3676 return; 3599 3677 3600 Q Library library(QLatin1String("wintab32"));3678 QSystemLibrary library(QLatin1String("wintab32")); 3601 3679 if (library.load()) { 3602 3680 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); … … 3782 3860 } 3783 3861 3862 #ifndef QT_NO_GESTURES 3784 3863 bool QETWidget::translateGestureEvent(const MSG &, const GESTUREINFO &gi) 3785 3864 { … … 3820 3899 return true; 3821 3900 } 3822 3901 #endif // QT_NO_GESTURES 3823 3902 3824 3903 void QApplication::setCursorFlashTime(int msecs) … … 4010 4089 void QApplicationPrivate::initializeMultitouch_sys() 4011 4090 { 4012 static const IID QT_IID_IInkTablets = {0x112086D9, 0x7779, 0x4535, {0xA6, 0x99, 0x86, 0x2B, 0x43, 0xAC, 0x18, 0x63} }; 4013 static const IID QT_IID_IInkTablet2 = {0x90c91ad2, 0xfa36, 0x49d6, {0x95, 0x16, 0xce, 0x8d, 0x57, 0x0f, 0x6f, 0x85} }; 4014 static const CLSID QT_CLSID_InkTablets = {0x6E4FCB12, 0x510A, 0x4d40, {0x93, 0x04, 0x1D, 0xA1, 0x0A, 0xE9, 0x14, 0x7C} }; 4015 4016 IInkTablets *iInkTablets = 0; 4017 HRESULT hr = CoCreateInstance(QT_CLSID_InkTablets, NULL, CLSCTX_ALL, QT_IID_IInkTablets, (void**)&iInkTablets); 4018 if (SUCCEEDED(hr)) { 4019 long count = 0; 4020 iInkTablets->get_Count(&count); 4021 for (long i = 0; i < count; ++i) { 4022 IInkTablet *iInkTablet = 0; 4023 hr = iInkTablets->Item(i, &iInkTablet); 4024 if (FAILED(hr)) 4025 continue; 4026 IInkTablet2 *iInkTablet2 = 0; 4027 hr = iInkTablet->QueryInterface(QT_IID_IInkTablet2, (void**)&iInkTablet2); 4028 iInkTablet->Release(); 4029 if (FAILED(hr)) 4030 continue; 4031 TabletDeviceKind kind; 4032 hr = iInkTablet2->get_DeviceKind(&kind); 4033 iInkTablet2->Release(); 4034 if (FAILED(hr)) 4035 continue; 4036 if (kind == TDK_Touch) { 4037 QApplicationPrivate::HasTouchSupport = true; 4038 break; 4039 } 4040 } 4041 iInkTablets->Release(); 4042 } 4043 4044 QLibrary library(QLatin1String("user32")); 4091 if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) { 4092 static const int QT_SM_DIGITIZER = 94; 4093 int value = GetSystemMetrics(QT_SM_DIGITIZER); 4094 static const int QT_NID_INTEGRATED_TOUCH = 0x01; 4095 static const int QT_NID_EXTERNAL_TOUCH = 0x02; 4096 static const int QT_NID_MULTI_INPUT = 0x40; 4097 QApplicationPrivate::HasTouchSupport = 4098 value & (QT_NID_INTEGRATED_TOUCH | QT_NID_EXTERNAL_TOUCH | QT_NID_MULTI_INPUT); 4099 } 4100 4101 QSystemLibrary library(QLatin1String("user32")); 4045 4102 // MinGW (g++ 3.4.5) accepts only C casts. 4046 4103 RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow")); -
trunk/src/gui/kernel/qapplication_x11.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 75 75 #include "qvarlengtharray.h" 76 76 #include "qdebug.h" 77 #include <private/qunicodetables_p.h>78 77 #include <private/qcrashhandler_p.h> 79 78 #include <private/qcolor_p.h> … … 214 213 215 214 "DTWM_IS_RUNNING\0" 216 "KDE_FULL_SESSION\0"217 "KWIN_RUNNING\0"218 "KWM_RUNNING\0"219 "GNOME_BACKGROUND_PROPERTIES\0"220 215 "ENLIGHTENMENT_DESKTOP\0" 216 "_DT_SAVE_MODE\0" 221 217 "_SGI_DESKS_MANAGER\0" 222 218 … … 279 275 "_NET_SYSTEM_TRAY_VISUAL\0" 280 276 277 "_NET_ACTIVE_WINDOW\0" 278 281 279 // Property formats 282 280 "COMPOUND_TEXT\0" … … 402 400 #endif 403 401 402 typedef bool(*QX11FilterFunction)(XEvent *event); 403 404 Q_GLOBAL_STATIC(QList<QX11FilterFunction>, x11Filters) 405 406 Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func) 407 { 408 Q_ASSERT(func); 409 410 if (QList<QX11FilterFunction> *list = x11Filters()) 411 list->append(func); 412 } 413 414 Q_GUI_EXPORT void qt_removeX11EventFilter(QX11FilterFunction func) 415 { 416 Q_ASSERT(func); 417 418 if (QList<QX11FilterFunction> *list = x11Filters()) 419 list->removeOne(func); 420 } 421 422 404 423 static bool qt_x11EventFilter(XEvent* ev) 405 424 { … … 407 426 if (qApp->filterEvent(ev, &unused)) 408 427 return true; 428 if (const QList<QX11FilterFunction> *list = x11Filters()) { 429 for (QList<QX11FilterFunction>::const_iterator it = list->constBegin(); it != list->constEnd(); ++it) { 430 if ((*it)(ev)) 431 return true; 432 } 433 } 434 409 435 return qApp->x11EventFilter(ev); 410 436 } … … 625 651 static int qt_x_errhandler(Display *dpy, XErrorEvent *err) 626 652 { 653 if (X11->display != dpy) { 654 // only handle X errors for our display 655 return 0; 656 } 657 627 658 switch (err->error_code) { 628 659 case BadAtom: … … 632 663 || err->resourceid == ATOM(_NET_SUPPORTED) 633 664 || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK) 634 || err->resourceid == ATOM(KDE_FULL_SESSION)635 || err->resourceid == ATOM(KWIN_RUNNING)636 665 || err->resourceid == ATOM(XdndProxy) 637 666 || err->resourceid == ATOM(XdndAware))) { … … 665 694 } 666 695 if (X11->ignore_badwindow) 667 return 0;668 break;669 670 case BadMatch:671 if (err->request_code == 42 /* X_SetInputFocus */)672 696 return 0; 673 697 break; … … 710 734 else if (err->request_code == X11->mitshm_major) 711 735 extensionName = "MIT-SHM"; 736 #ifndef QT_NO_XKB 737 else if(err->request_code == X11->xkb_major) 738 extensionName = "XKEYBOARD"; 739 #endif 712 740 713 741 char minor_str[256]; … … 1635 1663 X11->xinput_eventbase = 0; 1636 1664 X11->xinput_errorbase = 0; 1665 1666 X11->use_xkb = false; 1667 X11->xkb_major = 0; 1668 X11->xkb_eventbase = 0; 1669 X11->xkb_errorbase = 0; 1637 1670 1638 1671 // MIT-SHM … … 2109 2142 #endif // QT_NO_XINPUT 2110 2143 2144 #ifndef QT_NO_XKB 2145 int xkblibMajor = XkbMajorVersion; 2146 int xkblibMinor = XkbMinorVersion; 2147 X11->use_xkb = XkbQueryExtension(X11->display, 2148 &X11->xkb_major, 2149 &X11->xkb_eventbase, 2150 &X11->xkb_errorbase, 2151 &xkblibMajor, 2152 &xkblibMinor); 2153 if (X11->use_xkb) { 2154 // If XKB is detected, set the GrabsUseXKBState option so input method 2155 // compositions continue to work (ie. deadkeys) 2156 unsigned int state = XkbPCF_GrabsUseXKBStateMask; 2157 (void) XkbSetPerClientControls(X11->display, state, &state); 2158 2159 // select for group change events 2160 XkbSelectEventDetails(X11->display, 2161 XkbUseCoreKbd, 2162 XkbStateNotify, 2163 XkbAllStateComponentsMask, 2164 XkbGroupStateMask); 2165 2166 // current group state is queried when creating the keymapper, no need to do it here 2167 } 2168 #endif 2169 2170 2111 2171 #if !defined(QT_NO_FONTCONFIG) 2112 2172 int dpi = 0; … … 2123 2183 for (int s = 0; s < ScreenCount(X11->display); ++s) { 2124 2184 int subpixel = FC_RGBA_UNKNOWN; 2125 #if RENDER_MAJOR > 0 || RENDER_MINOR >= 62185 #if !defined(QT_NO_XRENDER) && (RENDER_MAJOR > 0 || RENDER_MINOR >= 6) 2126 2186 if (X11->use_xrender) { 2127 2187 int rsp = XRenderQuerySubpixelOrder(X11->display, s); … … 2187 2247 QKeyMapper::changeKeyboard(); 2188 2248 2189 #ifndef QT_NO_XKB2190 if (qt_keymapper_private()->useXKB) {2191 // If XKB is detected, set the GrabsUseXKBState option so input method2192 // compositions continue to work (ie. deadkeys)2193 unsigned int state = XkbPCF_GrabsUseXKBStateMask;2194 (void) XkbSetPerClientControls(X11->display, state, &state);2195 }2196 #endif // QT_NO_XKB2197 2198 2249 // Misc. initialization 2199 2250 #if 0 //disabled for now.. … … 2228 2279 X11->desktopVersion = 0; 2229 2280 2230 // See if the current window manager is using the freedesktop.org spec to give its name 2231 Window windowManagerWindow = XNone; 2232 Atom typeReturned; 2233 int formatReturned; 2234 unsigned long nitemsReturned; 2235 unsigned long unused; 2236 unsigned char *data = 0; 2237 if (XGetWindowProperty(QX11Info::display(), QX11Info::appRootWindow(), 2238 ATOM(_NET_SUPPORTING_WM_CHECK), 2239 0, 1024, False, XA_WINDOW, &typeReturned, 2240 &formatReturned, &nitemsReturned, &unused, &data) 2241 == Success) { 2242 if (typeReturned == XA_WINDOW && formatReturned == 32) 2243 windowManagerWindow = *((Window*) data); 2244 if (data) 2281 Atom type; 2282 int format; 2283 unsigned long length, after; 2284 uchar *data = 0; 2285 int rc; 2286 2287 do { 2288 if (!qgetenv("KDE_FULL_SESSION").isEmpty()) { 2289 X11->desktopEnvironment = DE_KDE; 2290 X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt(); 2291 break; 2292 } 2293 2294 if (qgetenv("DESKTOP_SESSION") == "gnome") { 2295 X11->desktopEnvironment = DE_GNOME; 2296 break; 2297 } 2298 2299 // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it 2300 if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) { 2301 X11->desktopEnvironment = DE_GNOME; 2302 break; 2303 } 2304 2305 rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_DT_SAVE_MODE), 2306 0, 2, False, XA_STRING, &type, &format, &length, 2307 &after, &data); 2308 if (rc == Success && length) { 2309 if (!strcmp(reinterpret_cast<char *>(data), "xfce4")) { 2310 // Pretend that xfce4 is gnome, as it uses the same libraries. 2311 // The detection above is stolen from xdg-open. 2312 X11->desktopEnvironment = DE_GNOME; 2313 break; 2314 } 2315 2316 // We got the property but it wasn't xfce4. Free data before it gets overwritten. 2245 2317 XFree(data); 2246 2247 if (windowManagerWindow != XNone) { 2248 QString wmName; 2249 Atom utf8atom = ATOM(UTF8_STRING); 2250 if (XGetWindowProperty(QX11Info::display(), windowManagerWindow, ATOM(_NET_WM_NAME), 2251 0, 1024, False, utf8atom, &typeReturned, 2252 &formatReturned, &nitemsReturned, &unused, &data) 2253 == Success) { 2254 if (typeReturned == utf8atom && formatReturned == 8) 2255 wmName = QString::fromUtf8((const char*)data); 2256 if (data) 2257 XFree(data); 2258 if (wmName == QLatin1String("KWin")) 2259 X11->desktopEnvironment = DE_KDE; 2260 if (wmName == QLatin1String("Metacity")) 2261 X11->desktopEnvironment = DE_GNOME; 2262 } 2263 } 2264 } 2265 2266 // Running a different/newer/older window manager? Try some other things 2267 if (X11->desktopEnvironment == DE_UNKNOWN){ 2268 Atom type; 2269 int format; 2270 unsigned long length, after; 2271 uchar *data = 0; 2272 2273 QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION")); 2274 if (session == QLatin1String("kde")) { 2275 X11->desktopEnvironment = DE_KDE; 2276 } else if (session == QLatin1String("gnome") || session == QLatin1String("xfce")) { 2277 X11->desktopEnvironment = DE_GNOME; 2278 } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING), 2279 0, 1, False, AnyPropertyType, &type, &format, &length, 2280 &after, &data) == Success && length) { 2318 data = 0; 2319 } 2320 2321 rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(DTWM_IS_RUNNING), 2322 0, 1, False, AnyPropertyType, &type, &format, &length, 2323 &after, &data); 2324 if (rc == Success && length) { 2281 2325 // DTWM is running, meaning most likely CDE is running... 2282 2326 X11->desktopEnvironment = DE_CDE; 2283 } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), 2284 ATOM(GNOME_BACKGROUND_PROPERTIES), 0, 1, False, AnyPropertyType, 2285 &type, &format, &length, &after, &data) == Success && length) { 2286 X11->desktopEnvironment = DE_GNOME; 2287 } else if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) { 2288 X11->desktopEnvironment = DE_GNOME; 2289 } else if ((XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KDE_FULL_SESSION), 2290 0, 1, False, AnyPropertyType, &type, &format, &length, &after, &data) == Success 2291 && length) 2292 || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWIN_RUNNING), 2293 0, 1, False, AnyPropertyType, &type, &format, &length, 2294 &after, &data) == Success 2295 && length) 2296 || (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(KWM_RUNNING), 2297 0, 1, False, AnyPropertyType, &type, &format, &length, 2298 &after, &data) == Success && length)) { 2299 X11->desktopEnvironment = DE_KDE; 2300 } else if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), ATOM(_SGI_DESKS_MANAGER), 2301 0, 1, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success 2302 && length) { 2327 break; 2328 } 2329 2330 rc = XGetWindowProperty(X11->display, QX11Info::appRootWindow(), 2331 ATOM(_SGI_DESKS_MANAGER), 0, 1, False, XA_WINDOW, 2332 &type, &format, &length, &after, &data); 2333 if (rc == Success && length) { 2303 2334 X11->desktopEnvironment = DE_4DWM; 2304 } 2305 if (data) 2306 XFree((char *)data); 2307 } 2308 2309 if (X11->desktopEnvironment == DE_KDE) 2310 X11->desktopVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt(); 2335 break; 2336 } 2337 2338 if (XGetWindowProperty(X11->display, QX11Info::appRootWindow(), 2339 ATOM(_NET_SUPPORTING_WM_CHECK), 2340 0, 1024, False, XA_WINDOW, &type, 2341 &format, &length, &after, &data) == Success) { 2342 if (type == XA_WINDOW && format == 32) { 2343 Window windowManagerWindow = *((Window*) data); 2344 XFree(data); 2345 data = 0; 2346 2347 if (windowManagerWindow != XNone) { 2348 Atom utf8atom = ATOM(UTF8_STRING); 2349 if (XGetWindowProperty(QX11Info::display(), windowManagerWindow, ATOM(_NET_WM_NAME), 2350 0, 1024, False, utf8atom, &type, 2351 &format, &length, &after, &data) == Success) { 2352 if (type == utf8atom && format == 8) { 2353 if (qstrcmp((const char *)data, "MCompositor") == 0) 2354 X11->desktopEnvironment = DE_MEEGO_COMPOSITOR; 2355 } 2356 } 2357 } 2358 } 2359 } 2360 2361 } while(0); 2362 2363 if (data) 2364 XFree((char *)data); 2311 2365 2312 2366 #if !defined(QT_NO_STYLE_GTK) … … 3053 3107 X11->time = event->xclient.data.l[1]; 3054 3108 QWidget *amw = activeModalWidget(); 3109 if (amw && amw->testAttribute(Qt::WA_X11DoNotAcceptFocus)) 3110 amw = 0; 3055 3111 if (amw && !QApplicationPrivate::tryModalHelper(widget, 0)) { 3056 3112 QWidget *p = amw->parentWidget(); … … 3251 3307 return 0; 3252 3308 } 3309 #ifndef QT_NO_XKB 3310 else if (X11->use_xkb && event->type == X11->xkb_eventbase) { 3311 XkbAnyEvent *xkbevent = (XkbAnyEvent *) event; 3312 switch (xkbevent->xkb_type) { 3313 case XkbStateNotify: 3314 { 3315 XkbStateNotifyEvent *xkbstateevent = (XkbStateNotifyEvent *) xkbevent; 3316 if ((xkbstateevent->changed & XkbGroupStateMask) != 0) { 3317 qt_keymapper_private()->xkb_currentGroup = xkbstateevent->group; 3318 QKeyMapper::changeKeyboard(); 3319 } 3320 break; 3321 } 3322 default: 3323 break; 3324 } 3325 } 3326 #endif 3253 3327 3254 3328 if (!widget) { // don't know this windows … … 3620 3694 case MapNotify: // window shown 3621 3695 if (widget->isWindow()) { 3696 // if we got a MapNotify when we were not waiting for it, it most 3697 // likely means the user has already asked to hide the window before 3698 // it ever being shown, so we try to withdraw a window after sending 3699 // the QShowEvent. 3700 bool pendingHide = widget->testAttribute(Qt::WA_WState_ExplicitShowHide) && widget->testAttribute(Qt::WA_WState_Hidden); 3622 3701 widget->d_func()->topData()->waitingForMapNotify = 0; 3623 3702 … … 3639 3718 } 3640 3719 } 3720 if (pendingHide) // hide the window 3721 XWithdrawWindow(X11->display, widget->internalWinId(), widget->x11Info().screen()); 3641 3722 } 3642 3723 break; … … 3686 3767 QWidget *newparent = QWidget::find(event->xreparent.parent); 3687 3768 if (! newparent || (newparent->windowType() == Qt::Desktop)) { 3688 // we don t'know about the new parent (or we've been3769 // we don't know about the new parent (or we've been 3689 3770 // reparented to root), perhaps a window manager 3690 3771 // has been (re)started? reset the focus model to unknown … … 5246 5327 if (isVisible() && data->crect.size() != oldSize) { 5247 5328 Q_ASSERT(d->extra->topextra); 5248 QWidgetBackingStore *bs = d->extra->topextra->backingStore ;5329 QWidgetBackingStore *bs = d->extra->topextra->backingStore.data(); 5249 5330 const bool hasStaticContents = bs && bs->hasStaticContents(); 5250 5331 // If we have a backing store with static contents, we have to disable the top-level -
trunk/src/gui/kernel/qboxlayout.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qboxlayout.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qclipboard.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 107 107 store or retrieve the clipboard contents in response to timer or 108 108 non-user-input events. 109 110 \i Since there is no standard way to copy and paste files between 111 applications on X11, various MIME types and conventions are currently 112 in use. For instance, Nautilus expects files to be supplied with a 113 \c{x-special/gnome-copied-files} MIME type with data beginning with 114 the cut/copy action, a newline character, and the URL of the file. 109 115 110 116 \endlist -
trunk/src/gui/kernel/qclipboard.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qclipboard_mac.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 624 624 #ifdef DEBUG_PASTEBOARD 625 625 if(fromGlobal) 626 qDebug("Pasteboard: Sync ronize!");626 qDebug("Pasteboard: Synchronize!"); 627 627 #endif 628 628 return fromGlobal; -
trunk/src/gui/kernel/qclipboard_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qclipboard_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qclipboard_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 51 51 #include "qevent.h" 52 52 #include "private/qcore_symbian_p.h" 53 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS 54 #include "txtclipboard.h" 55 #endif 56 #include "txtetext.h" 53 57 #include <QtDebug> 54 58 … … 57 61 QT_BEGIN_NAMESPACE 58 62 59 //### Mime Type mapping to UIDs60 61 63 const TUid KQtCbDataStream = {0x2001B2DD}; 62 64 const TInt KPlainTextBegin = 0; 63 65 64 66 class QClipboardData … … 142 144 HBufC* stringData = TPtrC(reinterpret_cast<const TUint16*>((*iter).utf16())).AllocLC(); 143 145 QByteArray ba = aData->data((*iter)); 144 qDebug() << "copy to clipboard mime: " << *iter << " data: " << ba;145 146 // mime type 146 147 aStream << TCardinality(stringData->Size()); … … 151 152 CleanupStack::PopAndDestroy(stringData); 152 153 } 154 } 155 156 void writeToSymbianStoreLX(const QMimeData* aData, CClipboard* clipboard) 157 { 158 // This function both leaves and throws exceptions. There must be no destructor 159 // dependencies between cleanup styles, and no cleanup stack dependencies on stacked objects. 160 if (aData->hasText()) { 161 CPlainText* text = CPlainText::NewL(); 162 CleanupStack::PushL(text); 163 164 TPtrC textPtr(qt_QString2TPtrC(aData->text())); 165 text->InsertL(KPlainTextBegin, textPtr); 166 text->CopyToStoreL(clipboard->Store(), clipboard->StreamDictionary(), 167 KPlainTextBegin, textPtr.Length()); 168 CleanupStack::PopAndDestroy(text); 169 } 170 } 171 172 void readSymbianStoreLX(QMimeData* aData, CClipboard* clipboard) 173 { 174 // This function both leaves and throws exceptions. There must be no destructor 175 // dependencies between cleanup styles, and no cleanup stack dependencies on stacked objects. 176 CPlainText* text = CPlainText::NewL(); 177 CleanupStack::PushL(text); 178 TInt dataLength = text->PasteFromStoreL(clipboard->Store(), clipboard->StreamDictionary(), 179 KPlainTextBegin); 180 if (dataLength == 0) { 181 User::Leave(KErrNotFound); 182 } 183 HBufC* hBuf = HBufC::NewL(dataLength); 184 TPtr buf = hBuf->Des(); 185 text->Extract(buf, KPlainTextBegin, dataLength); 186 187 QString string = qt_TDesC2QString(buf); 188 CleanupStack::PopAndDestroy(text); 189 190 aData->setText(string); 153 191 } 154 192 … … 175 213 aStream.ReadL(reinterpret_cast<uchar*>(ba.data_ptr()->data),dataSize); 176 214 ba.data_ptr()->size = dataSize; 177 qDebug() << "paste from clipboard mime: " << mimeType << " data: " << ba;178 215 aData->setData(mimeType,ba); 179 216 } … … 193 230 if (mode != Clipboard) return 0; 194 231 QClipboardData *d = clipboardData(); 232 bool dataExists(false); 195 233 if (d) 196 234 { … … 199 237 CClipboard* cb = CClipboard::NewForReadingLC(fs); 200 238 Q_ASSERT(cb); 239 //stream for qt 201 240 RStoreReadStream stream; 202 241 TStreamId stid = (cb->StreamDictionary()).At(KQtCbDataStream); 203 stream.OpenLC(cb->Store(),stid); 204 QT_TRYCATCH_LEAVING(readFromStreamLX(d->source(),stream)); 205 CleanupStack::PopAndDestroy(2,cb); 206 return d->source(); 242 if (stid != 0) { 243 stream.OpenLC(cb->Store(),stid); 244 QT_TRYCATCH_LEAVING(readFromStreamLX(d->source(),stream)); 245 CleanupStack::PopAndDestroy(&stream); 246 dataExists = true; 247 } 248 else { 249 //symbian clipboard 250 RStoreReadStream symbianStream; 251 TStreamId symbianStId = (cb->StreamDictionary()).At(KClipboardUidTypePlainText); 252 if (symbianStId != 0) { 253 symbianStream.OpenLC(cb->Store(), symbianStId); 254 QT_TRYCATCH_LEAVING(readSymbianStoreLX(d->source(), cb)); 255 CleanupStack::PopAndDestroy(&symbianStream); 256 dataExists = true; 257 } 258 } 259 CleanupStack::PopAndDestroy(cb); 207 260 }); 208 261 if (err != KErrNone){ … … 210 263 } 211 264 265 if (dataExists) { 266 return d->source(); 267 } 212 268 } 213 269 return 0; … … 224 280 RFs fs = qt_s60GetRFs(); 225 281 CClipboard* cb = CClipboard::NewForWritingLC(fs); 282 //stream for qt 226 283 RStoreWriteStream stream; 227 284 TStreamId stid = stream.CreateLC(cb->Store()); … … 231 288 (cb->StreamDictionary()).AssignL(KQtCbDataStream,stid); 232 289 cb->CommitL(); 233 CleanupStack::PopAndDestroy(2,cb); 290 291 //stream for symbian 292 RStoreWriteStream symbianStream; 293 TStreamId symbianStId = symbianStream.CreateLC(cb->Store()); 294 QT_TRYCATCH_LEAVING(writeToSymbianStoreLX(src, cb)); 295 (cb->StreamDictionary()).AssignL(KClipboardUidTypePlainText, symbianStId); 296 cb->CommitL(); 297 CleanupStack::PopAndDestroy(3,cb); 234 298 }); 235 299 if (err != KErrNone){ -
trunk/src/gui/kernel/qclipboard_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 142 142 clipBoardViewer->createWinId(); 143 143 clipBoardViewer->setObjectName(QLatin1String("internal clipboard owner")); 144 // We don t need this internal widget to appear in QApplication::topLevelWidgets()144 // We don't need this internal widget to appear in QApplication::topLevelWidgets() 145 145 if (QWidgetPrivate::allWidgets) 146 146 QWidgetPrivate::allWidgets->remove(clipBoardViewer); -
trunk/src/gui/kernel/qclipboard_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 66 66 #include "qdesktopwidget.h" 67 67 #include "qbitmap.h" 68 #include "qdatetime.h"69 68 #include "qiodevice.h" 70 69 #include "qbuffer.h" … … 77 76 #include "qx11info_x11.h" 78 77 #include "qimagewriter.h" 78 #include "qelapsedtimer.h" 79 79 #include "qvariant.h" 80 80 #include "qdnd_p.h" … … 133 133 requestor->createWinId(); 134 134 requestor->setObjectName(QLatin1String("internal clipboard requestor")); 135 // We don t need this internal widgets to appear in QApplication::topLevelWidgets()135 // We don't need this internal widgets to appear in QApplication::topLevelWidgets() 136 136 if (QWidgetPrivate::allWidgets) { 137 137 QWidgetPrivate::allWidgets->remove(owner); … … 457 457 if (data.timestamp == CurrentTime) { 458 458 setupOwner(); 459 int dummy = 0; 459 // We need this value just for completeness, we don't use it. 460 long dummy = 0; 460 461 Window ownerId = owner->internalWinId(); 461 462 XChangeProperty(X11->display, ownerId, … … 517 518 bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout) 518 519 { 519 QTime started = QTime::currentTime(); 520 QTime now = started; 520 QElapsedTimer started; 521 started.start(); 522 QElapsedTimer now = started; 521 523 522 524 if (QAbstractEventDispatcher::instance()->inherits("QtMotif") … … 546 548 usleep(50000); 547 549 548 now = QTime::currentTime(); 549 if (started > now) // crossed midnight 550 started = now; 550 now.start(); 551 551 552 552 QEventLoop::ProcessEventsFlags flags(QEventLoop::ExcludeUserInputEvents … … 577 577 qApp->x11ProcessEvent(&e); 578 578 579 now = QTime::currentTime(); 580 if ( started > now ) // crossed midnight 581 started = now; 579 now.start(); 582 580 583 581 XFlush(X11->display); … … 598 596 599 597 bool QX11Data::clipboardReadProperty(Window win, Atom property, bool deleteProperty, 600 QByteArray *buffer, int *size, Atom *type, int *format , bool nullterm)598 QByteArray *buffer, int *size, Atom *type, int *format) 601 599 { 602 600 int maxsize = maxSelectionIncr(display); … … 644 642 } 645 643 646 int newSize = proplen + (nullterm ? 1 : 0);644 int newSize = proplen; 647 645 buffer->resize(newSize); 648 646 … … 650 648 VDEBUG("QClipboard: read_property(): buffer resized to %d", buffer->size()); 651 649 652 if (ok ) {650 if (ok && newSize) { 653 651 // could allocate buffer 654 652 … … 686 684 textprop.encoding = *type; 687 685 textprop.format = *format; 688 textprop.nitems = length;686 textprop.nitems = buffer_offset; 689 687 textprop.value = (unsigned char *) buffer->data(); 690 688 … … 693 691 if (XmbTextPropertyToTextList(display, &textprop, &list_ret, 694 692 &count) == Success && count && list_ret) { 695 offset = strlen(list_ret[0]);696 buffer->resize(offset + (nullterm ? 1 : 0));693 offset = buffer_offset = strlen(list_ret[0]); 694 buffer->resize(offset); 697 695 memcpy(buffer->data(), list_ret[0], offset); 698 696 } 699 697 if (list_ret) XFreeStringList(list_ret); 700 698 } 701 702 // zero-terminate (for text)703 if (nullterm)704 buffer->data()[buffer_offset] = '\0';705 699 } 706 700 … … 745 739 event.xproperty.state != PropertyNewValue) 746 740 continue; 747 if (X11->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0 , false)) {741 if (X11->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) { 748 742 if (length == 0) { // no more data, we're done 749 743 if (nullterm) { … … 776 770 requestor = new QWidget(0); 777 771 requestor->setObjectName(QLatin1String("internal clipboard requestor")); 778 // We don t need this internal widget to appear in QApplication::topLevelWidgets()772 // We don't need this internal widget to appear in QApplication::topLevelWidgets() 779 773 if (QWidgetPrivate::allWidgets) 780 774 QWidgetPrivate::allWidgets->remove(requestor); … … 839 833 840 834 (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment); 841 return ATOM(INCR);835 return property; 842 836 } 843 837 … … 1073 1067 if (req->property == XNone 1074 1068 || !X11->clipboardReadProperty(req->requestor, req->property, false, &multi_data, 1075 0, &multi_type, &multi_format , 0)1069 0, &multi_type, &multi_format) 1076 1070 || multi_format != 32) { 1077 1071 // MULTIPLE property not formatted correctly … … 1295 1289 XSelectInput(dpy, win, PropertyChangeMask); 1296 1290 1297 if (X11->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0 , false)) {1291 if (X11->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0)) { 1298 1292 if (type == ATOM(INCR)) { 1299 1293 int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; … … 1522 1516 #endif 1523 1517 if (!owner || (selectionOwner && selectionOwner != owner->internalWinId()) || 1524 (!selectionOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))1518 (!selectionOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) 1525 1519 return qt_check_selection_sentinel(); 1526 1520 return false; … … 1536 1530 #endif 1537 1531 if (!owner || (clipboardOwner && clipboardOwner != owner->internalWinId()) || 1538 (!clipboardOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))1532 (!clipboardOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp))) 1539 1533 return qt_check_clipboard_sentinel(); 1540 1534 return false; -
trunk/src/gui/kernel/qcocoaapplication_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 80 80 #include <private/qt_cocoa_helpers_mac_p.h> 81 81 82 QT_USE_NAMESPACE 83 82 84 @implementation NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration)) 83 85 … … 108 110 } 109 111 112 - (void)qt_sendPostedMessage:(NSEvent *)event 113 { 114 // WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5! 115 // That is why we need to split the address in two parts: 116 quint64 lower = [event data1]; 117 quint64 upper = [event data2]; 118 QCocoaPostMessageArgs *args = reinterpret_cast<QCocoaPostMessageArgs *>(lower | (upper << 32)); 119 [args->target performSelector:args->selector]; 120 delete args; 121 } 122 123 - (BOOL)qt_sendEvent:(NSEvent *)event 124 { 125 if ([event type] == NSApplicationDefined) { 126 switch ([event subtype]) { 127 case QtCocoaEventSubTypePostMessage: 128 [NSApp qt_sendPostedMessage:event]; 129 return true; 130 default: 131 break; 132 } 133 } 134 return false; 135 } 136 110 137 @end 138 139 @implementation QNSApplication 140 141 // WARNING: If Qt did not create NSApplication (this can e.g. 142 // happend if Qt is used as a plugin from a 3rd-party cocoa 143 // application), QNSApplication::sendEvent will never be called. 144 // SO DO NOT RELY ON THIS FUNCTION BEING AVAILABLE. 145 // Plugin developers that _do_ control the NSApplication sub-class 146 // implementation of the 3rd-party application can call qt_sendEvent 147 // from the sub-class event handler (like we do here) to work around 148 // any issues. 149 - (void)sendEvent:(NSEvent *)event 150 { 151 if (![self qt_sendEvent:event]) 152 [super sendEvent:event]; 153 } 154 155 @end 156 111 157 #endif -
trunk/src/gui/kernel/qcocoaapplication_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 100 100 - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader); 101 101 - (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel; 102 103 - (void)qt_sendPostedMessage:(NSEvent *)event; 104 - (BOOL)qt_sendEvent:(NSEvent *)event; 102 105 @end 106 107 @interface QNSApplication : NSApplication { 108 } 109 @end 110 103 111 #endif -
trunk/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 180 180 181 181 // This function will only be called when NSApp is actually running. Before 182 // that, the kAEQuitApplication apple event will be sendt to182 // that, the kAEQuitApplication Apple event will be sent to 183 183 // QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm 184 184 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender … … 202 202 // INVARIANT: No event loop is executing. This probably 203 203 // means that Qt is used as a plugin, or as a part of a native 204 // Cocoa application. In any case it should be fine to 204 // Cocoa application. In any case it should be fine to 205 205 // terminate now: 206 206 return NSTerminateNow; 207 } else { 208 // Prevent Cocoa from terminating the application, since this simply 209 // exits the program whithout allowing QApplication::exec() to return. 210 // The call to QApplication::quit() above will instead quit the 211 // application from the Qt side. 212 return NSTerminateCancel; 213 } 207 } 208 209 return NSTerminateCancel; 214 210 } 215 211 … … 318 314 } 319 315 316 - (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent 317 { 318 Q_UNUSED(event); 319 Q_UNUSED(replyEvent); 320 [NSApp terminate:self]; 321 } 322 323 - (void)qtDispatcherToQAction:(id)sender 324 { 325 [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender]; 326 } 327 320 328 @end 321 329 #endif -
trunk/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qcocoamenuloader_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #include <private/qapplication_p.h> 48 48 #include <private/qt_mac_p.h> 49 #include <private/qmenubar_p.h> 49 50 #include <qmenubar.h> 51 #include <private/qt_cocoa_helpers_mac_p.h> 50 52 51 53 QT_FORWARD_DECLARE_CLASS(QCFString) 52 54 QT_FORWARD_DECLARE_CLASS(QString) 53 55 56 #ifndef QT_NO_TRANSLATION 57 QT_BEGIN_NAMESPACE 58 extern QString qt_mac_applicationmenu_string(int type); 59 QT_END_NAMESPACE 60 #endif 61 54 62 QT_USE_NAMESPACE 55 63 … … 58 66 - (void)awakeFromNib 59 67 { 68 servicesItem = [[appMenu itemWithTitle:@"Services"] retain]; 69 hideAllOthersItem = [[appMenu itemWithTitle:@"Hide Others"] retain]; 70 showAllItem = [[appMenu itemWithTitle:@"Show All"] retain]; 71 60 72 // Get the names in the nib to match the app name set by Qt. 61 73 NSString *appName = reinterpret_cast<const NSString*>(QCFString::toCFStringRef(qAppName())); … … 78 90 { 79 91 // The application menu is the menu in the menu bar that contains the 80 // 'Quit' item. When changing menu bar (e.g when swit hing between92 // 'Quit' item. When changing menu bar (e.g when switching between 81 93 // windows with different menu bars), we never recreate this menu, but 82 94 // instead pull it out the current menu bar and place into the new one: … … 119 131 - (void)dealloc 120 132 { 133 [servicesItem release]; 134 [hideAllOthersItem release]; 135 [showAllItem release]; 136 121 137 [lastAppSpecificItem release]; 122 138 [theMenu release]; … … 207 223 { 208 224 [NSApp hide:sender]; 225 } 226 227 - (void)qtUpdateMenubar 228 { 229 QMenuBarPrivate::macUpdateMenuBarImmediatly(); 230 } 231 232 - (void)qtTranslateApplicationMenu 233 { 234 #ifndef QT_NO_TRANSLATION 235 [servicesItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(0))]; 236 [hideItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(1).arg(qAppName()))]; 237 [hideAllOthersItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(2))]; 238 [showAllItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(3))]; 239 [preferencesItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(4))]; 240 [quitItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(5).arg(qAppName()))]; 241 [aboutItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(6).arg(qAppName()))]; 242 #endif 209 243 } 210 244 … … 222 256 } 223 257 } 258 259 - (void)orderFrontCharacterPalette:(id)sender 260 { 261 [NSApp orderFrontCharacterPalette:sender]; 262 } 224 263 @end 225 264 #endif // QT_MAC_USE_COCOA -
trunk/src/gui/kernel/qcocoamenuloader_mac_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 68 68 IBOutlet NSMenuItem *hideItem; 69 69 NSMenuItem *lastAppSpecificItem; 70 70 NSMenuItem *servicesItem; 71 NSMenuItem *hideAllOthersItem; 72 NSMenuItem *showAllItem; 71 73 } 72 74 - (void)ensureAppMenuInMenu:(NSMenu *)menu; … … 86 88 - (IBAction)hide:(id)sender; 87 89 - (IBAction)qtDispatcherToQAction:(id)sender; 90 - (void)qtUpdateMenubar; 91 - (void)orderFrontCharacterPalette:(id)sender; 88 92 @end 89 93 -
trunk/src/gui/kernel/qcocoapanel_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #import <private/qcocoaview_mac_p.h> 48 48 #import <private/qcocoawindowcustomthemeframe_mac_p.h> 49 #import <private/qcocoaapplication_mac_p.h> 49 50 #include <private/qapplication_p.h> 50 51 #include <private/qbackingstore_p.h> -
trunk/src/gui/kernel/qcocoapanel_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 55 55 #import <Cocoa/Cocoa.h> 56 56 57 QT_FORWARD_DECLARE_CLASS(QStringList); 58 57 59 @interface QT_MANGLE_NAMESPACE(QCocoaPanel) : NSPanel { 58 60 bool leftButtonIsRightButton; 61 QStringList *currentCustomDragTypes; 59 62 } 60 63 61 64 + (Class)frameViewClassForStyleMask:(NSUInteger)styleMask; 65 - (void)registerDragTypes; 66 62 67 @end 63 68 #endif 69 -
trunk/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 58 58 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm 59 59 extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp 60 extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp 61 extern void qt_event_request_window_change(QWidget *); // qapplication_mac.mm 62 extern void qt_mac_send_posted_gl_updates(QWidget *widget); // qapplication_mac.mm 63 64 Q_GLOBAL_STATIC(QPointer<QWidget>, currentDragTarget); 65 60 66 QT_END_NAMESPACE 61 67 68 - (id)initWithContentRect:(NSRect)contentRect 69 styleMask:(NSUInteger)windowStyle 70 backing:(NSBackingStoreType)bufferingType 71 defer:(BOOL)deferCreation 72 { 73 self = [super initWithContentRect:contentRect styleMask:windowStyle 74 backing:bufferingType defer:deferCreation]; 75 if (self) { 76 currentCustomDragTypes = 0; 77 } 78 return self; 79 } 80 81 - (void)dealloc 82 { 83 delete currentCustomDragTypes; 84 [super dealloc]; 85 } 86 62 87 - (BOOL)canBecomeKeyWindow 63 88 { 64 89 QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; 90 if (!widget) 91 return NO; // This should happen only for qt_root_win 65 92 66 93 bool isToolTip = (widget->windowType() == Qt::ToolTip); … … 69 96 } 70 97 98 - (BOOL)canBecomeMainWindow 99 { 100 QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)]; 101 if (!widget) 102 return NO; // This should happen only for qt_root_win 103 104 bool isToolTip = (widget->windowType() == Qt::ToolTip); 105 bool isPopup = (widget->windowType() == Qt::Popup); 106 bool isTool = (widget->windowType() == Qt::Tool); 107 return !(isPopup || isToolTip || isTool); 108 } 109 110 - (void)becomeMainWindow 111 { 112 [super becomeMainWindow]; 113 // Cocoa sometimes tell a hidden window to become the 114 // main window (and as such, show it). This can e.g 115 // happend when the application gets activated. If 116 // this is the case, we tell it to hide again: 117 if (![self isVisible]) 118 [self orderOut:self]; 119 } 120 71 121 - (void)toggleToolbarShown:(id)sender 72 122 { … … 75 125 } 76 126 77 /*78 The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever79 get hit. We automatically say we can be first responder if we are a window.80 So, the handling should get handled by the view. This is here more as a81 last resort (i.e., this is code that can potentially be removed).82 */83 - (void)keyDown:(NSEvent *)theEvent84 {85 bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);86 if (!keyOK)87 [super keyDown:theEvent];88 }89 90 - (void)keyUp:(NSEvent *)theEvent91 {92 bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);93 if (!keyOK)94 [super keyUp:theEvent];95 }96 97 127 - (void)flagsChanged:(NSEvent *)theEvent 98 128 { … … 107 137 } 108 138 139 - (void)qtDispatcherToQAction:(id)sender 140 { 141 // If this window is modal, the menu bar will be modally shaddowed. 142 // In that case, since the window will be in the first responder chain, 143 // we can still catch the trigger here and forward it to the menu bar. 144 // This is needed as a single modal dialog on Qt should be able to access 145 // the application menu (e.g. quit). 146 [[NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)] qtDispatcherToQAction:sender]; 147 } 148 149 - (void)terminate:(id)sender 150 { 151 // This function is called from the quit item in the menubar when this window 152 // is in the first responder chain (see also qtDispatcherToQAction above) 153 [NSApp terminate:sender]; 154 } 155 109 156 - (void)sendEvent:(NSEvent *)event 110 157 { 158 if ([event type] == NSApplicationDefined) { 159 switch ([event subtype]) { 160 case QtCocoaEventSubTypePostMessage: 161 [NSApp qt_sendPostedMessage:event]; 162 return; 163 default: 164 break; 165 } 166 return; 167 } 168 111 169 QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; 112 113 170 // Cocoa can hold onto the window after we've disavowed its knowledge. So, 114 171 // if we get sent an event afterwards just have it go through the super's … … 126 183 // sometimes need to redirect mouse events to the popup. 127 184 QWidget *popup = qAppInstance()->activePopupWidget(); 128 if (popup ) {185 if (popup && popup != widget) { 129 186 switch([event type]) 130 187 { … … 134 191 handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton); 135 192 // Don't call super here. This prevents us from getting the mouseUp event, 136 // which we need to send even if the mouseDown event was not accepted. 193 // which we need to send even if the mouseDown event was not accepted. 137 194 // (this is standard Qt behavior.) 138 195 break; … … 173 230 } 174 231 232 - (void)setInitialFirstResponder:(NSView *)view 233 { 234 // This method is called the first time the window is placed on screen and 235 // is the earliest point in time we can connect OpenGL contexts to NSViews. 236 QWidget *qwidget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; 237 if (qwidget) { 238 qt_event_request_window_change(qwidget); 239 qt_mac_send_posted_gl_updates(qwidget); 240 } 241 242 [super setInitialFirstResponder:view]; 243 } 244 175 245 - (BOOL)makeFirstResponder:(NSResponder *)responder 176 246 { … … 189 259 } 190 260 261 -(void)registerDragTypes 262 { 263 // Calling registerForDraggedTypes below is slow, so only do 264 // it once for each window, or when the custom types change. 265 QMacCocoaAutoReleasePool pool; 266 const QStringList& customTypes = qEnabledDraggedTypes(); 267 if (currentCustomDragTypes == 0 || *currentCustomDragTypes != customTypes) { 268 if (currentCustomDragTypes == 0) 269 currentCustomDragTypes = new QStringList(); 270 *currentCustomDragTypes = customTypes; 271 const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName"; 272 NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType, 273 NSFilenamesPboardType, NSStringPboardType, 274 NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType, 275 NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType, 276 NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType, 277 NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType, 278 NSURLPboardType, NSPDFPboardType, NSVCardPboardType, 279 NSFilesPromisePboardType, NSInkTextPboardType, 280 NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil]; 281 // Add custom types supported by the application. 282 for (int i = 0; i < customTypes.size(); i++) { 283 [supportedTypes addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(customTypes[i]))]; 284 } 285 [self registerForDraggedTypes:supportedTypes]; 286 } 287 } 288 289 - (QWidget *)dragTargetHitTest:(id <NSDraggingInfo>)sender 290 { 291 // Do a hittest to find the NSView under the 292 // mouse, and return the corresponding QWidget: 293 NSPoint windowPoint = [sender draggingLocation]; 294 NSView *candidateView = [[self contentView] hitTest:windowPoint]; 295 if (![candidateView isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) 296 return 0; 297 return [static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(candidateView) qt_qwidget]; 298 } 299 300 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender 301 { 302 // The user dragged something into the window. Send a draggingEntered message 303 // to the QWidget under the mouse. As the drag moves over the window, and over 304 // different widgets, we will handle enter and leave events from within 305 // draggingUpdated below. The reason why we handle this ourselves rather than 306 // subscribing for drag events directly in QCocoaView is that calling 307 // registerForDraggedTypes on the views will severly degrade initialization time 308 // for an application that uses a lot of drag subscribing widgets. 309 310 QWidget *target = [self dragTargetHitTest:sender]; 311 if (!target) 312 return [super draggingEntered:sender]; 313 if (target->testAttribute(Qt::WA_DropSiteRegistered) == false) 314 return NSDragOperationNone; 315 316 *currentDragTarget() = target; 317 return [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingEntered:sender]; 318 } 319 320 - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender 321 { 322 QWidget *target = [self dragTargetHitTest:sender]; 323 if (!target) 324 return [super draggingUpdated:sender]; 325 326 if (target == *currentDragTarget()) { 327 // The drag continues to move over the widget that we have sendt 328 // a draggingEntered message to. So just update the view: 329 return [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingUpdated:sender]; 330 } else { 331 // The widget under the mouse has changed. 332 // So we need to fake enter/leave events: 333 if (*currentDragTarget()) 334 [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingExited:sender]; 335 if (target->testAttribute(Qt::WA_DropSiteRegistered) == false) { 336 *currentDragTarget() = 0; 337 return NSDragOperationNone; 338 } 339 *currentDragTarget() = target; 340 return [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingEntered:sender]; 341 } 342 } 343 344 - (void)draggingExited:(id < NSDraggingInfo >)sender 345 { 346 QWidget *target = [self dragTargetHitTest:sender]; 347 if (!target) 348 return [super draggingExited:sender]; 349 350 if (*currentDragTarget()) { 351 [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) draggingExited:sender]; 352 *currentDragTarget() = 0; 353 } 354 } 355 356 - (BOOL)performDragOperation:(id < NSDraggingInfo >)sender 357 { 358 QWidget *target = [self dragTargetHitTest:sender]; 359 if (!target) 360 return [super performDragOperation:sender]; 361 362 BOOL dropResult = NO; 363 if (*currentDragTarget()) { 364 dropResult = [reinterpret_cast<NSView *>((*currentDragTarget())->winId()) performDragOperation:sender]; 365 *currentDragTarget() = 0; 366 } 367 return dropResult; 368 } 369 191 370 - (void)displayIfNeeded 192 371 { … … 205 384 } 206 385 207 386 // This is a hack and it should be removed once we find the real cause for 387 // the painting problems. 388 // We have a static variable that signals if we have been called before or not. 389 static bool firstDrawingInvocation = true; 390 391 // The method below exists only as a workaround to draw/not draw the baseline 392 // in the title bar. This is to support unifiedToolbar look. 393 394 // This method is very special. To begin with, it is a 395 // method that will get called only if we enable documentMode. 396 // Furthermore, it won't get called as a normal method, we swap 397 // this method with the normal implementation of drawRect in 398 // _NSThemeFrame. When this method is active, its mission is to 399 // first call the original drawRect implementation so the widget 400 // gets proper painting. After that, it needs to detect if there 401 // is a toolbar or not, in order to decide how to handle the unified 402 // look. The distinction is important since the presence and 403 // visibility of a toolbar change the way we enter into unified mode. 404 // When there is a toolbar and that toolbar is visible, the problem 405 // is as simple as to tell the toolbar not to draw its baseline. 406 // However when there is not toolbar or the toolbar is not visible, 407 // we need to draw a line on top of the baseline, because the baseline 408 // in that case will belong to the title. For this case we need to draw 409 // a line on top of the baseline. 410 // As usual, there is a special case. When we first are called, we might 411 // need to repaint ourselves one more time. We only need that if we 412 // didn't get the activation, i.e. when we are launched via the command 413 // line. And this only if the toolbar is visible from the beginning, 414 // so we have a special flag that signals if we need to repaint or not. 415 - (void)drawRectSpecial:(NSRect)rect 416 { 417 // Call the original drawing method. 418 [self drawRectOriginal:rect]; 419 NSWindow *window = [self window]; 420 NSToolbar *toolbar = [window toolbar]; 421 if(!toolbar) { 422 // There is no toolbar, we have to draw a line on top of the line drawn by Cocoa. 423 macDrawRectOnTop((void *)window); 424 } else { 425 if([toolbar isVisible]) { 426 // We tell Cocoa to avoid drawing the line at the end. 427 if(firstDrawingInvocation) { 428 firstDrawingInvocation = false; 429 macSyncDrawingOnFirstInvocation((void *)window); 430 } else 431 [toolbar setShowsBaselineSeparator:NO]; 432 } else { 433 // There is a toolbar but it is not visible so 434 // we have to draw a line on top of the line drawn by Cocoa. 435 macDrawRectOnTop((void *)window); 436 } 437 } 438 } -
trunk/src/gui/kernel/qcocoaview_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 82 82 extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp 83 83 extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm 84 extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp85 84 extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm 86 85 extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp 87 88 Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum) 89 { 90 if (buttonNum == 0) 91 return Qt::LeftButton; 92 if (buttonNum == 1) 93 return Qt::RightButton; 94 if (buttonNum == 2) 95 return Qt::MidButton; 96 if (buttonNum == 3) 97 return Qt::XButton1; 98 if (buttonNum == 4) 99 return Qt::XButton2; 100 return Qt::NoButton; 101 } 86 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); 102 87 103 88 struct dndenum_mapper … … 201 186 } 202 187 188 #ifdef ALIEN_DEBUG 189 static int qCocoaViewCount = 0; 190 #endif 203 191 204 192 @implementation QT_MANGLE_NAMESPACE(QCocoaView) … … 210 198 [self finishInitWithQWidget:widget widgetPrivate:widgetprivate]; 211 199 } 200 [self setFocusRingType:NSFocusRingTypeNone]; 212 201 composingText = new QString(); 202 203 #ifdef ALIEN_DEBUG 204 ++qCocoaViewCount; 205 qDebug() << "init: qCocoaViewCount is" << qCocoaViewCount; 206 #endif 207 213 208 composing = false; 214 209 sendKeyEvents = true; 215 currentCustomTypes = 0;216 210 [self setHidden:YES]; 217 211 return self; … … 228 222 } 229 223 230 -(void)registerDragTypes231 {232 QMacCocoaAutoReleasePool pool;233 // Calling registerForDraggedTypes is slow, so only do it once for each widget234 // or when the custom types change.235 const QStringList& customTypes = qEnabledDraggedTypes();236 if (currentCustomTypes == 0 || *currentCustomTypes != customTypes) {237 if (currentCustomTypes == 0)238 currentCustomTypes = new QStringList();239 *currentCustomTypes = customTypes;240 const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName";241 NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType,242 NSFilenamesPboardType, NSStringPboardType,243 NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType,244 NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType,245 NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType,246 NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType,247 NSURLPboardType, NSPDFPboardType, NSVCardPboardType,248 NSFilesPromisePboardType, NSInkTextPboardType,249 NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil];250 // Add custom types supported by the application.251 for (int i = 0; i < customTypes.size(); i++) {252 [supportedTypes addObject:reinterpret_cast<const NSString *>(QCFString::toCFStringRef(customTypes[i]))];253 }254 [self registerForDraggedTypes:supportedTypes];255 }256 }257 258 224 - (void)resetCursorRects 259 225 { 226 // [NSView addCursorRect] is slow, so bail out early if we can: 227 if (NSIsEmptyRect([self visibleRect])) 228 return; 229 260 230 QWidget *cursorWidget = qwidget; 261 231 … … 273 243 QRegion mask = qt_widget_private(cursorWidget)->extra->mask; 274 244 NSCursor *nscursor = static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursorWidget->cursor())); 275 if (mask.isEmpty()) { 245 // The mask could have the WA_MouseNoMask attribute set and that means that we have to ignore the mask. 246 if (mask.isEmpty() || cursorWidget->testAttribute(Qt::WA_MouseNoMask)) { 276 247 [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor]; 277 248 } else { … … 299 270 } 300 271 272 - (void)changeDraggingCursor:(NSDragOperation)newOperation 273 { 274 static SEL action = nil; 275 static bool operationSupported = false; 276 if (action == nil) { 277 action = NSSelectorFromString(@"operationNotAllowedCursor"); 278 if ([NSCursor respondsToSelector:action]) { 279 operationSupported = true; 280 } 281 } 282 if (operationSupported) { 283 NSCursor *notAllowedCursor = [NSCursor performSelector:action]; 284 bool isNotAllowedCursor = ([NSCursor currentCursor] == notAllowedCursor); 285 if (newOperation == NSDragOperationNone && !isNotAllowedCursor) { 286 [notAllowedCursor push]; 287 } else if (newOperation != NSDragOperationNone && isNotAllowedCursor) { 288 [notAllowedCursor pop]; 289 } 290 291 } 292 } 293 301 294 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender 302 295 { 303 if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false)304 return NSDragOperationNone;296 // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly 297 // from Cocoa. They modify the drag target, and might fake enter/leave events. 305 298 NSPoint windowPoint = [sender draggingLocation]; 306 if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {307 // pass the drag enter event to the view underneath.308 NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];309 if (candidateView && candidateView != self)310 return [candidateView draggingEntered:sender];311 }312 299 dragEnterSequence = [sender draggingSequenceNumber]; 313 300 [self addDropData:sender]; … … 336 323 // widget is not interested in this drag, so ignore this drop data. 337 324 [self removeDropData]; 325 [self changeDraggingCursor:NSDragOperationNone]; 338 326 return NSDragOperationNone; 339 327 } else { … … 357 345 } 358 346 QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent); 347 [self changeDraggingCursor:nsActions]; 359 348 return nsActions; 360 349 } … … 362 351 - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender 363 352 { 353 // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly 354 // from Cocoa. They modify the drag target, and might fake enter/leave events. 364 355 NSPoint windowPoint = [sender draggingLocation]; 365 if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {366 // pass the drag move event to the view underneath.367 NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];368 if (candidateView && candidateView != self)369 return [candidateView draggingUpdated:sender];370 }371 356 // in cases like QFocusFrame, the view under the mouse might 372 357 // not have received the drag enter. Generate a synthetic … … 375 360 [self draggingEntered:sender]; 376 361 // drag enter event was rejected, so ignore the move event. 377 if (dropData == 0) 362 if (dropData == 0) { 363 [self changeDraggingCursor:NSDragOperationNone]; 378 364 return NSDragOperationNone; 365 } 379 366 // return last value, if we are still in the answerRect. 380 367 NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint]; … … 383 370 QPoint posDrag(localPoint.x, localPoint.y); 384 371 if (qt_mac_mouse_inside_answer_rect(posDrag) 385 && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) 386 return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction)); 372 && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) { 373 NSDragOperation operation = QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction)); 374 [self changeDraggingCursor:operation]; 375 return operation; 376 } 387 377 // send drag move event to the widget 388 378 QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions; … … 401 391 mimeData = QDragManager::self()->dragPrivate()->data; 402 392 QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers); 403 qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction); 393 if (QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction != Qt::IgnoreAction 394 && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).buttons == qDMEvent.mouseButtons() 395 && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).modifiers == qDMEvent.keyboardModifiers()) 396 qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction); 404 397 qDMEvent.accept(); 405 398 QApplication::sendEvent(qwidget, &qDMEvent); … … 413 406 } 414 407 qt_mac_copy_answer_rect(qDMEvent); 408 [self changeDraggingCursor:operation]; 415 409 return operation; 416 410 } … … 418 412 - (void)draggingExited:(id < NSDraggingInfo >)sender 419 413 { 414 // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly 415 // from Cocoa. They modify the drag target, and might fake enter/leave events. 416 Q_UNUSED(sender); 420 417 dragEnterSequence = -1; 421 if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {422 // try sending the leave event to the last view which accepted drag enter.423 DnDParams *dndParams = [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent];424 NSView *candidateView = [[[self window] contentView] hitTest:dndParams->activeDragEnterPos];425 if (candidateView && candidateView != self)426 return [candidateView draggingExited:sender];427 }428 418 // drag enter event was rejected, so ignore the move event. 429 419 if (dropData) { … … 432 422 [self removeDropData]; 433 423 } 424 [self changeDraggingCursor:NSDragOperationEvery]; 425 434 426 } 435 427 436 428 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender 437 429 { 430 // NB: This function is called from QCoocaWindow/QCocoaPanel rather than directly 431 // from Cocoa. They modify the drag target, and might fake enter/leave events. 438 432 NSPoint windowPoint = [sender draggingLocation]; 439 433 dragEnterSequence = -1; 440 if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) {441 // pass the drop event to the view underneath.442 NSView *candidateView = [[[self window] contentView] hitTest:windowPoint];443 if (candidateView && candidateView != self)444 return [candidateView performDragOperation:sender];445 }446 434 [self addDropData:sender]; 447 435 … … 473 461 delete composingText; 474 462 [[NSNotificationCenter defaultCenter] removeObserver:self]; 475 delete currentCustomTypes; 476 [self unregisterDraggedTypes]; 463 464 #ifdef ALIEN_DEBUG 465 --qCocoaViewCount; 466 qDebug() << "qCocoaViewCount is" << qCocoaViewCount; 467 #endif 468 477 469 [super dealloc]; 478 470 } … … 480 472 - (BOOL)isOpaque; 481 473 { 474 if (!qwidgetprivate) 475 return [super isOpaque]; 482 476 return qwidgetprivate->isOpaque; 483 477 } … … 488 482 } 489 483 490 - (BOOL) preservesContentDuringLiveResize; 484 // We preserve the content of the view if WA_StaticContents is defined. 485 // 486 // More info in the Cocoa documentation: 487 // http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CocoaViewsGuide/Optimizing/Optimizing.html 488 - (BOOL) preservesContentDuringLiveResize 491 489 { 492 490 return qwidget->testAttribute(Qt::WA_StaticContents); … … 511 509 512 510 // Make sure the opengl context is updated on resize. 513 if (qwidgetprivate ->isGLWidget) {511 if (qwidgetprivate && qwidgetprivate->isGLWidget) { 514 512 qwidgetprivate->needWindowChange = true; 515 513 QEvent event(QEvent::MacGLWindowChange); … … 518 516 } 519 517 518 // We catch the 'setNeedsDisplay:' message in order to avoid a useless full repaint. 519 // During the resize, the top of the widget is repainted, probably because of the 520 // change of coordinate space (Quartz vs Qt). This is then followed by this message: 521 // -[NSView _setNeedsDisplayIfTopLeftChanged] 522 // which force a full repaint by sending the message 'setNeedsDisplay:'. 523 // That is what we are preventing here. 524 - (void)setNeedsDisplay:(BOOL)flag { 525 if (![self inLiveResize] || !(qwidget->testAttribute(Qt::WA_StaticContents))) { 526 [super setNeedsDisplay:flag]; 527 } 528 } 529 520 530 - (void)drawRect:(NSRect)aRect 521 531 { 532 if (!qwidget) 533 return; 534 522 535 if (QApplicationPrivate::graphicsSystem() != 0) { 523 if ( QWidgetBackingStore *bs =qwidgetprivate->maybeBackingStore()) {536 if (qwidgetprivate->maybeBackingStore()) { 524 537 // Drawing is handled on the window level 525 // See qcocoasharedwindowmethods_mac_p. 526 return; 538 // See qcocoasharedwindowmethods_mac_p.h 539 if (!qwidget->testAttribute(Qt::WA_PaintOnScreen)) 540 return; 527 541 } 528 542 } … … 536 550 537 551 const QRect qrect = QRect(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height); 538 QRegion qrgn(qrect); 552 QRegion qrgn; 553 554 const NSRect *rects; 555 NSInteger count; 556 [self getRectsBeingDrawn:&rects count:&count]; 557 for (int i = 0; i < count; ++i) { 558 QRect tmpRect = QRect(rects[i].origin.x, rects[i].origin.y, rects[i].size.width, rects[i].size.height); 559 qrgn += tmpRect; 560 } 539 561 540 562 if (!qwidget->isWindow() && !qobject_cast<QAbstractScrollArea *>(qwidget->parent())) { … … 570 592 } 571 593 594 // Check for alien widgets, use qwidgetPrivate->drawWidget() to draw the widget if this 595 // is the case. This makes sure child widgets are drawn as well, Cocoa does not know about 596 // those and wont send them drawRect calls. 597 if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false) { 572 598 if (engine && !qwidget->testAttribute(Qt::WA_NoSystemBackground) 573 599 && (qwidget->isWindow() || qwidget->autoFillBackground()) … … 589 615 #endif 590 616 qt_sendSpontaneousEvent(qwidget, &e); 617 } else { 618 qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false); // QWidgetPrivate::drawWidget sets this 619 QWidgetPrivate *qwidgetPrivate = qt_widget_private(qwidget); 620 qwidgetPrivate->drawWidget(qwidget, qrgn, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen | QWidgetPrivate::DrawRecursive, 0); 621 } 622 591 623 if (!redirectionOffset.isNull()) 592 624 QPainter::restoreRedirected(qwidget); … … 604 636 - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent 605 637 { 638 if (!qwidget) 639 return NO; 640 606 641 Q_UNUSED(theEvent); 607 642 return !qwidget->testAttribute(Qt::WA_MacNoClickThrough); … … 610 645 - (NSView *)hitTest:(NSPoint)aPoint 611 646 { 647 if (!qwidget) 648 return [super hitTest:aPoint]; 649 612 650 if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents)) 613 651 return nil; // You cannot hit a transparent for mouse event widget. … … 617 655 - (void)updateTrackingAreas 618 656 { 657 if (!qwidget) 658 return; 659 660 // [NSView addTrackingArea] is slow, so bail out early if we can: 661 if (NSIsEmptyRect([self visibleRect])) 662 return; 663 619 664 QMacCocoaAutoReleasePool pool; 620 665 if (NSArray *trackingArray = [self trackingAreas]) { … … 646 691 - (void)mouseEntered:(NSEvent *)event 647 692 { 693 if (!qwidget) 694 return; 648 695 if (qwidgetprivate->data.in_destructor) 649 696 return; 650 QEvent enterEvent(QEvent::Enter); 651 NSPoint windowPoint = [event locationInWindow]; 652 NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint]; 653 NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil]; 697 654 698 if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) { 699 QEvent enterEvent(QEvent::Enter); 700 NSPoint windowPoint = [event locationInWindow]; 701 NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint]; 702 NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil]; 655 703 QApplication::sendEvent(qwidget, &enterEvent); 656 704 qt_mouseover = qwidget; 657 705 658 // Update cursor and dispatch hover events.706 // Update cursor icon: 659 707 qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint()); 660 if (qwidget->testAttribute(Qt::WA_Hover) && 661 (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window())) { 662 QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1)); 663 QApplicationPrivate::instance()->notify_helper(qwidget, &he); 708 709 // Send mouse move and hover events as well: 710 if (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window()) { 711 // This mouse move event should be sendt, even when mouse 712 // tracking is switched off (to trigger tooltips): 713 NSEvent *mouseEvent = [NSEvent mouseEventWithType:NSMouseMoved 714 location:windowPoint modifierFlags:[event modifierFlags] timestamp:[event timestamp] 715 windowNumber:[event windowNumber] context:[event context] eventNumber:[event eventNumber] 716 clickCount:0 pressure:0]; 717 qt_mac_handleMouseEvent(self, mouseEvent, QEvent::MouseMove, Qt::NoButton); 718 719 if (qwidget->testAttribute(Qt::WA_Hover)) { 720 QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1)); 721 QApplicationPrivate::instance()->notify_helper(qwidget, &he); 722 } 664 723 } 665 724 } … … 668 727 - (void)mouseExited:(NSEvent *)event 669 728 { 729 if (!qwidget) 730 return; 731 670 732 QEvent leaveEvent(QEvent::Leave); 671 733 NSPoint globalPoint = [[event window] convertBaseToScreen:[event locationInWindow]]; … … 686 748 - (void)flagsChanged:(NSEvent *)theEvent 687 749 { 750 if (!qwidget) 751 return; 752 688 753 QWidget *widgetToGetKey = qwidget; 689 754 … … 697 762 - (void)mouseMoved:(NSEvent *)theEvent 698 763 { 764 if (!qwidget) 765 return; 766 699 767 // We always enable mouse tracking for all QCocoaView-s. In cases where we have 700 768 // child views, we will receive mouseMoved for both parent & the child (if … … 816 884 // Since deviceDelta is delivered as pixels rather than degrees, we need to 817 885 // convert from pixels to degrees in a sensible manner. 818 // It looks like four degrees per pixel behaves most native. 819 // Qt expects the unit for delta to be 1/8 of a degree: 820 deltaX = [theEvent deviceDeltaX]; 821 deltaY = [theEvent deviceDeltaY]; 822 deltaZ = [theEvent deviceDeltaZ]; 886 // It looks like 1/4 degrees per pixel behaves most native. 887 // (NB: Qt expects the unit for delta to be 8 per degree): 888 const int pixelsToDegrees = 2; // 8 * 1/4 889 deltaX = [theEvent deviceDeltaX] * pixelsToDegrees; 890 deltaY = [theEvent deviceDeltaY] * pixelsToDegrees; 891 deltaZ = [theEvent deviceDeltaZ] * pixelsToDegrees; 823 892 } else { 824 893 // carbonEventKind == kEventMouseWheelMoved … … 871 940 } 872 941 #endif //QT_NO_WHEELEVENT 873 874 if (!wheelOK) {875 return [super scrollWheel:theEvent];876 }877 942 } 878 943 … … 919 984 return; 920 985 986 #ifndef QT_NO_GESTURES 921 987 QNativeGestureEvent qNGEvent; 922 988 qNGEvent.gestureType = QNativeGestureEvent::Zoom; … … 925 991 qNGEvent.percentage = [event magnification]; 926 992 qt_sendSpontaneousEvent(qwidget, &qNGEvent); 993 #endif // QT_NO_GESTURES 927 994 } 928 995 … … 932 999 return; 933 1000 1001 #ifndef QT_NO_GESTURES 934 1002 QNativeGestureEvent qNGEvent; 935 1003 qNGEvent.gestureType = QNativeGestureEvent::Rotate; … … 938 1006 qNGEvent.percentage = -[event rotation]; 939 1007 qt_sendSpontaneousEvent(qwidget, &qNGEvent); 1008 #endif // QT_NO_GESTURES 940 1009 } 941 1010 … … 945 1014 return; 946 1015 1016 #ifndef QT_NO_GESTURES 947 1017 QNativeGestureEvent qNGEvent; 948 1018 qNGEvent.gestureType = QNativeGestureEvent::Swipe; … … 958 1028 qNGEvent.angle = 270.0f; 959 1029 qt_sendSpontaneousEvent(qwidget, &qNGEvent); 1030 #endif // QT_NO_GESTURES 960 1031 } 961 1032 … … 965 1036 return; 966 1037 1038 #ifndef QT_NO_GESTURES 967 1039 QNativeGestureEvent qNGEvent; 968 1040 qNGEvent.gestureType = QNativeGestureEvent::GestureBegin; … … 970 1042 qNGEvent.position = flipPoint(p).toPoint(); 971 1043 qt_sendSpontaneousEvent(qwidget, &qNGEvent); 1044 #endif // QT_NO_GESTURES 972 1045 } 973 1046 … … 977 1050 return; 978 1051 1052 #ifndef QT_NO_GESTURES 979 1053 QNativeGestureEvent qNGEvent; 980 1054 qNGEvent.gestureType = QNativeGestureEvent::GestureEnd; … … 982 1056 qNGEvent.position = flipPoint(p).toPoint(); 983 1057 qt_sendSpontaneousEvent(qwidget, &qNGEvent); 1058 #endif // QT_NO_GESTURES 984 1059 } 985 1060 … … 987 1062 { 988 1063 Q_UNUSED(note); 1064 if (!qwidget) 1065 return; 989 1066 if (qwidget->isWindow()) 990 1067 return; … … 1010 1087 QMacCocoaAutoReleasePool pool; 1011 1088 [super setEnabled:flag]; 1012 if (qwidget ->isEnabled() != flag)1089 if (qwidget && qwidget->isEnabled() != flag) 1013 1090 qwidget->setEnabled(flag); 1014 1091 } … … 1021 1098 - (BOOL)acceptsFirstResponder 1022 1099 { 1023 if (qwidget->isWindow()) 1100 if (!qwidget) 1101 return NO; 1102 // disabled widget shouldn't get focus even if it's a window. 1103 // hence disabled windows will not get any key or mouse events. 1104 if (!qwidget->isEnabled()) 1105 return NO; 1106 // Before accepting the focus for a window, we check that 1107 // the focusWidget (if any) is not contained in the same window. 1108 if (qwidget->isWindow() && !qt_widget_private(qwidget)->topData()->embedded 1109 && (!qApp->focusWidget() || qApp->focusWidget()->window() != qwidget)) { 1024 1110 return YES; // Always do it, so that windows can accept key press events. 1111 } 1025 1112 return qwidget->focusPolicy() != Qt::NoFocus; 1026 1113 } … … 1028 1115 - (BOOL)resignFirstResponder 1029 1116 { 1117 if (!qwidget) 1118 return NO; 1030 1119 // Seems like the following test only triggers if this 1031 1120 // view is inside a QMacNativeWidget: 1032 1121 if (qwidget == QApplication::focusWidget()) 1033 QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); 1122 qwidget->clearFocus(); 1123 return YES; 1124 } 1125 1126 - (BOOL)becomeFirstResponder 1127 { 1128 // see the comment in the acceptsFirstResponder - if the window "stole" focus 1129 // let it become the responder, but don't tell Qt 1130 if (qwidget && qt_widget_private(qwidget->window())->topData()->embedded 1131 && !QApplication::focusWidget() && qwidget->focusPolicy() != Qt::NoFocus) 1132 qwidget->setFocus(Qt::OtherFocusReason); 1034 1133 return YES; 1035 1134 } … … 1063 1162 } 1064 1163 1164 - (void) qt_clearQWidget 1165 { 1166 qwidget = 0; 1167 qwidgetprivate = 0; 1168 } 1169 1065 1170 - (BOOL)qt_leftButtonIsRightButton 1066 1171 { … … 1099 1204 if (sendKeyEvents && !composing) { 1100 1205 bool keyOK = qt_dispatchKeyEvent(theEvent, widgetToGetKey); 1101 if (!keyOK && !sendToPopup) 1102 [super keyDown:theEvent]; 1206 if (!keyOK && !sendToPopup) { 1207 // find the first responder that is not created by Qt and forward 1208 // the event to it (for example if Qt widget is embedded into native). 1209 QWidget *toplevel = qwidget->window(); 1210 if (toplevel && qt_widget_private(toplevel)->topData()->embedded) { 1211 if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview]) 1212 [w keyDown:theEvent]; 1213 } 1214 } 1103 1215 } 1104 1216 } … … 1109 1221 if (sendKeyEvents) { 1110 1222 bool keyOK = qt_dispatchKeyEvent(theEvent, qwidget); 1111 if (!keyOK) 1112 [super keyUp:theEvent]; 1223 if (!keyOK) { 1224 QWidget *toplevel = qwidget->window(); 1225 if (toplevel && qt_widget_private(toplevel)->topData()->embedded) { 1226 if (NSResponder *w = [qt_mac_nativeview_for(toplevel) superview]) 1227 [w keyUp:theEvent]; 1228 } 1229 } 1113 1230 } 1114 1231 } … … 1116 1233 - (void)viewWillMoveToWindow:(NSWindow *)window 1117 1234 { 1235 if (qwidget == 0) 1236 return; 1237 1118 1238 if (qwidget->windowFlags() & Qt::MSWindowsOwnDC 1119 1239 && (window != [self window])) { // OpenGL Widget 1120 // Create a stupid ClearDrawable Event1121 1240 QEvent event(QEvent::MacGLClearDrawable); 1122 1241 qApp->sendEvent(qwidget, &event); … … 1126 1245 - (void)viewDidMoveToWindow 1127 1246 { 1247 if (qwidget == 0) 1248 return; 1249 1128 1250 if (qwidget->windowFlags() & Qt::MSWindowsOwnDC && [self window]) { 1129 1251 // call update paint event … … 1321 1443 - (NSArray*) validAttributesForMarkedText 1322 1444 { 1445 if (qwidget == 0) 1446 return nil; 1447 1323 1448 if (!qwidget->testAttribute(Qt::WA_InputMethodEnabled)) 1324 1449 return nil; // Not sure if that's correct, but it's saves a malloc. … … 1471 1596 [dndParams.view release]; 1472 1597 [image release]; 1473 dragPrivate()->executed_action = Qt::IgnoreAction; 1598 if (dragPrivate()) 1599 dragPrivate()->executed_action = Qt::IgnoreAction; 1474 1600 object = 0; 1475 1601 Qt::DropAction performedAction(qt_mac_mapNSDragOperation(qMacDnDParams()->performedAction)); … … 1493 1619 } 1494 1620 } 1621 o->setMimeData(0); 1622 o->deleteLater(); 1495 1623 return performedAction; 1496 1624 } -
trunk/src/gui/kernel/qcocoaview_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 88 88 bool sendKeyEvents; 89 89 QString *composingText; 90 QStringList *currentCustomTypes;91 90 NSInteger dragEnterSequence; 92 91 } … … 98 97 - (void)draggingExited:(id < NSDraggingInfo >)sender; 99 98 - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender; 100 - (void)registerDragTypes;101 99 - (void)removeDropData; 102 100 - (void)addDropData:(id <NSDraggingInfo>)sender; … … 106 104 - (BOOL)isComposing; 107 105 - (QWidget *)qt_qwidget; 106 - (void) qt_clearQWidget; 108 107 - (BOOL)qt_leftButtonIsRightButton; 109 108 - (void)qt_setLeftButtonIsRightButton:(BOOL)isSwapped; 109 - (void)changeDraggingCursor:(NSDragOperation)newOperation; 110 110 + (DnDParams*)currentMouseEvent; 111 111 -
trunk/src/gui/kernel/qcocoawindow_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #import <private/qt_cocoa_helpers_mac_p.h> 48 48 #import <private/qcocoawindowcustomthemeframe_mac_p.h> 49 #import <private/qcocoaapplication_mac_p.h> 49 50 50 51 #include <QtGui/QWidget> -
trunk/src/gui/kernel/qcocoawindow_mac_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 74 74 @interface QT_MANGLE_NAMESPACE(QCocoaWindow) : NSWindow { 75 75 bool leftButtonIsRightButton; 76 QStringList *currentCustomDragTypes; 76 77 } 77 78 78 79 + (Class)frameViewClassForStyleMask:(NSUInteger)styleMask; 80 - (void)registerDragTypes; 81 79 82 @end 80 83 #endif -
trunk/src/gui/kernel/qcocoawindowcustomthemeframe_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qcocoawindowcustomthemeframe_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qcocoawindowdelegate_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 203 203 & ~Qt::WindowMaximized)); 204 204 qt_sendSpontaneousEvent(qwidget, &e); 205 } else { 206 widgetData->window_state = widgetData->window_state & ~Qt::WindowMaximized; 207 QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state 208 | Qt::WindowMaximized)); 209 qt_sendSpontaneousEvent(qwidget, &e); 205 210 } 206 211 NSRect rect = [[window contentView] frame]; … … 270 275 QWidget *qwidget = m_windowHash->value([notification object]); 271 276 Q_ASSERT(qwidget); 272 if (qwidget->isActiveWindow())273 return; // Widget is already active, no need to go through re-activation.274 275 277 onApplicationWindowChangedActivation(qwidget, true); 276 278 } … … 289 291 QWidget *qwidget = m_windowHash->value([notification object]); 290 292 Q_ASSERT(qwidget); 291 if (qwidget->isActiveWindow())292 return; // Widget is already active, no need to go through re-activation293 294 295 293 onApplicationWindowChangedActivation(qwidget, true); 296 294 } … … 313 311 // saving the current window geometry before the window is maximized 314 312 QWidget *qwidget = m_windowHash->value(window); 315 if (qwidget->isWindow() && !(qwidget->windowState() & Qt::WindowMaximized)) { 316 QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); 317 widgetPrivate->topData()->normalGeometry = qwidget->geometry(); 313 QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); 314 if (qwidget->isWindow()) { 315 if(qwidget->windowState() & Qt::WindowMaximized) { 316 // Restoring 317 widgetPrivate->topData()->wasMaximized = false; 318 } else { 319 // Maximizing 320 widgetPrivate->topData()->normalGeometry = qwidget->geometry(); 321 // If the window was maximized we need to update the coordinates since now it will start at 0,0. 322 // We do this in a special field that is only used when not restoring but manually resizing the window. 323 // Since the coordinates are fixed we just set a boolean flag. 324 widgetPrivate->topData()->wasMaximized = true; 325 } 318 326 } 319 327 return YES; … … 387 395 return NO; 388 396 } 397 398 - (void)syncContentViewFrame: (NSNotification *)notification 399 { 400 NSView *cView = [notification object]; 401 if (cView) { 402 NSWindow *window = [cView window]; 403 QWidget *qwidget = m_windowHash->value(window); 404 if (qwidget) { 405 QWidgetData *widgetData = qt_qwidget_data(qwidget); 406 NSRect rect = [cView frame]; 407 const QSize newSize(rect.size.width, rect.size.height); 408 const QSize &oldSize = widgetData->crect.size(); 409 if (newSize != oldSize) { 410 [self syncSizeForWidget:qwidget toSize:newSize fromSize:oldSize]; 411 } 412 } 413 414 } 415 } 416 389 417 @end 390 418 #endif// QT_MAC_USE_COCOA -
trunk/src/gui/kernel/qcocoawindowdelegate_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 106 106 window:(NSWindow *)window withNewSize:(NSSize)proposedSize; 107 107 - (QWidget *)qt_qwidgetForWindow:(NSWindow *)window; 108 - (void)syncContentViewFrame: (NSNotification *)notification; 108 109 @end 109 110 #endif -
trunk/src/gui/kernel/qcursor.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 142 142 \o \inlineimage cursor-closedhand.png 143 143 \o Qt::ClosedHandCursor \o \c closedhand 144 \row \o 145 \o Qt::DragMoveCursor \o \c dnd-move or \c move 146 \o 147 \o Qt::DragCopyCursor \o \c dnd-copy or \c copy 148 \row \o 149 \o Qt::DragLinkCursor \o \c dnd-link or \c link 144 150 \endtable 145 151 … … 224 230 Writes the \a cursor to the \a stream. 225 231 226 \sa { Format of the QDataStream operators}232 \sa {Serializing Qt Data Types} 227 233 */ 228 234 … … 251 257 Reads the \a cursor from the \a stream. 252 258 253 \sa { Format of the QDataStream operators}259 \sa {Serializing Qt Data Types} 254 260 */ 255 261 -
trunk/src/gui/kernel/qcursor.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qcursor_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 115 115 c->handle(); //force the cursor to get loaded, if it's not 116 116 117 if(1 || currentCursor != c->d) { 118 if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor 119 && currentCursor->curs.tc.anim) 120 currentCursor->curs.tc.anim->stop(); 121 QMacCocoaAutoReleasePool pool; 122 if(c->d->type == QCursorData::TYPE_ImageCursor) { 123 [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set]; 124 } else if(c->d->type == QCursorData::TYPE_ThemeCursor) { 125 #ifdef QT_MAC_USE_COCOA 126 if (c->d->curs.cp.nscursor == 0) 127 [[NSCursor arrowCursor] set]; 128 [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set]; 129 #else 130 if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) { 131 SetThemeCursor(c->d->curs.tc.curs); 132 } else { 133 if(!c->d->curs.tc.anim) 134 c->d->curs.tc.anim = new QMacAnimateCursor; 135 c->d->curs.tc.anim->start(c->d->curs.tc.curs); 136 } 137 #endif 117 if(currentCursor && currentCursor->type == QCursorData::TYPE_ThemeCursor 118 && currentCursor->curs.tc.anim) 119 currentCursor->curs.tc.anim->stop(); 120 if(c->d->type == QCursorData::TYPE_ImageCursor) { 121 [static_cast<NSCursor *>(c->d->curs.cp.nscursor) set]; 122 } else if(c->d->type == QCursorData::TYPE_ThemeCursor) { 123 if(SetAnimatedThemeCursor(c->d->curs.tc.curs, 0) == themeBadCursorIndexErr) { 124 SetThemeCursor(c->d->curs.tc.curs); 125 } else { 126 if(!c->d->curs.tc.anim) 127 c->d->curs.tc.anim = new QMacAnimateCursor; 128 c->d->curs.tc.anim->start(c->d->curs.tc.curs); 138 129 } 139 130 } … … 234 225 void QCursor::setPos(int x, int y) 235 226 { 227 #ifdef QT_MAC_USE_COCOA 228 CGPoint pos; 229 pos.x = x; 230 pos.y = y; 231 232 CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0); 233 CGEventPost(kCGHIDEventTap, e); 234 CFRelease(e); 235 #else 236 236 CGWarpMouseCursorPosition(CGPointMake(x, y)); 237 237 … … 250 250 qt_sendSpontaneousEvent(widget, &me); 251 251 } 252 #endif 252 253 } 253 254 … … 425 426 curs.cp.nscursor = [NSCursor closedHandCursor]; 426 427 break; 428 case Qt::DragCopyCursor: 429 type = QCursorData::TYPE_ThemeCursor; 430 curs.cp.nscursor = [NSCursor dragCopyCursor]; 431 break; 432 case Qt::DragMoveCursor: 433 type = QCursorData::TYPE_ThemeCursor; 434 curs.cp.nscursor = [NSCursor arrowCursor]; 435 break; 436 case Qt::DragLinkCursor: 437 type = QCursorData::TYPE_ThemeCursor; 438 curs.cp.nscursor = [NSCursor dragLinkCursor]; 439 break; 427 440 #define QT_USE_APPROXIMATE_CURSORS 428 441 #ifdef QT_USE_APPROXIMATE_CURSORS … … 520 533 curs.tc.curs = kThemeClosedHandCursor; 521 534 break; 535 case Qt::DragMoveCursor: 536 type = QCursorData::TYPE_ThemeCursor; 537 curs.tc.curs = kThemeArrowCursor; 538 break; 539 case Qt::DragCopyCursor: 540 type = QCursorData::TYPE_ThemeCursor; 541 curs.tc.curs = kThemeCopyArrowCursor; 542 break; 543 case Qt::DragLinkCursor: 544 type = QCursorData::TYPE_ThemeCursor; 545 curs.tc.curs = kThemeAliasArrowCursor; 546 break; 522 547 #define QT_USE_APPROXIMATE_CURSORS 523 548 #ifdef QT_USE_APPROXIMATE_CURSORS -
trunk/src/gui/kernel/qcursor_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qcursor_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qcursor_s60.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 45 45 #include <coecntrl.h> 46 46 #include <qcursor.h> 47 #include < qt_s60_p.h>47 #include <private/qt_s60_p.h> 48 48 #include <qbitmap.h> 49 49 #include <w32std.h> … … 473 473 RWsPointerCursor *pcurs = reinterpret_cast<RWsPointerCursor *> (handle); 474 474 node.SetCustomPointerCursor(*pcurs); 475 } 475 } else 476 476 #ifdef Q_SYMBIAN_HAS_SYSTEM_CURSORS 477 else{477 { 478 478 TInt shape = qt_symbian_translate_cursor_shape(cursor.shape()); 479 479 node.SetPointerCursor(shape); -
trunk/src/gui/kernel/qcursor_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 48 48 #include <qimage.h> 49 49 #include <qt_windows.h> 50 #include <private/qapplication_p.h> 50 51 51 52 QT_BEGIN_NAMESPACE … … 471 472 return; 472 473 } 474 case Qt::DragCopyCursor: 475 case Qt::DragMoveCursor: 476 case Qt::DragLinkCursor: { 477 QPixmap pixmap = QApplicationPrivate::instance()->getPixmapCursor(cshape); 478 hcurs = create32BitCursor(pixmap, hx, hy); 479 } 473 480 default: 474 481 qWarning("QCursor::update: Invalid cursor shape %d", cshape); -
trunk/src/gui/kernel/qcursor_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 40 40 ****************************************************************************/ 41 41 42 #include <qdebug.h> 42 43 #include <qdatastream.h> 43 44 #include <private/qcursor_p.h> 44 45 #include <private/qt_x11_p.h> 46 #include <private/qapplication_p.h> 45 47 #include <qbitmap.h> 46 48 #include <qcursor.h> … … 58 60 59 61 #include "qx11info_x11.h" 62 #include <private/qpixmap_x11_p.h> 60 63 61 64 QT_BEGIN_NAMESPACE … … 263 266 "left_ptr_watch", 264 267 "openhand", 265 "closedhand" 268 "closedhand", 269 "copy", 270 "move", 271 "link" 266 272 }; 267 273 268 274 #ifndef QT_NO_XCURSOR 269 if (X11->ptrXcursorLibraryLoadCursor) 270 hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]); 275 if (X11->ptrXcursorLibraryLoadCursor) { 276 // special case for non-standard dnd-* cursors 277 switch (cshape) { 278 case Qt::DragCopyCursor: 279 hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-copy"); 280 break; 281 case Qt::DragMoveCursor: 282 hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-move"); 283 break; 284 case Qt::DragLinkCursor: 285 hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, "dnd-link"); 286 break; 287 default: 288 break; 289 } 290 if (!hcurs) 291 hcurs = X11->ptrXcursorLibraryLoadCursor(dpy, cursorNames[cshape]); 292 } 271 293 if (hcurs) 272 294 return; 273 295 #endif // QT_NO_XCURSOR 274 296 275 static const char cur_blank_bits[] = {297 static const uchar cur_blank_bits[] = { 276 298 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 277 299 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, … … 281 303 282 304 #ifndef QT_USE_APPROXIMATE_CURSORS 283 static const char cur_ver_bits[] = {305 static const uchar cur_ver_bits[] = { 284 306 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 285 307 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f, 286 308 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 }; 287 static const char mcur_ver_bits[] = {309 static const uchar mcur_ver_bits[] = { 288 310 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 289 311 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f, 290 312 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 }; 291 static const char cur_hor_bits[] = {313 static const uchar cur_hor_bits[] = { 292 314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18, 293 315 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08, 294 316 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 295 static const char mcur_hor_bits[] = {317 static const uchar mcur_hor_bits[] = { 296 318 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c, 297 319 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c, 298 320 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 }; 299 static const char cur_bdiag_bits[] = {321 static const uchar cur_bdiag_bits[] = { 300 322 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e, 301 323 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00, 302 324 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 303 static const char mcur_bdiag_bits[] = {325 static const uchar mcur_bdiag_bits[] = { 304 326 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f, 305 327 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01, 306 328 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 }; 307 static const char cur_fdiag_bits[] = {329 static const uchar cur_fdiag_bits[] = { 308 330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00, 309 331 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c, 310 332 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 }; 311 static const char mcur_fdiag_bits[] = {333 static const uchar mcur_fdiag_bits[] = { 312 334 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00, 313 335 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e, 314 336 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 }; 315 static const char *cursor_bits16[] = {337 static const uchar *cursor_bits16[] = { 316 338 cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits, 317 339 cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits, 318 340 0, 0, cur_blank_bits, cur_blank_bits }; 319 341 320 static const char vsplit_bits[] = {342 static const uchar vsplit_bits[] = { 321 343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 322 344 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, … … 330 352 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 331 353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 332 static const char vsplitm_bits[] = {354 static const uchar vsplitm_bits[] = { 333 355 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 334 356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, … … 342 364 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 343 365 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 344 static const char hsplit_bits[] = {366 static const uchar hsplit_bits[] = { 345 367 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 346 368 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, … … 354 376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 355 377 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 356 static const char hsplitm_bits[] = {378 static const uchar hsplitm_bits[] = { 357 379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 358 380 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, … … 366 388 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 367 389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 368 static const char whatsthis_bits[] = {390 static const uchar whatsthis_bits[] = { 369 391 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00, 370 392 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00, … … 378 400 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 379 401 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; 380 static const char whatsthism_bits[] = {402 static const uchar whatsthism_bits[] = { 381 403 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00, 382 404 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00, … … 390 412 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 391 413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; 392 static const char busy_bits[] = {414 static const uchar busy_bits[] = { 393 415 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 394 416 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, … … 402 424 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 403 425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 404 static const char busym_bits[] = {426 static const uchar busym_bits[] = { 405 427 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 406 428 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, … … 415 437 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 416 438 417 static const char * const cursor_bits32[] = {439 static const uchar * const cursor_bits32[] = { 418 440 vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, 419 441 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits 420 442 }; 421 443 422 static const char forbidden_bits[] = {444 static const uchar forbidden_bits[] = { 423 445 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01, 424 446 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06, … … 426 448 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 }; 427 449 428 static const char forbiddenm_bits[] = {450 static const uchar forbiddenm_bits[] = { 429 451 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03, 430 452 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f, … … 432 454 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00}; 433 455 434 static const char openhand_bits[] = {456 static const uchar openhand_bits[] = { 435 457 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, 436 458 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, 437 459 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; 438 static const char openhandm_bits[] = {460 static const uchar openhandm_bits[] = { 439 461 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, 440 462 0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, 441 463 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; 442 static const char closedhand_bits[] = {464 static const uchar closedhand_bits[] = { 443 465 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, 444 466 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, 445 467 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; 446 static const char closedhandm_bits[] = {468 static const uchar closedhandm_bits[] = { 447 469 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, 448 470 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, 449 471 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; 450 472 451 static const char * const cursor_bits20[] = {473 static const uchar * const cursor_bits20[] = { 452 474 forbidden_bits, forbiddenm_bits 453 475 }; … … 463 485 fg.blue = 0; 464 486 int i = (cshape - Qt::SizeVerCursor) * 2; 465 pm = XCreateBitmapFromData(dpy, rootwin, cursor_bits16[i], 16, 16);466 pmm = XCreateBitmapFromData(dpy, rootwin, cursor_bits16[i + 1], 16, 16);487 pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i]), 16, 16); 488 pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char*>(cursor_bits16[i + 1]), 16, 16); 467 489 hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); 468 490 } else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor) … … 476 498 fg.blue = 0; 477 499 int i = (cshape - Qt::SplitVCursor) * 2; 478 pm = XCreateBitmapFromData(dpy, rootwin, cursor_bits32[i], 32, 32);479 pmm = XCreateBitmapFromData(dpy, rootwin, cursor_bits32[i + 1], 32, 32);500 pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i]), 32, 32); 501 pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits32[i + 1]), 32, 32); 480 502 int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor 481 503 || cshape == Qt::BusyCursor) ? 0 : 16; … … 490 512 fg.blue = 0; 491 513 int i = (cshape - Qt::ForbiddenCursor) * 2; 492 pm = XCreateBitmapFromData(dpy, rootwin, cursor_bits20[i], 20, 20);493 pmm = XCreateBitmapFromData(dpy, rootwin, cursor_bits20[i + 1], 20, 20);514 pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i]), 20, 20); 515 pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(cursor_bits20[i + 1]), 20, 20); 494 516 hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 10, 10); 495 517 } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) { … … 502 524 fg.blue = 0; 503 525 bool open = cshape == Qt::OpenHandCursor; 504 pm = XCreateBitmapFromData(dpy, rootwin, open ? openhand_bits : closedhand_bits, 16, 16); 505 pmm = XCreateBitmapFromData(dpy, rootwin, open ? openhandm_bits : closedhandm_bits, 16, 16); 526 pm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhand_bits : closedhand_bits), 16, 16); 527 pmm = XCreateBitmapFromData(dpy, rootwin, reinterpret_cast<const char *>(open ? openhandm_bits : closedhandm_bits), 16, 16); 528 hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); 529 } else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor 530 || cshape == Qt::DragLinkCursor) { 531 XColor bg, fg; 532 bg.red = 255 << 8; 533 bg.green = 255 << 8; 534 bg.blue = 255 << 8; 535 fg.red = 0; 536 fg.green = 0; 537 fg.blue = 0; 538 QImage image = QApplicationPrivate::instance()->getPixmapCursor(cshape).toImage(); 539 pm = QX11PixmapData::createBitmapFromImage(image); 540 pmm = QX11PixmapData::createBitmapFromImage(image.createAlphaMask().convertToFormat(QImage::Format_MonoLSB)); 506 541 hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8); 507 542 } … … 578 613 sh = XC_watch; 579 614 break; 615 case Qt::DragCopyCursor: 616 sh = XC_tcross; 617 break; 618 case Qt::DragLinkCursor: 619 sh = XC_center_ptr; 620 break; 621 case Qt::DragMoveCursor: 622 sh = XC_top_left_arrow; 623 break; 580 624 #endif /* QT_USE_APPROXIMATE_CURSORS */ 581 625 default: -
trunk/src/gui/kernel/qdesktopwidget.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qdesktopwidget.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qdesktopwidget.qdoc
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 7 7 ** This file is part of the documentation of the Qt Toolkit. 8 8 ** 9 ** $QT_BEGIN_LICENSE: LGPL$9 ** $QT_BEGIN_LICENSE:FDL$ 10 10 ** Commercial Usage 11 11 ** Licensees holding valid Qt Commercial licenses may use this file in 12 12 ** accordance with the Qt Commercial License Agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and Nokia. 15 ** 16 ** GNU Lesser General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU Lesser 18 ** General Public License version 2.1 as published by the Free Software 19 ** Foundation and appearing in the file LICENSE.LGPL included in the 20 ** packaging of this file. Please review the following information to 21 ** ensure the GNU Lesser General Public License version 2.1 requirements 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 23 ** 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 ** 28 ** GNU General Public License Usage 29 ** Alternatively, this file may be used under the terms of the GNU 30 ** General Public License version 3.0 as published by the Free Software 31 ** Foundation and appearing in the file LICENSE.GPL included in the 32 ** packaging of this file. Please review the following information to 33 ** ensure the GNU General Public License version 3.0 requirements will be 34 ** met: http://www.gnu.org/copyleft/gpl.html. 13 ** Software or, alternatively, in accordance with the terms contained in a 14 ** written agreement between you and Nokia. 15 ** 16 ** GNU Free Documentation License 17 ** Alternatively, this file may be used under the terms of the GNU Free 18 ** Documentation License version 1.3 as published by the Free Software 19 ** Foundation and appearing in the file included in the packaging of this 20 ** file. 35 21 ** 36 22 ** If you have questions regarding the use of this file, please contact -
trunk/src/gui/kernel/qdesktopwidget_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qdesktopwidget_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qdesktopwidget_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qdesktopwidget_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 104 104 rects->resize(QDesktopWidgetPrivate::screenCount); 105 105 workrects->resize(QDesktopWidgetPrivate::screenCount); 106 107 (*rects)[0].setRect(0, 0, S60->screenWidthInPixels, S60->screenHeightInPixels); 108 QRect wr = qt_TRect2QRect(static_cast<CEikAppUi*>(S60->appUi())->ClientRect()); 109 (*workrects)[0].setRect(wr.x(), wr.y(), wr.width(), wr.height()); 106 110 } 107 111 … … 147 151 } 148 152 149 const QRect QDesktopWidget::availableGeometry(int /* screen */) const 150 { 151 TRect clientRect = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); 152 return qt_TRect2QRect(clientRect); 153 } 154 155 const QRect QDesktopWidget::screenGeometry(int /* screen */) const 153 const QRect QDesktopWidget::availableGeometry(int screen) const 156 154 { 157 155 Q_D(const QDesktopWidget); 158 return QRect(0, 0, S60->screenWidthInPixels, S60->screenHeightInPixels); 159 } 156 if (screen < 0 || screen >= d->screenCount) 157 screen = d->primaryScreen; 158 159 return d->workrects->at(screen); 160 } 161 162 const QRect QDesktopWidget::screenGeometry(int screen) const 163 { 164 Q_D(const QDesktopWidget); 165 if (screen < 0 || screen >= d->screenCount) 166 screen = d->primaryScreen; 167 168 return d->rects->at(screen); 169 } 160 170 161 171 int QDesktopWidget::screenNumber(const QWidget * /* widget */) const -
trunk/src/gui/kernel/qdesktopwidget_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 43 43 #include "qt_windows.h" 44 44 #include "qapplication_p.h" 45 #include "qlibrary.h"45 #include <private/qsystemlibrary_p.h> 46 46 #include <qvector.h> 47 47 #include <limits.h> … … 77 77 78 78 typedef BOOL (WINAPI *InfoFunc)(HMONITOR, MONITORINFO*); 79 typedef BOOL ( CALLBACK *EnumProc)(HMONITOR, HDC, LPRECT, LPARAM);79 typedef BOOL (QT_WIN_CALLBACK *EnumProc)(HMONITOR, HDC, LPRECT, LPARAM); 80 80 typedef BOOL (WINAPI *EnumFunc)(HDC, LPCRECT, EnumProc, LPARAM); 81 81 … … 108 108 109 109 110 BOOL CALLBACK enumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM)110 BOOL QT_WIN_CALLBACK enumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM) 111 111 { 112 112 QDesktopWidgetPrivate::screenCount++; … … 156 156 157 157 #ifndef Q_OS_WINCE 158 Q Library user32Lib(QLatin1String("user32"));158 QSystemLibrary user32Lib(QLatin1String("user32")); 159 159 if (user32Lib.load()) { 160 160 enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors"); … … 174 174 getMonitorInfo = 0; 175 175 #else 176 Q Library coreLib(QLatin1String("coredll"));176 QSystemLibrary coreLib(QLatin1String("coredll")); 177 177 if (coreLib.load()) { 178 178 // CE >= 4.0 case -
trunk/src/gui/kernel/qdesktopwidget_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qdnd.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 61 61 #include <ctype.h> 62 62 63 #include <private/qapplication_p.h> 64 63 65 #ifndef QT_NO_DRAGANDDROP 64 66 65 67 QT_BEGIN_NAMESPACE 66 67 // These pixmaps approximate the images in the Windows User Interface Guidelines.68 69 // XPM70 71 static const char * const move_xpm[] = {72 "11 20 3 1",73 ". c None",74 #if defined(Q_WS_WIN)75 "a c #000000",76 "X c #FFFFFF", // Windows cursor is traditionally white77 #else78 "a c #FFFFFF",79 "X c #000000", // X11 cursor is traditionally black80 #endif81 "aa.........",82 "aXa........",83 "aXXa.......",84 "aXXXa......",85 "aXXXXa.....",86 "aXXXXXa....",87 "aXXXXXXa...",88 "aXXXXXXXa..",89 "aXXXXXXXXa.",90 "aXXXXXXXXXa",91 "aXXXXXXaaaa",92 "aXXXaXXa...",93 "aXXaaXXa...",94 "aXa..aXXa..",95 "aa...aXXa..",96 "a.....aXXa.",97 "......aXXa.",98 ".......aXXa",99 ".......aXXa",100 "........aa."};101 102 #if defined(Q_WS_WIN) || defined(Q_WS_PM)103 /* XPM */104 static const char * const ignore_xpm[] = {105 "24 30 3 1",106 ". c None",107 #if defined(Q_WS_WIN)108 "a c #000000",109 "X c #FFFFFF", // Windows cursor is traditionally white110 #else111 "a c #FFFFFF",112 "X c #000000", // OS/2 cursor is traditionally black113 #endif114 "aa......................",115 "aXa.....................",116 "aXXa....................",117 "aXXXa...................",118 "aXXXXa..................",119 "aXXXXXa.................",120 "aXXXXXXa................",121 "aXXXXXXXa...............",122 "aXXXXXXXXa..............",123 "aXXXXXXXXXa.............",124 "aXXXXXXaaaa.............",125 "aXXXaXXa................",126 "aXXaaXXa................",127 "aXa..aXXa...............",128 "aa...aXXa...............",129 "a.....aXXa..............",130 "......aXXa.....XXXX.....",131 ".......aXXa..XXaaaaXX...",132 ".......aXXa.XaaaaaaaaX..",133 "........aa.XaaaXXXXaaaX.",134 "...........XaaaaX..XaaX.",135 "..........XaaXaaaX..XaaX",136 "..........XaaXXaaaX.XaaX",137 "..........XaaX.XaaaXXaaX",138 "..........XaaX..XaaaXaaX",139 "...........XaaX..XaaaaX.",140 "...........XaaaXXXXaaaX.",141 "............XaaaaaaaaX..",142 ".............XXaaaaXX...",143 "...............XXXX....."};144 #endif145 146 /* XPM */147 static const char * const copy_xpm[] = {148 "24 30 3 1",149 ". c None",150 "a c #000000",151 "X c #FFFFFF",152 #if defined(Q_WS_WIN) // Windows cursor is traditionally white153 "aa......................",154 "aXa.....................",155 "aXXa....................",156 "aXXXa...................",157 "aXXXXa..................",158 "aXXXXXa.................",159 "aXXXXXXa................",160 "aXXXXXXXa...............",161 "aXXXXXXXXa..............",162 "aXXXXXXXXXa.............",163 "aXXXXXXaaaa.............",164 "aXXXaXXa................",165 "aXXaaXXa................",166 "aXa..aXXa...............",167 "aa...aXXa...............",168 "a.....aXXa..............",169 "......aXXa..............",170 ".......aXXa.............",171 ".......aXXa.............",172 "........aa...aaaaaaaaaaa",173 #else174 "XX......................",175 "XaX.....................",176 "XaaX....................",177 "XaaaX...................",178 "XaaaaX..................",179 "XaaaaaX.................",180 "XaaaaaaX................",181 "XaaaaaaaX...............",182 "XaaaaaaaaX..............",183 "XaaaaaaaaaX.............",184 "XaaaaaaXXXX.............",185 "XaaaXaaX................",186 "XaaXXaaX................",187 "XaX..XaaX...............",188 "XX...XaaX...............",189 "X.....XaaX..............",190 "......XaaX..............",191 ".......XaaX.............",192 ".......XaaX.............",193 "........XX...aaaaaaaaaaa",194 #endif195 ".............aXXXXXXXXXa",196 ".............aXXXXXXXXXa",197 ".............aXXXXaXXXXa",198 ".............aXXXXaXXXXa",199 ".............aXXaaaaaXXa",200 ".............aXXXXaXXXXa",201 ".............aXXXXaXXXXa",202 ".............aXXXXXXXXXa",203 ".............aXXXXXXXXXa",204 ".............aaaaaaaaaaa"};205 206 /* XPM */207 static const char * const link_xpm[] = {208 "24 30 3 1",209 ". c None",210 "a c #000000",211 "X c #FFFFFF",212 #if defined(Q_WS_WIN) // Windows cursor is traditionally white213 "aa......................",214 "aXa.....................",215 "aXXa....................",216 "aXXXa...................",217 "aXXXXa..................",218 "aXXXXXa.................",219 "aXXXXXXa................",220 "aXXXXXXXa...............",221 "aXXXXXXXXa..............",222 "aXXXXXXXXXa.............",223 "aXXXXXXaaaa.............",224 "aXXXaXXa................",225 "aXXaaXXa................",226 "aXa..aXXa...............",227 "aa...aXXa...............",228 "a.....aXXa..............",229 "......aXXa..............",230 ".......aXXa.............",231 ".......aXXa.............",232 "........aa...aaaaaaaaaaa",233 #else234 "XX......................",235 "XaX.....................",236 "XaaX....................",237 "XaaaX...................",238 "XaaaaX..................",239 "XaaaaaX.................",240 "XaaaaaaX................",241 "XaaaaaaaX...............",242 "XaaaaaaaaX..............",243 "XaaaaaaaaaX.............",244 "XaaaaaaXXXX.............",245 "XaaaXaaX................",246 "XaaXXaaX................",247 "XaX..XaaX...............",248 "XX...XaaX...............",249 "X.....XaaX..............",250 "......XaaX..............",251 ".......XaaX.............",252 ".......XaaX.............",253 "........XX...aaaaaaaaaaa",254 #endif255 ".............aXXXXXXXXXa",256 ".............aXXXaaaaXXa",257 ".............aXXXXaaaXXa",258 ".............aXXXaaaaXXa",259 ".............aXXaaaXaXXa",260 ".............aXXaaXXXXXa",261 ".............aXXaXXXXXXa",262 ".............aXXXaXXXXXa",263 ".............aXXXXXXXXXa",264 ".............aaaaaaaaaaa"};265 68 266 69 #ifndef QT_NO_DRAGANDDROP … … 332 135 Q_ASSERT(!instance); 333 136 334 #if defined(Q_WS_WIN) || defined(Q_WS_PM)335 n_cursor = 4;336 #else337 n_cursor = 3;338 #endif339 340 137 #ifdef Q_WS_QWS 341 138 currentActionForOverrideCursor = Qt::IgnoreAction; 342 #endif343 pm_cursor = new QPixmap[n_cursor];344 pm_cursor[0] = QPixmap((const char **)move_xpm);345 pm_cursor[1] = QPixmap((const char **)copy_xpm);346 pm_cursor[2] = QPixmap((const char **)link_xpm);347 #if defined(Q_WS_WIN) || defined(Q_WS_PM)348 pm_cursor[3] = QPixmap((const char **)ignore_xpm);349 139 #endif 350 140 object = 0; … … 374 164 #endif 375 165 instance = 0; 376 delete [] pm_cursor;377 166 delete dropData; 378 167 } … … 391 180 return d->customCursors[action]; 392 181 else if (action == Qt::MoveAction) 393 return pm_cursor[0];182 return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragMoveCursor); 394 183 else if (action == Qt::CopyAction) 395 return pm_cursor[1];184 return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragCopyCursor); 396 185 else if (action == Qt::LinkAction) 397 return pm_cursor[2];186 return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragLinkCursor); 398 187 #ifdef Q_WS_WIN 399 188 else if (action == Qt::IgnoreAction) 400 return pm_cursor[3];189 return QApplicationPrivate::instance()->getPixmapCursor(Qt::ForbiddenCursor); 401 190 #endif 402 191 return QPixmap(); -
trunk/src/gui/kernel/qdnd_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 676 676 if (atleastOne){ 677 677 DisposeDrag(dragRef); 678 o->setMimeData(0); 679 o->deleteLater(); 678 680 return action; 679 681 } … … 683 685 GetDragDropAction(dragRef, &ret); 684 686 DisposeDrag(dragRef); //cleanup 687 o->setMimeData(0); 688 o->deleteLater(); 685 689 return qt_mac_dnd_map_mac_default_action(ret); 686 690 } -
trunk/src/gui/kernel/qdnd_p.h
r786 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 283 283 284 284 private: 285 QPixmap *pm_cursor;286 int n_cursor;287 285 #ifdef Q_WS_QWS 288 286 Qt::DropAction currentActionForOverrideCursor; -
trunk/src/gui/kernel/qdnd_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 193 193 194 194 switch(e->type()) { 195 case QEvent::ShortcutOverride: 196 // prevent accelerators from firing while dragging 197 e->accept(); 198 return true; 195 199 196 200 case QEvent::KeyPress: -
trunk/src/gui/kernel/qdnd_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qdnd_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 516 516 // IDropSource Methods 517 517 //--------------------------------------------------------------------- 518 STDMETHODIMP518 QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP 519 519 QOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) 520 520 { … … 525 525 if (fEscapePressed) { 526 526 return ResultFromScode(DRAGDROP_S_CANCEL); 527 } else if (!(grfKeyState & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON))) { 527 } else if ((GetAsyncKeyState(VK_LBUTTON) == 0) 528 && (GetAsyncKeyState(VK_MBUTTON) == 0) 529 && (GetAsyncKeyState(VK_RBUTTON) == 0)) { 530 // grfKeyState is broken on CE & some Windows XP versions, 531 // therefore we need to check the state manually 528 532 return ResultFromScode(DRAGDROP_S_DROP); 529 533 } else { 530 #if defined(Q_OS_WINCE) 531 // grfKeyState is broken on CE, therefore need to check 532 // the state manually 533 if ((GetAsyncKeyState(VK_LBUTTON) == 0) && 534 (GetAsyncKeyState(VK_MBUTTON) == 0) && 535 (GetAsyncKeyState(VK_RBUTTON) == 0)) { 536 return ResultFromScode(DRAGDROP_S_DROP); 537 } 538 #else 534 #if !defined(Q_OS_WINCE) 539 535 if (currentButtons == Qt::NoButton) { 540 536 currentButtons = keystate_to_mousebutton(grfKeyState); … … 550 546 } 551 547 552 STDMETHODIMP548 QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP 553 549 QOleDropSource::GiveFeedback(DWORD dwEffect) 554 550 { … … 631 627 //--------------------------------------------------------------------- 632 628 633 STDMETHODIMP629 QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP 634 630 QOleDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) 635 631 { … … 693 689 } 694 690 695 STDMETHODIMP691 QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP 696 692 QOleDropTarget::DragOver(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) 697 693 { … … 763 759 } 764 760 765 STDMETHODIMP761 QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP 766 762 QOleDropTarget::DragLeave() 767 763 { … … 790 786 #define KEY_STATE_BUTTON_MASK (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON) 791 787 792 STDMETHODIMP788 QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP 793 789 QOleDropTarget::Drop(LPDATAOBJECT /*pDataObj*/, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect) 794 790 { -
trunk/src/gui/kernel/qdnd_x11.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 52 52 #include "qdesktopwidget.h" 53 53 #include "qevent.h" 54 #include "qdatetime.h"55 54 #include "qiodevice.h" 56 55 #include "qpointer.h" 57 56 #include "qcursor.h" 57 #include "qelapsedtimer.h" 58 58 #include "qvariant.h" 59 59 #include "qvector.h" … … 65 65 66 66 #include "qdnd_p.h" 67 #include "qapplication_p.h" 67 68 #include "qt_x11_p.h" 68 69 #include "qx11info_x11.h" … … 1112 1113 } 1113 1114 1114 1115 // TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8. 1116 static Qt::KeyboardModifiers currentKeyboardModifiers() 1117 { 1118 Window root; 1119 Window child; 1120 int root_x, root_y, win_x, win_y; 1121 uint keybstate; 1122 for (int i = 0; i < ScreenCount(X11->display); ++i) { 1123 if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child, 1124 &root_x, &root_y, &win_x, &win_y, &keybstate)) 1125 return X11->translateModifiers(keybstate & 0x00ff); 1126 } 1127 return 0; 1128 } 1115 1129 1116 1130 void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive) … … 1159 1173 if (!dropData) 1160 1174 dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData; 1175 1176 // Drop coming from another app? Update keyboard modifiers. 1177 if (!qt_xdnd_dragging) { 1178 QApplicationPrivate::modifier_buttons = currentKeyboardModifiers(); 1179 } 1161 1180 1162 1181 QDropEvent de(qt_xdnd_current_position, possible_actions, dropData, … … 1300 1319 } 1301 1320 1321 if (e->type() == QEvent::ShortcutOverride) { 1322 // prevent accelerators from firing while dragging 1323 e->accept(); 1324 return true; 1325 } 1326 1302 1327 if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { 1303 1328 QKeyEvent *ke = ((QKeyEvent*)e); … … 1341 1366 #ifndef QT_NO_CURSOR 1342 1367 noDropCursor = new QCursor(Qt::ForbiddenCursor); 1343 moveCursor = new QCursor( dragCursor(Qt::MoveAction), 0,0);1344 copyCursor = new QCursor( dragCursor(Qt::CopyAction), 0,0);1345 linkCursor = new QCursor( dragCursor(Qt::LinkAction), 0,0);1368 moveCursor = new QCursor(Qt::DragMoveCursor); 1369 copyCursor = new QCursor(Qt::DragCopyCursor); 1370 linkCursor = new QCursor(Qt::DragLinkCursor); 1346 1371 #endif 1347 1372 } … … 1863 1888 Atom type; 1864 1889 1865 if (X11->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0 , false)) {1890 if (X11->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0)) { 1866 1891 if (type == ATOM(INCR)) { 1867 1892 int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0; … … 1912 1937 QApplication::flush(); 1913 1938 1914 Q Time started = QTime::currentTime();1915 QTime now = started;1939 QElapsedTimer timer; 1940 timer.start(); 1916 1941 do { 1917 1942 XEvent event; 1918 1943 if (XCheckTypedEvent(X11->display, ClientMessage, &event)) 1919 1944 qApp->x11ProcessEvent(&event); 1920 1921 now = QTime::currentTime();1922 if (started > now) // crossed midnight1923 started = now;1924 1945 1925 1946 // sleep 50 ms, so we don't use up CPU cycles all the time. … … 1928 1949 usleep_tv.tv_usec = 50000; 1929 1950 select(0, 0, 0, 0, &usleep_tv); 1930 } while (object && started.msecsTo(now) < 1000);1951 } while (object && timer.hasExpired(1000)); 1931 1952 } 1932 1953 -
trunk/src/gui/kernel/qdrag.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 254 254 loop. Other events are still delivered to the application while 255 255 the operation is performed. On Windows, the Qt event loop is 256 blocked while during the operation. 256 blocked during the operation. However, QDrag::exec() on 257 Windows causes processEvents() to be called frequently to keep the GUI responsive. 258 If any loops or operations are called while a drag operation is active, it will block the drag operation. 257 259 */ 258 260 -
trunk/src/gui/kernel/qdrag.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qevent.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 1971 1971 Z-axis, pass zero here. 1972 1972 1973 The \a tangentialPressure param ater contins the tangential pressure of an air1973 The \a tangentialPressure parameter contins the tangential pressure of an air 1974 1974 brush. If the device does not support tangential pressure, pass 0 here. 1975 1975 … … 3422 3422 dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child(); 3423 3423 return dbg.space(); 3424 #ifndef QT_NO_GESTURES 3424 3425 case QEvent::Gesture: 3425 3426 n = "Gesture"; 3426 3427 break; 3428 #endif 3427 3429 default: 3428 3430 dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')'; … … 3626 3628 \since 4.6 3627 3629 \ingroup events 3628 \ingroup multitouch3630 \ingroup touch 3629 3631 3630 3632 \section1 Enabling Touch Events … … 3640 3642 Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a 3641 3643 widget, and the widget will receive all updates for the touch point until it is released. 3642 Note that it is possible for a widget to receive events for multipletouch points, and that3644 Note that it is possible for a widget to receive events for numerous touch points, and that 3643 3645 multiple widgets may be receiving touch events at the same time. 3644 3646 … … 3716 3718 \i As mentioned above, enabling touch events means multiple widgets can be receiving touch 3717 3719 events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents, 3718 this gives you great flexibility in designing multi-touch user interfaces. Be aware of the3720 this gives you great flexibility in designing touch user interfaces. Be aware of the 3719 3721 implications. For example, it is possible that the user is moving a QSlider with one finger and 3720 3722 pressing a QPushButton with another. The signals emitted by these widgets will be … … 3728 3730 \i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an 3729 3731 \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is 3730 undefined when opening a pop-up or grabbing the mouse while there are m ultiple active touch3732 undefined when opening a pop-up or grabbing the mouse while there are more than one active touch 3731 3733 points. 3732 3734 … … 4255 4257 } 4256 4258 4259 #ifndef QT_NO_GESTURES 4257 4260 /*! 4258 4261 \class QGestureEvent … … 4278 4281 QGestureEvent::accept() for each of them, or an event filter consumes the 4279 4282 event. 4283 4284 \section1 Further Reading 4285 4286 For an overview of gesture handling in Qt and information on using gestures 4287 in your applications, see the \l{Gestures Programming} document. 4280 4288 4281 4289 \sa QGesture, QGestureRecognizer, … … 4559 4567 #endif 4560 4568 4569 #endif // QT_NO_GESTURES 4570 4561 4571 QT_END_NAMESPACE -
trunk/src/gui/kernel/qevent.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 63 63 64 64 class QAction; 65 #ifndef QT_NO_GESTURES 65 66 class QGesture; 67 #endif 66 68 67 69 class Q_GUI_EXPORT QInputEvent : public QEvent … … 825 827 }; 826 828 829 #ifndef QT_NO_GESTURES 827 830 class QGesture; 828 831 class QGestureEventPrivate; … … 876 879 friend class QGestureManager; 877 880 }; 881 #endif // QT_NO_GESTURES 878 882 879 883 QT_END_NAMESPACE -
trunk/src/gui/kernel/qevent_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 121 121 }; 122 122 123 #ifndef QT_NO_GESTURES 123 124 class QNativeGestureEvent : public QEvent 124 125 { … … 165 166 QMap<Qt::GestureType, QWidget *> targetWidgets; 166 167 }; 167 168 #endif // QT_NO_GESTURES 168 169 169 170 class QFileOpenEventPrivate -
trunk/src/gui/kernel/qeventdispatcher_glib_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qeventdispatcher_glib_qws_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qeventdispatcher_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 91 91 #ifndef QT_NO_THREAD 92 92 # include "qmutex.h" 93 #endif 93 94 94 95 QT_BEGIN_NAMESPACE 95 96 96 97 QT_USE_NAMESPACE 97 #endif98 98 99 99 /***************************************************************************** … … 493 493 case NSOtherMouseUp: 494 494 case NSOtherMouseDragged: 495 #ifndef QT_NO_GESTURES 495 496 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 496 497 case NSEventTypeGesture: // touch events … … 501 502 case NSEventTypeEndGesture: 502 503 #endif 504 #endif // QT_NO_GESTURES 503 505 result = true; 504 506 break; … … 549 551 Q_D(QEventDispatcherMac); 550 552 d->interrupt = false; 553 554 #ifdef QT_MAC_USE_COCOA 555 bool interruptLater = false; 556 QtMacInterruptDispatcherHelp::cancelInterruptLater(); 557 #endif 558 551 559 // In case we end up recursing while we now process events, make sure 552 560 // that we send remaining posted Qt events before this call returns: … … 563 571 NSEvent* event = 0; 564 572 565 // If Qt is used as a plugin, or just added into a native cocoa 566 // application, we should not run or stop NSApplication; 567 // This will be done from outside Qt. 568 // And if processEvents is called manually (rather than from QEventLoop), we 569 // cannot enter a tight loop and block the call, but instead return after one flush: 570 bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning]; 571 bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec; 573 // First, send all previously excluded input events, if any: 574 if (!(flags & QEventLoop::ExcludeUserInputEvents)) { 575 while (!d->queuedUserInputEvents.isEmpty()) { 576 event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst()); 577 if (!filterEvent(event)) { 578 qt_mac_send_event(flags, event, 0); 579 retVal = true; 580 } 581 [event release]; 582 } 583 } 584 585 // If Qt is used as a plugin, or as an extension in a native cocoa 586 // application, we should not run or stop NSApplication; This will be 587 // done from the application itself. And if processEvents is called 588 // manually (rather than from a QEventLoop), we cannot enter a tight 589 // loop and block this call, but instead we need to return after one flush: 590 const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning]; 591 const bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec; 572 592 573 593 if (canExec_Qt && canExec_3rdParty) { 574 594 // We can use exec-mode, meaning that we can stay in a tight loop until 575 // interrupted. This is mostly an optimization, but it also allow us 576 // to use [NSApp run], which is the recommended way of running applications 577 // in cocoa. [NSApp run] should be called at least once for any cocoa app. 595 // interrupted. This is mostly an optimization, but it allow us to use 596 // [NSApp run], which is the normal code path for cocoa applications. 578 597 if (NSModalSession session = d->currentModalSession()) { 579 598 QBoolBlocker execGuard(d->currentExecIsNSAppRun, false); 580 599 while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) 581 600 qt_mac_waitForMoreModalSessionEvents(); 601 582 602 if (!d->interrupt && session == d->currentModalSessionCached) { 583 // INVARIANT: Someone called e.g.[NSApp stopModal:] from outside the event603 // Someone called [NSApp stopModal:] from outside the event 584 604 // dispatcher (e.g to stop a native dialog). But that call wrongly stopped 585 605 // 'session' as well. As a result, we need to restart all internal sessions: … … 592 612 } 593 613 retVal = true; 594 } else do{595 // INVARIANT:We cannot block the thread (and run in a tight loop).614 } else { 615 // We cannot block the thread (and run in a tight loop). 596 616 // Instead we will process all current pending events and return. 597 bool mustRelease = false; 598 599 if (!(flags & QEventLoop::ExcludeUserInputEvents) && !d->queuedUserInputEvents.isEmpty()) { 600 // Process a pending user input event 601 mustRelease = true; 602 event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst()); 603 } else { 604 if (NSModalSession session = d->currentModalSession()) { 605 if (flags & QEventLoop::WaitForMoreEvents) 606 qt_mac_waitForMoreModalSessionEvents(); 607 NSInteger status = [NSApp runModalSession:session]; 608 if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) { 609 // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event 610 // dispatcher (e.g to stop a native dialog). But that call wrongly stopped 611 // 'session' as well. As a result, we need to restart all internal sessions: 612 d->temporarilyStopAllModalSessions(); 613 } 614 retVal = true; 615 break; 616 } else { 617 event = [NSApp nextEventMatchingMask:NSAnyEventMask 618 untilDate:nil 619 inMode:NSDefaultRunLoopMode 620 dequeue: YES]; 621 622 if (event != nil) { 623 if (flags & QEventLoop::ExcludeUserInputEvents) { 624 if (IsMouseOrKeyEvent(event)) { 625 // retain event here? 626 [event retain]; 627 d->queuedUserInputEvents.append(event); 628 continue; 629 } 617 d->ensureNSAppInitialized(); 618 if (NSModalSession session = d->currentModalSession()) { 619 if (flags & QEventLoop::WaitForMoreEvents) 620 qt_mac_waitForMoreModalSessionEvents(); 621 NSInteger status = [NSApp runModalSession:session]; 622 if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) { 623 // INVARIANT: Someone called [NSApp stopModal:] from outside the event 624 // dispatcher (e.g to stop a native dialog). But that call wrongly stopped 625 // 'session' as well. As a result, we need to restart all internal sessions: 626 d->temporarilyStopAllModalSessions(); 627 } 628 retVal = true; 629 } else do { 630 event = [NSApp nextEventMatchingMask:NSAnyEventMask 631 untilDate:nil 632 inMode:NSDefaultRunLoopMode 633 dequeue: YES]; 634 635 if (event) { 636 if (flags & QEventLoop::ExcludeUserInputEvents) { 637 if (IsMouseOrKeyEvent(event)) { 638 [event retain]; 639 d->queuedUserInputEvents.append(event); 640 continue; 630 641 } 631 642 } 643 if (!filterEvent(event) && qt_mac_send_event(flags, event, 0)) 644 retVal = true; 632 645 } 633 } 634 if (event) { 635 if (!filterEvent(event) && qt_mac_send_event(flags, event, 0))636 retVal = true;637 if (mustRelease)638 [event release];639 }640 } while(!d->interrupt && event != nil);641 646 } while (!d->interrupt && event != nil); 647 648 // Since the window that holds modality might have changed while processing 649 // events, we we need to interrupt when we return back the previous process 650 // event recursion to ensure that we spin the correct modal session. 651 // We do the interruptLater at the end of the function to ensure that we don't 652 // disturb the 'wait for more events' below (as deleteLater will post an event): 653 interruptLater = true; 654 } 642 655 #else 643 656 do { … … 691 704 } 692 705 706 // If we're interrupted, we need to interrupt the _current_ 707 // recursion as well to check if it is still supposed to be 708 // executing. This way we wind down the stack until we land 709 // on a recursion that again calls processEvents (typically 710 // from QEventLoop), and set interrupt to false: 711 if (d->interrupt) 712 interrupt(); 713 693 714 #ifdef QT_MAC_USE_COCOA 694 // In case we _now_ process events using [NSApp run], we need to stop it to 695 // ensure that: 696 // 1. the QEventLoop that called us is still executing, or 697 // 2. we have a modal session that needs to be spun instead. 698 // In case this is a plain call to processEvents (perhaps from a loop) 699 // from the application (rather than from a QEventLoop), we delay the 700 // interrupting until we/ actually enter a lower loop level (hence the 701 // deffered delete of the object below): 702 QtMacInterruptDispatcherHelp::interruptLater(); 703 #endif 704 705 if (d->interrupt) { 706 // We should continue to leave all recursion to processEvents until 707 // processEvents is called again (e.g. from a QEventLoop that 708 // was not yet told to quit: 709 interrupt(); 710 } 715 if (interruptLater) 716 QtMacInterruptDispatcherHelp::interruptLater(); 717 #endif 711 718 712 719 return retVal; … … 738 745 MacTimerHash QEventDispatcherMacPrivate::macTimerHash; 739 746 bool QEventDispatcherMacPrivate::blockSendPostedEvents = false; 747 bool QEventDispatcherMacPrivate::interrupt = false; 740 748 741 749 #ifdef QT_MAC_USE_COCOA … … 743 751 bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false; 744 752 bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false; 753 bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false; 745 754 NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0; 746 755 747 int QEventDispatcherMacPrivate::activeModalSessionCount() 748 { 749 // Returns the number of modal sessions created 750 // (and not just pushed onto the stack, pending to be created) 751 int count = 0; 752 for (int i=cocoaModalSessionStack.size()-1; i>=0; --i) { 753 QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; 754 if (info.session) 755 ++count; 756 } 757 return count; 756 void QEventDispatcherMacPrivate::ensureNSAppInitialized() 757 { 758 // Some elements in Cocoa require NSApplication to be running before 759 // they get fully initialized, in particular the menu bar. This 760 // function is intended for cases where a dialog is told to execute before 761 // QApplication::exec is called, or the application spins the events loop 762 // manually rather than calling QApplication:exec. 763 // The function makes sure that NSApplication starts running, but stops 764 // it again as soon as the send posted events callback is called. That way 765 // we let Cocoa finish the initialization it seems to need. We'll only 766 // apply this trick at most once for any application, and we avoid doing it 767 // for the common case where main just starts QApplication::exec. 768 if (nsAppRunCalledByQt || [NSApp isRunning]) 769 return; 770 nsAppRunCalledByQt = true; 771 QBoolBlocker block1(interrupt, true); 772 QBoolBlocker block2(currentExecIsNSAppRun, true); 773 [NSApp run]; 758 774 } 759 775 760 776 void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions() 761 777 { 762 // Stop all created modal session, and as such, make then 763 // pending again. The next call to currentModalSession will 764 // recreate the session on top again: 778 // Flush, and Stop, all created modal session, and as 779 // such, make them pending again. The next call to 780 // currentModalSession will recreate them again. The 781 // reason to stop all session like this is that otherwise 782 // a call [NSApp stop] would not stop NSApp, but rather 783 // the current modal session. So if we need to stop NSApp 784 // we need to stop all the modal session first. To avoid changing 785 // the stacking order of the windows while doing so, we put 786 // up a block that is used in QCocoaWindow and QCocoaPanel: 765 787 int stackSize = cocoaModalSessionStack.size(); 766 for (int i= stackSize-1; i>=0; --i) {788 for (int i=0; i<stackSize; ++i) { 767 789 QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; 768 790 if (info.session) { … … 783 805 if (cocoaModalSessionStack.isEmpty()) 784 806 return 0; 785 786 // Since this code will end up calling our Qt event handler787 // (also from beginModalSessionForWindow), we need to block788 // that to avoid side effects of events beeing delivered:789 QBoolBlocker block(blockSendPostedEvents, true);790 791 if (![NSApp isRunning]) {792 // Sadly, we need to introduce this little event flush793 // to stop dialogs from blinking/poping in front if a794 // modal session restart was needed:795 while (NSEvent *event = [NSApp nextEventMatchingMask:0796 untilDate:nil797 inMode:NSDefaultRunLoopMode798 dequeue: YES]) {799 qt_mac_send_event(0, event, 0);800 }801 }802 807 803 808 int sessionCount = cocoaModalSessionStack.size(); … … 813 818 if (!window) 814 819 continue; 820 821 ensureNSAppInitialized(); 822 QBoolBlocker block1(blockSendPostedEvents, true); 823 info.nswindow = window; 824 [(NSWindow*) info.nswindow retain]; 825 int levelBeforeEnterModal = [window level]; 815 826 info.session = [NSApp beginModalSessionForWindow:window]; 827 // Make sure we don't stack the window lower that it was before 828 // entering modal, in case it e.g. had the stays-on-top flag set: 829 if (levelBeforeEnterModal > [window level]) 830 [window setLevel:levelBeforeEnterModal]; 816 831 } 817 832 currentModalSessionCached = info.session; 818 }819 833 cleanupModalSessionsNeeded = false; 834 } 820 835 return currentModalSessionCached; 821 836 } … … 830 845 if (window && [window isKindOfClass:[NSPanel class]]) { 831 846 [static_cast<NSPanel *>(window) setWorksWhenModal:worksWhenModal]; 832 if (worksWhenModal && dialogs[i]->isVisible()){847 if (worksWhenModal && [window isVisible]){ 833 848 [window orderFront:window]; 834 849 } … … 842 857 // active. And make the dialog children of 843 858 // the previous modal dialog unactive again: 859 QMacCocoaAutoReleasePool pool; 844 860 int size = cocoaModalSessionStack.size(); 845 861 if (size > 0){ … … 853 869 } 854 870 871 void QEventDispatcherMacPrivate::cleanupModalSessions() 872 { 873 // Go through the list of modal sessions, and end those 874 // that no longer has a widget assosiated; no widget means 875 // the the session has logically ended. The reason we wait like 876 // this to actually end the sessions for real (rather than at the 877 // point they were marked as stopped), is that ending a session 878 // when no other session runs below it on the stack will make cocoa 879 // drop some events on the floor. 880 QMacCocoaAutoReleasePool pool; 881 int stackSize = cocoaModalSessionStack.size(); 882 883 for (int i=stackSize-1; i>=0; --i) { 884 QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; 885 if (info.widget) { 886 // This session has a widget, and is therefore not marked 887 // as stopped. So just make it current. There might still be other 888 // stopped sessions on the stack, but those will be stopped on 889 // a later "cleanup" call. 890 currentModalSessionCached = info.session; 891 break; 892 } 893 cocoaModalSessionStack.remove(i); 894 currentModalSessionCached = 0; 895 if (info.session) { 896 [NSApp endModalSession:info.session]; 897 [(NSWindow *)info.nswindow release]; 898 } 899 } 900 901 updateChildrenWorksWhenModal(); 902 cleanupModalSessionsNeeded = false; 903 } 904 855 905 void QEventDispatcherMacPrivate::beginModalSession(QWidget *widget) 856 906 { … … 861 911 // currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if 862 912 // the widget pointer is zero, and the session pointer is non-zero (it will be fully 863 // stopped in endModalSession().864 QCocoaModalSessionInfo info = {widget, 0 };913 // stopped in cleanupModalSessions()). 914 QCocoaModalSessionInfo info = {widget, 0, 0}; 865 915 cocoaModalSessionStack.push(info); 866 916 updateChildrenWorksWhenModal(); … … 878 928 for (int i=stackSize-1; i>=0; --i) { 879 929 QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; 880 if (info.widget == widget) 930 if (info.widget == widget) { 881 931 info.widget = 0; 882 } 883 884 // Now we stop, and remove, all sessions marked as pending 885 // to be stopped on _top_ of the stack, if any: 886 bool needToInterruptEventDispatcher = false; 887 bool needToUpdateChildrenWorksWhenModal = false; 888 889 for (int i=stackSize-1; i>=0; --i) { 890 QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; 891 if (info.widget) 892 break; 893 cocoaModalSessionStack.remove(i); 894 needToUpdateChildrenWorksWhenModal = true; 895 currentModalSessionCached = 0; 896 if (info.session) { 897 [NSApp endModalSession:info.session]; 898 needToInterruptEventDispatcher = true; 899 } 900 } 901 902 if (needToUpdateChildrenWorksWhenModal) 903 updateChildrenWorksWhenModal(); 904 if (needToInterruptEventDispatcher) 905 QEventDispatcherMac::instance()->interrupt(); 932 if (i == stackSize-1) { 933 // The top sessions ended. Interrupt the event dispatcher 934 // to start spinning the correct session immidiatly: 935 currentModalSessionCached = 0; 936 cleanupModalSessionsNeeded = true; 937 QEventDispatcherMac::instance()->interrupt(); 938 } 939 } 940 } 906 941 } 907 942 … … 909 944 910 945 QEventDispatcherMacPrivate::QEventDispatcherMacPrivate() 911 : interrupt(false)912 946 { 913 947 } … … 968 1002 inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, const bool blockSendPostedEvents) 969 1003 { 970 if (blockSendPostedEvents || d->interrupt) { 1004 if (blockSendPostedEvents) { 1005 // We're told to not send posted events (because the event dispatcher 1006 // is currently working on setting up the correct session to run). But 1007 // we still need to make sure that we don't fall asleep until pending events 1008 // are sendt, so we just signal this need, and return: 971 1009 CFRunLoopSourceSignal(d->postedEventsSource); 972 } else { 973 if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) { 974 d->lastSerial = d->serialNumber; 975 QApplicationPrivate::sendPostedEvents(0, 0, d->threadData); 976 } 1010 return; 1011 } 1012 1013 #ifdef QT_MAC_USE_COCOA 1014 if (d->cleanupModalSessionsNeeded) 1015 d->cleanupModalSessions(); 1016 #endif 1017 1018 if (d->interrupt) { 1019 #ifdef QT_MAC_USE_COCOA 1020 if (d->currentExecIsNSAppRun) { 1021 // The event dispatcher has been interrupted. But since 1022 // [NSApplication run] is running the event loop, we 1023 // delayed stopping it until now (to let cocoa process 1024 // pending cocoa events first). 1025 if (d->currentModalSessionCached) 1026 d->temporarilyStopAllModalSessions(); 1027 [NSApp stop:NSApp]; 1028 d->cancelWaitForMoreEvents(); 1029 } 1030 #endif 1031 return; 1032 } 1033 1034 if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) { 1035 d->lastSerial = d->serialNumber; 1036 QApplicationPrivate::sendPostedEvents(0, 0, d->threadData); 977 1037 } 978 1038 } … … 984 1044 Q_UNUSED(ref); 985 1045 Q_UNUSED(activity); 1046 #ifdef QT_MAC_USE_COCOA 1047 QApplicationPrivate::qt_initAfterNSAppStarted(); 1048 #endif 986 1049 processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents); 987 1050 } … … 991 1054 processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents); 992 1055 } 1056 1057 #ifdef QT_MAC_USE_COCOA 1058 void QEventDispatcherMacPrivate::cancelWaitForMoreEvents() 1059 { 1060 // In case the event dispatcher is waiting for more 1061 // events somewhere, we post a dummy event to wake it up: 1062 QMacCocoaAutoReleasePool pool; 1063 [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint 1064 modifierFlags:0 timestamp:0. windowNumber:0 context:0 1065 subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO]; 1066 } 1067 #endif 993 1068 994 1069 void QEventDispatcherMac::interrupt() … … 1001 1076 CFRunLoopStop(mainRunLoop()); 1002 1077 #else 1003 QMacCocoaAutoReleasePool pool; 1004 // In case we wait for more events inside 1005 // processEvents (or NSApp run), post a dummy to wake it up: 1006 static const short NSAppShouldStopForQt = SHRT_MAX; 1007 [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint 1008 modifierFlags:0 timestamp:0. windowNumber:0 context:0 1009 subtype:NSAppShouldStopForQt data1:0 data2:0] atStart:NO]; 1010 1011 if (d->activeModalSessionCount() == 0) { 1012 // We should only stop NSApp if we actually started it (and 1013 // not some 3rd party application, e.g. if we are a plugin). 1014 if (d->nsAppRunCalledByQt) 1015 [NSApp stop:NSApp]; 1016 } 1078 // We do nothing more here than setting d->interrupt = true, and 1079 // poke the event loop if it is sleeping. Actually stopping 1080 // NSApp, or the current modal session, is done inside the send 1081 // posted events callback. We do this to ensure that all current pending 1082 // cocoa events gets delivered before we stop. Otherwise, if we now stop 1083 // the last event loop recursion, cocoa will just drop pending posted 1084 // events on the floor before we get a chance to reestablish a new session. 1085 d->cancelWaitForMoreEvents(); 1017 1086 #endif 1018 1087 } … … 1055 1124 } 1056 1125 1057 /////////////////////////////////////////////////////////////////////////////1058 1059 1126 #ifdef QT_MAC_USE_COCOA 1060 1127 … … 1063 1130 QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(false) 1064 1131 { 1065 // This is the whole point of encapsulation this code 1066 // inside a class; we can make the code (inside destructor) 1067 // execute on lower loop level: 1132 // The whole point of this class is that we enable a way to interrupt 1133 // the event dispatcher when returning back to a lower recursion level 1134 // than where interruptLater was called. This is needed to detect if 1135 // [NSApp run] should still be running at the recursion level it is at. 1136 // Since the interrupt is canceled if processEvents is called before 1137 // this object gets deleted, we also avoid interrupting unnecessary. 1068 1138 deleteLater(); 1069 1139 } … … 1073 1143 if (cancelled) 1074 1144 return; 1075 1076 1145 instance = 0; 1077 1078 if (QEventDispatcherMacPrivate::currentExecIsNSAppRun) {1079 int activeCount = QEventDispatcherMacPrivate::activeModalSessionCount();1080 if (activeCount > 0) {1081 // The problem we now have hit: [NSApp stop] will not stop NSApp1082 // if a session is active; it will stop the session instead.1083 // So to stop NSApp, we need to temporarily stop all the1084 // sessions, then stop NSApp, then restart the session on top again.1085 // We need to do this to ensure that we're not stuck inside1086 // [NSApp run] when we really should be running a modal session:1087 QEventDispatcherMacPrivate::temporarilyStopAllModalSessions();1088 }1089 }1090 // Always interrupt once more in case the modal session stack changed1091 // while processEvents was called manually from within the application:1092 1146 QEventDispatcherMac::instance()->interrupt(); 1093 1147 } 1094 1148 1095 void QtMacInterruptDispatcherHelp::interruptLater() { 1096 if (instance) { 1097 instance->cancelled = true; 1098 delete instance; 1099 } 1149 void QtMacInterruptDispatcherHelp::cancelInterruptLater() 1150 { 1151 if (!instance) 1152 return; 1153 instance->cancelled = true; 1154 delete instance; 1155 instance = 0; 1156 } 1157 1158 void QtMacInterruptDispatcherHelp::interruptLater() 1159 { 1160 cancelInterruptLater(); 1100 1161 instance = new QtMacInterruptDispatcherHelp; 1101 1162 } … … 1104 1165 1105 1166 QT_END_NAMESPACE 1167 -
trunk/src/gui/kernel/qeventdispatcher_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 101 101 QPointer<QWidget> widget; 102 102 NSModalSession session; 103 void *nswindow; 103 104 } QCocoaModalSessionInfo; 104 105 #endif … … 175 176 static bool currentExecIsNSAppRun; 176 177 static bool nsAppRunCalledByQt; 178 static bool cleanupModalSessionsNeeded; 177 179 static NSModalSession currentModalSessionCached; 180 static NSModalSession currentModalSession(); 178 181 static void updateChildrenWorksWhenModal(); 179 static NSModalSession currentModalSession();180 static int activeModalSessionCount();181 182 static void temporarilyStopAllModalSessions(); 182 183 static void beginModalSession(QWidget *widget); 183 184 static void endModalSession(QWidget *widget); 185 static void cancelWaitForMoreEvents(); 186 static void cleanupModalSessions(); 187 static void ensureNSAppInitialized(); 184 188 #endif 185 189 … … 191 195 QAtomicInt serialNumber; 192 196 int lastSerial; 193 bool interrupt;197 static bool interrupt; 194 198 private: 195 199 static Boolean postedEventSourceEqualCallback(const void *info1, const void *info2); … … 212 216 public: 213 217 static void interruptLater(); 218 static void cancelInterruptLater(); 214 219 }; 215 220 #endif -
trunk/src/gui/kernel/qeventdispatcher_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qeventdispatcher_qws_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qeventdispatcher_s60.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 45 45 46 46 QT_BEGIN_NAMESPACE 47 48 QtEikonEnv::QtEikonEnv() 49 : m_lastIterationCount(0) 50 , m_savedStatusCode(KRequestPending) 51 , m_hasAlreadyRun(false) 52 { 53 } 54 55 QtEikonEnv::~QtEikonEnv() 56 { 57 } 58 59 void QtEikonEnv::RunL() 60 { 61 QEventDispatcherS60 *dispatcher = qobject_cast<QEventDispatcherS60 *>(QAbstractEventDispatcher::instance()); 62 if (!dispatcher) { 63 CEikonEnv::RunL(); 64 return; 65 } 66 67 if (m_lastIterationCount != dispatcher->iterationCount()) { 68 m_hasAlreadyRun = false; 69 m_lastIterationCount = dispatcher->iterationCount(); 70 } 71 72 if (m_hasAlreadyRun) { 73 // Fool the active scheduler into believing we are still waiting for events. 74 // The window server thinks we are not, however. 75 m_savedStatusCode = iStatus.Int(); 76 iStatus = KRequestPending; 77 SetActive(); 78 dispatcher->queueDeferredActiveObjectsCompletion(); 79 } else { 80 m_hasAlreadyRun = true; 81 CEikonEnv::RunL(); 82 } 83 } 84 85 void QtEikonEnv::DoCancel() 86 { 87 complete(); 88 89 CEikonEnv::DoCancel(); 90 } 91 92 void QtEikonEnv::complete() 93 { 94 if (m_hasAlreadyRun) { 95 if (m_savedStatusCode != KRequestPending) { 96 TRequestStatus *status = &iStatus; 97 QEventDispatcherSymbian::RequestComplete(status, m_savedStatusCode); 98 m_savedStatusCode = KRequestPending; 99 } 100 m_hasAlreadyRun = false; 101 } 102 } 47 103 48 104 QEventDispatcherS60::QEventDispatcherS60(QObject *parent) … … 128 184 } 129 185 186 // reimpl 187 void QEventDispatcherS60::reactivateDeferredActiveObjects() 188 { 189 if (S60->qtOwnsS60Environment) { 190 static_cast<QtEikonEnv *>(CCoeEnv::Static())->complete(); 191 } 192 193 QEventDispatcherSymbian::reactivateDeferredActiveObjects(); 194 } 195 130 196 QT_END_NAMESPACE -
trunk/src/gui/kernel/qeventdispatcher_s60_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 57 57 #include "qt_s60_p.h" 58 58 59 #include <eikenv.h> 60 59 61 QT_BEGIN_NAMESPACE 62 63 class QEventDispatcherS60; 64 65 class QtEikonEnv : public CEikonEnv 66 { 67 public: 68 QtEikonEnv(); 69 ~QtEikonEnv(); 70 71 // from CActive. 72 void RunL(); 73 void DoCancel(); 74 75 void complete(); 76 77 private: 78 // Workaround for a BC break from S60 3.2 -> 5.0, where the CEikonEnv override was removed. 79 // To avoid linking to that when we build against 3.2, define an empty body here. 80 // Reserved_*() have been verified to be empty in the S60 code. 81 void Reserved_1() {} 82 void Reserved_2() {} 83 84 private: 85 int m_lastIterationCount; 86 TInt m_savedStatusCode; 87 bool m_hasAlreadyRun; 88 }; 60 89 61 90 class Q_GUI_EXPORT QEventDispatcherS60 : public QEventDispatcherSymbian … … 73 102 74 103 void saveInputEvent(QSymbianControl *control, QWidget *widget, QInputEvent *event); 104 105 void reactivateDeferredActiveObjects(); 75 106 76 107 private: -
trunk/src/gui/kernel/qeventdispatcher_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qeventdispatcher_x11_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qformlayout.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qformlayout.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qgesture.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 42 42 #include "qgesture.h" 43 43 #include "private/qgesture_p.h" 44 #include "private/qstandardgestures_p.h" 45 46 #ifndef QT_NO_GESTURES 44 47 45 48 QT_BEGIN_NAMESPACE … … 56 59 the QGestureRecognizer object that is registered with the application; see 57 60 QGestureRecognizer::registerRecognizer(). 61 62 For an overview of gesture handling in Qt and information on using gestures 63 in your applications, see the \l{Gestures Programming} document. 58 64 59 65 \section1 Gesture Properties … … 217 223 \image pangesture.png 218 224 219 \sa {Gestures Programming}, QPinchGesture, QSwipeGesture 225 For an overview of gesture handling in Qt and information on using gestures 226 in your applications, see the \l{Gestures Programming} document. 227 228 \sa QPinchGesture, QSwipeGesture 220 229 */ 221 230 … … 252 261 /*! 253 262 \property QPanGesture::acceleration 263 \brief the acceleration in the motion of the touch point for this gesture 264 */ 265 266 /*! 267 \property QPanGesture::horizontalVelocity 268 \brief the horizontal component of the motion of the touch point for this 269 gesture 270 \since 4.7.1 271 \internal 272 273 \sa verticalVelocity, acceleration 274 */ 275 276 /*! 277 \property QPanGesture::verticalVelocity 278 \brief the vertical component of the motion of the touch point for this 279 gesture 280 \since 4.7.1 281 \internal 282 283 \sa horizontalVelocity, acceleration 254 284 */ 255 285 … … 304 334 \since 4.6 305 335 \brief The QPinchGesture class describes a pinch gesture made my the user. 306 \ingroup multitouch336 \ingroup touch 307 337 \ingroup gestures 308 338 309 A pinch gesture is a form of multitouch user input in which the user typically339 A pinch gesture is a form of touch user input in which the user typically 310 340 touches two points on the input device with a thumb and finger, before moving 311 341 them closer together or further apart to change the scale factor, zoom, or level 312 342 of detail of the user interface. 343 344 For an overview of gesture handling in Qt and information on using gestures 345 in your applications, see the \l{Gestures Programming} document. 313 346 314 347 \image pinchgesture.png … … 320 353 of QPinchGesture in the Qt::GestureUpdated state. 321 354 322 \sa {Gestures Programming},QPanGesture, QSwipeGesture355 \sa QPanGesture, QSwipeGesture 323 356 */ 324 357 … … 387 420 388 421 The scale factor measures the scale factor associated with the distance 389 between two of the user's inputs on a multitouch device.422 between two of the user's inputs on a touch device. 390 423 391 424 \sa totalScaleFactor, lastScaleFactor … … 570 603 \image swipegesture.png 571 604 572 \sa {Gestures Programming}, QPanGesture, QPinchGesture 605 For an overview of gesture handling in Qt and information on using gestures 606 in your applications, see the \l{Gestures Programming} document. 607 608 \sa QPanGesture, QPinchGesture 573 609 */ 574 610 … … 613 649 swipe angle describes the angle between the direction of motion and the 614 650 x-axis as defined using the standard widget 615 \l{ TheCoordinate System}{coordinate system}.651 \l{Coordinate System}{coordinate system}. 616 652 617 653 \sa horizontalDirection, verticalDirection 654 */ 655 656 /*! 657 \property QSwipeGesture::velocity 658 \since 4.7.1 659 \internal 618 660 */ 619 661 … … 665 707 \ingroup gestures 666 708 667 \sa {Gestures Programming}, QPanGesture, QPinchGesture 709 For an overview of gesture handling in Qt and information on using gestures 710 in your applications, see the \l{Gestures Programming} document. 711 712 \sa QPanGesture, QPinchGesture 668 713 */ 669 714 … … 698 743 \ingroup gestures 699 744 700 \sa {Gestures Programming}, QPanGesture, QPinchGesture 745 For an overview of gesture handling in Qt and information on using gestures 746 in your applications, see the \l{Gestures Programming} document. 747 748 \sa QPanGesture, QPinchGesture 701 749 */ 702 750 … … 725 773 } 726 774 775 /*! 776 Set the timeout, in milliseconds, before the gesture triggers. 777 778 The recognizer will detect a touch down and and if \a msecs 779 later the touch is still down, it will trigger the QTapAndHoldGesture. 780 The default value is 700 milliseconds. 781 */ 782 // static 783 void QTapAndHoldGesture::setTimeout(int msecs) 784 { 785 QTapAndHoldGesturePrivate::Timeout = msecs; 786 } 787 788 /*! 789 Gets the timeout, in milliseconds, before the gesture triggers. 790 791 The recognizer will detect a touch down and and if timeout() 792 later the touch is still down, it will trigger the QTapAndHoldGesture. 793 The default value is 700 milliseconds. 794 */ 795 // static 796 int QTapAndHoldGesture::timeout() 797 { 798 return QTapAndHoldGesturePrivate::Timeout; 799 } 800 801 int QTapAndHoldGesturePrivate::Timeout = 700; // in ms 802 727 803 QT_END_NAMESPACE 804 805 #include <moc_qgesture.cpp> 806 807 #endif // QT_NO_GESTURES -
trunk/src/gui/kernel/qgesture.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 50 50 #include <QtCore/qmetatype.h> 51 51 52 #ifndef QT_NO_GESTURES 53 52 54 QT_BEGIN_HEADER 53 55 54 56 Q_DECLARE_METATYPE(Qt::GestureState) 57 Q_DECLARE_METATYPE(Qt::GestureType) 55 58 56 59 QT_BEGIN_NAMESPACE … … 111 114 Q_PROPERTY(QPointF delta READ delta STORED false) 112 115 Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration) 116 Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity) 117 Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity) 113 118 114 119 public: … … 133 138 Q_OBJECT 134 139 Q_DECLARE_PRIVATE(QPinchGesture) 140 Q_FLAGS(ChangeFlags ChangeFlag) 135 141 136 142 public: … … 190 196 }; 191 197 198 Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags) 199 192 200 QT_END_NAMESPACE 193 201 … … 206 214 Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false) 207 215 Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle) 216 Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity) 208 217 209 218 public: … … 251 260 void setPosition(const QPointF &pos); 252 261 262 static void setTimeout(int msecs); 263 static int timeout(); 264 253 265 friend class QTapAndHoldGestureRecognizer; 254 266 }; … … 259 271 QT_END_HEADER 260 272 273 #endif // QT_NO_GESTURES 274 261 275 #endif // QGESTURE_H -
trunk/src/gui/kernel/qgesture_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 56 56 #include "qrect.h" 57 57 #include "qpoint.h" 58 #include "qdatetime.h"59 58 #include "qgesture.h" 59 #include "qelapsedtimer.h" 60 60 #include "private/qobject_p.h" 61 62 #ifndef QT_NO_GESTURES 61 63 62 64 QT_BEGIN_NAMESPACE … … 70 72 : gestureType(Qt::CustomGesture), state(Qt::NoGesture), 71 73 isHotSpotSet(false), gestureCancelPolicy(0) 72 73 74 { 74 75 } … … 77 78 Qt::GestureState state; 78 79 QPointF hotSpot; 80 QPointF sceneHotSpot; 79 81 uint isHotSpotSet : 1; 80 82 uint gestureCancelPolicy : 2; … … 87 89 public: 88 90 QPanGesturePrivate() 89 : acceleration(0) 91 : acceleration(0), xVelocity(0), yVelocity(0) 90 92 { 91 93 } 94 95 qreal horizontalVelocity() const { return xVelocity; } 96 void setHorizontalVelocity(qreal value) { xVelocity = value; } 97 qreal verticalVelocity() const { return yVelocity; } 98 void setVerticalVelocity(qreal value) { yVelocity = value; } 92 99 93 100 QPointF lastOffset; … … 95 102 QPoint startPosition; 96 103 qreal acceleration; 104 qreal xVelocity; 105 qreal yVelocity; 97 106 }; 98 107 … … 104 113 QPinchGesturePrivate() 105 114 : totalChangeFlags(0), changeFlags(0), 106 totalScaleFactor( 0), lastScaleFactor(0), scaleFactor(0),115 totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), 107 116 totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), 108 117 isNewSequence(true) … … 138 147 verticalDirection(QSwipeGesture::NoDirection), 139 148 swipeAngle(0), 140 started(false), speed(0)149 started(false), velocityValue(0) 141 150 { 142 151 } 152 153 qreal velocity() const { return velocityValue; } 154 void setVelocity(qreal value) { velocityValue = value; } 143 155 144 156 QSwipeGesture::SwipeDirection horizontalDirection; … … 148 160 QPoint lastPositions[3]; 149 161 bool started; 150 qreal speed;151 Q Timetime;162 qreal velocityValue; 163 QElapsedTimer time; 152 164 }; 153 165 … … 176 188 QPointF position; 177 189 int timerId; 190 static int Timeout; 178 191 }; 179 192 180 193 QT_END_NAMESPACE 181 194 195 #endif // QT_NO_GESTURES 196 182 197 #endif // QGESTURE_P_H -
trunk/src/gui/kernel/qgesturemanager.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 67 67 #endif 68 68 69 #ifndef QT_NO_GESTURES 70 69 71 QT_BEGIN_NAMESPACE 70 72 71 73 QGestureManager::QGestureManager(QObject *parent) 72 : QObject(parent), state(NotGesture), m_lastCustomGestureId( 0)74 : QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture) 73 75 { 74 76 qRegisterMetaType<Qt::GestureState>(); … … 118 120 // generate a new custom gesture id 119 121 ++m_lastCustomGestureId; 120 type = Qt::GestureType( Qt::CustomGesture +m_lastCustomGestureId);122 type = Qt::GestureType(m_lastCustomGestureId); 121 123 } 122 124 m_recognizers.insertMulti(type, recognizer); … … 128 130 { 129 131 QList<QGestureRecognizer *> list = m_recognizers.values(type); 130 m_recognizers.remove(type); 132 while (QGestureRecognizer *recognizer = m_recognizers.take(type)) { 133 if (!m_obsoleteGestures.contains(recognizer)) { 134 // inserting even an empty QSet will cause the recognizer to be deleted on destruction of the manager 135 m_obsoleteGestures.insert(recognizer, QSet<QGesture *>()); 136 } 137 } 131 138 foreach (QGesture *g, m_gestureToRecognizer.keys()) { 132 139 QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); 133 140 if (list.contains(recognizer)) { 134 141 m_deletedRecognizers.insert(g, recognizer); 135 m_gestureToRecognizer.remove(g); 136 } 137 } 138 139 foreach (QGestureRecognizer *recognizer, list) { 140 QList<QGesture *> obsoleteGestures; 141 QMap<ObjectGesture, QList<QGesture *> >::Iterator iter = m_objectGestures.begin(); 142 while (iter != m_objectGestures.end()) { 143 ObjectGesture objectGesture = iter.key(); 144 if (objectGesture.gesture == type) 145 obsoleteGestures << iter.value(); 146 ++iter; 147 } 148 m_obsoleteGestures.insert(recognizer, obsoleteGestures); 142 } 143 } 144 145 QMap<ObjectGesture, QList<QGesture *> >::const_iterator iter = m_objectGestures.begin(); 146 while (iter != m_objectGestures.end()) { 147 ObjectGesture objectGesture = iter.key(); 148 if (objectGesture.gesture == type) { 149 foreach (QGesture *g, iter.value()) { 150 if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g)) { 151 m_gestureToRecognizer.remove(g); 152 m_obsoleteGestures[recognizer].insert(g); 153 } 154 } 155 } 156 ++iter; 149 157 } 150 158 } … … 155 163 while (iter != m_objectGestures.end()) { 156 164 ObjectGesture objectGesture = iter.key(); 157 if (objectGesture.gesture == type && target == objectGesture.object.data()) { 158 qDeleteAll(iter.value()); 165 if (objectGesture.gesture == type && target == objectGesture.object) { 166 QSet<QGesture *> gestures = iter.value().toSet(); 167 for (QHash<QGestureRecognizer *, QSet<QGesture *> >::iterator 168 it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e; ++it) { 169 it.value() -= gestures; 170 } 171 foreach (QGesture *g, gestures) { 172 m_deletedRecognizers.remove(g); 173 m_gestureToRecognizer.remove(g); 174 m_maybeGestures.remove(g); 175 m_activeGestures.remove(g); 176 m_gestureOwners.remove(g); 177 m_gestureTargets.remove(g); 178 m_gesturesToDelete.insert(g); 179 } 180 159 181 iter = m_objectGestures.erase(iter); 160 182 } else { … … 167 189 QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recognizer, Qt::GestureType type) 168 190 { 169 // if the widget is being deleted we should be careful l andnot to170 // create a new state, as it will create QWeakPointer which doesn t work191 // if the widget is being deleted we should be careful not to 192 // create a new state, as it will create QWeakPointer which doesn't work 171 193 // from the destructor. 172 194 if (object->isWidgetType()) { … … 178 200 } else { 179 201 Q_ASSERT(qobject_cast<QGraphicsObject *>(object)); 202 QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(object); 203 if (graphicsObject->QGraphicsItem::d_func()->inDestructor) 204 return 0; 180 205 #endif 181 206 } … … 272 297 QSet<QGesture *> activeToMaybeGestures = m_activeGestures & newMaybeGestures; 273 298 299 // check if a maybe gesture switched to canceled - reset it but don't send an event 300 QSet<QGesture *> maybeToCanceledGestures = m_maybeGestures & notGestures; 301 274 302 // check if a running gesture switched back to not gesture state, 275 303 // i.e. were canceled 276 304 QSet<QGesture *> canceledGestures = m_activeGestures & notGestures; 277 305 278 // start timers for new gestures in maybe state 279 foreach (QGesture *state, newMaybeGestures) { 280 QBasicTimer &timer = m_maybeGestures[state]; 281 if (!timer.isActive()) 282 timer.start(3000, this); 283 } 284 // kill timers for gestures that were in maybe state 306 // new gestures in maybe state 307 m_maybeGestures += newMaybeGestures; 308 309 // gestures that were in maybe state 285 310 QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures 286 311 | finishedGestures | canceledGestures 287 312 | notGestures); 288 foreach(QGesture *gesture, notMaybeGestures) { 289 QHash<QGesture *, QBasicTimer>::iterator it = 290 m_maybeGestures.find(gesture); 291 if (it != m_maybeGestures.end()) { 292 it.value().stop(); 293 m_maybeGestures.erase(it); 294 } 295 } 313 m_maybeGestures -= notMaybeGestures; 296 314 297 315 Q_ASSERT((startedGestures & finishedGestures).isEmpty()); … … 337 355 DEBUG() << "QGestureManager::filterEventThroughContexts:" 338 356 << "\n\tactiveGestures:" << m_activeGestures 339 << "\n\tmaybeGestures:" << m_maybeGestures .keys()357 << "\n\tmaybeGestures:" << m_maybeGestures 340 358 << "\n\tstarted:" << startedGestures 341 359 << "\n\ttriggered:" << triggeredGestures 342 360 << "\n\tfinished:" << finishedGestures 343 << "\n\tcanceled:" << canceledGestures; 361 << "\n\tcanceled:" << canceledGestures 362 << "\n\tmaybe-canceled:" << maybeToCanceledGestures; 344 363 } 345 364 … … 362 381 // reset gestures that ended 363 382 QSet<QGesture *> endedGestures = 364 finishedGestures + canceledGestures + undeliveredGestures ;383 finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; 365 384 foreach (QGesture *gesture, endedGestures) { 366 385 recycle(gesture); 367 386 m_gestureTargets.remove(gesture); 368 387 } 388 389 //Clean up the Gestures 390 qDeleteAll(m_gesturesToDelete); 391 m_gesturesToDelete.clear(); 392 369 393 return ret; 370 394 } … … 429 453 { 430 454 QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture); 431 Q_ASSERT(recognizer); 455 if(!recognizer) //The Gesture is removed while in the even loop, so the recognizers for this gestures was removed 456 return; 432 457 m_deletedRecognizers.remove(gesture); 433 458 if (m_deletedRecognizers.keys(recognizer).isEmpty()) { … … 582 607 // guess the target widget using the hotspot of the gesture 583 608 QPoint pt = gesture->hotSpot().toPoint(); 584 if (QWidget *w = qApp->topLevelAt(pt)) { 585 target = w->childAt(w->mapFromGlobal(pt)); 609 if (QWidget *topLevel = qApp->topLevelAt(pt)) { 610 QWidget *child = topLevel->childAt(topLevel->mapFromGlobal(pt)); 611 target = child ? child : topLevel; 586 612 } 587 613 } else { … … 676 702 } 677 703 678 void QGestureManager::timerEvent(QTimerEvent *event)679 {680 QHash<QGesture *, QBasicTimer>::iterator it = m_maybeGestures.begin(),681 e = m_maybeGestures.end();682 for (; it != e; ) {683 QBasicTimer &timer = it.value();684 Q_ASSERT(timer.isActive());685 if (timer.timerId() == event->timerId()) {686 timer.stop();687 QGesture *gesture = it.key();688 it = m_maybeGestures.erase(it);689 DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:"690 << gesture;691 recycle(gesture);692 } else {693 ++it;694 }695 }696 }697 698 704 void QGestureManager::recycle(QGesture *gesture) 699 705 { … … 702 708 gesture->setGestureCancelPolicy(QGesture::CancelNone); 703 709 recognizer->reset(gesture); 710 m_activeGestures.remove(gesture); 704 711 } else { 705 712 cleanupGesturesForRemovedRecognizer(gesture); … … 709 716 QT_END_NAMESPACE 710 717 718 #endif // QT_NO_GESTURES 719 711 720 #include "moc_qgesturemanager_p.cpp" -
trunk/src/gui/kernel/qgesturemanager_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 59 59 #include "qgesturerecognizer.h" 60 60 61 #ifndef QT_NO_GESTURES 62 61 63 QT_BEGIN_NAMESPACE 62 64 … … 86 88 87 89 protected: 88 void timerEvent(QTimerEvent *event);89 90 bool filterEventThroughContexts(const QMultiMap<QObject *, Qt::GestureType> &contexts, 90 91 QEvent *event); … … 94 95 95 96 QSet<QGesture *> m_activeGestures; 96 Q Hash<QGesture *, QBasicTimer> m_maybeGestures;97 QSet<QGesture *> m_maybeGestures; 97 98 98 99 enum State { … … 101 102 MaybeGesture // this means timers are up and waiting for some 102 103 // more events, and input events are handled by 103 // gesture recognizer explicit ely104 // gesture recognizer explicitly 104 105 } state; 105 106 106 107 struct ObjectGesture 107 108 { 108 Q WeakPointer<QObject>object;109 QObject* object; 109 110 Qt::GestureType gesture; 110 111 … … 112 113 inline bool operator<(const ObjectGesture &rhs) const 113 114 { 114 if (object .data() < rhs.object.data())115 if (object < rhs.object) 115 116 return true; 116 117 if (object == rhs.object) … … 128 129 int m_lastCustomGestureId; 129 130 130 QHash<QGestureRecognizer *, Q List<QGesture *> > m_obsoleteGestures;131 QHash<QGestureRecognizer *, QSet<QGesture *> > m_obsoleteGestures; 131 132 QHash<QGesture *, QGestureRecognizer *> m_deletedRecognizers; 133 QSet<QGesture *> m_gesturesToDelete; 132 134 void cleanupGesturesForRemovedRecognizer(QGesture *gesture); 133 135 … … 145 147 QT_END_NAMESPACE 146 148 149 #endif // QT_NO_GESTURES 150 147 151 #endif // QGESTUREMANAGER_P_H -
trunk/src/gui/kernel/qgesturerecognizer.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 45 45 #include "private/qgesturemanager_p.h" 46 46 47 #ifndef QT_NO_GESTURES 48 47 49 QT_BEGIN_NAMESPACE 48 50 … … 60 62 need to use this class directly. Instances will be created behind the scenes by the 61 63 framework. 64 65 For an overview of gesture handling in Qt and information on using gestures 66 in your applications, see the \l{Gestures Programming} document. 62 67 63 68 \section1 Recognizing Gestures … … 162 167 Reimplement this function to create a custom QGesture-derived gesture 163 168 object if necessary. 169 170 The application takes ownership of the created gesture object. 164 171 */ 165 172 QGesture *QGestureRecognizer::create(QObject *target) … … 182 189 d->state = Qt::NoGesture; 183 190 d->hotSpot = QPointF(); 191 d->sceneHotSpot = QPointF(); 184 192 d->isHotSpotSet = false; 185 193 } … … 229 237 230 238 QT_END_NAMESPACE 239 240 #endif // QT_NO_GESTURES -
trunk/src/gui/kernel/qgesturerecognizer.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 45 45 #include <QtCore/qglobal.h> 46 46 #include <QtCore/qnamespace.h> 47 48 #ifndef QT_NO_GESTURES 47 49 48 50 QT_BEGIN_HEADER … … 96 98 QT_END_HEADER 97 99 100 #endif // QT_NO_GESTURES 101 98 102 #endif // QGESTURERECOGNIZER_H -
trunk/src/gui/kernel/qgridlayout.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qgridlayout.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qguieventdispatcher_glib.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 217 217 } 218 218 219 void QGuiEventDispatcherGlib::flush() 220 { 221 XFlush(X11->display); 222 } 223 219 224 QT_END_NAMESPACE -
trunk/src/gui/kernel/qguieventdispatcher_glib_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 72 72 73 73 void startingUp(); 74 void flush(); 74 75 }; 75 76 -
trunk/src/gui/kernel/qguifunctions_wince.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 77 77 #endif 78 78 79 #ifndef SHDB_HIDE 80 #define SHDB_HIDE 0x0002 81 #endif 82 79 83 #ifndef SHFS_SHOWTASKBAR 80 84 #define SHFS_SHOWTASKBAR 0x0001 … … 113 117 typedef BOOL (*AygFullScreen)(HWND, DWORD); 114 118 typedef BOOL (*AygSHSipInfo)(UINT, UINT, PVOID, UINT); 119 typedef BOOL (*AygSHDoneButton)(HWND, DWORD); 115 120 116 121 static AygInitDialog ptrAygInitDialog = 0; 117 122 static AygFullScreen ptrAygFullScreen = 0; 118 123 static AygSHSipInfo ptrAygSHSipInfo = 0; 124 static AygSHDoneButton ptrAygSHDoneButton = 0; 119 125 static bool aygResolved = false; 120 126 … … 129 135 ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen"); 130 136 ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo"); 131 } 132 } 133 134 struct DIBINFO : public BITMAPINFO 135 { 136 RGBQUAD arColors[255]; 137 138 operator LPBITMAPINFO() { return (LPBITMAPINFO) this; } 139 operator LPBITMAPINFOHEADER() { return &bmiHeader; } 140 RGBQUAD* ColorTable() { return bmiColors; } 141 }; 137 ptrAygSHDoneButton = (AygSHDoneButton) ayglib.resolve("SHDoneButton"); 138 } 139 } 142 140 143 141 int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint) … … 324 322 if (widget->windowFlags() & Qt::WindowOkButtonHint) 325 323 shidi.dwFlags |= SHIDIF_DONEBUTTON; 324 if (!(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint))) 325 shidi.dwFlags |= SHIDIF_CANCELBUTTON; 326 326 resolveAygLibs(); 327 327 if (ptrAygInitDialog) … … 332 332 MoveWindow(hwnd, r.top, r.left, r.right - r.left, r.bottom - r.top, true); 333 333 SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong (hwnd, GWL_EXSTYLE) | WS_EX_NODRAG); 334 } 335 } 336 337 void qt_wince_unmaximize(QWidget *widget) 338 { 339 if (ptrAygSHDoneButton && qt_wince_is_mobile() 340 && !(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint))) 341 { 342 // Hide the [X] button, we've added in qt_wince_maximize. 343 ptrAygSHDoneButton(widget->winId(), SHDB_HIDE); 334 344 } 335 345 } -
trunk/src/gui/kernel/qguifunctions_wince.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qguiplatformplugin.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 82 82 if (!plugin) 83 83 { 84 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)84 #ifndef QT_NO_LIBRARY 85 85 86 86 QString key = QString::fromLocal8Bit(qgetenv("QT_PLATFORM_PLUGIN")); … … 190 190 } 191 191 192 /* return an ad itional default palette (only work on X11) */192 /* return an additional default palette (only work on X11) */ 193 193 QPalette QGuiPlatformPlugin::palette() 194 194 { -
trunk/src/gui/kernel/qguiplatformplugin_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qguivariant.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qkde.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qkde_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qkeymapper.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qkeymapper_mac.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 324 324 }; 325 325 326 static qt_mac_enum_mapper qt_mac_private_unicode[] = { 327 { 0xF700, QT_MAC_MAP_ENUM(Qt::Key_Up) }, //NSUpArrowFunctionKey 328 { 0xF701, QT_MAC_MAP_ENUM(Qt::Key_Down) }, //NSDownArrowFunctionKey 329 { 0xF702, QT_MAC_MAP_ENUM(Qt::Key_Left) }, //NSLeftArrowFunctionKey 330 { 0xF703, QT_MAC_MAP_ENUM(Qt::Key_Right) }, //NSRightArrowFunctionKey 331 { 0xF727, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertFunctionKey 332 { 0xF728, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteFunctionKey 333 { 0xF729, QT_MAC_MAP_ENUM(Qt::Key_Home) }, //NSHomeFunctionKey 334 { 0xF72B, QT_MAC_MAP_ENUM(Qt::Key_End) }, //NSEndFunctionKey 335 { 0xF72C, QT_MAC_MAP_ENUM(Qt::Key_PageUp) }, //NSPageUpFunctionKey 336 { 0xF72D, QT_MAC_MAP_ENUM(Qt::Key_PageDown) }, //NSPageDownFunctionKey 337 { 0xF72F, QT_MAC_MAP_ENUM(Qt::Key_ScrollLock) }, //NSScrollLockFunctionKey 338 { 0xF730, QT_MAC_MAP_ENUM(Qt::Key_Pause) }, //NSPauseFunctionKey 339 { 0xF731, QT_MAC_MAP_ENUM(Qt::Key_SysReq) }, //NSSysReqFunctionKey 340 { 0xF735, QT_MAC_MAP_ENUM(Qt::Key_Menu) }, //NSMenuFunctionKey 341 { 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintFunctionKey 342 { 0xF73A, QT_MAC_MAP_ENUM(Qt::Key_Clear) }, //NSClearDisplayFunctionKey 343 { 0xF73D, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertCharFunctionKey 344 { 0xF73E, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteCharFunctionKey 345 { 0xF741, QT_MAC_MAP_ENUM(Qt::Key_Select) }, //NSSelectFunctionKey 346 { 0xF742, QT_MAC_MAP_ENUM(Qt::Key_Execute) }, //NSExecuteFunctionKey 347 { 0xF746, QT_MAC_MAP_ENUM(Qt::Key_Help) }, //NSHelpFunctionKey 348 { 0xF747, QT_MAC_MAP_ENUM(Qt::Key_Mode_switch) }, //NSModeSwitchFunctionKey 349 { 0, QT_MAC_MAP_ENUM(0) } 350 }; 351 326 352 static int qt_mac_get_key(int modif, const QChar &key, int virtualKey) 327 353 { … … 378 404 return qt_mac_keyvkey_symbols[i].qt_code; 379 405 } 406 } 407 408 // check if they belong to key codes in private unicode range 409 if (key >= 0xf700 && key <= 0xf747) { 410 if (key >= 0xf704 && key <= 0xf726) { 411 return Qt::Key_F1 + (key.unicode() - 0xf704) ; 412 } 413 for (int i = 0; qt_mac_private_unicode[i].qt_code; i++) { 414 if (qt_mac_private_unicode[i].mac_code == key) { 415 return qt_mac_private_unicode[i].qt_code; 416 } 417 } 418 380 419 } 381 420 … … 634 673 if (iso639Code) { 635 674 keyboardInputLocale = QLocale(QCFString::toQString(iso639Code)); 636 QString monday = keyboardInputLocale.dayName(1); 637 bool rtl = false; 638 for (int i = 0; i < monday.length(); ++i) { 639 switch (monday.at(i).direction()) { 640 default: 641 break; 642 case QChar::DirR: 643 case QChar::DirAL: 644 case QChar::DirRLE: 645 case QChar::DirRLO: 646 rtl = true; 647 break; 648 } 649 if (rtl) 650 break; 651 } 652 keyboardInputDirection = rtl ? Qt::RightToLeft : Qt::LeftToRight; 675 keyboardInputDirection = keyboardInputLocale.textDirection(); 653 676 } else { 654 677 keyboardInputLocale = QLocale::c(); … … 718 741 } 719 742 720 if (qApp->inputContext() && qApp->inputContext()->isComposing()) { 743 QInputContext *currentContext = qApp->inputContext(); 744 if (currentContext && currentContext->isComposing()) { 721 745 if (ekind == kEventRawKeyDown) { 722 QMacInputContext *context = qobject_cast<QMacInputContext*>( qApp->inputContext());746 QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext); 723 747 if (context) 724 748 context->setLastKeydownEvent(event); … … 726 750 return false; 727 751 } 752 // Once we process the key down , we don't need to send the saved event again from 753 // kEventTextInputUnicodeForKeyEvent, so clear it. 754 if (currentContext && ekind == kEventRawKeyDown) { 755 QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext); 756 if (context) 757 context->setLastKeydownEvent(0); 758 } 759 728 760 //get modifiers 729 761 Qt::KeyboardModifiers modifiers; … … 734 766 return handled_event; 735 767 QString text(ourChar); 736 /* This is actually wrong - but unfortunat ly it is the best that can be768 /* This is actually wrong - but unfortunately it is the best that can be 737 769 done for now because of the Control/Meta mapping problems */ 738 770 if (modifiers & (Qt::ControlModifier | Qt::MetaModifier) … … 835 867 GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0, 836 868 sizeof(macModifiers), 0, &macModifiers); 869 #ifdef QT_MAC_USE_COCOA 870 // The unicode characters in the range 0xF700-0xF747 are reserved 871 // by Mac OS X for transient use as keyboard function keys. We 872 // wont send 'text' for such key events. This is done to match 873 // behavior on other platforms. 874 unsigned int *unicodeKey = (unsigned int*)info; 875 if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747) 876 text = QString(); 877 bool isAccepted; 878 #endif 837 879 handled_event = QKeyMapper::sendKeyEvent(widget, grab, 838 880 (ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress, … … 840 882 macScanCode, macVirtualKey, macModifiers 841 883 #ifdef QT_MAC_USE_COCOA 842 , static_cast<bool *>(info)884 ,&isAccepted 843 885 #endif 844 886 ); 887 #ifdef QT_MAC_USE_COCOA 888 *unicodeKey = (unsigned int)isAccepted; 889 #endif 845 890 } 846 891 return handled_event; … … 848 893 849 894 void 850 QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *) 895 QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void * 896 #if defined(QT_MAC_USE_COCOA) 897 unicodeKey // unicode character from NSEvent (modifiers applied) 898 #endif 899 ) 851 900 { 852 901 UInt32 macVirtualKey = 0; … … 876 925 keyLayout[macVirtualKey]->qtKey[i] = qtkey; 877 926 } 927 #ifndef Q_WS_MAC32 928 else { 929 const QChar unicode(*((UniChar *)unicodeKey)); 930 int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey); 931 if (qtkey == Qt::Key_unknown) 932 qtkey = unicode.unicode(); 933 keyLayout[macVirtualKey]->qtKey[i] = qtkey; 934 } 935 #endif 878 936 #ifdef Q_WS_MAC32 879 937 } else { -
trunk/src/gui/kernel/qkeymapper_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 193 193 bool grab); 194 194 195 bool useXKB;195 int xkb_currentGroup; 196 196 QXCoreDesc coreDesc; 197 197 -
trunk/src/gui/kernel/qkeymapper_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 53 53 { 54 54 keyboardInputLocale = QLocale::system(); 55 keyboardInputDirection = Qt::RightToLeft;55 keyboardInputDirection = keyboardInputLocale.textDirection(); 56 56 } 57 57 -
trunk/src/gui/kernel/qkeymapper_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 145 145 {EKeyDevice1, EStdKeyDevice1, Key_Context2}, // Found by manual testing. 146 146 {EKeyDevice3, EStdKeyDevice3, Key_Select}, 147 // {EKeyDevice7, EStdKeyDevice7, Key_Camera}, //not supported by qt yet 147 {EKeyDevice7, EStdKeyDevice7, Key_Camera}, 148 148 {EKeyApplication0, EStdKeyApplication0, Key_Menu}, // Found by manual testing. 149 149 {EKeyApplication1, EStdKeyApplication1, Key_Launch1}, // Found by manual testing. … … 162 162 {EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE}, 163 163 {EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF}, 164 // {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus}, //not supported by qt yet 164 {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus}, 165 165 {EKeyYes, EStdKeyYes, Key_Yes}, 166 166 {EKeyNo, EStdKeyNo, Key_No}, -
trunk/src/gui/kernel/qkeymapper_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 57 57 58 58 // Implemented elsewhere 59 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);59 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); 60 60 61 61 extern Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id); … … 620 620 * returns a DWORD. */ 621 621 622 LCID newLCID = MAKELCID(( DWORD)GetKeyboardLayout(0), SORT_DEFAULT);622 LCID newLCID = MAKELCID((quintptr)GetKeyboardLayout(0), SORT_DEFAULT); 623 623 // keyboardInputLocale = qt_localeFromLCID(newLCID); 624 624 -
trunk/src/gui/kernel/qkeymapper_x11.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 62 62 #include <ctype.h> 63 63 64 QT_BEGIN_NAMESPACE65 66 #ifndef QT_NO_XKB67 68 // bring in the auto-generated xkbLayoutData69 #include "qkeymapper_x11_p.cpp"70 71 64 #ifdef QT_LINUXBASE 72 65 // LSB's IsKeypadKey define is wrong - see … … 81 74 #endif 82 75 83 static void getLocaleAndDirection(QLocale *locale, 84 Qt::LayoutDirection *direction, 85 const QByteArray &layoutName, 86 const QByteArray &variantName) 76 QT_BEGIN_NAMESPACE 77 78 #ifndef QT_NO_XKB 79 80 // bring in the auto-generated xkbLayoutData 81 #include "qkeymapper_x11_p.cpp" 82 83 QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName) 87 84 { 88 85 int i = 0; 89 86 while (xkbLayoutData[i].layout != 0) { 90 if (layoutName == xkbLayoutData[i].layout && variantName == xkbLayoutData[i].variant) { 91 *locale = QLocale(xkbLayoutData[i].language, xkbLayoutData[i].country); 92 *direction = xkbLayoutData[i].direction; 93 return; 94 } 87 if (layoutName == xkbLayoutData[i].layout && variantName == xkbLayoutData[i].variant) 88 return QLocale(xkbLayoutData[i].language, xkbLayoutData[i].country); 95 89 ++i; 96 90 } 97 *locale = QLocale::c(); 98 *direction = Qt::LeftToRight; 91 return QLocale::c(); 99 92 } 100 93 #endif // QT_NO_XKB 101 102 94 103 95 // from qapplication_x11.cpp … … 249 241 250 242 QKeyMapperPrivate::QKeyMapperPrivate() 251 : keyboardInputDirection(Qt::LeftToRight), useXKB(false)243 : keyboardInputDirection(Qt::LeftToRight), xkb_currentGroup(0) 252 244 { 253 245 memset(&coreDesc, 0, sizeof(coreDesc)); 254 246 255 247 #ifndef QT_NO_XKB 256 int opcode = -1; 257 int xkbEventBase = -1; 258 int xkbErrorBase = -1; 259 int xkblibMajor = XkbMajorVersion; 260 int xkblibMinor = XkbMinorVersion; 261 if (XkbQueryExtension(X11->display, &opcode, &xkbEventBase, &xkbErrorBase, &xkblibMajor, &xkblibMinor)) 262 useXKB = true; 263 #endif 264 265 #if 0 266 qDebug() << "useXKB =" << useXKB; 248 if (X11->use_xkb) { 249 // get the current group 250 XkbStateRec xkbState; 251 if (XkbGetState(X11->display, XkbUseCoreKbd, &xkbState) == Success) 252 xkb_currentGroup = xkbState.group; 253 } 267 254 #endif 268 255 } … … 277 264 { 278 265 #ifndef QT_NO_XKB 279 if ( useXKB)266 if (X11->use_xkb) 280 267 return possibleKeysXKB(event); 281 268 #endif … … 487 474 { 488 475 #ifndef QT_NO_XKB 489 if ( useXKB) {476 if (X11->use_xkb) { 490 477 // try to determine the layout name and input direction by reading the _XKB_RULES_NAMES property off 491 478 // the root window … … 516 503 } while (p < end); 517 504 518 layoutName = QByteArray::fromRawData(names[2], qstrlen(names[2])); 519 variantName = QByteArray::fromRawData(names[3], qstrlen(names[3])); 505 // the layout names and variants are saved in the _XKB_RULES_NAMES property as a comma separated list 506 QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(','); 507 if (uint(xkb_currentGroup) < uint(layoutNames.count())) 508 layoutName = layoutNames.at(xkb_currentGroup); 509 QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(','); 510 if (uint(xkb_currentGroup) < uint(variantNames.count())) 511 variantName = variantNames.at(xkb_currentGroup); 520 512 } 521 513 … … 524 516 // qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ? 525 517 526 getLocaleAndDirection(&keyboardInputLocale, 527 &keyboardInputDirection, 528 layoutName, 529 variantName); 518 keyboardInputLocale = q_getKeyboardLocale(layoutName, variantName); 519 keyboardInputDirection = keyboardInputLocale.textDirection(); 530 520 531 521 #if 0 … … 535 525 << keyboardInputDirection; 536 526 #endif 537 538 527 if (data) 539 528 XFree(data); … … 575 564 // look at the modifier mapping, and get the correct masks for alt, meta, super, hyper, and mode_switch 576 565 #ifndef QT_NO_XKB 577 if ( useXKB) {566 if (X11->use_xkb) { 578 567 XkbDescPtr xkbDesc = XkbGetMap(X11->display, XkbAllClientInfoMask, XkbUseCoreKbd); 579 568 for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) { … … 1187 1176 XF86XK_LaunchC, Qt::Key_LaunchE, 1188 1177 XF86XK_LaunchD, Qt::Key_LaunchF, 1178 XF86XK_LaunchE, Qt::Key_LaunchG, 1179 XF86XK_LaunchF, Qt::Key_LaunchH, 1189 1180 1190 1181 // Qtopia keys -
trunk/src/gui/kernel/qkeymapper_x11_p.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 272 272 { "is", "nodeadkeys", Qt::LeftToRight, QLocale::Icelandic, QLocale::Iceland }, 273 273 // name = il, description = Israel 274 { "il", "", Qt:: LeftToRight, QLocale::Hebrew, QLocale::Israel },274 { "il", "", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel }, 275 275 // name = il:lyx, description = Israel 276 { "il", "lyx", Qt:: LeftToRight, QLocale::Hebrew, QLocale::Israel },276 { "il", "lyx", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel }, 277 277 // name = il:si1452, description = Israel 278 { "il", "si1452", Qt:: LeftToRight, QLocale::Hebrew, QLocale::Israel },278 { "il", "si1452", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel }, 279 279 // name = il:phonetic, description = Israel 280 { "il", "phonetic", Qt:: LeftToRight, QLocale::Hebrew, QLocale::Israel },280 { "il", "phonetic", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel }, 281 281 // name = it, description = Italy 282 282 { "it", "", Qt::LeftToRight, QLocale::Italian, QLocale::Italy }, … … 420 420 { "ch", "fr_sundeadkeys", Qt::LeftToRight, QLocale::French, QLocale::Switzerland }, 421 421 // name = sy, description = Syria 422 { "sy", "", Qt::RightToLeft, QLocale:: Arabic, QLocale::SyrianArabRepublic },422 { "sy", "", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic }, 423 423 // name = sy:syc, description = Syria 424 { "sy", "syc", Qt::RightToLeft, QLocale:: Arabic, QLocale::SyrianArabRepublic },424 { "sy", "syc", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic }, 425 425 // name = sy:syc_phonetic, description = Syria 426 { "sy", "syc_phonetic", Qt::RightToLeft, QLocale:: Arabic, QLocale::SyrianArabRepublic },426 { "sy", "syc_phonetic", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic }, 427 427 // name = tj, description = Tajikistan 428 428 { "tj", "", Qt::LeftToRight, QLocale::Tajik, QLocale::Tajikistan }, -
trunk/src/gui/kernel/qkeysequence.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 391 391 const char* name; 392 392 } keyname[] = { 393 //: This and all following "incomprehensible" strings in QShortcut context 394 //: are key names. Please use the localized names appearing on actual 395 //: keyboards or whatever is commonly used. 393 396 { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") }, 394 397 { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") }, … … 437 440 { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") }, 438 441 { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") }, 442 //: Media player pause button 443 { Qt::Key_MediaPause, QT_TRANSLATE_NOOP("QShortcut", "Media Pause") }, 444 //: Media player button to toggle between playing and paused 445 { Qt::Key_MediaTogglePlayPause, QT_TRANSLATE_NOOP("QShortcut", "Toggle Media Play/Pause") }, 439 446 { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") }, 440 447 { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") }, … … 573 580 // -------------------------------------------------------------- 574 581 // Device keys 575 { Qt::Key_Context1, QT_TRANSLATE_NOOP("QShortcut", "Context1") }, 576 { Qt::Key_Context2, QT_TRANSLATE_NOOP("QShortcut", "Context2") }, 577 { Qt::Key_Context3, QT_TRANSLATE_NOOP("QShortcut", "Context3") }, 578 { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") }, 579 { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") }, 580 { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") }, 581 { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") }, 582 582 { Qt::Key_Context1, QT_TRANSLATE_NOOP("QShortcut", "Context1") }, 583 { Qt::Key_Context2, QT_TRANSLATE_NOOP("QShortcut", "Context2") }, 584 { Qt::Key_Context3, QT_TRANSLATE_NOOP("QShortcut", "Context3") }, 585 { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") }, 586 //: Button to start a call (note: a separate button is used to end the call) 587 { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") }, 588 //: Button to end a call (note: a separate button is used to start the call) 589 { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") }, 590 //: Button that will hang up if we're in call, or make a call if we're not. 591 { Qt::Key_ToggleCallHangup, QT_TRANSLATE_NOOP("QShortcut", "Toggle Call/Hangup") }, 592 { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") }, 593 //: Button to trigger voice dialing 594 { Qt::Key_VoiceDial, QT_TRANSLATE_NOOP("QShortcut", "Voice Dial") }, 595 //: Button to redial the last number called 596 { Qt::Key_LastNumberRedial, QT_TRANSLATE_NOOP("QShortcut", "Last Number Redial") }, 597 //: Button to trigger the camera shutter (take a picture) 598 { Qt::Key_Camera, QT_TRANSLATE_NOOP("QShortcut", "Camera Shutter") }, 599 //: Button to focus the camera 600 { Qt::Key_CameraFocus, QT_TRANSLATE_NOOP("QShortcut", "Camera Focus") }, 601 602 // -------------------------------------------------------------- 603 // Japanese keyboard support 604 { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") }, 605 { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") }, 606 { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") }, 607 { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") }, 608 { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") }, 609 { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") }, 610 { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") }, 611 { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") }, 612 { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") }, 613 { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") }, 614 { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") }, 615 { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") }, 616 { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") }, 617 { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") }, 618 { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") }, 619 { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") }, 620 { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") }, 621 { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") }, 622 { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") }, 623 624 // -------------------------------------------------------------- 625 // Korean keyboard support 626 { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") }, 627 { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") }, 628 { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") }, 629 { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") }, 630 { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") }, 631 { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") }, 632 { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") }, 633 { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") }, 634 { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") }, 635 { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") }, 636 { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") }, 583 637 584 638 { 0, 0 } … … 697 751 {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11}, 698 752 {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Mac },//different priority from above 753 {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_X11}, 699 754 {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, 700 755 {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, … … 862 917 commas, e.g. "Alt+X,Ctrl+S,Q". 863 918 919 \a key should be in NativeText format. 920 864 921 This constructor is typically used with \link QObject::tr() tr 865 922 \endlink(), so that shortcut keys can be replaced in … … 875 932 d = new QKeySequencePrivate(); 876 933 assign(key); 934 } 935 936 /*! 937 \since 4.x 938 Creates a key sequence from the \a key string based on \a format. 939 */ 940 QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format) 941 { 942 d = new QKeySequencePrivate(); 943 assign(key, format); 877 944 } 878 945 … … 1039 1106 found = true; 1040 1107 } else { 1041 qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occur ences of '&'", qPrintable(text));1108 qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'", qPrintable(text)); 1042 1109 #endif 1043 1110 } … … 1056 1123 comma; for example, "Alt+X,Ctrl+S,Z". The return value is the 1057 1124 number of key codes added. 1125 \a keys should be in NativeText format. 1058 1126 */ 1059 1127 int QKeySequence::assign(const QString &ks) 1128 { 1129 return assign(ks, NativeText); 1130 } 1131 1132 /*! 1133 \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format) 1134 \since 4.x 1135 1136 Adds the given \a keys to the key sequence (based on \a format). 1137 \a keys may contain up to four key codes, provided they are 1138 separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return 1139 value is the number of key codes added. 1140 */ 1141 int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format) 1060 1142 { 1061 1143 QString keyseq = ks; … … 1087 1169 part = keyseq.left(-1 == p ? keyseq.length() : p - diff); 1088 1170 keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1)); 1089 d->key[n] = decodeString(part);1171 d->key[n] = QKeySequencePrivate::decodeString(part, format); 1090 1172 ++n; 1091 1173 } … … 1558 1640 QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format) 1559 1641 { 1560 QStringList sl = str.split(QLatin1String(", ")); 1561 int keys[4] = {0, 0, 0, 0}; 1562 int total = qMin(sl.count(), 4); 1563 for (int i = 0; i < total; ++i) 1564 keys[i] = QKeySequencePrivate::decodeString(sl[i], format); 1565 return QKeySequence(keys[0], keys[1], keys[2], keys[3]); 1642 return QKeySequence(str, format); 1566 1643 } 1567 1644 -
trunk/src/gui/kernel/qkeysequence.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 142 142 }; 143 143 144 enum SequenceFormat { 145 NativeText, 146 PortableText 147 }; 148 144 149 QKeySequence(); 145 150 QKeySequence(const QString &key); 151 QKeySequence(const QString &key, SequenceFormat format); 146 152 QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0); 147 153 QKeySequence(const QKeySequence &ks); … … 159 165 , Identical = ExactMatch 160 166 #endif 161 };162 163 enum SequenceFormat {164 NativeText,165 PortableText166 167 }; 167 168 … … 195 196 static QString encodeString(int key); 196 197 int assign(const QString &str); 198 int assign(const QString &str, SequenceFormat format); 197 199 void setKey(int key, int index); 198 200 -
trunk/src/gui/kernel/qkeysequence_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qlayout.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qlayout.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qlayout_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qlayoutengine.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qlayoutengine_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qlayoutitem.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qlayoutitem.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qmacdefines_mac.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qmacgesturerecognizer_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #include "qwidget.h" 48 48 #include "qdebug.h" 49 50 #ifndef QT_NO_GESTURES 49 51 50 52 QT_BEGIN_NAMESPACE … … 261 263 262 264 QT_END_NAMESPACE 265 266 #endif // QT_NO_GESTURES -
trunk/src/gui/kernel/qmacgesturerecognizer_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 58 58 #include "qgesturerecognizer.h" 59 59 60 #ifndef QT_NO_GESTURES 61 60 62 QT_BEGIN_NAMESPACE 61 63 … … 100 102 QT_END_NAMESPACE 101 103 104 #endif // QT_NO_GESTURES 105 102 106 #endif // QMACSWIPEGESTURERECOGNIZER_MAC_P_H -
trunk/src/gui/kernel/qmime.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qmime.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qmime_mac.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 155 155 \i public.file-url - converts to "text/uri-list" 156 156 \i public.tiff - converts to "application/x-qt-image" 157 \i public.vcard - converts to "text/plain" 157 158 \i com.apple.traditional-mac-plain-text - converts to "text/plain" 158 159 \i com.apple.pict - converts to "application/x-qt-image" … … 910 911 } 911 912 913 class QMacPasteboardMimeVCard : public QMacPasteboardMime 914 { 915 public: 916 QMacPasteboardMimeVCard() : QMacPasteboardMime(MIME_ALL){ } 917 QString convertorName(); 918 919 QString flavorFor(const QString &mime); 920 QString mimeFor(QString flav); 921 bool canConvert(const QString &mime, QString flav); 922 QVariant convertToMime(const QString &mime, QList<QByteArray> data, QString flav); 923 QList<QByteArray> convertFromMime(const QString &mime, QVariant data, QString flav); 924 }; 925 926 QString QMacPasteboardMimeVCard::convertorName() 927 { 928 return QString("VCard"); 929 } 930 931 bool QMacPasteboardMimeVCard::canConvert(const QString &mime, QString flav) 932 { 933 return mimeFor(flav) == mime; 934 } 935 936 QString QMacPasteboardMimeVCard::flavorFor(const QString &mime) 937 { 938 if(mime.startsWith(QLatin1String("text/plain"))) 939 return QLatin1String("public.vcard"); 940 return QString(); 941 } 942 943 QString QMacPasteboardMimeVCard::mimeFor(QString flav) 944 { 945 if (flav == QLatin1String("public.vcard")) 946 return QLatin1String("text/plain"); 947 return QString(); 948 } 949 950 QVariant QMacPasteboardMimeVCard::convertToMime(const QString &mime, QList<QByteArray> data, QString) 951 { 952 QByteArray cards; 953 if (mime == QLatin1String("text/plain")) { 954 for (int i=0; i<data.size(); ++i) 955 cards += data[i]; 956 } 957 return QVariant(cards); 958 } 959 960 QList<QByteArray> QMacPasteboardMimeVCard::convertFromMime(const QString &mime, QVariant data, QString) 961 { 962 QList<QByteArray> ret; 963 if (mime == QLatin1String("text/plain")) 964 ret.append(data.toString().toUtf8()); 965 return ret; 966 } 967 912 968 #ifdef QT3_SUPPORT 913 969 class QMacPasteboardMimeQt3Any : public QMacPasteboardMime { … … 1117 1173 new QMacPasteboardMimeUrl; 1118 1174 new QMacPasteboardMimeTypeName; 1175 new QMacPasteboardMimeVCard; 1119 1176 //make sure our "non-standard" types are always last! --Sam 1120 1177 new QMacPasteboardMimeAny; -
trunk/src/gui/kernel/qmime_win.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 953 953 s.setByteOrder(QDataStream::LittleEndian);// Intel byte order #### 954 954 if (cf == CF_DIB) { 955 if (img.format() > QImage::Format_ARGB32) 956 img = img.convertToFormat(QImage::Format_RGB32); 955 957 if (qt_write_dib(s, img)) 956 958 return setData(ba, pmedium); -
trunk/src/gui/kernel/qmotifdnd_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 386 386 unsigned char protocol_style) 387 387 { 388 DndReceiverProp receiver_prop ; 388 DndReceiverProp receiver_prop; 389 390 // squelch potential valgrind errors about uninitialized reads 391 memset(&receiver_prop, 0, sizeof(receiver_prop)); 389 392 390 393 receiver_prop.byte_order = DndByteOrder() ; … … 767 770 Atom type; 768 771 769 if (X11->clipboardReadProperty(tw->internalWinId(), Dnd_selection, true, &result, 0, &type, 0 , false)) {772 if (X11->clipboardReadProperty(tw->internalWinId(), Dnd_selection, true, &result, 0, &type, 0)) { 770 773 } 771 774 } -
trunk/src/gui/kernel/qmultitouch_mac.mm
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qmultitouch_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qnsframeview_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qnsthemeframe_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 158 158 - (char)shouldBeTreatedAsInkEvent:fp8; 159 159 - (char)_shouldBeTreatedAsInkEventInInactiveWindow:fp8; 160 - hitTest:(struct _NSPoint)fp8; 160 //- hitTest:(struct _NSPoint)fp8; // collides with hittest in qcocoasharedwindowmethods_mac_p.h 161 161 - (NSRect)_leftGroupRect; 162 162 - (NSRect)_rightGroupRect; -
trunk/src/gui/kernel/qnstitledframe_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qole_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qpalette.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 796 796 \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color) 797 797 798 Sets the brushin the specified color \a group, used for the given798 Sets the color in the specified color \a group, used for the given 799 799 color \a role, to the specified solid \a color. 800 800 … … 869 869 Returns true (slowly) if this palette is different from \a p; 870 870 otherwise returns false (usually quickly). 871 872 \note The current ColorGroup is not taken into account when 873 comparing palettes 874 875 \sa operator==() 871 876 */ 872 877 … … 874 879 Returns true (usually quickly) if this palette is equal to \a p; 875 880 otherwise returns false (slowly). 881 882 \note The current ColorGroup is not taken into account when 883 comparing palettes 884 885 \sa operator!=() 876 886 */ 877 887 bool QPalette::operator==(const QPalette &p) const -
trunk/src/gui/kernel/qpalette.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsessionmanager.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsessionmanager_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qshortcut.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qshortcut.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qshortcutmap.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qshortcutmap_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsizepolicy.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsizepolicy.qdoc
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 7 7 ** This file is part of the documentation of the Qt Toolkit. 8 8 ** 9 ** $QT_BEGIN_LICENSE: LGPL$9 ** $QT_BEGIN_LICENSE:FDL$ 10 10 ** Commercial Usage 11 11 ** Licensees holding valid Qt Commercial licenses may use this file in 12 12 ** accordance with the Qt Commercial License Agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** awritten agreement between you and Nokia.13 ** Software or, alternatively, in accordance with the terms contained in a 14 ** written agreement between you and Nokia. 15 15 ** 16 ** GNU Lesser General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU Lesser 18 ** General Public License version 2.1 as published by the Free Software 19 ** Foundation and appearing in the file LICENSE.LGPL included in the 20 ** packaging of this file. Please review the following information to 21 ** ensure the GNU Lesser General Public License version 2.1 requirements 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 23 ** 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 ** 28 ** GNU General Public License Usage 29 ** Alternatively, this file may be used under the terms of the GNU 30 ** General Public License version 3.0 as published by the Free Software 31 ** Foundation and appearing in the file LICENSE.GPL included in the 32 ** packaging of this file. Please review the following information to 33 ** ensure the GNU General Public License version 3.0 requirements will be 34 ** met: http://www.gnu.org/copyleft/gpl.html. 16 ** GNU Free Documentation License 17 ** Alternatively, this file may be used under the terms of the GNU Free 18 ** Documentation License version 1.3 as published by the Free Software 19 ** Foundation and appearing in the file included in the packaging of this 20 ** file. 35 21 ** 36 22 ** If you have questions regarding the use of this file, please contact -
trunk/src/gui/kernel/qsoftkeymanager.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 44 44 #include "qbitmap.h" 45 45 #include "private/qsoftkeymanager_p.h" 46 #include "private/q object_p.h"46 #include "private/qaction_p.h" 47 47 #include "private/qsoftkeymanager_common_p.h" 48 48 … … 105 105 switch (standardKey) { 106 106 case MenuSoftKey: // FALL-THROUGH 107 action->setProperty(MENU_ACTION_PROPERTY, QVariant(true)); // TODO: can be refactored away to use _q_action_menubar107 QActionPrivate::get(action)->menuActionSoftkeys = true; 108 108 case OkSoftKey: 109 109 case SelectSoftKey: … … 163 163 void QSoftKeyManager::updateSoftKeys() 164 164 { 165 QSoftKeyManager::instance()->d_func()->pendingUpdate = true; 165 166 QEvent *event = new QEvent(QEvent::UpdateSoftKeys); 166 167 QApplication::postEvent(QSoftKeyManager::instance(), event); … … 251 252 252 253 d->updateSoftKeys_sys(); 254 d->pendingUpdate = false; 253 255 return true; 254 256 } … … 256 258 void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action) 257 259 { 258 action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true));260 QActionPrivate::get(action)->forceEnabledInSoftkeys = true; 259 261 } 260 262 261 263 bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action) 262 264 { 263 bool ret = false; 264 QVariant property = action->property(FORCE_ENABLED_PROPERTY); 265 if (property.isValid() && property.toBool()) 266 ret = true; 267 return ret; 265 return QActionPrivate::get(action)->forceEnabledInSoftkeys; 268 266 } 269 267 … … 280 278 bool QSoftKeyManager::handleCommand(int command) 281 279 { 280 if (QSoftKeyManager::instance()->d_func()->pendingUpdate) 281 (void)QSoftKeyManager::instance()->handleUpdateSoftKeys(); 282 282 283 return static_cast<QSoftKeyManagerPrivateS60*>(QSoftKeyManager::instance()->d_func())->handleCommand(command); 283 284 } -
trunk/src/gui/kernel/qsoftkeymanager_common_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 72 72 QMultiHash<int, QAction*> requestedSoftKeyActions; 73 73 QWidget *initialSoftKeySource; 74 74 bool pendingUpdate; 75 75 }; 76 76 -
trunk/src/gui/kernel/qsoftkeymanager_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 64 64 class QSoftKeyManagerPrivate; 65 65 66 const char MENU_ACTION_PROPERTY[] = "_q_menuAction";67 const char FORCE_ENABLED_PROPERTY[] = "_q_forceEnabledInSoftkeys";68 69 66 class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject 70 67 { -
trunk/src/gui/kernel/qsoftkeymanager_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #include "private/qt_s60_p.h" 48 48 #include "private/qmenu_p.h" 49 #include "private/qaction_p.h" 49 50 #include "private/qsoftkeymanager_p.h" 50 51 #include "private/qsoftkeymanager_s60_p.h" … … 265 266 266 267 CEikImage* myimage = new (ELeave) CEikImage; 267 myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transfer ed268 myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transferred 268 269 269 270 EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership … … 385 386 QAction *action = realSoftKeyActions.value(command); 386 387 if (action) { 387 QVariant property = action->property(MENU_ACTION_PROPERTY);388 if (property .isValid() && property.toBool()) {388 bool property = QActionPrivate::get(action)->menuActionSoftkeys; 389 if (property) { 389 390 QT_TRAP_THROWING(tryDisplayMenuBarL()); 390 391 } else if (action->menu()) { … … 401 402 QMenu *menu = menuAction->menu(); 402 403 if(menu) 403 menuBar->addMenu( action->menu());404 menuBar->addMenu(menu); 404 405 else 405 406 menuBar->addAction(menuAction); -
trunk/src/gui/kernel/qsoftkeymanager_s60_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsound.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsound.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsound_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 89 89 QT_USE_NAMESPACE 90 90 91 @interface Q MacSoundDelegate: NSObject<NSSoundDelegate> {91 @interface QT_MANGLE_NAMESPACE(QMacSoundDelegate) : NSObject<NSSoundDelegate> { 92 92 QSound *qSound; // may be null. 93 93 QAuServerMac* server; … … 96 96 @end 97 97 98 @implementation Q MacSoundDelegate98 @implementation QT_MANGLE_NAMESPACE(QMacSoundDelegate) 99 99 -(id)initWithQSound:(QSound*)s:(QAuServerMac*)serv { 100 100 self = [super init]; … … 173 173 NSString *nsFileName = const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(fileName))); 174 174 NSSound * const nsSound = [[NSSound alloc] initWithContentsOfFile: nsFileName byReference:YES]; 175 Q MacSoundDelegate * const delegate = [[QMacSoundDelegatealloc] initWithQSound:qSound:this];175 QT_MANGLE_NAMESPACE(QMacSoundDelegate) * const delegate = [[QT_MANGLE_NAMESPACE(QMacSoundDelegate) alloc] initWithQSound:qSound:this]; 176 176 [nsSound setDelegate:delegate]; 177 177 [nsFileName release]; -
trunk/src/gui/kernel/qsound_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsound_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsound_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 151 151 // We don't have a way to inform about errors -> just decrement loops 152 152 // in order that QSound::isFinished will return true; 153 while (decLoop(sound) ) {}153 while (decLoop(sound) > 0) {} 154 154 if (staticPlayingSounds.removeAll(sound)) 155 155 delete sound; -
trunk/src/gui/kernel/qsound_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qsound_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qstackedlayout.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qstackedlayout.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qstandardgestures.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 46 46 #include "qwidget.h" 47 47 #include "qabstractscrollarea.h" 48 #include <qgraphicssceneevent.h> 48 49 #include "qdebug.h" 50 51 #ifndef QT_NO_GESTURES 49 52 50 53 QT_BEGIN_NAMESPACE … … 111 114 if (d->offset.x() > 10 || d->offset.y() > 10 || 112 115 d->offset.x() < -10 || d->offset.y() < -10) { 116 q->setHotSpot(p1.startScreenPos()); 113 117 result = QGestureRecognizer::TriggerGesture; 114 118 } else { … … 191 195 d->isHotSpotSet = true; 192 196 197 QPointF centerPoint = (p1.screenPos() + p2.screenPos()) / 2.0; 193 198 if (d->isNewSequence) { 194 199 d->startPosition[0] = p1.screenPos(); 195 200 d->startPosition[1] = p2.screenPos(); 196 } 197 QLineF line(p1.screenPos(), p2.screenPos()); 198 QLineF tmp(line); 199 tmp.setLength(line.length() / 2.); 200 QPointF centerPoint = tmp.p2(); 201 202 d->lastCenterPoint = d->centerPoint; 201 d->lastCenterPoint = centerPoint; 202 } else { 203 d->lastCenterPoint = d->centerPoint; 204 } 203 205 d->centerPoint = centerPoint; 206 204 207 d->changeFlags |= QPinchGesture::CenterPointChanged; 205 208 206 const qreal scaleFactor =207 QLineF(p1.screenPos(), p2.screenPos()).length()208 / QLineF(d->startPosition[0], d->startPosition[1]).length();209 209 if (d->isNewSequence) { 210 d->lastScaleFactor = scaleFactor; 210 d->scaleFactor = 1.0; 211 d->lastScaleFactor = 1.0; 211 212 } else { 212 213 d->lastScaleFactor = d->scaleFactor; 213 } 214 d->scaleFactor = scaleFactor; 215 d->totalScaleFactor += d->scaleFactor - d->lastScaleFactor; 214 QLineF line(p1.screenPos(), p2.screenPos()); 215 QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos()); 216 d->scaleFactor = line.length() / lastLine.length(); 217 } 218 d->totalScaleFactor = d->totalScaleFactor * d->scaleFactor; 216 219 d->changeFlags |= QPinchGesture::ScaleFactorChanged; 217 220 … … 224 227 const qreal rotationAngle = startAngle - angle; 225 228 if (d->isNewSequence) 226 d->lastRotationAngle = rotationAngle;229 d->lastRotationAngle = 0.0; 227 230 else 228 231 d->lastRotationAngle = d->rotationAngle; … … 263 266 264 267 d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF(); 265 d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 0;268 d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1; 266 269 d->totalRotationAngle = d->lastRotationAngle = d->rotationAngle = 0; 267 270 … … 301 304 switch (event->type()) { 302 305 case QEvent::TouchBegin: { 303 d-> speed= 1;304 d->time = QTime::currentTime();306 d->velocityValue = 1; 307 d->time.start(); 305 308 d->started = true; 306 309 result = QGestureRecognizer::MayBeGesture; … … 339 342 340 343 const int distance = xDistance >= yDistance ? xDistance : yDistance; 341 int elapsedTime = d->time. msecsTo(QTime::currentTime());344 int elapsedTime = d->time.restart(); 342 345 if (!elapsedTime) 343 346 elapsedTime = 1; 344 d->speed = 0.9 * d->speed + distance / elapsedTime; 345 d->time = QTime::currentTime(); 347 d->velocityValue = 0.9 * d->velocityValue + distance / elapsedTime; 346 348 d->swipeAngle = QLineF(p1.startScreenPos(), p1.screenPos()).angle(); 347 349 … … 405 407 d->lastPositions[0] = d->lastPositions[1] = d->lastPositions[2] = QPoint(); 406 408 d->started = false; 407 d-> speed= 0;408 d->time = QTime();409 d->velocityValue = 0; 410 d->time.invalidate(); 409 411 410 412 QGestureRecognizer::reset(state); … … 441 443 case QEvent::TouchBegin: { 442 444 d->position = ev->touchPoints().at(0).pos(); 445 q->setHotSpot(ev->touchPoints().at(0).screenPos()); 443 446 result = QGestureRecognizer::TriggerGesture; 444 447 break; … … 507 510 q->killTimer(d->timerId); 508 511 d->timerId = 0; 509 return QGestureRecognizer:: Ignore | QGestureRecognizer::ConsumeEventHint;512 return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint; 510 513 } 511 514 512 515 const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); 513 514 QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture; 515 516 enum { TimerInterval = 2000 }; 516 const QMouseEvent *me = static_cast<const QMouseEvent *>(event); 517 #ifndef QT_NO_GRAPHICSVIEW 518 const QGraphicsSceneMouseEvent *gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); 519 #endif 520 517 521 enum { TapRadius = 40 }; 518 522 519 523 switch (event->type()) { 520 case QEvent::TouchBegin: 521 d->position = ev->touchPoints().at(0).pos(); 524 #ifndef QT_NO_GRAPHICSVIEW 525 case QEvent::GraphicsSceneMousePress: 526 d->position = gsme->screenPos(); 527 q->setHotSpot(d->position); 522 528 if (d->timerId) 523 529 q->killTimer(d->timerId); 524 d->timerId = q->startTimer(TimerInterval); 525 result = QGestureRecognizer::TriggerGesture; 526 break; 530 d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); 531 return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout 532 #endif 533 case QEvent::MouseButtonPress: 534 d->position = me->globalPos(); 535 q->setHotSpot(d->position); 536 if (d->timerId) 537 q->killTimer(d->timerId); 538 d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); 539 return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout 540 case QEvent::TouchBegin: 541 d->position = ev->touchPoints().at(0).startScreenPos(); 542 q->setHotSpot(d->position); 543 if (d->timerId) 544 q->killTimer(d->timerId); 545 d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout); 546 return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout 547 #ifndef QT_NO_GRAPHICSVIEW 548 case QEvent::GraphicsSceneMouseRelease: 549 #endif 550 case QEvent::MouseButtonRelease: 527 551 case QEvent::TouchEnd: 528 if (d->timerId) 529 result = QGestureRecognizer::CancelGesture; 530 else 531 result = QGestureRecognizer::FinishGesture; 532 break; 552 return QGestureRecognizer::CancelGesture; // get out of the MayBeGesture state 533 553 case QEvent::TouchUpdate: 534 if ( q->state() != Qt::NoGesture&& ev->touchPoints().size() == 1) {554 if (d->timerId && ev->touchPoints().size() == 1) { 535 555 QTouchEvent::TouchPoint p = ev->touchPoints().at(0); 536 556 QPoint delta = p.pos().toPoint() - p.startPos().toPoint(); 537 557 if (delta.manhattanLength() <= TapRadius) 538 result = QGestureRecognizer::TriggerGesture; 539 } 540 break; 541 case QEvent::MouseButtonPress: 542 case QEvent::MouseMove: 543 case QEvent::MouseButtonRelease: 544 result = QGestureRecognizer::Ignore; 545 break; 558 return QGestureRecognizer::MayBeGesture; 559 } 560 return QGestureRecognizer::CancelGesture; 561 case QEvent::MouseMove: { 562 QPoint delta = me->globalPos() - d->position.toPoint(); 563 if (d->timerId && delta.manhattanLength() <= TapRadius) 564 return QGestureRecognizer::MayBeGesture; 565 return QGestureRecognizer::CancelGesture; 566 } 567 #ifndef QT_NO_GRAPHICSVIEW 568 case QEvent::GraphicsSceneMouseMove: { 569 QPoint delta = gsme->screenPos() - d->position.toPoint(); 570 if (d->timerId && delta.manhattanLength() <= TapRadius) 571 return QGestureRecognizer::MayBeGesture; 572 return QGestureRecognizer::CancelGesture; 573 } 574 #endif 546 575 default: 547 result = QGestureRecognizer::Ignore; 548 break; 549 } 550 return result; 576 return QGestureRecognizer::Ignore; 577 } 551 578 } 552 579 … … 565 592 566 593 QT_END_NAMESPACE 594 595 #endif // QT_NO_GESTURES -
trunk/src/gui/kernel/qstandardgestures_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 57 57 #include "private/qgesture_p.h" 58 58 59 #ifndef QT_NO_GESTURES 60 59 61 QT_BEGIN_NAMESPACE 60 62 … … 111 113 QT_END_NAMESPACE 112 114 115 #endif // QT_NO_GESTURES 116 113 117 #endif // QSTANDARDGESTURES_P_H -
trunk/src/gui/kernel/qt_cocoa_helpers_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 84 84 #include <private/qt_mac_p.h> 85 85 #include <private/qapplication_p.h> 86 #include <private/qcocoaapplication_mac_p.h> 86 87 #include <private/qcocoawindow_mac_p.h> 87 88 #include <private/qcocoaview_mac_p.h> … … 138 139 139 140 extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp; 140 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm141 141 extern QWidget * mac_mouse_grabber; 142 extern Q Pointer<QWidget>qt_button_down; //qapplication_mac.cpp142 extern QWidget *qt_button_down; //qapplication_mac.cpp 143 143 144 144 void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) … … 194 194 } 195 195 #else 196 qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut(); 196 197 ShowHideWindowToolbar(wnd, show, false); 197 198 #endif … … 370 371 371 372 #ifdef QT_MAC_USE_COCOA 373 374 // Clears the QWidget pointer that each QCocoaView holds. 375 void qt_mac_clearCocoaViewQWidgetPointers(QWidget *widget) 376 { 377 QT_MANGLE_NAMESPACE(QCocoaView) *cocoaView = reinterpret_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget)); 378 if (cocoaView && [cocoaView respondsToSelector:@selector(qt_qwidget)]) { 379 [cocoaView qt_clearQWidget]; 380 } 381 } 382 372 383 void qt_dispatchTabletProximityEvent(void * /*NSEvent * */ tabletEvent) 373 384 { … … 643 654 QKeyEventEx ke(cocoaEvent2QtEvent([event type]), qtKey, keyMods, text, [event isARepeat], qMax(1, keyLength), 644 655 macScanCode, [event keyCode], [event modifierFlags]); 645 qt_sendSpontaneousEvent(widgetToGetEvent, &ke); 646 return ke.isAccepted(); 647 } 648 #endif 656 return qt_sendSpontaneousEvent(widgetToGetEvent, &ke) && ke.isAccepted(); 657 } 658 #endif 659 660 Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum) 661 { 662 if (buttonNum == 0) 663 return Qt::LeftButton; 664 if (buttonNum == 1) 665 return Qt::RightButton; 666 if (buttonNum == 2) 667 return Qt::MidButton; 668 if (buttonNum == 3) 669 return Qt::XButton1; 670 if (buttonNum == 4) 671 return Qt::XButton2; 672 return Qt::NoButton; 673 } 649 674 650 675 // Helper to share code between QCocoaWindow and QCocoaView … … 659 684 EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef])); 660 685 Q_ASSERT(key_event); 686 unsigned int info = 0; 661 687 if ([event type] == NSKeyDown) { 662 qt_keymapper_private()->updateKeyMap(0, key_event, 0); 663 } 688 NSString *characters = [event characters]; 689 if ([characters length]) { 690 unichar value = [characters characterAtIndex:0]; 691 qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value); 692 info = value; 693 } 694 } 695 696 // Redirect keys to alien widgets. 697 if (widgetToGetEvent->testAttribute(Qt::WA_NativeWindow) == false) { 698 widgetToGetEvent = qApp->focusWidget(); 699 } 700 664 701 if (widgetToGetEvent == 0) 665 702 return false; … … 670 707 if (mustUseCocoaKeyEvent()) 671 708 return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent); 672 bool isAccepted; 673 qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &isAccepted, true); 674 return isAccepted; 709 bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true); 710 return consumed && (info != 0); 675 711 #endif 676 712 } … … 851 887 } 852 888 853 QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, button, keyMods); 889 Qt::MouseButtons buttons = 0; 890 { 891 UInt32 mac_buttons; 892 if (GetEventParameter((EventRef)[event eventRef], kEventParamMouseChord, typeUInt32, 0, 893 sizeof(mac_buttons), 0, &mac_buttons) == noErr) 894 buttons = qt_mac_get_buttons(mac_buttons); 895 } 896 897 QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods); 854 898 qt_sendSpontaneousEvent(widgetToGetEvent, &qme); 855 899 … … 916 960 } 917 961 } else { 918 extern Q Pointer<QWidget>qt_button_down; //qapplication_mac.cpp962 extern QWidget * qt_button_down; //qapplication_mac.cpp 919 963 QPoint pos; 920 964 widgetToGetMouse = QApplicationPrivate::pickMouseReceiver(qwidget, qglobalPoint, … … 928 972 929 973 NSPoint localPoint = [tmpView convertPoint:windowPoint fromView:nil]; 930 QPoint qlocalPoint(localPoint.x, localPoint.y); 974 QPoint qlocalPoint = QPoint(localPoint.x, localPoint.y); 975 976 // Search for alien child widgets (either on this qwidget or on the popup) 977 if (widgetToGetMouse->testAttribute(Qt::WA_NativeWindow) == false || qt_widget_private(widgetToGetMouse)->hasAlienChildren) { 978 QPoint qScreenPoint = flipPoint(globalPoint).toPoint(); 979 #ifdef ALIEN_DEBUG 980 qDebug() << "alien mouse event" << qScreenPoint << possibleAlien; 981 #endif 982 QWidget *possibleAlien = widgetToGetMouse->childAt(qlocalPoint); 983 if (possibleAlien) { 984 qlocalPoint = possibleAlien->mapFromGlobal(widgetToGetMouse->mapToGlobal(qlocalPoint)); 985 widgetToGetMouse = possibleAlien; 986 } 987 } 931 988 932 989 EventRef carbonEvent = static_cast<EventRef>(const_cast<void *>([theEvent eventRef])); … … 938 995 NSInteger clickCount = [theEvent clickCount]; 939 996 Qt::MouseButtons buttons = 0; 997 static Qt::MouseButton previousButton = Qt::NoButton; 940 998 { 941 999 UInt32 mac_buttons; … … 956 1014 Q_ASSERT(clickCount > 0); 957 1015 #endif 958 if (clickCount % 2 == 0 )1016 if (clickCount % 2 == 0 && (previousButton == Qt::NoButton || previousButton == button)) 959 1017 eventType = QEvent::MouseButtonDblClick; 960 1018 if (button == Qt::LeftButton && (keyMods & Qt::MetaModifier)) { … … 968 1026 [theView qt_setLeftButtonIsRightButton: false]; 969 1027 } 1028 qt_button_down = 0; 970 1029 break; 971 1030 } 972 1031 [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->localPoint = localPoint; 973 1032 QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods); 974 qt_sendSpontaneousEvent(widgetToGetMouse, &qme); 1033 1034 #ifdef ALIEN_DEBUG 1035 qDebug() << "sending mouse event to" << widgetToGetMouse; 1036 #endif 1037 extern QWidget *qt_button_down; 1038 extern QPointer<QWidget> qt_last_mouse_receiver; 1039 1040 if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false) 1041 qt_sendSpontaneousEvent(widgetToGetMouse, &qme); 1042 else 1043 QApplicationPrivate::sendMouseEvent(widgetToGetMouse, &qme, widgetToGetMouse, qwidget, &qt_button_down, 1044 qt_last_mouse_receiver); 1045 975 1046 if (eventType == QEvent::MouseButtonPress && button == Qt::RightButton) { 976 1047 QContextMenuEvent qcme(QContextMenuEvent::Mouse, qlocalPoint, qglobalPoint, keyMods); 977 1048 qt_sendSpontaneousEvent(widgetToGetMouse, &qcme); 978 1049 } 1050 previousButton = button; 979 1051 return true; 980 1052 #endif … … 1098 1170 } 1099 1171 1172 #if QT_MAC_USE_COCOA 1173 void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widget) 1174 { 1175 QMacCocoaAutoReleasePool pool; 1176 OSWindowRef theWindow = static_cast<OSWindowRef>(window); 1177 if(!theWindow) 1178 return; 1179 id theClass = [[[theWindow contentView] superview] class]; 1180 // What we do here is basically to add a new selector to NSThemeFrame called 1181 // "drawRectOriginal:" which will contain the original implementation of 1182 // "drawRect:". After that we get the new implementation from QCocoaWindow 1183 // and exchange them. The new implementation is called drawRectSpecial. 1184 // We cannot just add the method because it might have been added before and since 1185 // we cannot remove a method once it has been added we need to ask QCocoaWindow if 1186 // we did the swap or not. 1187 if(!widget->drawRectOriginalAdded) { 1188 Method m2 = class_getInstanceMethod(theClass, @selector(drawRect:)); 1189 if(!m2) { 1190 // This case is pretty extreme, no drawRect means no drawing! 1191 return; 1192 } 1193 class_addMethod(theClass, @selector(drawRectOriginal:), method_getImplementation(m2), method_getTypeEncoding(m2)); 1194 widget->drawRectOriginalAdded = true; 1195 } 1196 if(widget->originalDrawMethod) { 1197 Method m0 = class_getInstanceMethod([theWindow class], @selector(drawRectSpecial:)); 1198 if(!m0) { 1199 // Ok, this means the methods were never swapped. Just ignore 1200 return; 1201 } 1202 Method m1 = class_getInstanceMethod(theClass, @selector(drawRect:)); 1203 if(!m1) { 1204 // Ok, this means the methods were never swapped. Just ignore 1205 return; 1206 } 1207 // We have the original method here. Proceed and swap the methods. 1208 method_exchangeImplementations(m1, m0); 1209 widget->originalDrawMethod = false; 1210 [window display]; 1211 } 1212 } 1213 1214 void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivate *widget) 1215 { 1216 QMacCocoaAutoReleasePool pool; 1217 OSWindowRef theWindow = static_cast<OSWindowRef>(window); 1218 id theClass = [[[theWindow contentView] superview] class]; 1219 // Now we need to revert the methods to their original state. 1220 // We cannot remove the method, so we just keep track of it in QCocoaWindow. 1221 Method m0 = class_getInstanceMethod([theWindow class], @selector(drawRectSpecial:)); 1222 if(!m0) { 1223 // Ok, this means the methods were never swapped. Just ignore 1224 return; 1225 } 1226 Method m1 = class_getInstanceMethod(theClass, @selector(drawRect:)); 1227 if(!m1) { 1228 // Ok, this means the methods were never swapped. Just ignore 1229 return; 1230 } 1231 method_exchangeImplementations(m1, m0); 1232 widget->originalDrawMethod = true; 1233 [window display]; 1234 } 1235 #endif // QT_MAC_USE_COCOA 1236 1100 1237 void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show) 1101 1238 { 1239 if(!window) 1240 return; 1102 1241 #if QT_MAC_USE_COCOA 1103 1242 QMacCocoaAutoReleasePool pool; 1104 1243 OSWindowRef theWindow = static_cast<OSWindowRef>(window); 1105 1244 NSToolbar *macToolbar = [theWindow toolbar]; 1106 if (macToolbar) 1107 [macToolbar setShowsBaselineSeparator: show]; 1108 #endif 1245 [macToolbar setShowsBaselineSeparator:show]; 1246 #endif // QT_MAC_USE_COCOA 1109 1247 } 1110 1248 … … 1291 1429 [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) set]; 1292 1430 } 1431 1432 // WARNING: If Qt did not create NSApplication (e.g. in case it is 1433 // used as a plugin), and at the same time, there is no window on 1434 // screen (or the window that the event is sendt to becomes hidden etc 1435 // before the event gets delivered), the message will not be performed. 1436 bool qt_cocoaPostMessage(id target, SEL selector) 1437 { 1438 if (!target) 1439 return false; 1440 1441 NSInteger windowNumber = 0; 1442 if (![NSApp isMemberOfClass:[QNSApplication class]]) { 1443 // INVARIANT: Cocoa is not using our NSApplication subclass. That means 1444 // we don't control the main event handler either. So target the event 1445 // for one of the windows on screen: 1446 NSWindow *nswin = [NSApp mainWindow]; 1447 if (!nswin) { 1448 nswin = [NSApp keyWindow]; 1449 if (!nswin) 1450 return false; 1451 } 1452 windowNumber = [nswin windowNumber]; 1453 } 1454 1455 // WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5! 1456 // That is why we need to split the address in two parts: 1457 QCocoaPostMessageArgs *args = new QCocoaPostMessageArgs(target, selector); 1458 quint32 lower = quintptr(args); 1459 quint32 upper = quintptr(args) >> 32; 1460 NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined 1461 location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:windowNumber 1462 context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper]; 1463 [NSApp postEvent:e atStart:NO]; 1464 return true; 1465 } 1293 1466 #endif 1294 1467 … … 1306 1479 } 1307 1480 1481 void qt_mac_post_retranslateAppMenu() 1482 { 1483 #ifdef QT_MAC_USE_COCOA 1484 QMacCocoaAutoReleasePool pool; 1485 qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu)); 1486 #endif 1487 } 1488 1489 #ifdef QT_MAC_USE_COCOA 1490 // This method implements the magic for the drawRectSpecial method. 1491 // We draw a line at the upper edge of the content view in order to 1492 // override the title baseline. 1493 void macDrawRectOnTop(void * /*OSWindowRef */window) 1494 { 1495 OSWindowRef theWindow = static_cast<OSWindowRef>(window); 1496 NSView *contentView = [theWindow contentView]; 1497 if(!contentView) 1498 return; 1499 // Get coordinates of the content view 1500 NSRect contentRect = [contentView frame]; 1501 // Draw a line on top of the already drawn line. 1502 // We need to check if we are active or not to use the proper color. 1503 if([window isKeyWindow] || [window isMainWindow]) { 1504 [[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0] set]; 1505 } else { 1506 [[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0] set]; 1507 } 1508 NSPoint origin = NSMakePoint(0, contentRect.size.height); 1509 NSPoint end = NSMakePoint(contentRect.size.width, contentRect.size.height); 1510 [NSBezierPath strokeLineFromPoint:origin toPoint:end]; 1511 } 1512 1513 // This method will (or at least should) get called only once. 1514 // Its mission is to find out if we are active or not. If we are active 1515 // we assume that we were launched via finder, otherwise we assume 1516 // we were called from the command line. The distinction is important, 1517 // since in the first case we don't need to trigger a paintEvent, while 1518 // in the second case we do. 1519 void macSyncDrawingOnFirstInvocation(void * /*OSWindowRef */window) 1520 { 1521 OSWindowRef theWindow = static_cast<OSWindowRef>(window); 1522 NSApplication *application = [NSApplication sharedApplication]; 1523 NSToolbar *toolbar = [window toolbar]; 1524 if([application isActive]) { 1525 // Launched from finder 1526 [toolbar setShowsBaselineSeparator:NO]; 1527 } else { 1528 // Launched from commandline 1529 [toolbar setVisible:false]; 1530 [toolbar setShowsBaselineSeparator:NO]; 1531 [toolbar setVisible:true]; 1532 [theWindow display]; 1533 } 1534 } 1535 1536 void qt_cocoaStackChildWindowOnTopOfOtherChildren(QWidget *childWidget) 1537 { 1538 if (!childWidget) 1539 return; 1540 1541 QWidget *parent = childWidget->parentWidget(); 1542 if (childWidget->isWindow() && parent) { 1543 if ([[qt_mac_window_for(parent) childWindows] containsObject:qt_mac_window_for(childWidget)]) { 1544 QWidgetPrivate *d = qt_widget_private(childWidget); 1545 d->setSubWindowStacking(false); 1546 d->setSubWindowStacking(true); 1547 } 1548 } 1549 } 1550 1551 #endif // QT_MAC_USE_COCOA 1552 1308 1553 QT_END_NAMESPACE -
trunk/src/gui/kernel/qt_cocoa_helpers_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 73 73 ** 74 74 ****************************************************************************/ 75 76 #ifndef QT_COCOA_HELPERS_MAC_P_H 77 #define QT_COCOA_HELPERS_MAC_P_H 75 78 76 79 // … … 115 118 116 119 QT_BEGIN_NAMESPACE 120 121 enum { 122 QtCocoaEventSubTypeWakeup = SHRT_MAX, 123 QtCocoaEventSubTypePostMessage = SHRT_MAX-1 124 }; 125 117 126 Qt::MouseButtons qt_mac_get_buttons(int buttons); 118 127 Qt::MouseButton qt_mac_get_button(EventMouseButton button); … … 126 135 void macSendToolbarChangeEvent(QWidget *widget); 127 136 void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::HIContentBorderMetrics &metrics); 137 void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widget); 138 void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivate *widget); 128 139 void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show); 129 140 void * /*NSImage */qt_mac_create_nsimage(const QPixmap &pm); … … 135 146 bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent); 136 147 void qt_cocoaChangeOverrideCursor(const QCursor &cursor); 148 // These methods exists only for supporting unified mode. 149 void macDrawRectOnTop(void * /*OSWindowRef */ window); 150 void macSyncDrawingOnFirstInvocation(void * /*OSWindowRef */window); 151 void qt_cocoaStackChildWindowOnTopOfOtherChildren(QWidget *widget); 137 152 #endif 138 153 void qt_mac_menu_collapseSeparators(void * /*NSMenu */ menu, bool collapse); … … 182 197 inline NSString *qt_mac_QStringToNSString(const QString &qstr) 183 198 { return [reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr)) autorelease]; } 184 #endif 199 200 #ifdef QT_MAC_USE_COCOA 201 class QCocoaPostMessageArgs { 202 public: 203 id target; 204 SEL selector; 205 QCocoaPostMessageArgs(id target, SEL selector) : target(target), selector(selector) 206 { 207 [target retain]; 208 } 209 210 ~QCocoaPostMessageArgs() 211 { 212 [target release]; 213 } 214 }; 215 bool qt_cocoaPostMessage(id target, SEL selector); 216 #endif 217 218 #endif 219 220 void qt_mac_post_retranslateAppMenu(); 185 221 186 222 QT_END_NAMESPACE 223 224 #endif // QT_COCOA_HELPERS_MAC_P_H -
trunk/src/gui/kernel/qt_gui_pch.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qt_mac.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qt_mac_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 58 58 #ifdef __OBJC__ 59 59 #include <Cocoa/Cocoa.h> 60 #ifdef QT_MAC_USE_COCOA 61 #include <objc/runtime.h> 62 #endif // QT_MAC_USE_COCOA 60 63 #endif 61 64 -
trunk/src/gui/kernel/qt_s60_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 63 63 #include "qpointer.h" 64 64 #include "qapplication.h" 65 #include "qelapsedtimer.h" 66 #include "QtCore/qthreadstorage.h" 65 67 #include <w32std.h> 66 68 #include <coecntrl.h> … … 86 88 #define Q_SYMBIAN_ECOLOR16MAP TDisplayMode(13) 87 89 90 class Q_AUTOTEST_EXPORT QS60ThreadLocalData 91 { 92 public: 93 QS60ThreadLocalData(); 94 ~QS60ThreadLocalData(); 95 bool usingCONEinstances; 96 RWsSession wsSession; 97 CWsScreenDevice *screenDevice; 98 }; 99 88 100 class QS60Data 89 101 { 90 102 public: 91 103 QS60Data(); 104 QThreadStorage<QS60ThreadLocalData *> tls; 92 105 TUid uid; 93 106 int screenDepth; … … 103 116 int defaultDpiY; 104 117 WId curWin; 105 int virtualMouseLastKey;106 118 enum PressedKeys { 107 119 Select = 0x1, … … 109 121 Down = 0x4, 110 122 Left = 0x8, 111 Up = 0x10 123 Up = 0x10, 124 LeftUp = 0x20, 125 RightUp = 0x40, 126 RightDown = 0x80, 127 LeftDown = 0x100 112 128 }; 113 129 int virtualMousePressedKeys; // of the above type, but avoids casting problems 114 int virtualMouseAccel; 130 int virtualMouseAccelDX; 131 int virtualMouseAccelDY; 132 QElapsedTimer virtualMouseAccelTimeout; 115 133 int virtualMouseMaxAccel; 116 134 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS … … 124 142 int avkonComponentsSupportTransparency : 1; 125 143 int menuBeingConstructed : 1; 144 int orientationSet : 1; 126 145 QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type 146 static CEikButtonGroupContainer *cba; 147 148 enum ScanCodeState { 149 Unpressed, 150 KeyDown, 151 KeyDownAndKey 152 }; 153 QHash<TInt, ScanCodeState> scanCodeStates; 154 127 155 static inline void updateScreenSize(); 128 staticinline RWsSession& wsSession();156 inline RWsSession& wsSession(); 129 157 static inline RWindowGroup& windowGroup(); 130 staticinline CWsScreenDevice* screenDevice();158 inline CWsScreenDevice* screenDevice(); 131 159 static inline CCoeAppUi* appUi(); 132 160 static inline CEikMenuBar* menuBar(); … … 137 165 static inline CAknContextPane* contextPane(); 138 166 static inline CEikButtonGroupContainer* buttonGroupContainer(); 139 167 static inline void setButtonGroupContainer(CEikButtonGroupContainer* newCba); 168 static void setStatusPaneAndButtonGroupVisibility(bool statusPaneVisible, bool buttonGroupVisible); 169 #endif 170 static void controlVisibilityChanged(CCoeControl *control, bool visible); 171 172 #ifdef Q_OS_SYMBIAN 140 173 TTrapHandler *s60InstalledTrapHandler; 141 174 #endif 142 175 }; 143 176 144 Q S60Data* qGlobalS60Data();177 Q_AUTOTEST_EXPORT QS60Data* qGlobalS60Data(); 145 178 #define S60 qGlobalS60Data() 146 179 … … 182 215 void setFocusSafely(bool focus); 183 216 217 bool isControlActive(); 218 184 219 #ifdef Q_WS_S60 185 220 void FadeBehindPopup(bool fade){ popupFader.FadeBehindPopup( this, this, fade); } … … 190 225 CCoeControl* FadedComponent(TInt /*aIndex*/) {return this;} 191 226 #else 192 #warning No fallback implementation for QSymbianControl::FadeBehindPopup227 // #warning No fallback implementation for QSymbianControl::FadeBehindPopup 193 228 void FadeBehindPopup(bool /*fade*/){ } 194 229 #endif … … 203 238 void HandlePointerEvent(const TPointerEvent& aPointerEvent); 204 239 TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType); 240 TKeyResponse sendSymbianKeyEvent(const TKeyEvent &keyEvent, QEvent::Type type); 205 241 TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); 242 TKeyResponse handleVirtualMouse(const TKeyEvent& keyEvent,TEventCode type); 206 243 bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); 207 244 void sendMouseEvent( … … 211 248 Qt::MouseButton button, 212 249 Qt::KeyboardModifiers modifiers); 250 void processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure); 213 251 void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); 214 252 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER 215 253 void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); 216 254 #endif 255 256 public: 217 257 void handleClientAreaChange(); 218 258 … … 223 263 QWidget *qwidget; 224 264 QLongTapTimer* m_longTapDetector; 265 QElapsedTimer m_doubleClickTimer; 225 266 bool m_ignoreFocusChanged : 1; 226 267 bool m_symbianPopupIsOpen : 1; … … 233 274 234 275 inline QS60Data::QS60Data() 235 { 236 memclr(this, sizeof(QS60Data)); //zero init data 276 : uid(TUid::Null()), 277 screenDepth(0), 278 screenWidthInPixels(0), 279 screenHeightInPixels(0), 280 screenWidthInTwips(0), 281 screenHeightInTwips(0), 282 defaultDpiX(0), 283 defaultDpiY(0), 284 curWin(0), 285 virtualMousePressedKeys(0), 286 virtualMouseAccelDX(0), 287 virtualMouseAccelDY(0), 288 virtualMouseMaxAccel(0), 289 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS 290 brokenPointerCursors(0), 291 #endif 292 hasTouchscreen(0), 293 mouseInteractionEnabled(0), 294 virtualMouseRequired(0), 295 qtOwnsS60Environment(0), 296 supportsPremultipliedAlpha(0), 297 avkonComponentsSupportTransparency(0), 298 menuBeingConstructed(0), 299 orientationSet(0), 300 s60ApplicationFactory(0) 301 #ifdef Q_OS_SYMBIAN 302 ,s60InstalledTrapHandler(0) 303 #endif 304 { 237 305 } 238 306 … … 247 315 S60->screenHeightInTwips = params.iTwipsSize.iHeight; 248 316 249 S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20;317 S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 10; 250 318 251 319 TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch; … … 257 325 inline RWsSession& QS60Data::wsSession() 258 326 { 259 return CCoeEnv::Static()->WsSession(); 327 if(!tls.hasLocalData()) { 328 tls.setLocalData(new QS60ThreadLocalData); 329 } 330 return tls.localData()->wsSession; 260 331 } 261 332 … … 267 338 inline CWsScreenDevice* QS60Data::screenDevice() 268 339 { 269 return CCoeEnv::Static()->ScreenDevice(); 340 if(!tls.hasLocalData()) { 341 tls.setLocalData(new QS60ThreadLocalData); 342 } 343 return tls.localData()->screenDevice; 270 344 } 271 345 … … 314 388 inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer() 315 389 { 316 return CEikonEnv::Static()->AppUiFactory()->Cba(); 390 return QS60Data::cba; 391 } 392 393 inline void QS60Data::setButtonGroupContainer(CEikButtonGroupContainer *newCba) 394 { 395 QS60Data::cba = newCba; 317 396 } 318 397 #endif // Q_WS_S60 -
trunk/src/gui/kernel/qt_x11_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 332 332 333 333 struct QX11Data; 334 extern Q X11Data *qt_x11Data;334 extern Q_GUI_EXPORT QX11Data *qt_x11Data; 335 335 336 336 enum DesktopEnvironment { … … 339 339 DE_GNOME, 340 340 DE_CDE, 341 DE_MEEGO_COMPOSITOR, 341 342 DE_4DWM 342 343 }; … … 351 352 bool clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout); 352 353 bool clipboardReadProperty(Window win, Atom property, bool deleteProperty, 353 QByteArray *buffer, int *size, Atom *type, int *format , bool nullterm);354 QByteArray *buffer, int *size, Atom *type, int *format); 354 355 QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm); 355 356 … … 439 440 int xinput_eventbase; 440 441 int xinput_errorbase; 442 443 // for XKEYBOARD support 444 bool use_xkb; 445 int xkb_major; 446 int xkb_eventbase; 447 int xkb_errorbase; 441 448 442 449 QList<QWidget *> deferred_map; … … 565 572 566 573 DTWM_IS_RUNNING, 567 KDE_FULL_SESSION,568 KWIN_RUNNING,569 KWM_RUNNING,570 GNOME_BACKGROUND_PROPERTIES,571 574 ENLIGHTENMENT_DESKTOP, 575 _DT_SAVE_MODE, 572 576 _SGI_DESKS_MANAGER, 573 577 … … 629 633 630 634 _NET_SYSTEM_TRAY_VISUAL, 635 636 _NET_ACTIVE_WINDOW, 631 637 632 638 // Property formats -
trunk/src/gui/kernel/qtooltip.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qtooltip.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwhatsthis.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 144 144 */ 145 145 146 Q_ DECL_IMPORT externvoid qDeleteInEventHandler(QObject *o);146 Q_CORE_EXPORT void qDeleteInEventHandler(QObject *o); 147 147 148 148 class QWhatsThat : public QWidget -
trunk/src/gui/kernel/qwhatsthis.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwidget.cpp
r786 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 68 68 # include "qt_cocoa_helpers_mac_p.h" 69 69 # include "qmainwindow.h" 70 # include "qtoolbar.h" 71 # include <private/qmainwindowlayout_p.h> 70 72 #endif 71 73 #if defined(Q_WS_QWS) … … 127 129 #endif // QT_KEYPAD_NAVIGATION 128 130 131 #ifdef Q_WS_S60 132 #include <aknappui.h> 133 #endif 134 129 135 // widget/widget data creation count 130 136 //#define QWIDGET_EXTRA_DEBUG … … 165 171 extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp 166 172 extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp 173 174 /*! 175 \internal 176 \class QWidgetBackingStoreTracker 177 \brief Class which allows tracking of which widgets are using a given backing store 178 179 QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer, 180 which maintains a list of the QWidgets which are currently using the backing 181 store. This list is modified via the registerWidget and unregisterWidget functions. 182 */ 183 184 QWidgetBackingStoreTracker::QWidgetBackingStoreTracker() 185 : m_ptr(0) 186 { 187 188 } 189 190 QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker() 191 { 192 delete m_ptr; 193 } 194 195 /*! 196 \internal 197 Destroy the contained QWidgetBackingStore, if not null, and clear the list of 198 widgets using the backing store, then create a new QWidgetBackingStore, providing 199 the QWidget. 200 */ 201 void QWidgetBackingStoreTracker::create(QWidget *widget) 202 { 203 destroy(); 204 m_ptr = new QWidgetBackingStore(widget); 205 } 206 207 /*! 208 \internal 209 Destroy the contained QWidgetBackingStore, if not null, and clear the list of 210 widgets using the backing store. 211 */ 212 void QWidgetBackingStoreTracker::destroy() 213 { 214 delete m_ptr; 215 m_ptr = 0; 216 m_widgets.clear(); 217 } 218 219 /*! 220 \internal 221 Add the widget to the list of widgets currently using the backing store. 222 If the widget was already in the list, this function is a no-op. 223 */ 224 void QWidgetBackingStoreTracker::registerWidget(QWidget *w) 225 { 226 Q_ASSERT(m_ptr); 227 Q_ASSERT(w->internalWinId()); 228 Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr); 229 m_widgets.insert(w); 230 } 231 232 /*! 233 \internal 234 Remove the widget from the list of widgets currently using the backing store. 235 If the widget was in the list, and removing it causes the list to be empty, 236 the backing store is deleted. 237 If the widget was not in the list, this function is a no-op. 238 */ 239 void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w) 240 { 241 if (m_widgets.remove(w) && m_widgets.isEmpty()) { 242 delete m_ptr; 243 m_ptr = 0; 244 } 245 } 246 247 /*! 248 \internal 249 Recursively remove widget and all of its descendents. 250 */ 251 void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget) 252 { 253 unregisterWidget(widget); 254 foreach (QObject *child, widget->children()) 255 if (QWidget *childWidget = qobject_cast<QWidget *>(child)) 256 unregisterWidgetSubtree(childWidget); 257 } 167 258 168 259 QWidgetPrivate::QWidgetPrivate(int version) … … 203 294 , isGLWidget(0) 204 295 , usesDoubleBufferedGLContext(0) 296 #ifndef QT_NO_IM 297 , inheritsInputMethodHints(0) 298 #endif 205 299 #if defined(Q_WS_X11) 206 300 , picture(0) … … 209 303 #elif defined(Q_WS_WIN) 210 304 , noPaintOnScreen(0) 305 #ifndef QT_NO_GESTURES 211 306 , nativeGesturePanEnabled(0) 307 #endif 212 308 #elif defined(Q_WS_MAC) 213 309 , needWindowChange(0) 310 , hasAlienChildren(0) 214 311 , window_event(0) 215 312 , qd_hd(0) … … 226 323 isWidget = true; 227 324 memset(high_attributes, 0, sizeof(high_attributes)); 325 #if QT_MAC_USE_COCOA 326 drawRectOriginalAdded = false; 327 originalDrawMethod = true; 328 changeMethods = false; 329 #endif // QT_MAC_USE_COCOA 228 330 #ifdef QWIDGET_EXTRA_DEBUG 229 331 static int count = 0; … … 246 348 } 247 349 350 class QDummyWindowSurface : public QWindowSurface 351 { 352 public: 353 QDummyWindowSurface(QWidget *window) : QWindowSurface(window) {} 354 QPaintDevice *paintDevice() { return window(); } 355 void flush(QWidget *, const QRegion &, const QPoint &) {} 356 }; 357 248 358 QWindowSurface *QWidgetPrivate::createDefaultWindowSurface() 249 359 { 250 360 Q_Q(QWidget); 251 if (QApplicationPrivate::graphicsSystem()) 252 return QApplicationPrivate::graphicsSystem()->createWindowSurface(q); 253 return createDefaultWindowSurface_sys(); 361 362 QWindowSurface *surface; 363 if (q->property("_q_DummyWindowSurface").toBool()) { 364 surface = new QDummyWindowSurface(q); 365 } else { 366 if (QApplicationPrivate::graphicsSystem()) 367 surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q); 368 else 369 surface = createDefaultWindowSurface_sys(); 370 } 371 372 return surface; 254 373 } 255 374 … … 286 405 if (ic) 287 406 return ic; 288 #endif289 407 return qApp->inputContext(); 408 #else 409 return 0; 410 #endif 290 411 } 291 412 … … 312 433 This function sets the input context \a context 313 434 on this widget. 435 436 Qt takes ownership of the given input \a context. 314 437 315 438 \sa inputContext() … … 321 444 if (!testAttribute(Qt::WA_InputMethodEnabled)) 322 445 return; 446 if (context == d->ic) 447 return; 323 448 if (d->ic) 324 449 delete d->ic; 325 450 d->ic = context; 451 if (d->ic) 452 d->ic->setParent(this); 326 453 #endif 327 454 } … … 639 766 \i mouseMoveEvent() is called whenever the mouse moves while a mouse 640 767 button is held down. This can be useful during drag and drop 641 operations. If you call setMouseTracking(true), you get mouse move642 events even when no buttons are held down. (See also the \l{Drag643 and Drop} guide.)768 operations. If you call \l{setMouseTracking()}{setMouseTracking}(true), 769 you get mouse move events even when no buttons are held down. 770 (See also the \l{Drag and Drop} guide.) 644 771 \i keyReleaseEvent() is called whenever a key is released and while it 645 772 is held down (if the key is auto-repeating). In that case, the … … 671 798 one of the more specialized handlers above. 672 799 673 Events and the mechanism used to deliver them are covered in the674 \l{ Events and Event Filters} document.800 Events and the mechanism used to deliver them are covered in 801 \l{The Event System}. 675 802 676 803 \section1 Groups of Functions and Properties … … 1011 1138 \sa windowFlags 1012 1139 */ 1013 1014 1140 QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) 1015 1141 : QObject(*new QWidgetPrivate, 0), QPaintDevice() … … 1106 1232 } 1107 1233 if (customize) 1108 ; // don't modify window flags if the user explicit ely set them.1234 ; // don't modify window flags if the user explicitly set them. 1109 1235 else if (type == Qt::Dialog || type == Qt::Sheet) 1110 1236 #ifndef Q_WS_WINCE … … 1128 1254 1129 1255 Q_ASSERT(allWidgets); 1130 allWidgets->insert(q); 1256 if (allWidgets) 1257 allWidgets->insert(q); 1131 1258 1132 1259 QWidget *desktopWidget = 0; … … 1175 1302 q->setAttribute(Qt::WA_NativeWindow); 1176 1303 1304 #ifdef Q_WS_MAC 1305 q->setAttribute(Qt::WA_NativeWindow); 1306 #endif 1307 1177 1308 q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute() 1178 1309 adjustQuitOnCloseAttribute(); … … 1181 1312 1182 1313 //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later 1314 #ifdef Q_OS_SYMBIAN 1315 if (isGLWidget) { 1316 // Don't waste GPU mem for unnecessary large egl surface 1317 data.crect = QRect(0,0,2,2); 1318 } else { 1319 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640); 1320 } 1321 #else 1183 1322 data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480); 1323 #endif 1184 1324 1185 1325 focus_next = focus_prev = q; … … 1270 1410 1271 1411 if (QWidget *parent = parentWidget()) { 1412 #ifdef Q_WS_MAC 1413 if (testAttribute(Qt::WA_NativeWindow) == false) 1414 parent->d_func()->hasAlienChildren = true; 1415 #endif 1272 1416 if (type & Qt::Window) { 1273 1417 if (!parent->testAttribute(Qt::WA_WState_Created)) … … 1331 1475 // a real toplevel window needs a backing store 1332 1476 if (isWindow() && windowType() != Qt::Desktop) { 1333 delete d->topData()->backingStore; 1334 // QWidgetBackingStore will check this variable, hence it must be 0 1335 d->topData()->backingStore = 0; 1477 d->topData()->backingStore.destroy(); 1336 1478 if (hasBackingStoreSupport()) 1337 d->topData()->backingStore = new QWidgetBackingStore(this);1479 d->topData()->backingStore.create(this); 1338 1480 } 1339 1481 … … 1378 1520 if (paintingActive()) 1379 1521 qWarning("QWidget: %s (%s) deleted while being painted", className(), name()); 1522 #endif 1523 1524 #ifndef QT_NO_GESTURES 1525 foreach (Qt::GestureType type, d->gestureContext.keys()) 1526 ungrabGesture(type); 1380 1527 #endif 1381 1528 … … 1440 1587 } 1441 1588 1442 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)1589 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 1443 1590 else if (!internalWinId() && isVisible()) { 1444 1591 qApp->d_func()->sendSyntheticEnterLeave(this); … … 1458 1605 // not have a reference to this widget that will be used later to 1459 1606 // notify the window it no longer has a surface. 1460 delete d->extra->topextra->backingStore; 1461 d->extra->topextra->backingStore = 0; 1607 d->extra->topextra->backingStore.destroy(); 1462 1608 } 1463 1609 #endif … … 1475 1621 1476 1622 if (d->declarativeData) { 1477 d->declarativeData->destroyed(this);1623 QAbstractDeclarativeData::destroyed(d->declarativeData, this); 1478 1624 d->declarativeData = 0; // don't activate again in ~QObject 1479 1625 } 1626 1627 #ifdef QT_MAC_USE_COCOA 1628 // QCocoaView holds a pointer back to this widget. Clear it now 1629 // to make sure it's not followed later on. The lifetime of the 1630 // QCocoaView might exceed the lifetime of this widget in cases 1631 // where Cocoa itself holds references to it. 1632 extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *); 1633 qt_mac_clearCocoaViewQWidgetPointers(this); 1634 #endif 1480 1635 1481 1636 if (!d->children.isEmpty()) … … 1529 1684 1530 1685 if(oldWinId != id) { 1531 // Do not emit an event when the old winId is destroyed. This only 1532 // happens (a) during widget destruction, and (b) immediately prior 1533 // to creation of a new winId, for example as a result of re-parenting. 1534 if(id != 0) { 1535 QEvent e(QEvent::WinIdChange); 1536 QCoreApplication::sendEvent(q, &e); 1537 } 1686 QEvent e(QEvent::WinIdChange); 1687 QCoreApplication::sendEvent(q, &e); 1538 1688 } 1539 1689 } … … 1547 1697 x->icon = 0; 1548 1698 x->iconPixmap = 0; 1549 x->backingStore = 0;1550 1699 x->windowSurface = 0; 1551 1700 x->sharedPainter = 0; … … 1561 1710 x->inRepaint = false; 1562 1711 x->embedded = 0; 1712 #ifdef Q_WS_MAC 1713 #ifdef QT_MAC_USE_COCOA 1714 x->wasMaximized = false; 1715 #endif // QT_MAC_USE_COCOA 1716 #endif // Q_WS_MAC 1563 1717 createTLSysExtra(); 1564 1718 #ifdef QWIDGET_EXTRA_DEBUG … … 1626 1780 if (extra->topextra) { 1627 1781 deleteTLSysExtra(); 1628 delete extra->topextra->backingStore;1782 extra->topextra->backingStore.destroy(); 1629 1783 delete extra->topextra->icon; 1630 1784 delete extra->topextra->iconPixmap; … … 2308 2462 { 2309 2463 if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { 2464 #ifdef ALIEN_DEBUG 2465 qDebug() << "QWidget::winId: creating native window for" << this; 2466 #endif 2310 2467 QWidget *that = const_cast<QWidget*>(this); 2311 2468 that->setAttribute(Qt::WA_NativeWindow); … … 2320 2477 { 2321 2478 Q_Q(QWidget); 2479 2480 #ifdef ALIEN_DEBUG 2481 qDebug() << "QWidgetPrivate::createWinId for" << q << winid; 2482 #endif 2322 2483 const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); 2323 2484 if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { … … 2362 2523 { 2363 2524 Q_D(QWidget); 2525 #ifdef ALIEN_DEBUG 2526 qDebug() << "QWidget::createWinId" << this; 2527 #endif 2364 2528 // qWarning("QWidget::createWinId is obsolete, please fix your code."); 2365 2529 d->createWinId(); … … 2508 2672 QStyle *oldStyle = q->style(); 2509 2673 #ifndef QT_NO_STYLE_STYLESHEET 2510 Q Style *origStyle = 0;2674 QWeakPointer<QStyle> origStyle; 2511 2675 #endif 2512 2676 … … 2522 2686 2523 2687 #ifndef QT_NO_STYLE_STYLESHEET 2524 origStyle = extra->style ;2688 origStyle = extra->style.data(); 2525 2689 #endif 2526 2690 extra->style = newStyle; … … 2551 2715 } 2552 2716 2717 #ifndef QT_NO_STYLE_STYLESHEET 2718 if (!qobject_cast<QStyleSheetStyle*>(newStyle)) { 2719 if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) { 2720 cssStyle->clearWidgetFont(q); 2721 } 2722 } 2723 #endif 2724 2553 2725 QEvent e(QEvent::StyleChange); 2554 2726 QApplication::sendEvent(q, &e); … … 2558 2730 2559 2731 #ifndef QT_NO_STYLE_STYLESHEET 2560 if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {2561 if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle)) {2562 cssStyle->clearWidgetFont(q);2563 }2564 }2565 #endif2566 2567 #ifndef QT_NO_STYLE_STYLESHEET2568 2732 // dereference the old stylesheet style 2569 if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle ))2733 if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data())) 2570 2734 proxy->deref(); 2571 2735 #endif … … 2868 3032 void QWidget::showFullScreen() 2869 3033 { 3034 #ifdef Q_WS_MAC 3035 // If the unified toolbar is enabled, we have to disable it before going fullscreen. 3036 QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); 3037 if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) { 3038 mainWindow->setUnifiedTitleAndToolBarOnMac(false); 3039 QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); 3040 mainLayout->activateUnifiedToolbarAfterFullScreen = true; 3041 } 3042 #endif // Q_WS_MAC 2870 3043 ensurePolished(); 2871 3044 #ifdef QT3_SUPPORT … … 2900 3073 setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) 2901 3074 | Qt::WindowMaximized); 3075 #ifdef Q_WS_MAC 3076 // If the unified toolbar was enabled before going fullscreen, we have to enable it back. 3077 QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); 3078 if (mainWindow) 3079 { 3080 QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); 3081 if (mainLayout->activateUnifiedToolbarAfterFullScreen) { 3082 mainWindow->setUnifiedTitleAndToolBarOnMac(true); 3083 mainLayout->activateUnifiedToolbarAfterFullScreen = false; 3084 } 3085 } 3086 #endif // Q_WS_MAC 2902 3087 show(); 2903 3088 } … … 2921 3106 | Qt::WindowMaximized 2922 3107 | Qt::WindowFullScreen)); 3108 #ifdef Q_WS_MAC 3109 // If the unified toolbar was enabled before going fullscreen, we have to enable it back. 3110 QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this); 3111 if (mainWindow) 3112 { 3113 QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); 3114 if (mainLayout->activateUnifiedToolbarAfterFullScreen) { 3115 mainWindow->setUnifiedTitleAndToolBarOnMac(true); 3116 mainLayout->activateUnifiedToolbarAfterFullScreen = false; 3117 } 3118 } 3119 #endif // Q_WS_MAC 2923 3120 show(); 2924 3121 } … … 4733 4930 direction. 4734 4931 4932 This method no longer affects text layout direction since Qt 4.7. 4933 4735 4934 \sa QApplication::layoutDirection 4736 4935 */ … … 4738 4937 { 4739 4938 Q_D(QWidget); 4939 4940 if (direction == Qt::LayoutDirectionAuto) { 4941 unsetLayoutDirection(); 4942 return; 4943 } 4740 4944 4741 4945 setAttribute(Qt::WA_SetLayoutDirection); … … 4891 5095 const QRegion &sourceRegion, RenderFlags renderFlags) 4892 5096 { 4893 Q_D(QWidget); 4894 if (!target) { 4895 qWarning("QWidget::render: null pointer to paint device"); 4896 return; 4897 } 4898 4899 const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter; 4900 QRegion paintRegion = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags) 4901 : sourceRegion; 4902 if (paintRegion.isEmpty()) 4903 return; 4904 4905 #ifndef Q_WS_MAC 4906 QPainter *oldSharedPainter = inRenderWithPainter ? d->sharedPainter() : 0; 4907 4908 // Use the target's shared painter if set (typically set when doing 4909 // "other->render(widget);" in the widget's paintEvent. 4910 if (target->devType() == QInternal::Widget) { 4911 QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); 4912 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) { 4913 QPainter *targetPainter = targetPrivate->sharedPainter(); 4914 if (targetPainter && targetPainter->isActive()) 4915 d->setSharedPainter(targetPainter); 4916 } 4917 } 4918 #endif 4919 4920 // Use the target's redirected device if set and adjust offset and paint 4921 // region accordingly. This is typically the case when people call render 4922 // from the paintEvent. 4923 QPoint offset = targetOffset; 4924 offset -= paintRegion.boundingRect().topLeft(); 4925 QPoint redirectionOffset; 4926 QPaintDevice *redirected = 0; 4927 4928 if (target->devType() == QInternal::Widget) 4929 redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); 4930 if (!redirected) 4931 redirected = QPainter::redirected(target, &redirectionOffset); 4932 4933 if (redirected) { 4934 target = redirected; 4935 offset -= redirectionOffset; 4936 } 4937 4938 if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). 4939 if (QPaintEngine *targetEngine = target->paintEngine()) { 4940 const QRegion targetSystemClip = targetEngine->systemClip(); 4941 if (!targetSystemClip.isEmpty()) 4942 paintRegion &= targetSystemClip.translated(-offset); 4943 } 4944 } 4945 4946 // Set backingstore flags. 4947 int flags = QWidgetPrivate::DrawPaintOnScreen | QWidgetPrivate::DrawInvisible; 4948 if (renderFlags & DrawWindowBackground) 4949 flags |= QWidgetPrivate::DrawAsRoot; 4950 4951 if (renderFlags & DrawChildren) 4952 flags |= QWidgetPrivate::DrawRecursive; 4953 else 4954 flags |= QWidgetPrivate::DontSubtractOpaqueChildren; 4955 4956 #ifdef Q_WS_QWS 4957 flags |= QWidgetPrivate::DontSetCompositionMode; 4958 #endif 4959 4960 if (target->devType() == QInternal::Printer) { 4961 QPainter p(target); 4962 d->render_helper(&p, targetOffset, paintRegion, renderFlags); 4963 return; 4964 } 4965 4966 #ifndef Q_WS_MAC 4967 // Render via backingstore. 4968 d->drawWidget(target, paintRegion, offset, flags, d->sharedPainter()); 4969 4970 // Restore shared painter. 4971 if (oldSharedPainter) 4972 d->setSharedPainter(oldSharedPainter); 4973 #else 4974 // Render via backingstore (no shared painter). 4975 d->drawWidget(target, paintRegion, offset, flags, 0); 4976 #endif 5097 d_func()->render(target, targetOffset, sourceRegion, renderFlags, false); 4977 5098 } 4978 5099 … … 5334 5455 if (paintEngine) { 5335 5456 setRedirected(pdev, -offset); 5336 5457 #ifdef Q_WS_MAC 5458 // (Alien support) Special case for Mac when redirecting: If the paint device 5459 // is of the Widget type we need to set WA_WState_InPaintEvent since painting 5460 // outside the paint event is not supported on QWidgets. The attributeis 5461 // restored further down. 5462 if (pdev->devType() == QInternal::Widget) 5463 static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent); 5464 5465 #endif 5337 5466 if (sharedPainter) 5338 5467 paintEngine->d_func()->systemClip = toBePainted; … … 5375 5504 //restore 5376 5505 if (paintEngine) { 5506 #ifdef Q_WS_MAC 5507 if (pdev->devType() == QInternal::Widget) 5508 static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false); 5509 #endif 5377 5510 restoreRedirected(); 5378 5511 if (!sharedPainter) … … 5418 5551 , sharedPainter, backingStore); 5419 5552 } 5553 } 5554 5555 void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, 5556 const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, 5557 bool readyToRender) 5558 { 5559 if (!target) { 5560 qWarning("QWidget::render: null pointer to paint device"); 5561 return; 5562 } 5563 5564 const bool inRenderWithPainter = extra && extra->inRenderWithPainter; 5565 QRegion paintRegion = !inRenderWithPainter && !readyToRender 5566 ? prepareToRender(sourceRegion, renderFlags) 5567 : sourceRegion; 5568 if (paintRegion.isEmpty()) 5569 return; 5570 5571 #ifndef Q_WS_MAC 5572 QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0; 5573 5574 // Use the target's shared painter if set (typically set when doing 5575 // "other->render(widget);" in the widget's paintEvent. 5576 if (target->devType() == QInternal::Widget) { 5577 QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func(); 5578 if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) { 5579 QPainter *targetPainter = targetPrivate->sharedPainter(); 5580 if (targetPainter && targetPainter->isActive()) 5581 setSharedPainter(targetPainter); 5582 } 5583 } 5584 #endif 5585 5586 // Use the target's redirected device if set and adjust offset and paint 5587 // region accordingly. This is typically the case when people call render 5588 // from the paintEvent. 5589 QPoint offset = targetOffset; 5590 offset -= paintRegion.boundingRect().topLeft(); 5591 QPoint redirectionOffset; 5592 QPaintDevice *redirected = 0; 5593 5594 if (target->devType() == QInternal::Widget) 5595 redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset); 5596 if (!redirected) 5597 redirected = QPainter::redirected(target, &redirectionOffset); 5598 5599 if (redirected) { 5600 target = redirected; 5601 offset -= redirectionOffset; 5602 } 5603 5604 if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp). 5605 if (QPaintEngine *targetEngine = target->paintEngine()) { 5606 const QRegion targetSystemClip = targetEngine->systemClip(); 5607 if (!targetSystemClip.isEmpty()) 5608 paintRegion &= targetSystemClip.translated(-offset); 5609 } 5610 } 5611 5612 // Set backingstore flags. 5613 int flags = DrawPaintOnScreen | DrawInvisible; 5614 if (renderFlags & QWidget::DrawWindowBackground) 5615 flags |= DrawAsRoot; 5616 5617 if (renderFlags & QWidget::DrawChildren) 5618 flags |= DrawRecursive; 5619 else 5620 flags |= DontSubtractOpaqueChildren; 5621 5622 #ifdef Q_WS_QWS 5623 flags |= DontSetCompositionMode; 5624 #endif 5625 5626 if (target->devType() == QInternal::Printer) { 5627 QPainter p(target); 5628 render_helper(&p, targetOffset, paintRegion, renderFlags); 5629 return; 5630 } 5631 5632 #ifndef Q_WS_MAC 5633 // Render via backingstore. 5634 drawWidget(target, paintRegion, offset, flags, sharedPainter()); 5635 5636 // Restore shared painter. 5637 if (oldSharedPainter) 5638 setSharedPainter(oldSharedPainter); 5639 #else 5640 // Render via backingstore (no shared painter). 5641 drawWidget(target, paintRegion, offset, flags, 0); 5642 #endif 5420 5643 } 5421 5644 … … 5537 5760 } 5538 5761 5539 5540 5762 QRect effectRect; 5541 5763 5542 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {5764 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) 5543 5765 effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); 5544 5545 } else if (mode == QGraphicsEffect::PadToTransparentBorder) { 5766 else if (mode == QGraphicsEffect::PadToTransparentBorder) 5546 5767 effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect(); 5547 5548 } else { 5768 else 5549 5769 effectRect = sourceRect.toAlignedRect(); 5550 5551 }5552 5770 5553 5771 if (offset) 5554 5772 *offset = effectRect.topLeft(); 5555 5773 5556 if (deviceCoordinates) {5557 // Clip to device rect.5558 int left, top, right, bottom;5559 effectRect.getCoords(&left, &top, &right, &bottom);5560 if (left < 0) {5561 if (offset)5562 offset->rx() += -left;5563 effectRect.setX(0);5564 }5565 if (top < 0) {5566 if (offset)5567 offset->ry() += -top;5568 effectRect.setY(0);5569 }5570 // NB! We use +-1 for historical reasons (see QRect documentation).5571 QPaintDevice *device = context->painter->device();5572 const int deviceWidth = device->width();5573 const int deviceHeight = device->height();5574 if (right + 1 > deviceWidth)5575 effectRect.setRight(deviceWidth - 1);5576 if (bottom + 1 > deviceHeight)5577 effectRect.setBottom(deviceHeight -1);5578 }5579 5580 5774 pixmapOffset -= effectRect.topLeft(); 5581 5775 5582 5776 QPixmap pixmap(effectRect.size()); 5583 5777 pixmap.fill(Qt::transparent); 5584 m_widget->render(&pixmap, pixmapOffset );5778 m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren); 5585 5779 return pixmap; 5586 5780 } … … 6186 6380 } 6187 6381 if (!isHidden()) { 6382 #ifndef QT_NO_GRAPHICSVIEW 6383 // Update proxy state 6384 if (QWExtra *topData = window()->d_func()->extra) 6385 if (topData->proxyWidget && topData->proxyWidget->hasFocus()) 6386 topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); 6387 #endif 6188 6388 // Send event to self 6189 6389 QFocusEvent event(QEvent::FocusIn, reason); … … 6465 6665 QWidget *fn = first->d_func()->focus_next; 6466 6666 6467 if (fn == second )6667 if (fn == second || first == second) 6468 6668 return; 6469 6669 … … 6694 6894 QByteArray QWidget::saveGeometry() const 6695 6895 { 6896 #ifdef QT_MAC_USE_COCOA 6897 // We check if the window was maximized during this invocation. If so, we need to record the 6898 // starting position as 0,0. 6899 Q_D(const QWidget); 6900 QRect newFramePosition = frameGeometry(); 6901 QRect newNormalPosition = normalGeometry(); 6902 if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) { 6903 // Change the starting position 6904 newFramePosition.moveTo(0, 0); 6905 newNormalPosition.moveTo(0, 0); 6906 } 6907 #endif // QT_MAC_USE_COCOA 6696 6908 QByteArray array; 6697 6909 QDataStream stream(&array, QIODevice::WriteOnly); … … 6703 6915 << majorVersion 6704 6916 << minorVersion 6917 #ifdef QT_MAC_USE_COCOA 6918 << newFramePosition 6919 << newNormalPosition 6920 #else 6705 6921 << frameGeometry() 6706 6922 << normalGeometry() 6923 #endif // QT_MAC_USE_COCOA 6707 6924 << qint32(QApplication::desktop()->screenNumber(this)) 6708 6925 << quint8(windowState() & Qt::WindowMaximized) … … 7281 7498 bool isEmbedded = false; 7282 7499 #if !defined QT_NO_GRAPHICSVIEW 7283 isEmbedded = q->isWindow() && nearestGraphicsProxyWidget(q->parentWidget()) != 0;7500 isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0; 7284 7501 #else 7285 7502 Q_UNUSED(isEmbedded); … … 7318 7535 // hidden. 7319 7536 if (wasVisible) { 7320 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)7537 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 7321 7538 qApp->d_func()->sendSyntheticEnterLeave(q); 7322 7539 #endif … … 7349 7566 it. It will not be automatically shown when the parent is shown. 7350 7567 7351 To check visib lity, use !isVisible() instead (notice the exclamation mark).7568 To check visibility, use !isVisible() instead (notice the exclamation mark). 7352 7569 7353 7570 isHidden() implies !isVisible(), but a widget can be not visible … … 7450 7667 d->show_helper(); 7451 7668 7452 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)7669 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 7453 7670 qApp->d_func()->sendSyntheticEnterLeave(this); 7454 7671 #endif … … 7582 7799 } 7583 7800 } 7584 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_ PM)7801 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_PM) 7585 7802 qApp->d_func()->sendSyntheticEnterLeave(widget); 7586 7803 #endif … … 7626 7843 QApplication::quit(); 7627 7844 #endif 7628 // Attempt to close the application only if this widget has the 7629 // WA_QuitOnClose flag set set and has a non-visible parent 7630 quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible() || parentWidget->testAttribute(Qt::WA_DontShowOnScreen)); 7845 // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent 7846 quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible()); 7631 7847 7632 7848 if (quitOnClose) { 7633 / / If there is no non-withdrawn primary window left (except7634 // the ones without QuitOnClose or with WA_DontShowOnScreen),7635 // we emit the lastWindowClosed signal7849 /* if there is no non-withdrawn primary window left (except 7850 the ones without QuitOnClose), we emit the lastWindowClosed 7851 signal */ 7636 7852 QWidgetList list = QApplication::topLevelWidgets(); 7637 7853 bool lastWindowClosed = true; 7638 7854 for (int i = 0; i < list.size(); ++i) { 7639 7855 QWidget *w = list.at(i); 7640 if ((w->isVisible() && !w->testAttribute(Qt::WA_DontShowOnScreen)) 7641 && !w->parentWidget() && w->testAttribute(Qt::WA_QuitOnClose)) { 7642 lastWindowClosed = false; 7643 break; 7644 } 7856 if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose)) 7857 continue; 7858 lastWindowClosed = false; 7859 break; 7645 7860 } 7646 7861 if (lastWindowClosed) … … 8484 8699 break; 8485 8700 } 8701 #ifndef QT_NO_GESTURES 8486 8702 case QEvent::Gesture: 8487 8703 event->ignore(); 8488 8704 break; 8705 #endif 8489 8706 #ifndef QT_NO_PROPERTIES 8490 8707 case QEvent::DynamicPropertyChange: { … … 8513 8730 This event handler can be reimplemented to handle state changes. 8514 8731 8515 The state being changed in this event can be retrieved through event \a8516 event.8732 The state being changed in this event can be retrieved through the \a event 8733 supplied. 8517 8734 8518 8735 Change events include: QEvent::ToolBarChange, … … 8625 8842 while ((w = QApplication::activePopupWidget()) && w != this){ 8626 8843 w->close(); 8627 if (QApplication::activePopupWidget() == w) // widget does not want to dis sappear8844 if (QApplication::activePopupWidget() == w) // widget does not want to disappear 8628 8845 w->hide(); // hide at least 8629 8846 } … … 9078 9295 { 9079 9296 #ifndef QT_NO_IM 9080 Q_D(const QWidget); 9081 return d->imHints; 9297 const QWidgetPrivate *priv = d_func(); 9298 while (priv->inheritsInputMethodHints) { 9299 priv = priv->q_func()->parentWidget()->d_func(); 9300 Q_ASSERT(priv); 9301 } 9302 return priv->imHints; 9082 9303 #else //QT_NO_IM 9083 9304 return 0; … … 9090 9311 Q_D(QWidget); 9091 9312 d->imHints = hints; 9092 // Optimi sation to update input context only it has already been created.9313 // Optimization to update input context only it has already been created. 9093 9314 if (d->ic || qApp->d_func()->inputContext) { 9094 9315 QInputContext *ic = inputContext(); … … 9634 9855 QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const 9635 9856 { 9857 if (children.isEmpty()) 9858 return 0; 9859 9860 #ifdef Q_WS_MAC 9636 9861 Q_Q(const QWidget); 9637 #ifdef Q_WS_MAC 9862 // Unified tool bars on the Mac require special handling since they live outside 9863 // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8 9638 9864 bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q) 9639 9865 && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac(); 9640 #endif 9641 9642 if ( 9866 if (includeFrame) 9867 return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame); 9868 #endif 9869 9870 if (!pointInsideRectAndMask(p)) 9871 return 0; 9872 return childAtRecursiveHelper(p, ignoreChildrenInDestructor); 9873 } 9874 9875 QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const 9876 { 9877 #ifndef Q_WS_MAC 9878 Q_UNUSED(includeFrame); 9879 #endif 9880 for (int i = children.size() - 1; i >= 0; --i) { 9881 QWidget *child = qobject_cast<QWidget *>(children.at(i)); 9882 if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents) 9883 || (ignoreChildrenInDestructor && child->data->in_destructor)) { 9884 continue; 9885 } 9886 9887 // Map the point 'p' from parent coordinates to child coordinates. 9888 QPoint childPoint = p; 9643 9889 #ifdef Q_WS_MAC 9644 !includeFrame && 9645 #endif 9646 !q->rect().contains(p)) 9647 return 0; 9648 9649 for (int i = children.size(); i > 0 ;) { 9650 --i; 9651 QWidget *w = qobject_cast<QWidget *>(children.at(i)); 9652 if (w && !w->isWindow() && !w->isHidden() 9653 && (w->geometry().contains(p) 9654 #ifdef Q_WS_MAC 9655 || (includeFrame && w->geometry().contains(qt_mac_nativeMapFromParent(w, p))) 9656 #endif 9657 )) { 9658 if (ignoreChildrenInDestructor && w->data->in_destructor) 9659 continue; 9660 if (w->testAttribute(Qt::WA_TransparentForMouseEvents)) 9661 continue; 9662 QPoint childPoint = w->mapFromParent(p); 9663 #ifdef Q_WS_MAC 9664 if (includeFrame && !w->geometry().contains(p)) 9665 childPoint = qt_mac_nativeMapFromParent(w, p); 9666 #endif 9667 if (QWidget *t = w->d_func()->childAt_helper(childPoint, ignoreChildrenInDestructor)) 9668 return t; 9669 // if WMouseNoMask is set the widget mask is ignored, if 9670 // the widget has no mask then the WMouseNoMask flag has no 9671 // effect 9672 if (w->testAttribute(Qt::WA_MouseNoMask) || w->mask().contains(childPoint) 9673 || w->mask().isEmpty()) 9674 return w; 9675 } 9890 // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar. 9891 // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal 9892 // QWidget::mapFromParent won't do the trick. 9893 if (includeFrame && qobject_cast<QToolBar *>(child)) 9894 childPoint = qt_mac_nativeMapFromParent(child, p); 9895 else 9896 #endif 9897 childPoint -= child->data->crect.topLeft(); 9898 9899 // Check if the point hits the child. 9900 if (!child->d_func()->pointInsideRectAndMask(childPoint)) 9901 continue; 9902 9903 // Do the same for the child's descendants. 9904 if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor)) 9905 return w; 9906 9907 // We have found our target; namely the child at position 'p'. 9908 return child; 9676 9909 } 9677 9910 return 0; … … 9830 10063 bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; 9831 10064 9832 #if defined(Q_WS_X11) || defined(Q_WS_WIN) 10065 #if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) 9833 10066 if (newParent && parent && !desktopWidget) { 9834 10067 if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) … … 9852 10085 focusWidget()->clearFocus(); 9853 10086 10087 QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData(); 10088 QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStore : 0; 10089 9854 10090 d->setParent_sys(parent, f); 10091 10092 QTLWExtra *topExtra = window()->d_func()->maybeTopData(); 10093 QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStore : 0; 10094 if (oldBsTracker && oldBsTracker != bsTracker) 10095 oldBsTracker->unregisterWidgetSubtree(this); 10096 9855 10097 if (desktopWidget) 9856 10098 parent = 0; … … 10315 10557 #endif // QT3_SUPPORT 10316 10558 10317 /*! 10318 Sets the attribute \a attribute on this widget if \a on is true; 10319 otherwise clears the attribute. 10320 10321 \sa testAttribute() 10322 */ 10323 void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) 10324 { 10325 if (testAttribute(attribute) == on) 10326 return; 10327 10328 Q_D(QWidget); 10329 Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), 10330 "QWidget::setAttribute(WidgetAttribute, bool)", 10331 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); 10332 10333 #if defined(Q_WS_WIN) || defined(Q_WS_PM) 10334 // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0 10335 if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) { 10336 // see qwidget_[win|pm].cpp, ::paintEngine for details 10337 paintEngine(); 10338 if (d->noPaintOnScreen) 10339 return; 10340 } 10341 #endif 10342 10559 /*! 10560 \internal 10561 10562 This just sets the corresponding attribute bit to 1 or 0 10563 */ 10564 static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, 10565 QWidgetPrivate *d) 10566 { 10343 10567 if (attribute < int(8*sizeof(uint))) { 10344 10568 if (on) … … 10354 10578 d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint)))); 10355 10579 } 10580 } 10581 10582 /*! 10583 Sets the attribute \a attribute on this widget if \a on is true; 10584 otherwise clears the attribute. 10585 10586 \sa testAttribute() 10587 */ 10588 void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) 10589 { 10590 if (testAttribute(attribute) == on) 10591 return; 10592 10593 Q_D(QWidget); 10594 Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), 10595 "QWidget::setAttribute(WidgetAttribute, bool)", 10596 "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); 10597 10598 #if defined(Q_WS_WIN) || defined(Q_WS_PM) 10599 // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0 10600 if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) { 10601 // see qwidget_[win|pm].cpp, ::paintEngine for details 10602 paintEngine(); 10603 if (d->noPaintOnScreen) 10604 return; 10605 } 10606 #endif 10607 10608 setAttribute_internal(attribute, on, data, d); 10356 10609 10357 10610 switch (attribute) { … … 10412 10665 { 10413 10666 // We can only have one of these set at a time 10414 static const int MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, 10415 Qt::WA_MacMiniSize, 0 }; 10416 for (int i = 0; MacSizes[i] != 0; ++i) { 10417 if (MacSizes[i] == attribute) 10418 continue; 10419 int macsize_x = MacSizes[i] - 8*sizeof(uint); 10420 int macsize_int_off = macsize_x / (8*sizeof(uint)); 10421 d->high_attributes[macsize_int_off] &= ~(1<<(macsize_x-(macsize_int_off*8*sizeof(uint)))); 10667 const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, 10668 Qt::WA_MacMiniSize }; 10669 for (int i = 0; i < 3; ++i) { 10670 if (MacSizes[i] != attribute) 10671 setAttribute_internal(MacSizes[i], false, data, d); 10422 10672 } 10423 10673 d->macUpdateSizeAttribute(); … … 10486 10736 case Qt::WA_PaintOnScreen: 10487 10737 d->updateIsOpaque(); 10488 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 10738 #if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) 10489 10739 // Recreate the widget if it's already created as an alien widget and 10490 10740 // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. … … 10542 10792 d->updateIsOpaque(); 10543 10793 break; 10794 case Qt::WA_X11DoNotAcceptFocus: 10795 if (testAttribute(Qt::WA_WState_Created)) 10796 d->updateX11AcceptFocus(); 10797 break; 10544 10798 #endif 10545 10799 case Qt::WA_DontShowOnScreen: { … … 10597 10851 break; 10598 10852 case Qt::WA_AcceptTouchEvents: 10599 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_ WS_S60)10853 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) 10600 10854 if (on) 10601 10855 d->registerTouchWindow(); 10602 10856 #endif 10603 10857 break; 10858 case Qt::WA_LockPortraitOrientation: 10859 case Qt::WA_LockLandscapeOrientation: 10860 case Qt::WA_AutoOrientation: { 10861 const Qt::WidgetAttribute orientations[3] = { 10862 Qt::WA_LockPortraitOrientation, 10863 Qt::WA_LockLandscapeOrientation, 10864 Qt::WA_AutoOrientation 10865 }; 10866 10867 if (on) { 10868 // We can only have one of these set at a time 10869 for (int i = 0; i < 3; ++i) { 10870 if (orientations[i] != attribute) 10871 setAttribute_internal(orientations[i], false, data, d); 10872 } 10873 } 10874 10875 #ifdef Q_WS_S60 10876 CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi()); 10877 const CAknAppUiBase::TAppUiOrientation s60orientations[] = { 10878 CAknAppUiBase::EAppUiOrientationPortrait, 10879 CAknAppUiBase::EAppUiOrientationLandscape, 10880 CAknAppUiBase::EAppUiOrientationAutomatic 10881 }; 10882 CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified; 10883 for (int i = 0; i < 3; ++i) { 10884 if (testAttribute(orientations[i])) { 10885 s60orientation = s60orientations[i]; 10886 break; 10887 } 10888 } 10889 QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation)); 10890 S60->orientationSet = true; 10891 #endif 10892 break; 10893 } 10604 10894 default: 10605 10895 break; … … 10959 11249 #if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) 10960 11250 Q_D(QWidget); 10961 // and optimi sation to update input context only it has already been created.11251 // and optimization to update input context only it has already been created. 10962 11252 if (d->ic || qApp->d_func()->inputContext) { 10963 11253 QInputContext *ic = inputContext(); … … 11785 12075 Tells us if it there is currently a reachable widget by keypad navigation in 11786 12076 a certain \a orientation. 11787 If no navigation is possible, occur ing key events in that \a orientation may11788 be used to interact with the value in the focus sed widget, even though it12077 If no navigation is possible, occurring key events in that \a orientation may 12078 be used to interact with the value in the focused widget, even though it 11789 12079 currently has not the editFocus. 11790 12080 … … 11806 12096 navigation. If there is no QTabWidget, the horizontal key events can be used 11807 12097 to 11808 interact with the value in the focus sed widget, even though it currently has12098 interact with the value in the focused widget, even though it currently has 11809 12099 not the editFocus. 11810 12100 … … 12006 12296 */ 12007 12297 12298 #ifndef QT_NO_GESTURES 12008 12299 /*! 12009 12300 Subscribes the widget to a given \a gesture with specific \a flags. … … 12029 12320 Q_D(QWidget); 12030 12321 if (d->gestureContext.remove(gesture)) { 12031 QGestureManager *manager = QGestureManager::instance();12032 manager->cleanupCachedGestures(this, gesture);12033 } 12034 } 12035 12322 if (QGestureManager *manager = QGestureManager::instance()) 12323 manager->cleanupCachedGestures(this, gesture); 12324 } 12325 } 12326 #endif // QT_NO_GESTURES 12036 12327 12037 12328 /*! … … 12357 12648 #endif 12358 12649 12650 #if QT_MAC_USE_COCOA 12651 void QWidgetPrivate::syncUnifiedMode() { 12652 // The whole purpose of this method is to keep the unifiedToolbar in sync. 12653 // That means making sure we either exchange the drawing methods or we let 12654 // the toolbar know that it does not require to draw the baseline. 12655 Q_Q(QWidget); 12656 // This function makes sense only if this is a top level 12657 if(!q->isWindow()) 12658 return; 12659 OSWindowRef window = qt_mac_window_for(q); 12660 if(changeMethods) { 12661 // Ok, we are in documentMode. 12662 if(originalDrawMethod) 12663 qt_mac_replaceDrawRect(window, this); 12664 } else { 12665 if(!originalDrawMethod) 12666 qt_mac_replaceDrawRectOriginal(window, this); 12667 } 12668 } 12669 12670 #endif // QT_MAC_USE_COCOA 12671 12359 12672 QT_END_NAMESPACE 12360 12673 -
trunk/src/gui/kernel/qwidget.h
r705 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 361 361 #endif //QT_NO_GRAPHICSEFFECT 362 362 363 #ifndef QT_NO_GESTURES 363 364 void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags()); 364 365 void ungrabGesture(Qt::GestureType type); 366 #endif 365 367 366 368 public Q_SLOTS: … … 757 759 friend class QStyleSheetStyle; 758 760 friend struct QWidgetExceptionCleaner; 761 #ifndef QT_NO_GESTURES 759 762 friend class QGestureManager; 760 763 friend class QWinNativePanGestureRecognizer; 764 #endif // QT_NO_GESTURES 761 765 friend class QWidgetEffectSourcePrivate; 762 766 … … 788 792 friend void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp); 789 793 friend void qt_net_remove_user_time(QWidget *tlw); 794 friend void qt_set_winid_on_widget(QWidget*, Qt::HANDLE); 790 795 #endif 791 796 -
trunk/src/gui/kernel/qwidget_mac.mm
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 115 115 QT_BEGIN_NAMESPACE 116 116 117 // qmainwindow.cpp 118 extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); 119 117 120 #define XCOORD_MAX 16383 118 121 #define WRECT_MAX 8191 … … 461 464 bool qt_isGenuineQWidget(const QWidget *window) 462 465 { 463 return window && qt_isGenuineQWidget(OSViewRef(window->winId())); 466 if (!window) 467 return false; 468 469 if (!window->internalWinId()) 470 return true; //alien 471 472 return qt_isGenuineQWidget(OSViewRef(window->internalWinId())); 464 473 } 465 474 … … 747 756 } 748 757 758 #ifndef QT_NO_GESTURES 749 759 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 750 760 /* We build the release package against the 10.4 SDK. … … 763 773 }; 764 774 #endif 775 #endif // QT_NO_GESTURES 765 776 766 777 // window events … … 1071 1082 break; } 1072 1083 1084 #ifndef QT_NO_GESTURES 1073 1085 case kEventClassGesture: { 1074 1086 // First, find the widget that was under … … 1137 1149 QApplication::sendSpontaneousEvent(widget, &qNGEvent); 1138 1150 break; } 1151 #endif // QT_NO_GESTURES 1139 1152 1140 1153 default: … … 1590 1603 QWidget *widget = static_cast<QWidget*>(object); 1591 1604 if(qt_mac_is_macdrawer(widget)) { 1605 bool oldState = widget->testAttribute(Qt::WA_WState_ExplicitShowHide); 1592 1606 if(visible) { 1593 1607 if (!widget->testAttribute(Qt::WA_WState_ExplicitShowHide)) … … 1595 1609 } else { 1596 1610 widget->hide(); 1597 widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false); 1611 if(!oldState) 1612 widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false); 1598 1613 } 1599 1614 } … … 1913 1928 else if(popup || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 && type == Qt::SplashScreen)) 1914 1929 wclass = kModalWindowClass; 1915 else if( q->testAttribute(Qt::WA_ShowModal) ||type == Qt::Dialog)1930 else if(type == Qt::Dialog) 1916 1931 wclass = kMovableModalWindowClass; 1917 1932 else if(type == Qt::ToolTip) … … 1920 1935 && type == Qt::SplashScreen)) 1921 1936 wclass = kFloatingWindowClass; 1937 else if(q->testAttribute(Qt::WA_ShowModal)) 1938 wclass = kMovableModalWindowClass; 1922 1939 else 1923 1940 wclass = kDocumentWindowClass; … … 2023 2040 if((tmp_wattr & known_attribs[i].tag) == known_attribs[i].tag) { 2024 2041 tmp_wattr ^= known_attribs[i].tag; 2025 qDebug("Qt: internal: * %s %s", known_attribs[i].name,2026 (GetAvailableWindowAttributes(wclass) & known_attribs[i].tag) ? "" : "(*)");2027 2042 } 2028 2043 } … … 2219 2234 } 2220 2235 #else // QT_MAC_USE_COCOA 2236 2237 void QWidgetPrivate::setWindowLevel() 2238 { 2239 Q_Q(QWidget); 2240 const QWidget * const windowParent = q->window()->parentWidget(); 2241 const QWidget * const primaryWindow = windowParent ? windowParent->window() : 0; 2242 NSInteger winLevel = -1; 2243 2244 if (q->windowType() == Qt::Popup) { 2245 winLevel = NSPopUpMenuWindowLevel; 2246 // Popup should be in at least the same level as its parent. 2247 if (primaryWindow) { 2248 OSWindowRef parentRef = qt_mac_window_for(primaryWindow); 2249 winLevel = qMax([parentRef level], winLevel); 2250 } 2251 } else if (q->windowType() == Qt::Tool) { 2252 winLevel = NSFloatingWindowLevel; 2253 } else if (q->windowType() == Qt::Dialog) { 2254 // Correct modality level (NSModalPanelWindowLevel) will be 2255 // set by cocoa when creating a modal session later. 2256 winLevel = NSNormalWindowLevel; 2257 } 2258 2259 // StayOnTop window should appear above Tool windows. 2260 if (data.window_flags & Qt::WindowStaysOnTopHint) 2261 winLevel = NSPopUpMenuWindowLevel; 2262 // Tooltips should appear above StayOnTop windows. 2263 if (q->windowType() == Qt::ToolTip) 2264 winLevel = NSScreenSaverWindowLevel; 2265 // All other types are Normal level. 2266 if (winLevel == -1) 2267 winLevel = NSNormalWindowLevel; 2268 [qt_mac_window_for(q) setLevel:winLevel]; 2269 } 2270 2221 2271 void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWindowRef) 2222 2272 { … … 2260 2310 registerDropSite(true); 2261 2311 transferChildren(); 2312 2313 // Tell Cocoa explicit that we wan't the view to receive key events 2314 // (regardless of focus policy) because this is how it works on other 2315 // platforms (and in the carbon port): 2316 if (!qApp->focusWidget()) 2317 [windowRef makeFirstResponder:nsview]; 2262 2318 } 2263 2319 … … 2291 2347 } 2292 2348 2349 if (qApp->overrideCursor()) 2350 [windowRef disableCursorRects]; 2351 2352 setWindowLevel(); 2293 2353 macUpdateHideOnSuspend(); 2294 2354 macUpdateOpaqueSizeGrip(); … … 2319 2379 determineWindowClass(); 2320 2380 createWindow_sys(); 2321 if (QMainWindowLayout *mwl = qobject_cast<QMainWindowLayout *>(q->layout())) { 2381 2382 if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) { 2322 2383 mwl->updateHIToolBarStatus(); 2323 2384 } … … 2565 2626 } else { 2566 2627 data.fstrut_dirty = false; // non-toplevel widgets don't have a frame, so no need to update the strut 2567 if(OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) { 2628 2629 #ifdef QT_MAC_USE_COCOA 2630 if (q->testAttribute(Qt::WA_NativeWindow) == false || 2631 q->internalWinId() != 0) { 2632 #ifdef ALIEN_DEBUG 2633 qDebug() << "Skipping native widget creation for" << this; 2634 #endif 2635 } else 2636 #endif 2637 if (OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) { 2568 2638 #ifndef QT_MAC_USE_COCOA 2569 2639 HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height()); … … 2625 2695 { 2626 2696 Q_D(QWidget); 2697 d->aboutToDestroy(); 2627 2698 if (!isWindow() && parentWidget()) 2628 2699 parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); … … 2721 2792 } 2722 2793 2794 #ifdef QT_MAC_USE_COCOA 2795 void QWidgetPrivate::setSubWindowStacking(bool set) 2796 { 2797 // This will set/remove a visual relationship between parent and child on screen. 2798 // The reason for doing this is to ensure that a child always stacks infront of 2799 // its parent. Unfortunatly is turns out that [NSWindow addChildWindow] has 2800 // several unwanted side-effects, one of them being the moving of a child when 2801 // moving the parent, which we choose to accept. A way tougher side-effect is 2802 // that Cocoa will hide the parent if you hide the child. And in the case of 2803 // a tool window, since it will normally hide when you deactivate the 2804 // application, Cocoa will hide the parent upon deactivate as well. The result often 2805 // being no more visible windows on screen. So, to make a long story short, we only 2806 // allow parent-child relationships between windows that both are either a plain window 2807 // or a dialog. 2808 2809 Q_Q(QWidget); 2810 if (!q->isWindow()) 2811 return; 2812 NSWindow *qwin = [qt_mac_nativeview_for(q) window]; 2813 if (!qwin) 2814 return; 2815 Qt::WindowType qtype = q->windowType(); 2816 if (set && !(qtype == Qt::Window || qtype == Qt::Dialog)) 2817 return; 2818 if (set && ![qwin isVisible]) 2819 return; 2820 2821 if (QWidget *parent = q->parentWidget()) { 2822 if (NSWindow *pwin = [qt_mac_nativeview_for(parent) window]) { 2823 if (set) { 2824 Qt::WindowType ptype = parent->window()->windowType(); 2825 if ([pwin isVisible] && (ptype == Qt::Window || ptype == Qt::Dialog) && ![qwin parentWindow]) { 2826 NSInteger level = [qwin level]; 2827 [pwin addChildWindow:qwin ordered:NSWindowAbove]; 2828 if ([qwin level] < level) 2829 [qwin setLevel:level]; 2830 } 2831 } else { 2832 [pwin removeChildWindow:qwin]; 2833 } 2834 } 2835 } 2836 2837 QObjectList widgets = q->children(); 2838 for (int i=0; i<widgets.size(); ++i) { 2839 QWidget *child = qobject_cast<QWidget *>(widgets.at(i)); 2840 if (child && child->isWindow()) { 2841 if (NSWindow *cwin = [qt_mac_nativeview_for(child) window]) { 2842 if (set) { 2843 Qt::WindowType ctype = child->window()->windowType(); 2844 if ([cwin isVisible] && (ctype == Qt::Window || ctype == Qt::Dialog) && ![cwin parentWindow]) { 2845 NSInteger level = [cwin level]; 2846 [qwin addChildWindow:cwin ordered:NSWindowAbove]; 2847 if ([cwin level] < level) 2848 [cwin setLevel:level]; 2849 } 2850 } else { 2851 [qwin removeChildWindow:qt_mac_window_for(child)]; 2852 } 2853 } 2854 } 2855 } 2856 } 2857 #endif 2858 2723 2859 void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) 2724 2860 { … … 2768 2904 if (wasWindow) { 2769 2905 oldToolbar = [oldWindow toolbar]; 2770 [oldToolbar retain]; 2771 oldToolbarVisible = [oldToolbar isVisible]; 2772 [oldWindow setToolbar:nil]; 2906 if (oldToolbar) { 2907 [oldToolbar retain]; 2908 oldToolbarVisible = [oldToolbar isVisible]; 2909 [oldWindow setToolbar:nil]; 2910 } 2773 2911 } 2774 2912 #endif … … 2781 2919 //recreate and setup flags 2782 2920 QObjectPrivate::setParent_helper(parent); 2783 QPoint pt = q->pos();2784 2921 bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); 2785 2922 if (wasCreated && !qt_isGenuineQWidget(q)) 2786 2923 return; 2787 2924 2788 if ( (data.window_flags & Qt::Sheet) && topData && topData->opacity == 242)2925 if (!q->testAttribute(Qt::WA_WState_WindowOpacitySet)) { 2789 2926 q->setWindowOpacity(1.0f); 2927 q->setAttribute(Qt::WA_WState_WindowOpacitySet, false); 2928 } 2790 2929 2791 2930 setWinId(0); //do after the above because they may want the id … … 2796 2935 q->setAttribute(Qt::WA_WState_Hidden, false); 2797 2936 adjustFlags(data.window_flags, q); 2798 // keep compatibility with previous versions, we need to preserve the created state 2799 // (but we recreate the winId for the widget being reparented, again for compatibility) 2800 if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created))) { 2937 // keep compatibility with previous versions, we need to preserve the created state. 2938 // (but we recreate the winId for the widget being reparented, again for compatibility, 2939 // unless this is an alien widget. ) 2940 const bool nonWindowWithCreatedParent = !q->isWindow() && parent->testAttribute(Qt::WA_WState_Created); 2941 const bool nativeWidget = q->internalWinId() != 0; 2942 if (wasCreated || nativeWidget && nonWindowWithCreatedParent) { 2801 2943 createWinId(); 2802 2944 if (q->isWindow()) { … … 2805 2947 // (only for performance, it gets called a lot anyway). 2806 2948 if (!wasCreated) { 2807 if (QMainWindowLayout *mwl = q object_cast<QMainWindowLayout *>(q->layout())) {2949 if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) { 2808 2950 mwl->updateHIToolBarStatus(); 2809 2951 } … … 2830 2972 // So redo the status one more time. It apparently is not an issue with Cocoa. 2831 2973 if (q->isWindow()) { 2832 if (QMainWindowLayout *mwl = q object_cast<QMainWindowLayout *>(q->layout())) {2974 if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) { 2833 2975 mwl->updateHIToolBarStatus(); 2834 2976 } … … 2875 3017 } 2876 3018 } 2877 2878 3019 invalidateBuffer(q->rect()); 2879 3020 qt_event_request_window_change(q); … … 2883 3024 { 2884 3025 Q_D(const QWidget); 2885 if (!testAttribute(Qt::WA_WState_Created) ) {3026 if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { 2886 3027 QPoint p = pos + data->crect.topLeft(); 2887 3028 return isWindow() ? p : parentWidget()->mapToGlobal(p); … … 2910 3051 { 2911 3052 Q_D(const QWidget); 2912 if (!testAttribute(Qt::WA_WState_Created) ) {3053 if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { 2913 3054 QPoint p = isWindow() ? pos : parentWidget()->mapFromGlobal(pos); 2914 3055 return p - data->crect.topLeft(); … … 3181 3322 #ifndef QT_MAC_USE_COCOA 3182 3323 ActivateWindow(win, true); 3324 qApp->setActiveWindow(tlw); 3183 3325 #else 3184 3326 [win makeKeyWindow]; 3185 3327 #endif 3186 qApp->setActiveWindow(tlw);3187 3328 } else if(!isMinimized()) { 3188 3329 #ifndef QT_MAC_USE_COCOA … … 3209 3350 HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); 3210 3351 #else 3211 [qt_mac_nativeview_for(q) setNeedsDisplay:YES];3352 qt_mac_set_needs_display(q, QRegion()); 3212 3353 #endif 3213 3354 return; … … 3247 3388 } 3248 3389 #else 3249 // Cocoa doesn't do regions, it seems more efficient to just update the bounding rect instead of a potential number of message passes for each rect. 3250 const QRect &boundingRect = rgn.boundingRect(); 3251 [qt_mac_nativeview_for(q) setNeedsDisplayInRect:NSMakeRect(boundingRect.x(), 3252 boundingRect.y(), boundingRect.width(), 3253 boundingRect.height())]; 3390 // Alien support: get the first native ancestor widget (will be q itself in the non-alien case), 3391 // map the coordinates from q space to NSView space and invalidate the rect. 3392 QWidget *nativeParent = q->internalWinId() ? q : q->nativeParentWidget(); 3393 if (nativeParent == 0) 3394 return; 3395 3396 QVector<QRect> rects = rgn.rects(); 3397 for (int i = 0; i < rects.count(); ++i) { 3398 const QRect &rect = rects.at(i); 3399 3400 const QRect nativeBoundingRect = QRect( 3401 QPoint(q->mapTo(nativeParent, rect.topLeft())), 3402 QSize(rect.size())); 3403 3404 [qt_mac_nativeview_for(nativeParent) setNeedsDisplayInRect:NSMakeRect(nativeBoundingRect.x(), 3405 nativeBoundingRect.y(), nativeBoundingRect.width(), 3406 nativeBoundingRect.height())]; 3407 } 3254 3408 #endif 3255 3409 } … … 3275 3429 3276 3430 bool realWindow = isRealWindow(); 3431 #ifndef QT_MAC_USE_COCOA 3277 3432 if (realWindow && !q->testAttribute(Qt::WA_Moved)) { 3433 if (qt_mac_is_macsheet(q)) 3434 recreateMacWindow(); 3278 3435 q->createWinId(); 3279 3436 if (QWidget *p = q->parentWidget()) { 3280 3437 p->createWinId(); 3281 #ifndef QT_MAC_USE_COCOA3282 3438 RepositionWindow(qt_mac_window_for(q), qt_mac_window_for(p), kWindowCenterOnParentWindow); 3283 #else3284 CGRect parentFrame = NSRectToCGRect([qt_mac_window_for(p) frame]);3285 OSWindowRef windowRef = qt_mac_window_for(q);3286 NSRect windowFrame = [windowRef frame];3287 NSPoint parentCenter = NSMakePoint(CGRectGetMidX(parentFrame), CGRectGetMidY(parentFrame));3288 [windowRef setFrameTopLeftPoint:NSMakePoint(parentCenter.x - (windowFrame.size.width / 2),3289 (parentCenter.y + (windowFrame.size.height / 2)))];3290 #endif3291 3439 } else { 3292 #ifndef QT_MAC_USE_COCOA3293 3440 RepositionWindow(qt_mac_window_for(q), 0, kWindowCenterOnMainScreen); 3294 #else 3295 // Ideally we would do a "center" here, but NSWindow's center is more equivalent to 3296 // kWindowAlertPositionOnMainScreen instead of kWindowCenterOnMainScreen. 3297 QRect availGeo = QApplication::desktop()->availableGeometry(q); 3298 // Center the content only. 3299 data.crect.moveCenter(availGeo.center()); 3300 QRect fStrut = frameStrut(); 3301 QRect frameRect(data.crect.x() - fStrut.left(), data.crect.y() - fStrut.top(), 3302 fStrut.left() + fStrut.right() + data.crect.width(), 3303 fStrut.top() + fStrut.bottom() + data.crect.height()); 3304 NSRect cocoaFrameRect = NSMakeRect(frameRect.x(), flipYCoordinate(frameRect.bottom() + 1), frameRect.width(), frameRect.height()); 3305 [qt_mac_window_for(q) setFrame:cocoaFrameRect display:NO]; 3306 #endif 3307 } 3308 } 3441 } 3442 } 3443 #endif 3444 3309 3445 data.fstrut_dirty = true; 3310 3446 if (realWindow) { … … 3337 3473 // sync the opacity value back (in case of a fade). 3338 3474 [window setAlphaValue:q->windowOpacity()]; 3339 [window makeKeyAndOrderFront:window]; 3340 3341 // If this window is app modal, we need to start spinning 3342 // a modal session for it. Interrupting 3343 // the event dispatcher will make this happend: 3344 if (data.window_modality == Qt::ApplicationModal) 3345 QEventDispatcherMac::instance()->interrupt(); 3475 3476 QWidget *top = 0; 3477 if (QApplicationPrivate::tryModalHelper(q, &top)) { 3478 [window makeKeyAndOrderFront:window]; 3479 // If this window is app modal, we need to start spinning 3480 // a modal session for it. Interrupting 3481 // the event dispatcher will make this happend: 3482 if (data.window_modality == Qt::ApplicationModal) 3483 QEventDispatcherMac::instance()->interrupt(); 3484 } else { 3485 // The window is modally shaddowed, so we need to make 3486 // sure that we don't pop in front of the modal window: 3487 [window orderFront:window]; 3488 if (!top->testAttribute(Qt::WA_DontShowOnScreen)) { 3489 if (NSWindow *modalWin = qt_mac_window_for(top)) 3490 [modalWin orderFront:window]; 3491 } 3492 } 3493 setSubWindowStacking(true); 3346 3494 #endif 3347 3495 if (q->windowType() == Qt::Popup) { … … 3362 3510 #ifndef QT_MAC_USE_COCOA 3363 3511 qt_event_request_activate(q); 3364 #else3365 [qt_mac_window_for(q) makeKeyWindow];3366 3512 #endif 3367 3513 } … … 3405 3551 QMacCocoaAutoReleasePool pool; 3406 3552 if(q->isWindow()) { 3553 #ifdef QT_MAC_USE_COCOA 3554 setSubWindowStacking(false); 3555 #endif 3407 3556 OSWindowRef window = qt_mac_window_for(q); 3408 3557 if(qt_mac_is_macsheet(q)) { … … 3470 3619 #endif 3471 3620 } 3472 if(q->isActiveWindow() && !(q->windowType() == Qt::Popup)) { 3621 #ifndef QT_MAC_USE_COCOA 3622 // If the window we now hide was the active window, we need 3623 // to find, and activate another window on screen. NB: Cocoa takes care of this 3624 // logic for us (and distinquishes between main windows and key windows) 3625 if (q->isActiveWindow() && !(q->windowType() == Qt::Popup)) { 3473 3626 QWidget *w = 0; 3474 3627 if(q->parentWidget()) 3475 3628 w = q->parentWidget()->window(); 3476 3629 if(!w || (!w->isVisible() && !w->isMinimized())) { 3477 #ifndef QT_MAC_USE_COCOA3478 3630 for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true); 3479 3631 wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) { … … 3495 3647 } 3496 3648 } 3497 #else3498 NSArray *windows = [NSApp windows];3499 NSUInteger totalWindows = [windows count];3500 for (NSUInteger i = 0; i < totalWindows; ++i) {3501 OSWindowRef wp = [windows objectAtIndex:i];3502 if ((w = qt_mac_find_window(wp)))3503 break;3504 }3505 #endif3506 3649 } 3507 3650 if(w && w->isVisible() && !w->isMinimized()) { 3508 #ifndef QT_MAC_USE_COCOA 3509 qt_event_request_activate(w); 3510 #else 3511 [qt_mac_window_for(w) makeKeyWindow]; 3512 #endif 3513 } 3514 } 3651 qt_event_request_activate(w); 3652 } 3653 } 3654 #endif 3515 3655 } else { 3516 3656 invalidateBuffer(q->rect()); … … 3734 3874 QMacCocoaAutoReleasePool pool; 3735 3875 if (isRealWindow()) { 3736 // Calling orderFront shows the window on Cocoa too. 3876 // With the introduction of spaces it is not as simple as just raising the window. 3877 // First we need to check if we are in the right space. If we are, then we just continue 3878 // as usual. The problem comes when we are not in the active space. There are two main cases: 3879 // 1. Our parent was moved to a new space. In this case we want the window to be raised 3880 // in the same space as its parent. 3881 // 2. We don't have a parent. For this case we will just raise the window and let Cocoa 3882 // switch to the corresponding space. 3883 // NOTICE: There are a lot of corner cases here. We are keeping this simple for now, if 3884 // required we will introduce special handling for some of them. 3737 3885 if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { 3738 [qt_mac_window_for(q) orderFront:qt_mac_window_for(q)]; 3886 OSWindowRef window = qt_mac_window_for(q); 3887 // isOnActiveSpace is available only from 10.6 onwards, so we need to check if it is 3888 // available before calling it. 3889 if([window respondsToSelector:@selector(isOnActiveSpace)]) { 3890 if(![window performSelector:@selector(isOnActiveSpace)]) { 3891 QWidget *parentWidget = q->parentWidget(); 3892 if(parentWidget) { 3893 OSWindowRef parentWindow = qt_mac_window_for(parentWidget); 3894 if(parentWindow && [parentWindow isOnActiveSpace]) { 3895 // The window was created in a different space. Therefore if we want 3896 // to show it in the current space we need to recreate it in the new 3897 // space. 3898 recreateMacWindow(); 3899 window = qt_mac_window_for(q); 3900 } 3901 } 3902 } 3903 } 3904 [window orderFront:window]; 3739 3905 } 3740 3906 if (qt_mac_raise_process) { //we get to be the active process now … … 3849 4015 flag 3850 4016 */ 3851 static void qt_mac_update_widget_posi siton(QWidget *q, QRect oldRect, QRect newRect)4017 static void qt_mac_update_widget_position(QWidget *q, QRect oldRect, QRect newRect) 3852 4018 { 3853 4019 #ifndef QT_MAC_USE_COCOA … … 3874 4040 3875 4041 // the position update is a part of a drag-and-drop operation 3876 QDragManager::self()->object || 3877 3878 // we are on Panther (no HIViewSetNeedsDisplayInRect) 3879 QSysInfo::MacintoshVersion < QSysInfo::MV_10_4 4042 QDragManager::self()->object || 4043 4044 // we are on Panther (no HIViewSetNeedsDisplayInRect) 4045 QSysInfo::MacintoshVersion < QSysInfo::MV_10_4 3880 4046 ){ 3881 4047 HIViewSetFrame(view, &bounds); … … 3946 4112 Q_UNUSED(oldRect); 3947 4113 NSRect bounds = NSMakeRect(newRect.x(), newRect.y(), 3948 4114 newRect.width(), newRect.height()); 3949 4115 [qt_mac_nativeview_for(q) setFrame:bounds]; 3950 4116 #endif … … 3983 4149 3984 4150 QRect parentWRect; 3985 if (q->isWindow() && topData()->embedded) { 4151 bool isEmbeddedWindow = (q->isWindow() && topData()->embedded); 4152 if (isEmbeddedWindow) { 3986 4153 #ifndef QT_MAC_USE_COCOA 3987 4154 HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q)); … … 4008 4175 if (parentWRect.isValid()) { 4009 4176 // parent is clipped, and we have to clip to the same limit as parent 4010 if (!parentWRect.contains(xrect) ) {4177 if (!parentWRect.contains(xrect) && !isEmbeddedWindow) { 4011 4178 xrect &= parentWRect; 4012 4179 wrect = xrect; … … 4110 4277 } 4111 4278 4112 qt_mac_update_widget_posi siton(q, oldRect, xrect);4279 qt_mac_update_widget_position(q, oldRect, xrect); 4113 4280 4114 4281 if (jump) … … 4182 4349 QMacCocoaAutoReleasePool pool; 4183 4350 bool realWindow = isRealWindow(); 4351 BOOL needDisplay = realWindow ? YES : NO; 4184 4352 4185 4353 if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){ … … 4196 4364 } 4197 4365 #else 4366 if (!isMove && !q->testAttribute(Qt::WA_Moved) && !q->isVisible()) { 4367 // INVARIANT: The location of the window has not yet been set. The default will 4368 // instead be to center it on the desktop, or over the parent, if any. Since we now 4369 // resize the window, we need to adjust the top left position to keep the window 4370 // centeralized. And we need to to this now (and before show) in case the positioning 4371 // of other windows (e.g. sub-windows) depend on this position: 4372 if (QWidget *p = q->parentWidget()) { 4373 x = p->geometry().center().x() - (w / 2); 4374 y = p->geometry().center().y() - (h / 2); 4375 } else { 4376 QRect availGeo = QApplication::desktop()->availableGeometry(q); 4377 x = availGeo.center().x() - (w / 2); 4378 y = availGeo.center().y() - (h / 2); 4379 } 4380 } 4381 4198 4382 QSize olds = q->size(); 4199 4383 const bool isResize = (olds != QSize(w, h)); … … 4213 4397 && cocoaFrameRect.size.width != 0 4214 4398 && cocoaFrameRect.size.height != 0) { 4215 [window setFrame:cocoaFrameRect display: NO];4399 [window setFrame:cocoaFrameRect display:needDisplay]; 4216 4400 } else { 4217 4401 // The window is moved and resized (or resized to zero). … … 4222 4406 // window back and forth inbetween. 4223 4407 cocoaFrameRect.origin.y += 1; 4224 [window setFrame:cocoaFrameRect display: NO];4408 [window setFrame:cocoaFrameRect display:needDisplay]; 4225 4409 cocoaFrameRect.origin.y -= 1; 4226 4410 [window setFrameOrigin:cocoaFrameRect.origin]; … … 4248 4432 4249 4433 const bool visible = q->isVisible(); 4434 // Apply size restrictions, applicable for Windows & Widgets. 4435 if (QWExtra *extra = extraData()) { 4436 w = qMin(w, extra->maxw); 4437 h = qMin(h, extra->maxh); 4438 w = qMax(w, extra->minw); 4439 h = qMax(h, extra->minh); 4440 } 4250 4441 data.crect = QRect(x, y, w, h); 4251 4442 … … 4612 4803 SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on); 4613 4804 #else 4614 NSView *view = qt_mac_nativeview_for(q); 4615 if (on && [view isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaView) class]]) { 4616 [static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(view) registerDragTypes]; 4805 NSWindow *win = qt_mac_window_for(q); 4806 if (on) { 4807 if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaWindow) class]]) 4808 [static_cast<QT_MANGLE_NAMESPACE(QCocoaWindow) *>(win) registerDragTypes]; 4809 else if ([win isKindOfClass:[QT_MANGLE_NAMESPACE(QCocoaPanel) class]]) 4810 [static_cast<QT_MANGLE_NAMESPACE(QCocoaPanel) *>(win) registerDragTypes]; 4617 4811 } 4618 4812 #endif … … 4730 4924 [window invalidateShadow]; 4731 4925 } 4732 [qt_mac_nativeview_for(q) setNeedsDisplay:YES];4926 qt_mac_set_needs_display(q, QRegion()); 4733 4927 } 4734 4928 #endif … … 4770 4964 4771 4965 if (windowParent && q->windowModality() == Qt::WindowModal){ 4772 // Window should be window-modal, which implies a sheet.4966 // INVARIANT: Window should be window-modal (which implies a sheet). 4773 4967 if (!alreadySheet) { 4774 4968 // NB: the following call will call setModal_sys recursivly: … … 4787 4981 } 4788 4982 } else { 4789 // Window shold not be window-modal, and as such, not a sheet.4983 // INVARIANT: Window shold _not_ be window-modal (and as such, not a sheet). 4790 4984 if (alreadySheet){ 4791 4985 // NB: the following call will call setModal_sys recursivly: … … 4793 4987 windowRef = qt_mac_window_for(q); 4794 4988 } 4795 if (q->windowModality() == Qt::ApplicationModal) { 4796 [windowRef setLevel:NSModalPanelWindowLevel]; 4797 } else if (primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { 4798 // INVARIANT: Our window is a dialog that has a dialog parent that is 4799 // application modal, or . This means that q is supposed to be on top of this 4800 // dialog and not be modally shaddowed: 4801 [windowRef setLevel:NSModalPanelWindowLevel]; 4989 if (q->windowModality() == Qt::NonModal 4990 && primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) { 4991 // INVARIANT: Our window has a parent that is application modal. 4992 // This means that q is supposed to be on top of this window and 4993 // not be modally shaddowed: 4802 4994 if ([windowRef isKindOfClass:[NSPanel class]]) 4803 4995 [static_cast<NSPanel *>(windowRef) setWorksWhenModal:YES]; 4804 } else {4805 // INVARIANT: q should not be modal.4806 NSInteger winLevel = -1;4807 if (q->windowType() == Qt::Popup) {4808 winLevel = NSPopUpMenuWindowLevel;4809 // Popup should be in at least the same level as its parent.4810 if (primaryWindow) {4811 OSWindowRef parentRef = qt_mac_window_for(primaryWindow);4812 winLevel = qMax([parentRef level], winLevel);4813 }4814 } else if (q->windowType() == Qt::Tool) {4815 winLevel = NSFloatingWindowLevel;4816 } else if (q->windowType() == Qt::Dialog) {4817 winLevel = NSModalPanelWindowLevel;4818 }4819 4820 // StayOnTop window should appear above Tool windows.4821 if (data.window_flags & Qt::WindowStaysOnTopHint)4822 winLevel = NSPopUpMenuWindowLevel;4823 // Tooltips should appear above StayOnTop windows.4824 if (q->windowType() == Qt::ToolTip)4825 winLevel = NSScreenSaverWindowLevel;4826 // All other types are Normal level.4827 if (winLevel == -1)4828 winLevel = NSNormalWindowLevel;4829 [windowRef setLevel:winLevel];4830 4996 } 4831 4997 } … … 5007 5173 recreateMacWindow(); 5008 5174 #else 5009 QMainWindowLayout *layout = q object_cast<QMainWindowLayout *>(q->layout());5175 QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q)); 5010 5176 if (q->testAttribute(Qt::WA_MacBrushedMetal)) { 5011 5177 if (layout) -
trunk/src/gui/kernel/qwidget_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 115 115 class QStyle; 116 116 117 class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker 118 { 119 120 public: 121 QWidgetBackingStoreTracker(); 122 ~QWidgetBackingStoreTracker(); 123 124 void create(QWidget *tlw); 125 void destroy(); 126 127 void registerWidget(QWidget *w); 128 void unregisterWidget(QWidget *w); 129 void unregisterWidgetSubtree(QWidget *w); 130 131 inline QWidgetBackingStore* data() 132 { 133 return m_ptr; 134 } 135 136 inline QWidgetBackingStore* operator->() 137 { 138 return m_ptr; 139 } 140 141 inline QWidgetBackingStore& operator*() 142 { 143 return *m_ptr; 144 } 145 146 inline operator bool() const 147 { 148 return (0 != m_ptr); 149 } 150 151 private: 152 Q_DISABLE_COPY(QWidgetBackingStoreTracker) 153 154 private: 155 QWidgetBackingStore* m_ptr; 156 QSet<QWidget *> m_widgets; 157 }; 158 117 159 struct QTLWExtra { 118 160 // *************************** Cross-platform variables ***************************** … … 121 163 QIcon *icon; // widget icon 122 164 QPixmap *iconPixmap; 123 QWidgetBackingStore *backingStore;165 QWidgetBackingStoreTracker backingStore; 124 166 QWindowSurface *windowSurface; 125 167 QPainter *sharedPainter; … … 163 205 #endif 164 206 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN 207 uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered. 165 208 HICON winIconBig; // internal big Windows icon 166 209 HICON winIconSmall; // internal small Windows icon … … 174 217 IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys. 175 218 quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys() 219 #ifdef QT_MAC_USE_COCOA 220 // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and 221 // manually resized. 222 // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the 223 // starting position as 0,0 instead of the normal starting position. 224 bool wasMaximized; 225 #endif // QT_MAC_USE_COCOA 226 176 227 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS 177 228 #ifndef QT_NO_QWS_MANAGER … … 180 231 #elif defined(Q_OS_SYMBIAN) 181 232 uint inExpose : 1; // Prevents drawing recursion 233 uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency 182 234 #elif defined(Q_WS_PM) 183 235 HWND fId; … … 396 448 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, 397 449 QWidget::RenderFlags renderFlags); 450 void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, 451 QWidget::RenderFlags renderFlags, bool readyToRender); 398 452 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, 399 453 QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0); … … 502 556 bool setMaximumSize_helper(int &maxw, int &maxh); 503 557 void setConstraints_sys(); 558 bool pointInsideRectAndMask(const QPoint &) const; 504 559 QWidget *childAt_helper(const QPoint &, bool) const; 560 QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const; 505 561 void updateGeometry_helper(bool forceUpdate); 506 562 … … 508 564 void setLayoutItemMargins(int left, int top, int right, int bottom); 509 565 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0); 566 567 // aboutToDestroy() is called just before the contents of 568 // QWidget::destroy() is executed. It's used to signal QWidget 569 // sub-classes that their internals are about to be released. 570 virtual void aboutToDestroy() {} 510 571 511 572 QInputContext *inputContext() const; … … 685 746 QList<QAction*> actions; 686 747 #endif 748 #ifndef QT_NO_GESTURES 687 749 QMap<Qt::GestureType, Qt::GestureFlags> gestureContext; 750 #endif 688 751 689 752 // Bit fields. 690 uint high_attributes[ 3]; // the low ones are in QWidget::widget_attributes753 uint high_attributes[4]; // the low ones are in QWidget::widget_attributes 691 754 QPalette::ColorRole fg_role : 8; 692 755 QPalette::ColorRole bg_role : 8; … … 698 761 uint isGLWidget : 1; 699 762 uint usesDoubleBufferedGLContext : 1; 763 #ifndef QT_NO_IM 764 uint inheritsInputMethodHints : 1; 765 #endif 700 766 701 767 // *************************** Platform specific ************************************ … … 711 777 void x11UpdateIsOpaque(); 712 778 bool isBackgroundInherited() const; 779 void updateX11AcceptFocus(); 713 780 #elif defined(Q_WS_PM) // <----------------------------------------------------------- PM 714 781 uint noPaintOnScreen : 1; // see qwidget_pm.cpp ::paintEngine() … … 722 789 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN 723 790 uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine() 791 #ifndef QT_NO_GESTURES 724 792 uint nativeGesturePanEnabled : 1; 725 793 #endif 726 794 bool shouldShowMaximizeButton(); 727 795 void winUpdateIsOpaque(); … … 737 805 // This is new stuff 738 806 uint needWindowChange : 1; 807 uint hasAlienChildren : 1; 739 808 740 809 // Each wiget keeps a list of all its child and grandchild OpenGL widgets. … … 783 852 void finishCreateWindow_sys_Carbon(OSWindowRef windowRef); 784 853 #else 854 void setSubWindowStacking(bool set); 855 void setWindowLevel(); 785 856 void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef); 786 857 void syncCocoaMask(); 787 858 void finishCocoaMaskSetup(); 859 void syncUnifiedMode(); 860 // Did we add the drawRectOriginal method? 861 bool drawRectOriginalAdded; 862 // Is the original drawRect method available? 863 bool originalDrawMethod; 864 // Do we need to change the methods? 865 bool changeMethods; 788 866 #endif 789 867 void determineWindowClass(); … … 923 1001 } 924 1002 1003 inline bool QWidgetPrivate::pointInsideRectAndMask(const QPoint &p) const 1004 { 1005 Q_Q(const QWidget); 1006 return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask) 1007 || extra->mask.contains(p)); 1008 } 1009 925 1010 inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const 926 1011 { 927 1012 Q_Q(const QWidget); 928 1013 QTLWExtra *x = q->window()->d_func()->maybeTopData(); 929 return x ? x->backingStore : 0;1014 return x ? x->backingStore.data() : 0; 930 1015 } 931 1016 -
trunk/src/gui/kernel/qwidget_qws.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 257 257 { 258 258 Q_D(QWidget); 259 259 d->aboutToDestroy(); 260 260 if (!isWindow() && parentWidget()) 261 261 parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); … … 1018 1018 const QScreen *screen = d->getScreen(); 1019 1019 return qRound(screen->height() / double(screen->physicalHeight() / 25.4)); 1020 } else if (m == PdmNumColors) { 1021 QScreen *screen = d->getScreen(); 1022 int ret = screen->colorCount(); 1023 if (!ret) { 1024 const int depth = qwsDisplay()->depth(); 1025 switch (depth) { 1026 case 1: 1027 ret = 2; 1028 break; 1029 case 8: 1030 ret = 256; 1031 break; 1032 case 16: 1033 ret = 65536; 1034 break; 1035 case 24: 1036 ret = 16777216; 1037 break; 1038 case 32: 1039 ret = 2147483647; 1040 break; 1041 } 1042 } 1043 return ret; 1020 1044 } else { 1021 1045 val = QPaintDevice::metric(m);// XXX -
trunk/src/gui/kernel/qwidget_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 55 55 #ifdef Q_WS_S60 56 56 #include <aknappui.h> 57 #include <eikbtgpc.h> 57 58 #endif 58 59 59 // This is necessary in order to be able to perform delayed invo kation on slots60 // This is necessary in order to be able to perform delayed invocation on slots 60 61 // which take arguments of type WId. One example is 61 62 // QWidgetPrivate::_q_delayedDestroy, which is used to delay destruction of … … 63 64 Q_DECLARE_METATYPE(WId) 64 65 66 // Workaround for the fact that S60 SDKs 3.x do not contain the akntoolbar.h 67 // header, even though the documentation says that it should be there, and indeed 68 // it is present in the library. 69 class CAknToolbar : public CAknControl, 70 public MCoeControlObserver, 71 public MCoeControlBackground, 72 public MEikCommandObserver, 73 public MAknFadedComponent 74 { 75 public: 76 IMPORT_C void SetToolbarVisibility(const TBool visible); 77 }; 78 65 79 QT_BEGIN_NAMESPACE 66 80 … … 69 83 QWidget *QWidgetPrivate::mouseGrabber = 0; 70 84 QWidget *QWidgetPrivate::keyboardGrabber = 0; 85 CEikButtonGroupContainer *QS60Data::cba = 0; 71 86 72 87 static bool isEqual(const QList<QAction*>& a, const QList<QAction*>& b) … … 366 381 // Symbian windows are always created in an inactive state 367 382 // We perform this assignment for the case where the window is being re-created 368 // as a aresult of a call to setParent_sys, on either this widget or one of its383 // as a result of a call to setParent_sys, on either this widget or one of its 369 384 // ancestors. 370 385 extra->activated = 0; … … 410 425 // Symbian windows are always created in an inactive state 411 426 // We perform this assignment for the case where the window is being re-created 412 // as a aresult of a call to setParent_sys, on either this widget or one of its427 // as a result of a call to setParent_sys, on either this widget or one of its 413 428 // ancestors. 414 429 extra->activated = 0; … … 434 449 drawableWindow->PointerFilter(EPointerFilterEnterExit 435 450 | EPointerFilterMove | EPointerFilterDrag, 0); 451 drawableWindow->EnableVisibilityChangeEvents(); 436 452 437 453 if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) { … … 481 497 482 498 QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); 499 const bool isFullscreen = q->windowState() & Qt::WindowFullScreen; 500 const TBool cbaRequested = q->windowFlags() & Qt::WindowSoftkeysVisibleHint; 483 501 484 502 #ifdef Q_WS_S60 485 503 // Lazily initialize the S60 screen furniture when the first window is shown. 486 if ( !QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)504 if (q->isWindow() && !QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) 487 505 && !S60->buttonGroupContainer() && !S60->statusPane()) { 488 489 bool isFullscreen = q->windowState() & Qt::WindowFullScreen;490 506 491 507 if (!q->testAttribute(Qt::WA_DontShowOnScreen)) { … … 494 510 CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi()); 495 511 MEikAppUiFactory *factory = CEikonEnv::Static()->AppUiFactory(); 496 TRAP_IGNORE(factory->ReadAppInfoResourceL(0, ui)); 497 if (S60->buttonGroupContainer()) 498 S60->buttonGroupContainer()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); 512 513 QT_TRAP_THROWING( 514 factory->CreateResourceIndependentFurnitureL(ui); 515 516 TRect boundingRect = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); 517 518 CEikButtonGroupContainer *cba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, 519 CEikButtonGroupContainer::EHorizontal,ui,R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); 520 if (isFullscreen && !cbaRequested) 521 cba->MakeVisible(false); 522 523 CEikButtonGroupContainer *oldCba = factory->SwapButtonGroup(cba); 524 Q_ASSERT(!oldCba); 525 S60->setButtonGroupContainer(cba); 526 527 // If the creation of the first widget is delayed, for example by doing it 528 // inside the event loop, S60 somehow "forgets" to set the visibility of the 529 // toolbar (the three middle softkeys) when you flip the phone over, so we 530 // need to do it ourselves to avoid a "hole" in the application, even though 531 // Qt itself does not use the toolbar directly.. 532 CAknAppUi *appui = dynamic_cast<CAknAppUi *>(CEikonEnv::Static()->AppUi()); 533 if (appui) { 534 CAknToolbar *toolbar = appui->PopupToolbar(); 535 if (toolbar && !toolbar->IsVisible()) 536 toolbar->SetToolbarVisibility(ETrue); 537 } 538 539 CEikMenuBar *menuBar = new(ELeave) CEikMenuBar; 540 menuBar->ConstructL(ui, 0, R_AVKON_MENUPANE_EMPTY); 541 menuBar->SetMenuType(CEikMenuBar::EMenuOptions); 542 S60->appUi()->AddToStackL(menuBar,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus); 543 544 CEikMenuBar *oldMenu = factory->SwapMenuBar(menuBar); 545 Q_ASSERT(!oldMenu); 546 ) 499 547 500 548 if (S60->statusPane()) { … … 503 551 QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId()); 504 552 S60->statusPane()->SetObserver(desktopControl); 505 506 // Hide the status pane if fullscreen OR507 // Fill client area if maximized OR508 // Put window below status pane unless the window has an explicit position.509 553 if (isFullscreen) { 510 S60->statusPane()->MakeVisible(false); 511 } else if (q->windowState() & Qt::WindowMaximized) { 512 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); 513 id->SetExtent(r.iTl, r.Size()); 514 } else if (!q->testAttribute(Qt::WA_Moved)) { 515 id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl); 554 const bool cbaVisible = S60->buttonGroupContainer() && S60->buttonGroupContainer()->IsVisible(); 555 S60->setStatusPaneAndButtonGroupVisibility(false, cbaVisible); 516 556 } 517 557 } … … 520 560 #endif 521 561 562 // Fill client area if maximized OR 563 // Put window below status pane unless the window has an explicit position. 564 if (!isFullscreen) { 565 if (q->windowState() & Qt::WindowMaximized) { 566 TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); 567 id->SetExtent(r.iTl, r.Size()); 568 } else if (!q->testAttribute(Qt::WA_Moved) && q->windowType() != Qt::Dialog) { 569 id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl); 570 } 571 } 572 522 573 id->MakeVisible(true); 523 574 524 if(q->isWindow() )575 if(q->isWindow()&&!q->testAttribute(Qt::WA_ShowWithoutActivating)) 525 576 id->setFocusSafely(true); 526 577 } … … 555 606 556 607 if (id) { 557 //Incorrect optimi sation - for popup windows, Qt's focus is moved before608 //Incorrect optimization - for popup windows, Qt's focus is moved before 558 609 //hide_sys is called, resulting in the popup window keeping its elevated 559 610 //position in the CONE control stack. … … 683 734 if ((q->windowType() == Qt::Desktop)) 684 735 old_winid = 0; 736 737 // old_winid may not have received a 'not visible' visibility 738 // changed event before being destroyed; make sure that it is 739 // removed from the backing store's list of visible windows. 740 if (old_winid) 741 S60->controlVisibilityChanged(old_winid, false); 742 685 743 setWinId(0); 686 744 … … 738 796 return; 739 797 740 if ((data.window_flags & Qt::FramelessWindowHint) == 0) 741 return; 798 createTLExtra(); 742 799 743 800 RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); … … 745 802 #ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE 746 803 window->SetSurfaceTransparency(!isOpaque); 804 extra->topextra->nativeWindowTransparencyEnabled = !isOpaque; 747 805 #else 748 806 if (!isOpaque) { 749 807 const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA)); 750 if (window->SetTransparencyAlphaChannel() == KErrNone) 808 if (window->SetTransparencyAlphaChannel() == KErrNone) { 751 809 window->SetBackgroundColor(TRgb(255, 255, 255, 0)); 752 } else 810 extra->topextra->nativeWindowTransparencyEnabled = 1; 811 812 if (extra->topextra->backingStore.data() && 813 QApplicationPrivate::graphics_system_name == QLatin1String("openvg")) { 814 // Semi-transparent EGL surfaces aren't supported. We need to 815 // recreate backing store to get translucent surface (raster surface). 816 extra->topextra->backingStore.create(q); 817 extra->topextra->backingStore.registerWidget(q); 818 } 819 } 820 } else if (extra->topextra->nativeWindowTransparencyEnabled) { 753 821 window->SetTransparentRegion(TRegionFix<1>()); 822 extra->topextra->nativeWindowTransparencyEnabled = 0; 823 } 754 824 #endif 755 825 } … … 909 979 void QWidgetPrivate::createTLSysExtra() 910 980 { 911 extra->topextra->backingStore = 0;912 981 extra->topextra->inExpose = 0; 982 extra->topextra->nativeWindowTransparencyEnabled = 0; 913 983 } 914 984 915 985 void QWidgetPrivate::deleteTLSysExtra() 916 986 { 917 delete extra->topextra->backingStore; 918 extra->topextra->backingStore = 0; 987 extra->topextra->backingStore.destroy(); 919 988 } 920 989 … … 952 1021 if (q->testAttribute(Qt::WA_WState_Created) && q->windowType() != Qt::Desktop) { 953 1022 RWindow *rwindow = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); 954 rwindow->EnableAdvancedPointers(); 1023 QSymbianControl *window = static_cast<QSymbianControl *>(q->effectiveWinId()); 1024 //Enabling advanced pointer events for controls that already have active windows causes a panic. 1025 if (!window->isControlActive()) 1026 rwindow->EnableAdvancedPointers(); 955 1027 } 956 1028 #endif … … 1087 1159 1088 1160 const TBool isFullscreen = newstate & Qt::WindowFullScreen; 1161 #ifdef Q_WS_S60 1089 1162 const TBool cbaRequested = windowFlags() & Qt::WindowSoftkeysVisibleHint; 1090 1163 const TBool cbaVisible = CEikButtonGroupContainer::Current() ? true : false; … … 1093 1166 if (oldstate == newstate && !softkeyVisibilityChange) 1094 1167 return; 1168 #endif // Q_WS_S60 1095 1169 1096 1170 if (isWindow()) { … … 1111 1185 1112 1186 #ifdef Q_WS_S60 1113 // Hide window decoration when switching to fullsccreen / minimized otherwise show decoration. 1114 // The window decoration visibility has to be changed before doing actual window state 1115 // change since in that order the availableGeometry will return directly the right size and 1116 // we will avoid unnecessarty redraws 1117 CEikStatusPane *statusPane = S60->statusPane(); 1118 CEikButtonGroupContainer *buttonGroup = S60->buttonGroupContainer(); 1119 TBool visible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); 1120 if (statusPane) 1121 statusPane->MakeVisible(visible); 1122 if (buttonGroup) { 1123 // Visibility 1124 buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested)); 1187 bool decorationsVisible(false); 1188 if (!parentWidget()) { // Only top level native windows have control over cba/status pane 1189 // Hide window decoration when switching to fullscreen / minimized otherwise show decoration. 1190 // The window decoration visibility has to be changed before doing actual window state 1191 // change since in that order the availableGeometry will return directly the right size and 1192 // we will avoid unnecessary redraws 1193 decorationsVisible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); 1194 const bool statusPaneVisibility = decorationsVisible; 1195 const bool buttonGroupVisibility = (decorationsVisible || (isFullscreen && cbaRequested)); 1196 S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); 1125 1197 } 1126 1198 #endif // Q_WS_S60 … … 1135 1207 const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; 1136 1208 if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) { 1209 setAttribute(Qt::WA_OutsideWSRange, false); 1137 1210 window->SetExtentToWholeScreen(); 1138 1211 } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) { 1212 setAttribute(Qt::WA_OutsideWSRange, false); 1139 1213 TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this)); 1140 1214 window->SetExtent(maxExtent.iTl, maxExtent.Size()); … … 1145 1219 // normal mode after showing the status pane, the geometry would overlap so we should 1146 1220 // move it if it never had an explicit position. 1147 if (!wasMoved && statusPane && visible) {1221 if (!wasMoved && S60->statusPane() && decorationsVisible) { 1148 1222 TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl; 1149 1223 normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY)); … … 1179 1253 { 1180 1254 Q_D(QWidget); 1255 d->aboutToDestroy(); 1181 1256 if (!isWindow() && parentWidget()) 1182 1257 parentWidget()->d_func()->invalidateBuffer(geometry()); … … 1226 1301 // so we flush the command buffer to ensure that the freeing of 1227 1302 // those resources and deleting the window can happen "atomically" 1228 S60->wsSession().Flush(); 1303 if (qApp) 1304 S60->wsSession().Flush(); 1229 1305 } 1230 1306 } -
trunk/src/gui/kernel/qwidget_win.cpp
r807 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 48 48 #include "qimage.h" 49 49 #include "qlayout.h" 50 #include "qlibrary.h"51 50 #include "qpainter.h" 52 51 #include "qstack.h" … … 66 65 #include <private/qwininputcontext_p.h> 67 66 #include <private/qpaintengine_raster_p.h> 67 #include <private/qsystemlibrary_p.h> 68 68 69 69 #if defined(Q_WS_WINCE) … … 71 71 QT_USE_NAMESPACE 72 72 extern void qt_wince_maximize(QWidget *widget); //defined in qguifunctions_wince.cpp 73 extern void qt_wince_unmaximize(QWidget *widget); //defined in qguifunctions_wince.cpp 73 74 extern void qt_wince_minimize(HWND hwnd); //defined in qguifunctions_wince.cpp 74 75 extern void qt_wince_full_screen(HWND hwnd, bool fullScreen, UINT swpf); //defined in qguifunctions_wince.cpp … … 124 125 static PtrWTQueueSizeGet ptrWTQueueSizeGet = 0; 125 126 static PtrWTQueueSizeSet ptrWTQueueSizeSet = 0; 127 #ifndef QT_NO_TABLETEVENT 126 128 static void init_wintab_functions(); 127 129 static void qt_tablet_init(); 128 130 static void qt_tablet_cleanup(); 131 #endif // QT_NO_TABLETEVENT 129 132 extern HCTX qt_tablet_context; 130 133 extern bool qt_tablet_tilt_support; … … 137 140 138 141 extern bool qt_is_gui_used; 142 143 #ifndef QT_NO_TABLETEVENT 139 144 static void init_wintab_functions() 140 145 { … … 144 149 if (!qt_is_gui_used) 145 150 return; 146 Q Library library(QLatin1String("wintab32"));151 QSystemLibrary library(QLatin1String("wintab32")); 147 152 ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW"); 148 153 ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); … … 162 167 qt_tablet_widget->createWinId(); 163 168 qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget")); 164 // We don t need this internal widget to appear in QApplication::topLevelWidgets()169 // We don't need this internal widget to appear in QApplication::topLevelWidgets() 165 170 if (QWidgetPrivate::allWidgets) 166 171 QWidgetPrivate::allWidgets->remove(qt_tablet_widget); … … 228 233 qt_tablet_widget = 0; 229 234 } 235 #endif // QT_NO_TABLETEVENT 230 236 231 237 const QString qt_reg_winclass(QWidget *w); // defined in qapplication_win.cpp … … 244 250 static HHOOK journalRec = 0; 245 251 246 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);252 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); 247 253 248 254 #define XCOORD_MAX 16383 … … 513 519 } 514 520 521 #ifndef QT_NO_TABLETEVENT 515 522 if (q != qt_tablet_widget && QWidgetPrivate::mapper) 516 523 qt_tablet_init(); 524 #endif // QT_NO_TABLETEVENT 517 525 518 526 if (q->testAttribute(Qt::WA_DropSiteRegistered)) … … 538 546 { 539 547 Q_D(QWidget); 548 d->aboutToDestroy(); 540 549 if (!isWindow() && parentWidget()) 541 550 parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); … … 826 835 // The procedure does nothing, but is required for mousegrabbing to work 827 836 #ifndef Q_WS_WINCE 828 LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam)837 LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) 829 838 { 830 839 return CallNextHookEx(journalRec, nCode, wParam, lParam); … … 1093 1102 invalidateBuffer(q->rect()); 1094 1103 return; 1104 } 1105 1106 if (data.window_flags & Qt::Window) { 1107 QTLWExtra *extra = topData(); 1108 if (!extra->hotkeyRegistered) { 1109 // Try to set the hotkey using information from STARTUPINFO 1110 STARTUPINFO startupInfo; 1111 GetStartupInfo(&startupInfo); 1112 // If STARTF_USEHOTKEY is set, hStdInput is the virtual keycode 1113 if (startupInfo.dwFlags & 0x00000200) { 1114 WPARAM hotKey = (WPARAM)startupInfo.hStdInput; 1115 SendMessage(data.winid, WM_SETHOTKEY, hotKey, 0); 1116 } 1117 extra->hotkeyRegistered = 1; 1118 } 1095 1119 } 1096 1120 … … 1142 1166 if (IsZoomed(q->internalWinId())) 1143 1167 data.window_state |= Qt::WindowMaximized; 1168 // This is to resolve the problem where popups are opened from the 1169 // system tray and not being implicitly activated 1170 if (q->windowType() == Qt::Popup && 1171 !q->parentWidget() && !qApp->activeWindow()) 1172 q->activateWindow(); 1144 1173 } 1145 1174 … … 1519 1548 if (data.window_flags & Qt::MSWindowsFixedSizeDialogHint) 1520 1549 return false; 1521 // if the user explicit ely asked for the maximize button, we try to add1550 // if the user explicitly asked for the maximize button, we try to add 1522 1551 // it even if the window has fixed size. 1523 1552 if (data.window_flags & Qt::CustomizeWindowHint && … … 1688 1717 void QWidgetPrivate::createTLSysExtra() 1689 1718 { 1719 extra->topextra->hotkeyRegistered = 0; 1690 1720 extra->topextra->savedFlags = 0; 1691 1721 extra->topextra->winIconBig = 0; … … 1861 1891 if (!function_resolved) { 1862 1892 ptrSetLayeredWindowAttributes = 1863 (PtrSetLayeredWindowAttributes) Q Library::resolve(QLatin1String("user32"),1893 (PtrSetLayeredWindowAttributes) QSystemLibrary::resolve(QLatin1String("user32"), 1864 1894 "SetLayeredWindowAttributes"); 1865 1895 function_resolved = true; … … 2048 2078 void QWidgetPrivate::winSetupGestures() 2049 2079 { 2050 #if !defined(QT_NO_ NATIVE_GESTURES)2080 #if !defined(QT_NO_GESTURES) && !defined(QT_NO_NATIVE_GESTURES) 2051 2081 Q_Q(QWidget); 2052 2082 if (!q || !q->isVisible() || !nativeGesturePanEnabled) -
trunk/src/gui/kernel/qwidget_wince.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 48 48 const QString qt_reg_winclass(QWidget *w); // defined in qapplication_win.cpp 49 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);49 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM); 50 50 51 51 //#define TABLET_DEBUG … … 64 64 typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int); 65 65 66 #ifndef QT_NO_TABLETEVENT 66 67 static void qt_tablet_init_wce(); 67 68 static void qt_tablet_cleanup_wce(); … … 136 137 qt_tablet_widget = 0; 137 138 } 139 #endif // QT_NO_TABLETEVENT 138 140 139 141 … … 359 361 } 360 362 363 #ifndef QT_NO_TABLETEVENT 361 364 if (q != qt_tablet_widget && QWidgetPrivate::mapper) 362 365 qt_tablet_init_wce(); 366 #endif // QT_NO_TABLETEVENT 363 367 364 368 if (q->testAttribute(Qt::WA_DropSiteRegistered)) … … 495 499 SetWindowLong(internalWinId(), GWL_STYLE, style); 496 500 SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG); 501 qt_wince_unmaximize(this); 497 502 } 498 503 if (isVisible() && newstate & Qt::WindowMaximized) … … 587 592 588 593 // The procedure does nothing, but is required for mousegrabbing to work 589 LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) {594 LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) { 590 595 Q_UNUSED(nCode); 591 596 Q_UNUSED(wParam); -
trunk/src/gui/kernel/qwidget_x11.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 50 50 #include "qlayout.h" 51 51 #include "qtextcodec.h" 52 #include "q datetime.h"52 #include "qelapsedtimer.h" 53 53 #include "qcursor.h" 54 54 #include "qstack.h" … … 353 353 QApplication::flush(); 354 354 XEvent ev; 355 Q Timet;355 QElapsedTimer t; 356 356 t.start(); 357 357 static const int maximumWaitTime = 2000; … … 781 781 memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy 782 782 wm_hints.flags = InputHint | StateHint | WindowGroupHint; 783 wm_hints.input = True;783 wm_hints.input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True; 784 784 wm_hints.initial_state = NormalState; 785 785 wm_hints.window_group = X11->wm_client_leader; … … 890 890 891 891 } 892 } else if (q-> testAttribute(Qt::WA_SetCursor) && q->internalWinId()) {892 } else if (q->internalWinId()) { 893 893 qt_x11_enforce_cursor(q); 894 if (QWidget *p = q->parentWidget()) // reset the cursor on the native parent 895 qt_x11_enforce_cursor(p); 894 896 } 895 897 … … 1024 1026 { 1025 1027 Q_D(QWidget); 1028 d->aboutToDestroy(); 1026 1029 if (!isWindow() && parentWidget()) 1027 1030 parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); … … 1167 1170 // keep compatibility with previous versions, we need to preserve the created state 1168 1171 // (but we recreate the winId for the widget being reparented, again for compatibility) 1169 if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created)))1172 if (wasCreated) 1170 1173 createWinId(); 1171 1174 if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden) … … 1642 1645 X11->userTime = X11->time; 1643 1646 qt_net_update_user_time(tlw, X11->userTime); 1644 XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); 1647 1648 if (X11->isSupportedByWM(ATOM(_NET_ACTIVE_WINDOW)) 1649 && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)) { 1650 XEvent e; 1651 e.xclient.type = ClientMessage; 1652 e.xclient.message_type = ATOM(_NET_ACTIVE_WINDOW); 1653 e.xclient.display = X11->display; 1654 e.xclient.window = tlw->internalWinId(); 1655 e.xclient.format = 32; 1656 e.xclient.data.l[0] = 1; // 1 == application 1657 e.xclient.data.l[1] = X11->userTime; 1658 if (QWidget *aw = QApplication::activeWindow()) 1659 e.xclient.data.l[2] = aw->internalWinId(); 1660 else 1661 e.xclient.data.l[2] = XNone; 1662 e.xclient.data.l[3] = 0; 1663 e.xclient.data.l[4] = 0; 1664 XSendEvent(X11->display, RootWindow(X11->display, tlw->x11Info().screen()), 1665 false, SubstructureNotifyMask | SubstructureRedirectMask, &e); 1666 } else { 1667 if (!qt_widget_private(tlw)->topData()->waitingForMapNotify) 1668 XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time); 1669 } 1645 1670 } 1646 1671 } … … 1909 1934 if (flags & Qt::WindowStaysOnBottomHint) 1910 1935 qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time"; 1911 netWmState.append(ATOM(_NET_WM_STATE_ABOVE)); 1912 netWmState.append(ATOM(_NET_WM_STATE_STAYS_ON_TOP)); 1936 if (!netWmState.contains(ATOM(_NET_WM_STATE_ABOVE))) 1937 netWmState.append(ATOM(_NET_WM_STATE_ABOVE)); 1938 if (!netWmState.contains(ATOM(_NET_WM_STATE_STAYS_ON_TOP))) 1939 netWmState.append(ATOM(_NET_WM_STATE_STAYS_ON_TOP)); 1913 1940 } else if (flags & Qt::WindowStaysOnBottomHint) { 1914 netWmState.append(ATOM(_NET_WM_STATE_BELOW)); 1941 if (!netWmState.contains(ATOM(_NET_WM_STATE_BELOW))) 1942 netWmState.append(ATOM(_NET_WM_STATE_BELOW)); 1915 1943 } 1916 1944 if (q->isFullScreen()) { 1917 netWmState.append(ATOM(_NET_WM_STATE_FULLSCREEN)); 1945 if (!netWmState.contains(ATOM(_NET_WM_STATE_FULLSCREEN))) 1946 netWmState.append(ATOM(_NET_WM_STATE_FULLSCREEN)); 1918 1947 } 1919 1948 if (q->isMaximized()) { 1920 netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ)); 1921 netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_VERT)); 1949 if (!netWmState.contains(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ))) 1950 netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_HORZ)); 1951 if (!netWmState.contains(ATOM(_NET_WM_STATE_MAXIMIZED_VERT))) 1952 netWmState.append(ATOM(_NET_WM_STATE_MAXIMIZED_VERT)); 1922 1953 } 1923 1954 if (data.window_modality != Qt::NonModal) { 1924 netWmState.append(ATOM(_NET_WM_STATE_MODAL)); 1955 if (!netWmState.contains(ATOM(_NET_WM_STATE_MODAL))) 1956 netWmState.append(ATOM(_NET_WM_STATE_MODAL)); 1925 1957 } 1926 1958 … … 2979 3011 } 2980 3012 // none found, replace one 2981 int i = rand() % 16;3013 int i = qrand() % 16; 2982 3014 2983 3015 if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) { … … 3031 3063 } 3032 3064 3065 void QWidgetPrivate::updateX11AcceptFocus() 3066 { 3067 Q_Q(QWidget); 3068 if (!q->isWindow() || !q->internalWinId()) 3069 return; 3070 3071 XWMHints *h = XGetWMHints(X11->display, q->internalWinId()); 3072 XWMHints wm_hints; 3073 if (!h) { 3074 memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy 3075 h = &wm_hints; 3076 } 3077 h->flags |= InputHint; 3078 h->input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True; 3079 3080 XSetWMHints(X11->display, q->internalWinId(), h); 3081 if (h != &wm_hints) 3082 XFree((char *)h); 3083 } 3084 3033 3085 QT_END_NAMESPACE -
trunk/src/gui/kernel/qwidgetaction.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwidgetaction.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwidgetaction_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwidgetcreate_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwindowdefs.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwindowdefs_win.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 50 50 #include "private/qapplication_p.h" 51 51 #include "private/qwidget_p.h" 52 53 #ifndef QT_NO_GESTURES 52 54 53 55 QT_BEGIN_NAMESPACE … … 128 130 129 131 QT_END_NAMESPACE 132 133 #endif // QT_NO_GESTURES -
trunk/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 55 55 56 56 #include <QGestureRecognizer> 57 #include <objbase.h>58 57 59 class IInkRectangle; 60 class TabletHardwareCapabilities; 61 class TabletPropertyMetricUnit; 62 DECLARE_INTERFACE_(IInkTablet, IDispatch) 63 { 64 STDMETHOD(get_Name)(THIS_ BSTR *Name) PURE; 65 STDMETHOD(get_PlugAndPlayId)(THIS_ BSTR *Id) PURE; 66 STDMETHOD(get_MaximumInputRectangle)(THIS_ IInkRectangle **Rectangle) PURE; 67 STDMETHOD(get_HardwareCapabilities)(THIS_ TabletHardwareCapabilities *Capabilities) PURE; 68 STDMETHOD(IsPacketPropertySupported)(THIS_ BSTR packetPropertyName) PURE; 69 STDMETHOD(GetPropertyMetrics)(THIS_ BSTR propertyName, long *Minimum, long *Maximum, TabletPropertyMetricUnit *Units, float *Resolution) PURE; 70 }; 71 enum TabletDeviceKind 72 { 73 TDK_Mouse = 0, 74 TDK_Pen = 1, 75 TDK_Touch = 2 76 }; 77 DECLARE_INTERFACE_(IInkTablet2, IDispatch) 78 { 79 STDMETHOD(get_DeviceKind)(THIS_ TabletDeviceKind *Kind) PURE; 80 }; 81 DECLARE_INTERFACE_(IInkTablets, IDispatch) 82 { 83 STDMETHOD(get_Count)(THIS_ long *Count) PURE; 84 STDMETHOD(get__NewEnum)(THIS_ IUnknown **_NewEnum) PURE; 85 STDMETHOD(get_DefaultTablet)(THIS_ IInkTablet **DefaultTablet) PURE; 86 STDMETHOD(Item)(THIS_ long Index, IInkTablet **Tablet) PURE; 87 STDMETHOD(IsPacketPropertySupported)(THIS_ BSTR packetPropertyName, VARIANT_BOOL *Supported) PURE; 88 }; 58 #ifndef QT_NO_GESTURES 89 59 90 60 QT_BEGIN_NAMESPACE … … 106 76 QT_END_NAMESPACE 107 77 78 #endif // QT_NO_GESTURES 79 108 80 #endif // QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H -
trunk/src/gui/kernel/qx11embed_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 48 48 #include <qstyle.h> 49 49 #include <qstyleoption.h> 50 #include <q datetime.h>50 #include <qelapsedtimer.h> 51 51 #include <qpointer.h> 52 52 #include <qdebug.h> … … 1071 1071 d->focusProxy->setAttribute(Qt::WA_NativeWindow); 1072 1072 d->focusProxy->setAttribute(Qt::WA_DontCreateNativeAncestors); 1073 d->focusProxy->createWinId(); 1073 1074 d->focusProxy->setGeometry(-1, -1, 1, 1); 1074 1075 … … 1136 1137 /*! \internal 1137 1138 1138 Returns w ether or not the windows' embedded flag is set.1139 Returns whether or not the windows' embedded flag is set. 1139 1140 */ 1140 1141 bool QX11EmbedContainerPrivate::isEmbedded() const … … 1232 1233 preemptively workaround buggy window managers. 1233 1234 */ 1234 Q Timet;1235 QElapsedTimer t; 1235 1236 t.start(); 1236 1237 -
trunk/src/gui/kernel/qx11embed_x11.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qx11info_x11.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) -
trunk/src/gui/kernel/qx11info_x11.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com)
Note:
See TracChangeset
for help on using the changeset viewer.