Changeset 846 for trunk/src/gui/kernel


Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
192 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/kernel.pri

    r651 r846  
    121121        kernel/qclipboard_s60.cpp\
    122122        kernel/qdnd_s60.cpp \
    123         kernel/qsound_s60.cpp \
    124         kernel/qsoftkeymanager_s60.cpp
     123        kernel/qsound_s60.cpp
    125124
    126125    HEADERS += \
    127126        kernel/qt_s60_p.h \
    128         kernel/qeventdispatcher_s60_p.h \
    129         kernel/qsoftkeymanager_s60_p.h
     127        kernel/qeventdispatcher_s60_p.h
    130128
    131129    LIBS += -lbafl -lestor
     
    133131    INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
    134132    INCLUDEPATH += ../3rdparty/s60
     133
     134    contains(QT_CONFIG, s60) {
     135        SOURCES += kernel/qsoftkeymanager_s60.cpp
     136        HEADERS += kernel/qsoftkeymanager_s60_p.h
     137    }
    135138}
    136139
     
    219222        OBJECTIVE_HEADERS += \
    220223                qcocoawindow_mac_p.h \
     224                qcocoapanel_mac_p.h \
    221225                qcocoawindowdelegate_mac_p.h \
    222226                qcocoaview_mac_p.h \
  • trunk/src/gui/kernel/qaction.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8282QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
    8383                                   visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false),
     84                                   forceEnabledInSoftkeys(false), menuActionSoftkeys(false),
     85                                   iconVisibleInMenu(-1),
    8486                                   menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey),
    85                                    priority(QAction::NormalPriority), iconVisibleInMenu(-1)
     87                                   priority(QAction::NormalPriority)
    8688{
    8789#ifdef QT3_SUPPORT
  • trunk/src/gui/kernel/qaction.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    247247    friend class QShortcutMap;
    248248    friend class QToolButton;
     249#ifdef Q_WS_MAC
     250    friend void qt_mac_clear_status_text(QAction *action);
     251#endif
    249252};
    250253
  • trunk/src/gui/kernel/qaction_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7676    ~QActionPrivate();
    7777
     78    static QActionPrivate *get(QAction *q)
     79    {
     80        return q->d_func();
     81    }
     82
    7883    bool showStatusText(QWidget *w, const QString &str);
    7984
     
    104109    uint separator : 1;
    105110    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
    106117    QAction::MenuRole menuRole;
    107118    QAction::SoftKeyRole softKeyRole;
    108119    QAction::Priority priority;
    109     int iconVisibleInMenu : 3;  // Only has values -1, 0, and 1
     120
    110121    QList<QWidget *> widgets;
    111122#ifndef QT_NO_GRAPHICSVIEW
  • trunk/src/gui/kernel/qactiongroup.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qactiongroup.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qapplication.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6666#include "qdebug.h"
    6767#include "private/qgraphicssystemfactory_p.h"
     68#include "private/qgraphicssystem_p.h"
    6869#include "private/qstylesheetstyle_p.h"
    6970#include "private/qstyle_p.h"
     
    7172#include <QtGui/qgraphicsproxywidget.h>
    7273
     74#ifdef QT_GRAPHICSSYSTEM_RUNTIME
     75#include "private/qgraphicssystem_runtime_p.h"
     76#endif
     77
    7378#include "qinputcontext.h"
    7479#include "qkeymapper_p.h"
     
    7883#endif
    7984
    80 #if defined(Q_WS_X11) || defined(Q_WS_S60)
     85#if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN)
    8186#include "qinputcontextfactory.h"
    8287#endif
     
    9095
    9196#include <stdlib.h>
     97
     98#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
     99#include <link.h>
     100#endif
    92101
    93102#include "qapplication_p.h"
     
    123132{
    124133#if defined(Q_WS_WINCE)
     134    Q_INIT_RESOURCE_EXTERN(qstyle_wince)
    125135    Q_INIT_RESOURCE(qstyle_wince);
    126136#elif defined(Q_OS_SYMBIAN)
     137    Q_INIT_RESOURCE_EXTERN(qstyle_s60)
    127138    Q_INIT_RESOURCE(qstyle_s60);
    128139#else
     140    Q_INIT_RESOURCE_EXTERN(qstyle)
    129141    Q_INIT_RESOURCE(qstyle);
    130142#endif
    131 
     143    Q_INIT_RESOURCE_EXTERN(qmessagebox)
    132144    Q_INIT_RESOURCE(qmessagebox);
    133145#if !defined(QT_NO_PRINTDIALOG)
     146    Q_INIT_RESOURCE_EXTERN(qprintdialog)
    134147    Q_INIT_RESOURCE(qprintdialog);
    135148#endif
     
    139152QT_BEGIN_NAMESPACE
    140153
    141 Q_DECL_IMPORT extern void qt_call_post_routines();
     154Q_CORE_EXPORT void qt_call_post_routines();
    142155
    143156int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0
     
    182195#endif
    183196
     197#ifndef QT_NO_GESTURES
    184198    gestureManager = 0;
    185199    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
    186210
    187211    if (!self)
     
    432456QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system
    433457QString QApplicationPrivate::graphics_system_name;         // graphics system id - for delayed initialization
     458bool QApplicationPrivate::runtime_graphics_system = false;
    434459
    435460Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
     
    455480int qt_antialiasing_threshold = -1;
    456481static int drag_time = 500;
     482#ifndef QT_GUI_DRAG_DISTANCE
     483#define QT_GUI_DRAG_DISTANCE 4
     484#endif
    457485#ifdef Q_OS_SYMBIAN
    458486// The screens are a bit too small to for your thumb when using only 4 pixels drag distance.
    459 static int drag_distance = 8;
     487static int drag_distance = 12; //XXX move to qplatformdefs.h
    460488#else
    461 static int drag_distance = 4;
     489static int drag_distance = QT_GUI_DRAG_DISTANCE;
    462490#endif
    463491static Qt::LayoutDirection layout_direction = Qt::LeftToRight;
     
    472500bool QApplicationPrivate::widgetCount = false;
    473501bool QApplicationPrivate::load_testability = false;
     502QString QApplicationPrivate::qmljs_debug_arguments;
    474503#ifdef QT_KEYPAD_NAVIGATION
    475504#  ifdef Q_OS_SYMBIAN
     
    488517    if (!widget)
    489518        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)
    493520    return !widget->isWindow()
    494521# ifdef Q_BACKINGSTORE_SUBSURFACES
     
    545572        if (arg == "-qdevel" || arg == "-qdebug") {
    546573            // obsolete argument
     574        } else if (arg.indexOf("-qmljsdebugger=", 0) != -1) {
     575            qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15));
    547576        } else if (arg.indexOf("-style=", 0) != -1) {
    548577            s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
     
    650679        \o  -graphicssystem, sets the backend to be used for on-screen widgets
    651680            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.
    652684    \endlist
    653685
     
    658690            that is shown.
    659691        \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.
    661694        \o  -bg or \c -background \e color, sets the default background color
    662695            and an application palette (light and dark shades are calculated).
     
    684717    \endlist
    685718
     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
    686725    \sa arguments()
    687726*/
     
    752791{ Q_D(QApplication); d->construct();  QApplicationPrivate::app_compile_version = _internal;}
    753792
     793#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
     794static 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
    754800
    755801/*!
     
    766812    qt_is_gui_used = (qt_appType != QApplication::Tty);
    767813    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
    768830    // Must be called before initialize()
    769831    qt_init(this, qt_appType
     
    778840    extern void qt_gui_eval_init(uint);
    779841    qt_gui_eval_init(application_type);
     842#endif
     843
     844#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
     845    symbianInit();
    780846#endif
    781847
     
    786852            typedef void (*TasInitialize)(void);
    787853            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
    788860            if (initFunction) {
    789861                initFunction();
     
    879951
    880952extern void qInitDrawhelperAsm();
     953extern void qInitImageConversions();
    881954extern int qRegisterGuiVariant();
    882955extern int qUnregisterGuiVariant();
     
    9361009    // Set up which span functions should be used in raster engine...
    9371010    qInitDrawhelperAsm();
     1011    // and QImage conversion functions
     1012    qInitImageConversions();
    9381013
    9391014#ifndef QT_NO_WHEELEVENT
     
    10281103    QApplicationPrivate::is_app_closing = true;
    10291104    QApplicationPrivate::is_app_running = false;
    1030 
    1031     delete qt_desktopWidget;
    1032     qt_desktopWidget = 0;
    1033 
    1034 #ifndef QT_NO_CLIPBOARD
    1035     delete qt_clipboard;
    1036     qt_clipboard = 0;
    1037 #endif
    10381105
    10391106    delete QWidgetPrivate::mapper;
     
    10521119    }
    10531120
     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
    10541138    delete QApplicationPrivate::app_pal;
    10551139    QApplicationPrivate::app_pal = 0;
     
    10751159    delete QApplicationPrivate::app_icon;
    10761160    QApplicationPrivate::app_icon = 0;
     1161    delete QApplicationPrivate::graphics_system;
     1162    QApplicationPrivate::graphics_system = 0;
    10771163#ifndef QT_NO_CURSOR
    10781164    d->cursor_list.clear();
     
    13471433        //
    13481434        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()) {
    13501441            style = QApplicationPrivate::styleOverride;
    1351         else
     1442        } else if (!envStyle.isEmpty()) {
     1443            style = envStyle;
     1444        } else {
    13521445            style = QApplicationPrivate::desktopStyleKey();
     1446        }
    13531447
    13541448        QStyle *&app_style = QApplicationPrivate::app_style;
     
    15331627    \c{"raster"} and \c{"opengl"}.
    15341628
    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
    15391641    is called.
    15401642
     
    15441646void QApplication::setGraphicsSystem(const QString &system)
    15451647{
    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;
    15471656}
    15481657
     
    21972306    bool did_close = true;
    21982307    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)
    22012310            break;
    22022311        did_close = w->close();
     
    22052314    for (int i = 0; did_close && i < list.size(); ++i) {
    22062315        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) {
    22082319            did_close = w->close();
    22092320            list = QApplication::topLevelWidgets();
     
    22942405                         " and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
    22952406}
     2407#if defined(Q_WS_MAC)
     2408static 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    };
     2417QString 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
    22962428#endif
    22972429
     
    23222454        setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight);
    23232455#endif
     2456#if defined(QT_MAC_USE_COCOA)
     2457        qt_mac_post_retranslateAppMenu();
     2458#endif
    23242459        QWidgetList list = topLevelWidgets();
    23252460        for (int i = 0; i < list.size(); ++i) {
     
    23282463                postEvent(w, new QEvent(QEvent::LanguageChange));
    23292464        }
     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
    23302478    } else if (e->type() == QEvent::Timer) {
    23312479        QTimerEvent *te = static_cast<QTimerEvent*>(e);
     
    24562604    }
    24572605
     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
    24582613    for(int i = 0; i < toBeDeactivated.size(); ++i) {
    24592614        QWidget *w = toBeDeactivated.at(i);
     
    26902845#elif defined(Q_WS_X11)
    26912846            qt_x11_enforce_cursor(cursorWidget, true);
    2692 #elif defined(Q_WS_S60)
     2847#elif defined(Q_OS_SYMBIAN)
    26932848            qt_symbian_set_cursor(cursorWidget, true);
    26942849#elif defined(Q_WS_PM)
     
    29983153}
    29993154
    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)
    30013156/*
    30023157    This function should only be called when the widget changes visibility, i.e.
     
    30583213#endif // QT_NO_CURSOR
    30593214}
    3060 #endif // Q_WS_WIN || Q_WS_PM || Q_WS_X11
     3215#endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC || Q_WS_PM
    30613216
    30623217/*!
     
    34653620void QApplication::setLayoutDirection(Qt::LayoutDirection direction)
    34663621{
    3467     if (layout_direction == direction)
     3622    if (layout_direction == direction || direction == Qt::LayoutDirectionAuto)
    34683623        return;
    34693624
     
    36413796    }
    36423797
     3798#ifndef QT_NO_GESTURES
    36433799    // walk through parents and check for gestures
    36443800    if (d->gestureManager) {
     
    36853841        }
    36863842    }
    3687 
     3843#endif // QT_NO_GESTURES
    36883844
    36893845    // User input and window activation makes tooltips sleep
     
    41904346        break;
    41914347
     4348#ifndef QT_NO_GESTURES
    41924349    case QEvent::NativeGesture:
    41934350    {
     
    42434400                    for (int i = 0; i < gestures.size(); ++i) {
    42444401                        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)) {
    42464405                            // if the gesture was accepted, mark the target widget for it
    42474406                            gestureEvent->d_func()->targetWidgets[g->gestureType()] = w;
    42484407                            gestureEvent->setAccepted(g, true);
    4249                         } else if (!eventAccepted && !ge.isAccepted(g)) {
     4408                        } else {
    42504409                            // if the gesture was explicitly ignored by the application,
    42514410                            // put it back so a parent can get it
     
    42684427        break;
    42694428    }
     4429#endif // QT_NO_GESTURES
    42704430    default:
    42714431        res = d->notify_helper(receiver, e);
     
    52095369*/
    52105370
     5371#ifndef QT_NO_IM
    52115372// ************************************************************************
    52125373// Input Method support
     
    52175378    with \a inputContext.
    52185379
     5380    Qt takes ownership of the given \a inputContext.
     5381
    52195382    \sa inputContext()
    52205383*/
     
    52225385{
    52235386#ifndef QT_NO_IM
    5224     Q_D(QApplication);
    5225     Q_UNUSED(d);// only static members being used.
     5387    if (inputContext == QApplicationPrivate::inputContext)
     5388        return;
    52265389    if (!inputContext) {
    52275390        qWarning("QApplication::setInputContext: called with 0 input context");
    52285391        return;
    52295392    }
    5230     delete d->inputContext;
    5231     d->inputContext = inputContext;
     5393    delete QApplicationPrivate::inputContext;
     5394    QApplicationPrivate::inputContext = inputContext;
     5395    QApplicationPrivate::inputContext->setParent(this);
    52325396#endif
    52335397}
     
    52565420        that->d_func()->inputContext = qic;
    52575421    }
    5258 #elif defined(Q_WS_S60)
     5422#elif defined(Q_OS_SYMBIAN)
    52595423    if (!d->inputContext) {
    52605424        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        }
    52625436    }
    52635437#endif
     
    52675441#endif
    52685442}
     5443#endif // QT_NO_IM
    52695444
    52705445//Returns the current platform used by keyBindings
     
    56945869}
    56955870
     5871#ifndef QT_NO_GESTURES
    56965872QGestureManager* QGestureManager::instance()
    56975873{
    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
     5887static 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 */
     5920static 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 */
     5958static 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 */
     6018static 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
     6077QPixmap 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
     6107QString QApplicationPrivate::qmljsDebugArgumentsString()
     6108{
     6109    return qmljs_debug_arguments;
    57026110}
    57036111
  • trunk/src/gui/kernel/qapplication.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6262QT_BEGIN_HEADER
    6363
    64 #if defined(Q_WS_S60)
     64#if defined(Q_OS_SYMBIAN)
    6565class CApaApplication;
    6666#endif
     
    119119    enum Type { Tty, GuiClient, GuiServer };
    120120
    121 #ifdef Q_WS_S60
     121#ifdef Q_OS_SYMBIAN
    122122    typedef CApaApplication * (*QS60MainApplicationFactory)();
    123123#endif
     
    131131    QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION);
    132132#endif
    133 #if defined(Q_WS_S60)
     133#if defined(Q_OS_SYMBIAN)
    134134    QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION);
    135135#endif
     
    272272    virtual void saveState(QSessionManager& sm);
    273273#endif
     274
     275#ifndef QT_NO_IM
    274276    void setInputContext(QInputContext *);
    275277    QInputContext *inputContext() const;
     278#endif
    276279
    277280    static QLocale keyboardInputLocale();
     
    371374    QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
    372375#endif
    373 #if defined(Q_WS_S60) || defined(qdoc)
     376#if defined(Q_OS_SYMBIAN) || defined(qdoc)
    374377    QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv);
    375378#endif
     
    381384
    382385    friend class QGraphicsWidget;
     386    friend class QGraphicsItem;
    383387    friend class QGraphicsScene;
    384388    friend class QGraphicsScenePrivate;
     
    403407    friend class QDirectPainterPrivate;
    404408#endif
     409#ifndef QT_NO_GESTURES
    405410    friend class QGestureManager;
     411#endif
    406412
    407413#if defined(Q_WS_MAC) || defined(Q_WS_X11)
     
    411417    Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents())
    412418#endif
     419#if defined(Q_OS_SYMBIAN)
     420    Q_PRIVATE_SLOT(d_func(), void _q_aboutToQuit())
     421#endif
    413422};
    414423
  • trunk/src/gui/kernel/qapplication_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    185185static bool qt_mac_collapse_on_dblclick = true;
    186186extern int qt_antialiasing_threshold; // from qapplication.cpp
    187 QPointer<QWidget> qt_button_down;                // widget got last button-down
     187QWidget * qt_button_down;                // widget got last button-down
     188QPointer<QWidget> qt_last_mouse_receiver;
    188189#ifndef QT_MAC_USE_COCOA
    189190static bool qt_button_down_in_content; // whether the button_down was in the content area.
     
    737738static void qt_mac_update_child_gl_widgets(QWidget *widget)
    738739{
    739     if (widget->isWindow())
    740         return;
    741 
    742740    // Update all OpenGL child widgets for the given widget.
    743741    QList<QWidgetPrivate::GlWidgetInfo> &glWidgets = qt_widget_private(widget)->glWidgets;
     
    12211219
    12221220#endif
    1223         if (!app_proc_ae_handlerUPP) {
     1221        if (!app_proc_ae_handlerUPP && !QApplication::testAttribute(Qt::AA_MacPluginApplication)) {
    12241222            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, &current_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            }
    12281233        }
    12291234
     
    12381243    // Cocoa application delegate
    12391244#ifdef QT_MAC_USE_COCOA
    1240     NSApplication *cocoaApp = [NSApplication sharedApplication];
     1245    NSApplication *cocoaApp = [QNSApplication sharedApplication];
    12411246    QMacCocoaAutoReleasePool pool;
    12421247    NSObject *oldDelegate = [cocoaApp delegate];
     
    12591264        [newDelegate setMenuLoader:qtMenuLoader];
    12601265        [qtMenuLoader release];
    1261 
    1262         NSAppleEventManager *eventManager = [NSAppleEventManager sharedAppleEventManager];
    1263         [eventManager setEventHandler:newDelegate andSelector:@selector(getUrl:withReplyEvent:)
    1264           forEventClass:kInternetEventClass andEventID:kAEGetURL];
    12651266    }
    12661267#endif
     
    13621363  QApplication cursor stack
    13631364 *****************************************************************************/
     1365#ifdef QT_MAC_USE_COCOA
     1366void 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
     1381void 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
    13641390void QApplication::setOverrideCursor(const QCursor &cursor)
    13651391{
     
    13681394#ifdef QT_MAC_USE_COCOA
    13691395    QMacCocoaAutoReleasePool pool;
     1396    if (qApp->d_func()->cursor_list.size() == 1)
     1397        qApp->d_func()->disableUsageOfCursorRects(true);
    13701398    [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) push];
    13711399#else
     
    13841412    QMacCocoaAutoReleasePool pool;
    13851413    [NSCursor pop];
     1414    if (qApp->d_func()->cursor_list.isEmpty())
     1415        qApp->d_func()->disableUsageOfCursorRects(false);
    13861416#else
    13871417    if (qApp && qApp->activeWindow()) {
     
    17271757            // As a results of this, and to make sure we dont't receive duplicate events,
    17281758            // 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;
    17291764            SInt32 mdelt = 0;
    17301765            GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0,
    17311766                              sizeof(mdelt), 0, &mdelt);
    1732             wheel_deltaX = mdelt;
     1767            wheel_deltaX = mdelt * pixelsToDegrees;
    17331768            mdelt = 0;
    17341769            GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0,
    17351770                              sizeof(mdelt), 0, &mdelt);
    1736             wheel_deltaY = mdelt;
     1771            wheel_deltaY = mdelt * pixelsToDegrees;
    17371772            GetEventParameter(event, kEventParamEventRef, typeEventRef, 0,
    17381773                              sizeof(compatibilityEvent), 0, &compatibilityEvent);
     
    24092444            if(!handled_event) {
    24102445                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);
    24202461                        }
    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                        }
    24302470                    }
    24312471                } else if(cmd.commandID == kHICommandSelectWindow) {
     
    24572497#endif
    24582498}
     2499
     2500#ifdef QT_MAC_USE_COCOA
     2501void QApplicationPrivate::qt_initAfterNSAppStarted()
     2502{
     2503    setupAppleEvents();
     2504    updateOverrideCursor();
     2505}
     2506
     2507void 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
    24592528
    24602529// In Carbon this is your one stop for apple events.
     
    30093078
    30103079    QMenuBar::macUpdateMenuBar();
    3011 
     3080    QApplicationPrivate::updateOverrideCursor();
    30123081#else
    30133082    Q_UNUSED(widget);
  • trunk/src/gui/kernel/qapplication_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8585class QWidget;
    8686class QSocketNotifier;
     87#ifndef QT_NO_GESTURES
    8788class QGestureManager;
     89#endif
    8890
    8991extern bool qt_is_gui_used;
     
    201203typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE);
    202204
     205#ifndef QT_NO_GESTURES
    203206typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID);
    204207typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE);
     
    264267#endif
    265268
     269#endif // QT_NO_GESTURES
     270
    266271#endif // Q_WS_WIN
    267272
     
    414419    static QGraphicsSystem *graphics_system;
    415420    static QString graphics_system_name;
     421    static bool runtime_graphics_system;
    416422
    417423private:
     
    442448    static bool widgetCount; // Coupled with -widgetcount switch
    443449    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
    444453#ifdef Q_WS_MAC
    445454    static bool native_modal_dialog_active;
     
    461470    static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long);
    462471    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
    463478    static bool qt_mac_apply_settings();
    464479#endif
     
    509524    int symbianResourceChange(const QSymbianEvent *symbianEvent);
    510525
    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)
    513529    void sendSyntheticEnterLeave(QWidget *widget);
    514530#endif
     
    517533#endif
    518534
     535#ifndef QT_NO_GESTURES
    519536    QGestureManager *gestureManager;
    520537    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);
    521548
    522549    QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId;
     
    543570    bool translateTouchEvent(const MSG &msg);
    544571
     572#ifndef QT_NO_GESTURES
    545573    PtrGetGestureInfo GetGestureInfo;
    546574    PtrGetGestureExtraArgs GetGestureExtraArgs;
     
    551579    PtrUpdatePanningFeedback UpdatePanningFeedback;
    552580    PtrEndPanningFeedback EndPanningFeedback;
     581#endif // QT_NO_GESTURES
    553582#endif
    554583
     
    583612
    584613#ifdef Q_OS_SYMBIAN
    585     static QHash<TInt, TUint> scanCodeCache;
     614    QHash<TInt, TUint> scanCodeCache;
    586615#endif
    587616
  • trunk/src/gui/kernel/qapplication_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qapplication_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6363#include "private/qmenubar_p.h"
    6464#include "private/qsoftkeymanager_p.h"
     65#ifdef QT_GRAPHICSSYSTEM_RUNTIME
     66#include "private/qgraphicssystem_runtime_p.h"
     67#endif
    6568
    6669#include "apgwgnam.h" // For CApaWindowGroupName
    6770#include <mdaaudiotoneplayer.h>     // For CMdaAudioToneUtility
    6871
    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)
    7473# include <private/qs60mainapplication_p.h>
    7574# include <centralrepository.h>
    7675# 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
    7783#endif
    7884
     
    8288#include <hal_data.h>
    8389
     90#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
     91#include <graphics/wstfxconst.h>
     92#endif
     93
    8494QT_BEGIN_NAMESPACE
     95
     96// Goom Events through Window Server
     97static const int KGoomMemoryLowEvent = 0x10282DBF;
     98static const int KGoomMemoryGoodEvent = 0x20026790;
    8599
    86100#if defined(QT_DEBUG)
     
    101115{
    102116    return qt_s60Data();
     117}
     118
     119#ifdef Q_WS_S60
     120void 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
     144void 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    }
    103168}
    104169
     
    198263
    199264
    200 QHash<TInt, TUint> QApplicationPrivate::scanCodeCache;
    201 
    202265static Qt::KeyboardModifiers mapToQtModifiers(TUint s60Modifiers)
    203266{
     
    346409    if (!desktop)
    347410    {
    348         if (isWindowOwning or !qwidget->parentWidget())
     411        if (isWindowOwning || !qwidget->parentWidget())
    349412            CreateWindowL(S60->windowGroup());
    350413        else
     
    365428        SetFocusing(true);
    366429        m_longTapDetector = QLongTapTimer::NewL(this);
     430        m_doubleClickTimer.invalidate();
    367431
    368432        DrawableWindow()->SetPointerGrab(ETrue);
    369433    }
     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
    370462}
    371463
    372464QSymbianControl::~QSymbianControl()
    373465{
     466    // Ensure backing store is deleted before the top-level
     467    // window is destroyed
     468    qt_widget_private(qwidget)->topData()->backingStore.destroy();
     469
    374470    if (S60->curWin == this)
    375471        S60->curWin = 0;
     
    408504{
    409505    QApplicationPrivate *d = QApplicationPrivate::instance();
     506    QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY));
    410507    qreal pressure;
    411508    if(d->pressureSupported
     
    414511    else
    415512        pressure = qreal(1.0);
    416 
     513    processTouchEvent(event->PointerNumber(), event->iType, screenPos, pressure);
     514}
     515#endif
     516
     517void QSymbianControl::processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure)
     518{
    417519    QRect screenGeometry = qApp->desktop()->screenGeometry(qwidget);
    418520
     521    QApplicationPrivate *d = QApplicationPrivate::instance();
     522
    419523    QList<QTouchEvent::TouchPoint> points = d->appAllTouchPoints;
    420     while (points.count() <= event->PointerNumber())
     524    while (points.count() <= pointerNumber)
    421525        points.append(QTouchEvent::TouchPoint(points.count()));
    422526
     
    425529        QTouchEvent::TouchPoint &touchPoint = points[i];
    426530
    427         if (touchPoint.id() == event->PointerNumber()) {
     531        if (touchPoint.id() == pointerNumber) {
    428532            Qt::TouchPointStates state;
    429             switch (event->iType) {
     533            switch (type) {
    430534            case TPointerEvent::EButton1Down:
     535#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
    431536            case TPointerEvent::EEnterHighPressure:
     537#endif
    432538                state = Qt::TouchPointPressed;
    433539                break;
    434540            case TPointerEvent::EButton1Up:
     541#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
    435542            case TPointerEvent::EExitCloseProximity:
     543#endif
    436544                state = Qt::TouchPointReleased;
    437545                break;
     
    444552                break;
    445553            }
    446             if (event->PointerNumber() == 0)
     554            if (pointerNumber == 0)
    447555                state |= Qt::TouchPointPrimary;
    448556            touchPoint.setState(state);
    449557
    450             QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY));
    451558            touchPoint.setScreenPos(screenPos);
    452559            touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(),
     
    473580                                                points);
    474581}
    475 #endif
    476582
    477583void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent)
     
    547653#endif
    548654
     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
    549662    sendMouseEvent(receiver, type, globalPos, button, modifiers);
    550663}
     
    594707TKeyResponse QSymbianControl::OfferKeyEvent(const TKeyEvent& keyEvent, TEventCode type)
    595708{
    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
     782TKeyResponse 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            }
    629811        } 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
     830TKeyResponse QSymbianControl::handleVirtualMouse(const TKeyEvent& keyEvent,TEventCode type)
     831{
    634832#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)
    660874                        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;
    762877                }
    763878            }
    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                }
    772984            }
    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
    7771005    return EKeyWasNotConsumed;
    7781006}
     
    8061034            return EKeyWasConsumed;
    8071035    }
    808 #endif // !defined(QT_NO_IM) && defined(Q_WS_S60)
     1036#endif // !defined(QT_NO_IM) && defined(Q_OS_SYMBIAN)
    8091037
    8101038    if (widget && qt_sendSpontaneousEvent(widget, keyEvent))
     
    8441072    if (!topExtra->inExpose) {
    8451073        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        }
    8461082        QRect exposeRect = qt_TRect2QRect(controlRect);
    8471083        qwidget->d_func()->syncBackingStore(exposeRect);
     
    8671103
    8681104    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
    8701115        CFbsBitmap *bitmap = s60Surface->symbianBitmap();
    8711116        CWindowGc &gc = SystemGc();
    8721117
    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) {
    8741123        case QWExtra::Disable:
    8751124            // Do nothing
    8761125            break;
    877 
    8781126        case QWExtra::Blit:
    8791127            if (qwidget->d_func()->isOpaque)
     
    8811129            gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect);
    8821130            break;
    883 
    8841131        case QWExtra::ZeroFill:
    885             if (Window().DisplayMode() == EColor16MA) {
     1132            if (Window().DisplayMode() == EColor16MA
     1133                || Window().DisplayMode() == Q_SYMBIAN_ECOLOR16MAP) {
    8861134                gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    8871135                gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
     
    8931141            };
    8941142            break;
    895 
    8961143        default:
    8971144            Q_ASSERT(false);
     
    9361183                tlwExtra->inTopLevelResize = false;
    9371184        } 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            }
    9401189        }
    9411190    }
     
    9961245#ifdef Q_WS_S60
    9971246        // 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);
    10081255        }
    10091256#endif
    10101257    } 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;
    10161276            }
    1017             m_symbianPopupIsOpen = true;
    1018             return;
    1019         }
    1020 
    1021         QApplication::setActiveWindow(0);
     1277
     1278            QApplication::setActiveWindow(0);
     1279        }
    10221280    }
    10231281    // else { We don't touch the active window unless we were explicitly activated or deactivated }
     
    10621320    {
    10631321        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);
    10641325        break;
    10651326    }
     
    10911352    // the top of the stack may randomly be assigned focus by Symbian, for example
    10921353    // when creating new windows (specifically in CCoeAppUi::HandleStackChanged()).
     1354
     1355    // Close any popups.
     1356    CEikonEnv::Static()->EikAppUi()->StopDisplayingMenuBar();
     1357
    10931358    if (focus) {
    10941359        S60->appUi()->RemoveFromStack(this);
     
    11111376}
    11121377
     1378bool QSymbianControl::isControlActive()
     1379{
     1380    return IsActivated() ? true : false;
     1381}
     1382
    11131383/*!
    11141384    \typedef QApplication::QS60MainApplicationFactory
     
    11611431        TTrapHandler *origTrapHandler = User::TrapHandler();
    11621432
    1163         // The S60 framework has not been initalized. We need to do it.
     1433        // The S60 framework has not been initialized. We need to do it.
    11641434        TApaApplicationFactory factory(S60->s60ApplicationFactory ?
    11651435                S60->s60ApplicationFactory : newS60Application);
     
    11681438        // After this construction, CEikonEnv will be available from CEikonEnv::Static().
    11691439        // (much like our qApp).
    1170         CEikonEnv* coe = new CEikonEnv;
     1440        QtEikonEnv* coe = new QtEikonEnv;
    11711441        //not using QT_TRAP_THROWING, because coe owns the cleanupstack so it can't be pushed there.
    11721442        if(err == KErrNone)
     
    12751545        }
    12761546    }
    1277 #endif
    1278 
     1547    delete repository;
     1548    repository = 0;
     1549#endif
     1550
     1551#ifdef QT_KEYPAD_NAVIGATION
    12791552    if (touch) {
    12801553        QApplicationPrivate::navigationMode = Qt::NavigationModeNone;
     
    12821555        QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
    12831556    }
     1557#endif
    12841558
    12851559#ifndef QT_NO_CURSOR
     
    13141588    QApplicationPrivate::setSystemFont(systemFont);
    13151589
     1590#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
     1591    QObject::connect(qApp, SIGNAL(aboutToQuit()), qApp, SLOT(_q_aboutToQuit()));
     1592#endif
     1593
    13161594/*
    13171595 ### Commented out for now as parameter handling not needed in SOS(yet). Code below will break testlib with -o flag
     
    13371615
    13381616    // Register WId with the metatype system.  This is to enable
    1339     // QWidgetPrivate::create_sys to used delayed slot invokation in order
     1617    // QWidgetPrivate::create_sys to used delayed slot invocation in order
    13401618    // to destroy WId objects during reparenting.
    13411619    qRegisterMetaType<WId>("WId");
    13421620}
     1621
     1622extern void qt_cleanup_symbianFontDatabase(); // qfontdatabase_s60.cpp
    13431623
    13441624/*****************************************************************************
     
    13521632    }
    13531633    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();
    13541637// S60 structure and window server session are freed in eventdispatcher destructor as they are needed there
    13551638
     
    13631646    S60->wsSession().SetPointerCursorMode(EPointerCursorNone);
    13641647
     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
    13651655    if (S60->qtOwnsS60Environment) {
    13661656        // Restore the S60 framework trap handler. See qt_init().
     
    13981688void QApplicationPrivate::enterModal_sys(QWidget *widget)
    13991689{
     1690#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
     1691    S60->wsSession().SendEffectCommand(ETfxCmdAppModalModeEnter);
     1692#endif
    14001693    if (widget) {
    14011694        static_cast<QSymbianControl *>(widget->effectiveWinId())->FadeBehindPopup(ETrue);
     
    14131706void QApplicationPrivate::leaveModal_sys(QWidget *widget)
    14141707{
     1708#ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS
     1709    S60->wsSession().SendEffectCommand(ETfxCmdAppModalModeExit);
     1710#endif
    14151711    if (widget) {
    14161712        static_cast<QSymbianControl *>(widget->effectiveWinId())->FadeBehindPopup(EFalse);
     
    17031999                return 1;
    17042000            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);
    17202005            return 1;
    17212006        }
     
    17352020        }
    17362021#endif
     2022#ifdef QT_SOFTKEYS_ENABLED
     2023        QSoftKeyManager::updateSoftKeys();
     2024#endif
    17372025        break;
    17382026    case EEventFocusLost:
     
    17512039#endif
    17522040        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
    17532091    default:
    17542092        break;
     
    18172155        break;
    18182156    default:
     2157#ifdef Q_WS_S60
    18192158        bool handled = QSoftKeyManager::handleCommand(command);
    18202159        if (handled)
    18212160            ret = 1;
    1822 #ifdef Q_WS_S60
    18232161        else
    18242162            ret = QMenuBarPrivate::symbianCommands(command);
     
    19162254TUint QApplicationPrivate::resolveS60ScanCode(TInt scanCode, TUint keysym)
    19172255{
     2256    if (!scanCode)
     2257        return keysym;
     2258
     2259    QApplicationPrivate *d = QApplicationPrivate::instance();
     2260
    19182261    if (keysym) {
    19192262        // If keysym is specified, cache it.
    1920         scanCodeCache.insert(scanCode, keysym);
     2263        d->scanCodeCache.insert(scanCode, keysym);
    19212264        return keysym;
    19222265    } else {
    19232266        // If not, retrieve the cached version.
    1924         return scanCodeCache[scanCode];
     2267        return d->scanCodeCache[scanCode];
    19252268    }
    19262269}
     
    19332276    if (HAL::Get(HALData::EPointer3DMaxPressure, maxTouchPressure) != KErrNone)
    19342277        maxTouchPressure = KMaxTInt;
     2278#else
     2279    pressureSupported = 0;
     2280    maxTouchPressure = KMaxTInt;
    19352281#endif
    19362282}
     
    20392385#endif // QT_NO_CURSOR
    20402386
     2387void 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
     2395QS60ThreadLocalData::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
     2412QS60ThreadLocalData::~QS60ThreadLocalData()
     2413{
     2414    if (!usingCONEinstances) {
     2415        delete screenDevice;
     2416        wsSession.Close();
     2417    }
     2418}
     2419
    20412420QT_END_NAMESPACE
  • trunk/src/gui/kernel/qapplication_win.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5353#include <tpcshell.h>
    5454#ifdef QT_WINCE_GESTURES
     55#ifndef QT_NO_GESTURES
    5556#include <gesture.h>
     57#endif
    5658#endif
    5759#endif
     
    6769#include "qpointer.h"
    6870#include "qhash.h"
    69 #include "qlibrary.h"
    7071#include "qmetaobject.h"
    7172#include "qmime.h"
     
    8081#include "qtooltip.h"
    8182#include "qt_windows.h"
     83#include "qscrollbar.h"
    8284#if defined(QT_NON_COMMERCIAL)
    8385#include "qnc_win.h"
     
    9294#include <private/qkeymapper_p.h>
    9395#include <private/qlocale_p.h>
     96#include <private/qsystemlibrary_p.h>
    9497#include "qevent_p.h"
    9598
     
    115118#  include <winable.h>
    116119#endif
    117 
    118 #include "private/qwinnativepangesturerecognizer_win_p.h"
    119120
    120121#ifndef WM_TOUCH
     
    198199#endif
    199200
     201#ifndef QT_NO_GESTURES
    200202typedef DWORD (API *AygRecognizeGesture)(SHRGINFO*);
    201203static AygRecognizeGesture ptrRecognizeGesture = 0;
     
    205207    if (!aygResolved) {
    206208        aygResolved = true;
    207         QLibrary ayglib(QLatin1String("aygshell"));
     209        QSystemLibrary ayglib(QLatin1String("aygshell"));
    208210        if (!ayglib.load())
    209211            return;
     
    211213    }
    212214}
     215#endif // QT_NO_GESTURES
    213216
    214217#endif
     
    442445#endif
    443446
    444 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
     447extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
    445448
    446449class QETWidget : public QWidget                // event translator widget
     
    463466    bool        translateCloseEvent(const MSG &msg);
    464467    bool        translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets);
     468#ifndef QT_NO_GESTURES
    465469    bool        translateGestureEvent(const MSG &msg, const GESTUREINFO &gi);
     470#endif
    466471    void        repolishStyle(QStyle &style);
    467472    inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); }
     
    702707}
    703708
     709static 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
    704726/*****************************************************************************
    705727  qt_init() - initializes Qt for Windows
     
    812834#ifndef Q_OS_WINCE
    813835    ptrUpdateLayeredWindowIndirect =
    814         (PtrUpdateLayeredWindowIndirect) QLibrary::resolve(QLatin1String("user32"),
     836        (PtrUpdateLayeredWindowIndirect) QSystemLibrary::resolve(QLatin1String("user32"),
    815837                                                           "UpdateLayeredWindowIndirect");
    816838    ptrUpdateLayeredWindow =
    817         (PtrUpdateLayeredWindow) QLibrary::resolve(QLatin1String("user32"),
     839        (PtrUpdateLayeredWindow) QSystemLibrary::resolve(QLatin1String("user32"),
    818840                                                   "UpdateLayeredWindow");
    819841
     
    823845    // Notify Vista and Windows 7 that we support highter DPI settings
    824846    ptrSetProcessDPIAware = (PtrSetProcessDPIAware)
    825         QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
     847        QSystemLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
    826848    if (ptrSetProcessDPIAware)
    827849        ptrSetProcessDPIAware();
    828850#endif
    829851
     852#ifndef QT_NO_GESTURES
    830853    priv->GetGestureInfo = 0;
    831854    priv->GetGestureExtraArgs = 0;
     
    843866  #if !defined(QT_NO_NATIVE_GESTURES)
    844867    priv->GetGestureInfo =
    845             (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
     868            (PtrGetGestureInfo)QSystemLibrary::resolve(QLatin1String("user32"),
    846869                                                 "GetGestureInfo");
    847870    priv->GetGestureExtraArgs =
    848             (PtrGetGestureExtraArgs)QLibrary::resolve(QLatin1String("user32"),
     871            (PtrGetGestureExtraArgs)QSystemLibrary::resolve(QLatin1String("user32"),
    849872                                                      "GetGestureExtraArgs");
    850873    priv->CloseGestureInfoHandle =
    851             (PtrCloseGestureInfoHandle)QLibrary::resolve(QLatin1String("user32"),
     874            (PtrCloseGestureInfoHandle)QSystemLibrary::resolve(QLatin1String("user32"),
    852875                                                         "CloseGestureInfoHandle");
    853876    priv->SetGestureConfig =
    854             (PtrSetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
     877            (PtrSetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"),
    855878                                                   "SetGestureConfig");
    856879    priv->GetGestureConfig =
    857             (PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
     880            (PtrGetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"),
    858881                                                   "GetGestureConfig");
    859882  #endif // QT_NO_NATIVE_GESTURES
     883    QSystemLibrary libTheme(QLatin1String("uxtheme"));
    860884    priv->BeginPanningFeedback =
    861             (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
    862                                                        "BeginPanningFeedback");
     885            (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback");
    863886    priv->UpdatePanningFeedback =
    864             (PtrUpdatePanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
    865                                                         "UpdatePanningFeedback");
     887            (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback");
    866888    priv->EndPanningFeedback =
    867         (PtrEndPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
    868                                                    "EndPanningFeedback");
    869 #endif
     889        (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback");
     890#endif
     891#endif // QT_NO_GESTURES
    870892}
    871893
     
    934956        cname = QLatin1String("QGLWidget");
    935957        style = CS_DBLCLKS;
     958#ifndef Q_WS_WINCE
     959        style |= CS_OWNDC;
     960#endif
    936961        icon  = true;
    937962    } else if (flags & Qt::MSWindowsOwnDC) {
     
    14011426}
    14021427
    1403 extern "C"
    1404 LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
     1428extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    14051429{
    14061430    bool result = true;
     
    14761500    switch (message) {
    14771501#ifndef Q_WS_WINCE
     1502#ifndef QT_NO_SESSIONMANAGER
    14781503    case WM_QUERYENDSESSION: {
    14791504        if (sm_smActive) // bogus message from windows
     
    15081533        RETURN(0);
    15091534    }
     1535#endif
    15101536    case WM_DISPLAYCHANGE:
    15111537        if (QApplication::type() == QApplication::Tty)
     
    15281554#ifdef Q_WS_WINCE
    15291555        // CE SIP hide/show
    1530         if (wParam == SPI_SETSIPINFO) {
     1556        if (qt_desktopWidget && wParam == SPI_SETSIPINFO) {
    15311557            QResizeEvent re(QSize(0, 0), QSize(0, 0)); // Calculated by QDesktopWidget
    15321558            QApplication::sendEvent(qt_desktopWidget, &re);
     
    15801606    case WM_RBUTTONDOWN:
    15811607    case WM_XBUTTONDOWN:
     1608    case WM_LBUTTONDBLCLK:
     1609    case WM_RBUTTONDBLCLK:
     1610    case WM_MBUTTONDBLCLK:
     1611    case WM_XBUTTONDBLCLK:
    15821612        if (qt_win_ignoreNextMouseReleaseEvent)
    15831613            qt_win_ignoreNextMouseReleaseEvent = false;
     
    16491679                        shrg.dwFlags = SHRG_RETURNCMD | SHRG_NOANIMATION;
    16501680                        resolveAygLibs();
     1681#ifndef QT_NO_GESTURES
    16511682                        if (ptrRecognizeGesture && (ptrRecognizeGesture(&shrg) == GN_CONTEXTMENU)) {
    16521683                            if (QApplication::activePopupWidget())
     
    16551686                            result = qt_sendSpontaneousEvent(alienWidget, &e);
    16561687                        }
     1688#endif // QT_NO_GESTURES
    16571689                    }
    16581690                }
     
    19181950                    if (!widget->testAttribute(Qt::WA_SetLocale))
    19191951                        widget->dptr()->setLocale_helper(QLocale(), true);
     1952                    QEvent e(QEvent::LocaleChange);
     1953                    QApplication::sendEvent(qApp, &e);
    19201954                }
    19211955            }
     
    19281962                }
    19291963            }
     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
    19301973            break;
    19311974
     
    21962239            break;
    21972240
     2241#ifndef QT_NO_CONTEXTMENU
    21982242            case WM_CONTEXTMENU:
    21992243            {
     
    22242268            break;
    22252269#endif
     2270#endif
    22262271
    22272272        case WM_IME_STARTCOMPOSITION:
     
    22802325            {
    22812326                // 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) {
    22832328                    result = false;
    22842329                    break;
     
    22922337                    oleaccChecked = true;
    22932338#if !defined(Q_OS_WINCE)
    2294                     ptrLresultFromObject = (PtrLresultFromObject)QLibrary::resolve(QLatin1String("oleacc.dll"), "LresultFromObject");
     2339                    ptrLresultFromObject = (PtrLresultFromObject)QSystemLibrary::resolve(QLatin1String("oleacc"), "LresultFromObject");
    22952340#endif
    22962341                }
     
    24452490                QApplication::postEvent(widget, new QEvent(QEvent::OkRequest));
    24462491            if (CancelCommand)
    2447                 QApplication::postEvent(widget, new QEvent(QEvent::Close));
     2492                widget->showMinimized();
    24482493            else
    24492494#ifndef QT_NO_MENUBAR
     
    25272572            result = false;
    25282573            break;
     2574#ifndef QT_NO_GESTURES
    25292575#if !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
    25302576        case WM_GESTURE: {
     
    25612607        }
    25622608#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
    25632621        default:
    25642622            result = false;                        // event was not processed
     
    29833041                msgPtr->lParam = mouseMsg.lParam;
    29843042                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));
    29863047                // Remove the mouse move message
    29873048                PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE,
     
    30093070        }
    30103071    }
     3072#ifndef Q_OS_WINCE
     3073    static bool trackMouseEventLookup = false;
     3074    typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT);
     3075    static PtrTrackMouseEvent ptrTrackMouseEvent = 0;
     3076#endif
    30113077    state  = translateButtonState(msg.wParam, type, button); // button state
    30123078    const QPoint widgetPos = mapFromGlobal(QPoint(msg.pt.x, msg.pt.y));
     
    30733139
    30743140            if (curWin != 0) {
    3075                 static bool trackMouseEventLookup = false;
    3076                 typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT);
    3077                 static PtrTrackMouseEvent ptrTrackMouseEvent = 0;
    30783141                if (!trackMouseEventLookup) {
    30793142                    trackMouseEventLookup = true;
    3080                     ptrTrackMouseEvent = (PtrTrackMouseEvent)QLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent");
     3143                    ptrTrackMouseEvent = (PtrTrackMouseEvent)QSystemLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent");
    30813144                }
    30823145                if (ptrTrackMouseEvent && !qApp->d_func()->inPopupMode()) {
     
    31893252        }
    31903253
     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
    31913269        if (type == QEvent::MouseButtonPress
    31923270            && QApplication::activePopupWidget() != activePopupWidget
    31933271            && replayPopupMouseEvent) {
    3194             // the popup dissappeared. Replay the event
     3272            // the popup disappeared. Replay the event
    31953273            QWidget* w = QApplication::widgetAt(gpos.x, gpos.y);
    31963274            if (w && !QApplicationPrivate::isBlockedByModal(w)) {
     
    34293507#endif // QT_NO_TABLETEVENT
    34303508
    3431 // Update the "dynamic" informations of a cursor device (pen, airbrush, etc).
     3509// Update the "dynamic" information of a cursor device (pen, airbrush, etc).
    34323510// The dynamic information is the information of QTabletDeviceData that can change
    34333511// in time (eraser or pen if a device is turned around).
     
    35983676        return;
    35993677
    3600     QLibrary library(QLatin1String("wintab32"));
     3678    QSystemLibrary library(QLatin1String("wintab32"));
    36013679    if (library.load()) {
    36023680        ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
     
    37823860}
    37833861
     3862#ifndef QT_NO_GESTURES
    37843863bool QETWidget::translateGestureEvent(const MSG &, const GESTUREINFO &gi)
    37853864{
     
    38203899    return true;
    38213900}
    3822 
     3901#endif // QT_NO_GESTURES
    38233902
    38243903void  QApplication::setCursorFlashTime(int msecs)
     
    40104089void QApplicationPrivate::initializeMultitouch_sys()
    40114090{
    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"));
    40454102    // MinGW (g++ 3.4.5) accepts only C casts.
    40464103    RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
  • trunk/src/gui/kernel/qapplication_x11.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7575#include "qvarlengtharray.h"
    7676#include "qdebug.h"
    77 #include <private/qunicodetables_p.h>
    7877#include <private/qcrashhandler_p.h>
    7978#include <private/qcolor_p.h>
     
    214213
    215214    "DTWM_IS_RUNNING\0"
    216     "KDE_FULL_SESSION\0"
    217     "KWIN_RUNNING\0"
    218     "KWM_RUNNING\0"
    219     "GNOME_BACKGROUND_PROPERTIES\0"
    220215    "ENLIGHTENMENT_DESKTOP\0"
     216    "_DT_SAVE_MODE\0"
    221217    "_SGI_DESKS_MANAGER\0"
    222218
     
    279275    "_NET_SYSTEM_TRAY_VISUAL\0"
    280276
     277    "_NET_ACTIVE_WINDOW\0"
     278
    281279    // Property formats
    282280    "COMPOUND_TEXT\0"
     
    402400#endif
    403401
     402typedef bool(*QX11FilterFunction)(XEvent *event);
     403
     404Q_GLOBAL_STATIC(QList<QX11FilterFunction>, x11Filters)
     405
     406Q_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
     414Q_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
    404423static bool qt_x11EventFilter(XEvent* ev)
    405424{
     
    407426    if (qApp->filterEvent(ev, &unused))
    408427        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
    409435    return qApp->x11EventFilter(ev);
    410436}
     
    625651static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
    626652{
     653    if (X11->display != dpy) {
     654        // only handle X errors for our display
     655        return 0;
     656    }
     657
    627658    switch (err->error_code) {
    628659    case BadAtom:
     
    632663                || err->resourceid == ATOM(_NET_SUPPORTED)
    633664                || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
    634                 || err->resourceid == ATOM(KDE_FULL_SESSION)
    635                 || err->resourceid == ATOM(KWIN_RUNNING)
    636665                || err->resourceid == ATOM(XdndProxy)
    637666                || err->resourceid == ATOM(XdndAware))) {
     
    665694        }
    666695        if (X11->ignore_badwindow)
    667             return 0;
    668         break;
    669 
    670     case BadMatch:
    671         if (err->request_code == 42 /* X_SetInputFocus */)
    672696            return 0;
    673697        break;
     
    710734        else if (err->request_code == X11->mitshm_major)
    711735            extensionName = "MIT-SHM";
     736#ifndef QT_NO_XKB
     737        else if(err->request_code == X11->xkb_major)
     738            extensionName = "XKEYBOARD";
     739#endif
    712740
    713741        char minor_str[256];
     
    16351663    X11->xinput_eventbase = 0;
    16361664    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;
    16371670
    16381671    // MIT-SHM
     
    21092142#endif // QT_NO_XINPUT
    21102143
     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
    21112171#if !defined(QT_NO_FONTCONFIG)
    21122172        int dpi = 0;
     
    21232183        for (int s = 0; s < ScreenCount(X11->display); ++s) {
    21242184            int subpixel = FC_RGBA_UNKNOWN;
    2125 #if RENDER_MAJOR > 0 || RENDER_MINOR >= 6
     2185#if !defined(QT_NO_XRENDER) && (RENDER_MAJOR > 0 || RENDER_MINOR >= 6)
    21262186            if (X11->use_xrender) {
    21272187                int rsp = XRenderQuerySubpixelOrder(X11->display, s);
     
    21872247        QKeyMapper::changeKeyboard();
    21882248
    2189 #ifndef QT_NO_XKB
    2190         if (qt_keymapper_private()->useXKB) {
    2191             // If XKB is detected, set the GrabsUseXKBState option so input method
    2192             // compositions continue to work (ie. deadkeys)
    2193             unsigned int state = XkbPCF_GrabsUseXKBStateMask;
    2194             (void) XkbSetPerClientControls(X11->display, state, &state);
    2195         }
    2196 #endif // QT_NO_XKB
    2197 
    21982249        // Misc. initialization
    21992250#if 0 //disabled for now..
     
    22282279        X11->desktopVersion = 0;
    22292280
    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.
    22452317                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) {
    22812325                // DTWM is running, meaning most likely CDE is running...
    22822326                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) {
    23032334                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);
    23112365
    23122366#if !defined(QT_NO_STYLE_GTK)
     
    30533107                    X11->time = event->xclient.data.l[1];
    30543108                QWidget *amw = activeModalWidget();
     3109                if (amw && amw->testAttribute(Qt::WA_X11DoNotAcceptFocus))
     3110                    amw = 0;
    30553111                if (amw && !QApplicationPrivate::tryModalHelper(widget, 0)) {
    30563112                    QWidget *p = amw->parentWidget();
     
    32513307        return 0;
    32523308    }
     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
    32533327
    32543328    if (!widget) {                                // don't know this windows
     
    36203694    case MapNotify:                                // window shown
    36213695        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);
    36223701            widget->d_func()->topData()->waitingForMapNotify = 0;
    36233702
     
    36393718                }
    36403719            }
     3720            if (pendingHide) // hide the window
     3721                XWithdrawWindow(X11->display, widget->internalWinId(), widget->x11Info().screen());
    36413722        }
    36423723        break;
     
    36863767                QWidget *newparent = QWidget::find(event->xreparent.parent);
    36873768                if (! newparent || (newparent->windowType() == Qt::Desktop)) {
    3688                     // we dont' know about the new parent (or we've been
     3769                    // we don't know about the new parent (or we've been
    36893770                    // reparented to root), perhaps a window manager
    36903771                    // has been (re)started?  reset the focus model to unknown
     
    52465327        if (isVisible() && data->crect.size() != oldSize) {
    52475328            Q_ASSERT(d->extra->topextra);
    5248             QWidgetBackingStore *bs = d->extra->topextra->backingStore;
     5329            QWidgetBackingStore *bs = d->extra->topextra->backingStore.data();
    52495330            const bool hasStaticContents = bs && bs->hasStaticContents();
    52505331            // If we have a backing store with static contents, we have to disable the top-level
  • trunk/src/gui/kernel/qboxlayout.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qboxlayout.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qclipboard.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    107107    store or retrieve the clipboard contents in response to timer or
    108108    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.
    109115
    110116    \endlist
  • trunk/src/gui/kernel/qclipboard.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qclipboard_mac.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    624624#ifdef DEBUG_PASTEBOARD
    625625    if(fromGlobal)
    626         qDebug("Pasteboard: Syncronize!");
     626        qDebug("Pasteboard: Synchronize!");
    627627#endif
    628628    return fromGlobal;
  • trunk/src/gui/kernel/qclipboard_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qclipboard_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qclipboard_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5151#include "qevent.h"
    5252#include "private/qcore_symbian_p.h"
     53#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
     54#include "txtclipboard.h"
     55#endif
     56#include "txtetext.h"
    5357#include <QtDebug>
    5458
     
    5761QT_BEGIN_NAMESPACE
    5862
    59 //###  Mime Type mapping to UIDs
    60 
    6163const TUid KQtCbDataStream = {0x2001B2DD};
    62 
     64const TInt KPlainTextBegin = 0;
    6365
    6466class QClipboardData
     
    142144        HBufC* stringData = TPtrC(reinterpret_cast<const TUint16*>((*iter).utf16())).AllocLC();
    143145        QByteArray ba = aData->data((*iter));
    144         qDebug() << "copy to clipboard mime: " << *iter << " data: " << ba;
    145146        // mime type
    146147        aStream << TCardinality(stringData->Size());
     
    151152        CleanupStack::PopAndDestroy(stringData);
    152153    }
     154}
     155
     156void 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
     172void 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);
    153191}
    154192
     
    175213        aStream.ReadL(reinterpret_cast<uchar*>(ba.data_ptr()->data),dataSize);
    176214        ba.data_ptr()->size = dataSize;
    177         qDebug() << "paste from clipboard mime: " << mimeType << " data: " << ba;
    178215        aData->setData(mimeType,ba);
    179216    }
     
    193230    if (mode != Clipboard) return 0;
    194231    QClipboardData *d = clipboardData();
     232    bool dataExists(false);
    195233    if (d)
    196234    {
     
    199237            CClipboard* cb = CClipboard::NewForReadingLC(fs);
    200238            Q_ASSERT(cb);
     239            //stream for qt
    201240            RStoreReadStream stream;
    202241            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);
    207260        });
    208261        if (err != KErrNone){
     
    210263        }
    211264
     265        if (dataExists) {
     266            return d->source();
     267        }
    212268    }
    213269    return 0;
     
    224280            RFs fs = qt_s60GetRFs();
    225281            CClipboard* cb = CClipboard::NewForWritingLC(fs);
     282            //stream for qt
    226283            RStoreWriteStream  stream;
    227284            TStreamId stid = stream.CreateLC(cb->Store());
     
    231288            (cb->StreamDictionary()).AssignL(KQtCbDataStream,stid);
    232289            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);
    234298        });
    235299        if (err != KErrNone){
  • trunk/src/gui/kernel/qclipboard_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    142142        clipBoardViewer->createWinId();
    143143        clipBoardViewer->setObjectName(QLatin1String("internal clipboard owner"));
    144         // We dont need this internal widget to appear in QApplication::topLevelWidgets()
     144        // We don't need this internal widget to appear in QApplication::topLevelWidgets()
    145145        if (QWidgetPrivate::allWidgets)
    146146            QWidgetPrivate::allWidgets->remove(clipBoardViewer);
  • trunk/src/gui/kernel/qclipboard_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6666#include "qdesktopwidget.h"
    6767#include "qbitmap.h"
    68 #include "qdatetime.h"
    6968#include "qiodevice.h"
    7069#include "qbuffer.h"
     
    7776#include "qx11info_x11.h"
    7877#include "qimagewriter.h"
     78#include "qelapsedtimer.h"
    7979#include "qvariant.h"
    8080#include "qdnd_p.h"
     
    133133    requestor->createWinId();
    134134    requestor->setObjectName(QLatin1String("internal clipboard requestor"));
    135     // We dont need this internal widgets to appear in QApplication::topLevelWidgets()
     135    // We don't need this internal widgets to appear in QApplication::topLevelWidgets()
    136136    if (QWidgetPrivate::allWidgets) {
    137137        QWidgetPrivate::allWidgets->remove(owner);
     
    457457        if (data.timestamp == CurrentTime) {
    458458            setupOwner();
    459             int dummy = 0;
     459            // We need this value just for completeness, we don't use it.
     460            long dummy = 0;
    460461            Window ownerId = owner->internalWinId();
    461462            XChangeProperty(X11->display, ownerId,
     
    517518bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout)
    518519{
    519     QTime started = QTime::currentTime();
    520     QTime now = started;
     520    QElapsedTimer started;
     521    started.start();
     522    QElapsedTimer now = started;
    521523
    522524    if (QAbstractEventDispatcher::instance()->inherits("QtMotif")
     
    546548            usleep(50000);
    547549
    548             now = QTime::currentTime();
    549             if (started > now)                        // crossed midnight
    550                 started = now;
     550            now.start();
    551551
    552552            QEventLoop::ProcessEventsFlags flags(QEventLoop::ExcludeUserInputEvents
     
    577577                qApp->x11ProcessEvent(&e);
    578578
    579             now = QTime::currentTime();
    580             if ( started > now )                        // crossed midnight
    581                 started = now;
     579            now.start();
    582580
    583581            XFlush(X11->display);
     
    598596
    599597bool 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)
    601599{
    602600    int           maxsize = maxSelectionIncr(display);
     
    644642    }
    645643
    646     int newSize = proplen + (nullterm ? 1 : 0);
     644    int newSize = proplen;
    647645    buffer->resize(newSize);
    648646
     
    650648    VDEBUG("QClipboard: read_property(): buffer resized to %d", buffer->size());
    651649
    652     if (ok) {
     650    if (ok && newSize) {
    653651        // could allocate buffer
    654652
     
    686684            textprop.encoding = *type;
    687685            textprop.format = *format;
    688             textprop.nitems = length;
     686            textprop.nitems = buffer_offset;
    689687            textprop.value = (unsigned char *) buffer->data();
    690688
     
    693691            if (XmbTextPropertyToTextList(display, &textprop, &list_ret,
    694692                         &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);
    697695                memcpy(buffer->data(), list_ret[0], offset);
    698696            }
    699697            if (list_ret) XFreeStringList(list_ret);
    700698        }
    701 
    702         // zero-terminate (for text)
    703         if (nullterm)
    704             buffer->data()[buffer_offset] = '\0';
    705699    }
    706700
     
    745739             event.xproperty.state != PropertyNewValue)
    746740            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)) {
    748742            if (length == 0) {                // no more data, we're done
    749743                if (nullterm) {
     
    776770    requestor = new QWidget(0);
    777771    requestor->setObjectName(QLatin1String("internal clipboard requestor"));
    778     // We dont need this internal widget to appear in QApplication::topLevelWidgets()
     772    // We don't need this internal widget to appear in QApplication::topLevelWidgets()
    779773    if (QWidgetPrivate::allWidgets)
    780774        QWidgetPrivate::allWidgets->remove(requestor);
     
    839833
    840834            (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
    841             return ATOM(INCR);
     835            return property;
    842836        }
    843837
     
    10731067                if (req->property == XNone
    10741068                    || !X11->clipboardReadProperty(req->requestor, req->property, false, &multi_data,
    1075                                                    0, &multi_type, &multi_format, 0)
     1069                                                   0, &multi_type, &multi_format)
    10761070                    || multi_format != 32) {
    10771071                    // MULTIPLE property not formatted correctly
     
    12951289    XSelectInput(dpy, win, PropertyChangeMask);
    12961290
    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)) {
    12981292        if (type == ATOM(INCR)) {
    12991293            int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
     
    15221516#endif
    15231517    if (!owner || (selectionOwner && selectionOwner != owner->internalWinId()) ||
    1524         (!selectionOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))
     1518        (!selectionOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp)))
    15251519        return qt_check_selection_sentinel();
    15261520    return false;
     
    15361530#endif
    15371531    if (!owner || (clipboardOwner && clipboardOwner != owner->internalWinId()) ||
    1538         (!clipboardOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))
     1532        (!clipboardOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp)))
    15391533        return qt_check_clipboard_sentinel();
    15401534    return false;
  • trunk/src/gui/kernel/qcocoaapplication_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8080#include <private/qt_cocoa_helpers_mac_p.h>
    8181
     82QT_USE_NAMESPACE
     83
    8284@implementation NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration))
    8385
     
    108110}
    109111
     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
    110137@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
    111157#endif
  • trunk/src/gui/kernel/qcocoaapplication_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    100100- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader);
    101101- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel;
     102
     103- (void)qt_sendPostedMessage:(NSEvent *)event;
     104- (BOOL)qt_sendEvent:(NSEvent *)event;
    102105@end
     106
     107@interface QNSApplication : NSApplication {
     108}
     109@end
     110
    103111#endif
  • trunk/src/gui/kernel/qcocoaapplicationdelegate_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    180180
    181181// This function will only be called when NSApp is actually running. Before
    182 // that, the kAEQuitApplication apple event will be sendt to
     182// that, the kAEQuitApplication Apple event will be sent to
    183183// QApplicationPrivate::globalAppleEventProcessor in qapplication_mac.mm
    184184- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
     
    202202        // INVARIANT: No event loop is executing. This probably
    203203        // 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
    205205        // terminate now:
    206206        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;
    214210}
    215211
     
    318314}
    319315
     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
    320328@end
    321329#endif
  • trunk/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qcocoamenuloader_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#include <private/qapplication_p.h>
    4848#include <private/qt_mac_p.h>
     49#include <private/qmenubar_p.h>
    4950#include <qmenubar.h>
     51#include <private/qt_cocoa_helpers_mac_p.h>
    5052
    5153QT_FORWARD_DECLARE_CLASS(QCFString)
    5254QT_FORWARD_DECLARE_CLASS(QString)
    5355
     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
    5462QT_USE_NAMESPACE
    5563
     
    5866- (void)awakeFromNib
    5967{
     68    servicesItem = [[appMenu itemWithTitle:@"Services"] retain];
     69    hideAllOthersItem = [[appMenu itemWithTitle:@"Hide Others"] retain];
     70    showAllItem = [[appMenu itemWithTitle:@"Show All"] retain];
     71
    6072    // Get the names in the nib to match the app name set by Qt.
    6173    NSString *appName = reinterpret_cast<const NSString*>(QCFString::toCFStringRef(qAppName()));
     
    7890{
    7991    // The application menu is the menu in the menu bar that contains the
    80     // 'Quit' item. When changing menu bar (e.g when swithing between
     92    // 'Quit' item. When changing menu bar (e.g when switching between
    8193    // windows with different menu bars), we never recreate this menu, but
    8294    // instead pull it out the current menu bar and place into the new one:
     
    119131- (void)dealloc
    120132{
     133    [servicesItem release];
     134    [hideAllOthersItem release];
     135    [showAllItem release];
     136
    121137    [lastAppSpecificItem release];
    122138    [theMenu release];
     
    207223{
    208224    [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
    209243}
    210244
     
    222256    }
    223257}
     258
     259 - (void)orderFrontCharacterPalette:(id)sender
     260 {
     261     [NSApp orderFrontCharacterPalette:sender];
     262 }
    224263@end
    225264#endif // QT_MAC_USE_COCOA
  • trunk/src/gui/kernel/qcocoamenuloader_mac_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6868    IBOutlet NSMenuItem *hideItem;
    6969    NSMenuItem *lastAppSpecificItem;
    70 
     70    NSMenuItem *servicesItem;
     71    NSMenuItem *hideAllOthersItem;
     72    NSMenuItem *showAllItem;
    7173}
    7274- (void)ensureAppMenuInMenu:(NSMenu *)menu;
     
    8688- (IBAction)hide:(id)sender;
    8789- (IBAction)qtDispatcherToQAction:(id)sender;
     90- (void)qtUpdateMenubar;
     91- (void)orderFrontCharacterPalette:(id)sender;
    8892@end
    8993
  • trunk/src/gui/kernel/qcocoapanel_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#import <private/qcocoaview_mac_p.h>
    4848#import <private/qcocoawindowcustomthemeframe_mac_p.h>
     49#import <private/qcocoaapplication_mac_p.h>
    4950#include <private/qapplication_p.h>
    5051#include <private/qbackingstore_p.h>
  • trunk/src/gui/kernel/qcocoapanel_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5555#import <Cocoa/Cocoa.h>
    5656
     57QT_FORWARD_DECLARE_CLASS(QStringList);
     58
    5759@interface QT_MANGLE_NAMESPACE(QCocoaPanel) : NSPanel {
    5860    bool leftButtonIsRightButton;
     61    QStringList *currentCustomDragTypes;
    5962}
    6063
    6164+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
     65- (void)registerDragTypes;
     66
    6267@end
    6368#endif
     69
  • trunk/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5858extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
    5959extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
     60extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp
     61extern void qt_event_request_window_change(QWidget *); // qapplication_mac.mm
     62extern void qt_mac_send_posted_gl_updates(QWidget *widget); // qapplication_mac.mm
     63
     64Q_GLOBAL_STATIC(QPointer<QWidget>, currentDragTarget);
     65
    6066QT_END_NAMESPACE
    6167
     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
    6287- (BOOL)canBecomeKeyWindow
    6388{
    6489    QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)];
     90    if (!widget)
     91        return NO; // This should happen only for qt_root_win
    6592
    6693    bool isToolTip = (widget->windowType() == Qt::ToolTip);
     
    6996}
    7097
     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
    71121- (void)toggleToolbarShown:(id)sender
    72122{
     
    75125}
    76126
    77 /*
    78     The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
    79     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 a
    81     last resort (i.e., this is code that can potentially be removed).
    82  */
    83 - (void)keyDown:(NSEvent *)theEvent
    84 {
    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 *)theEvent
    91 {
    92     bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
    93     if (!keyOK)
    94         [super keyUp:theEvent];
    95 }
    96 
    97127- (void)flagsChanged:(NSEvent *)theEvent
    98128{
     
    107137}
    108138
     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
    109156- (void)sendEvent:(NSEvent *)event
    110157{
     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
    111169    QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
    112 
    113170    // Cocoa can hold onto the window after we've disavowed its knowledge. So,
    114171    // if we get sent an event afterwards just have it go through the super's
     
    126183    // sometimes need to redirect mouse events to the popup.
    127184    QWidget *popup = qAppInstance()->activePopupWidget();
    128     if (popup) {
     185    if (popup && popup != widget) {
    129186        switch([event type])
    130187        {
     
    134191            handled = qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton);
    135192            // 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.
    137194            // (this is standard Qt behavior.)
    138195            break;
     
    173230}
    174231
     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
    175245- (BOOL)makeFirstResponder:(NSResponder *)responder
    176246{
     
    189259}
    190260
     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
    191370- (void)displayIfNeeded
    192371{
     
    205384}
    206385
    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.
     389static 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  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8282extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp
    8383extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm
    84 extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp
    8584extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm
    8685extern 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 }
     86extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
    10287
    10388struct dndenum_mapper
     
    201186}
    202187
     188#ifdef ALIEN_DEBUG
     189static int qCocoaViewCount = 0;
     190#endif
    203191
    204192@implementation QT_MANGLE_NAMESPACE(QCocoaView)
     
    210198        [self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
    211199    }
     200    [self setFocusRingType:NSFocusRingTypeNone];
    212201    composingText = new QString();
     202
     203#ifdef ALIEN_DEBUG
     204    ++qCocoaViewCount;
     205    qDebug() << "init: qCocoaViewCount is" << qCocoaViewCount;
     206#endif
     207
    213208    composing = false;
    214209    sendKeyEvents = true;
    215     currentCustomTypes = 0;
    216210    [self setHidden:YES];
    217211    return self;
     
    228222}
    229223
    230 -(void)registerDragTypes
    231 {
    232     QMacCocoaAutoReleasePool pool;
    233     // Calling registerForDraggedTypes is slow, so only do it once for each widget
    234     // 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 
    258224- (void)resetCursorRects
    259225{
     226    // [NSView addCursorRect] is slow, so bail out early if we can:
     227    if (NSIsEmptyRect([self visibleRect]))
     228        return;
     229
    260230    QWidget *cursorWidget = qwidget;
    261231
     
    273243    QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
    274244    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)) {
    276247        [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
    277248    } else {
     
    299270}
    300271
     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
    301294- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
    302295{
    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.
    305298    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     }
    312299    dragEnterSequence = [sender draggingSequenceNumber];
    313300    [self addDropData:sender];
     
    336323        // widget is not interested in this drag, so ignore this drop data.
    337324        [self removeDropData];
     325        [self changeDraggingCursor:NSDragOperationNone];
    338326        return NSDragOperationNone;
    339327    } else {
     
    357345        }
    358346        QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent);
     347        [self changeDraggingCursor:nsActions];
    359348        return nsActions;
    360349    }
     
    362351- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
    363352{
     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.
    364355    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     }
    371356    // in cases like QFocusFrame, the view under the mouse might
    372357    // not have received the drag enter. Generate a synthetic
     
    375360        [self draggingEntered:sender];
    376361    // drag enter event was rejected, so ignore the move event.
    377     if (dropData == 0)
     362    if (dropData == 0) {
     363        [self changeDraggingCursor:NSDragOperationNone];
    378364        return NSDragOperationNone;
     365    }
    379366    // return last value, if we are still in the answerRect.
    380367    NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
     
    383370    QPoint posDrag(localPoint.x, localPoint.y);
    384371    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    }
    387377    // send drag move event to the widget
    388378    QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
     
    401391        mimeData = QDragManager::self()->dragPrivate()->data;
    402392    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);
    404397    qDMEvent.accept();
    405398    QApplication::sendEvent(qwidget, &qDMEvent);
     
    413406    }
    414407    qt_mac_copy_answer_rect(qDMEvent);
     408    [self changeDraggingCursor:operation];
    415409    return operation;
    416410}
     
    418412- (void)draggingExited:(id < NSDraggingInfo >)sender
    419413{
     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);
    420417    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     }
    428418    // drag enter event was rejected, so ignore the move event.
    429419    if (dropData) {
     
    432422        [self removeDropData];
    433423    }
     424    [self changeDraggingCursor:NSDragOperationEvery];
     425
    434426}
    435427
    436428- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
    437429{
     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.
    438432    NSPoint windowPoint = [sender draggingLocation];
    439433    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     }
    446434    [self addDropData:sender];
    447435
     
    473461    delete composingText;
    474462    [[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
    477469    [super dealloc];
    478470}
     
    480472- (BOOL)isOpaque;
    481473{
     474    if (!qwidgetprivate)
     475        return [super isOpaque];
    482476    return qwidgetprivate->isOpaque;
    483477}
     
    488482}
    489483
    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
    491489{
    492490    return qwidget->testAttribute(Qt::WA_StaticContents);
     
    511509
    512510    // Make sure the opengl context is updated on resize.
    513     if (qwidgetprivate->isGLWidget) {
     511    if (qwidgetprivate && qwidgetprivate->isGLWidget) {
    514512        qwidgetprivate->needWindowChange = true;
    515513        QEvent event(QEvent::MacGLWindowChange);
     
    518516}
    519517
     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
    520530- (void)drawRect:(NSRect)aRect
    521531{
     532    if (!qwidget)
     533        return;
     534
    522535    if (QApplicationPrivate::graphicsSystem() != 0) {
    523         if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) {
     536        if (qwidgetprivate->maybeBackingStore()) {
    524537            // 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;
    527541        }
    528542    }
     
    536550
    537551        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        }
    539561
    540562        if (!qwidget->isWindow() && !qobject_cast<QAbstractScrollArea *>(qwidget->parent())) {
     
    570592        }
    571593
     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) {
    572598        if (engine && !qwidget->testAttribute(Qt::WA_NoSystemBackground)
    573599            && (qwidget->isWindow() || qwidget->autoFillBackground())
     
    589615#endif
    590616        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
    591623        if (!redirectionOffset.isNull())
    592624            QPainter::restoreRedirected(qwidget);
     
    604636- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
    605637{
     638    if (!qwidget)
     639        return NO;
     640
    606641    Q_UNUSED(theEvent);
    607642    return !qwidget->testAttribute(Qt::WA_MacNoClickThrough);
     
    610645- (NSView *)hitTest:(NSPoint)aPoint
    611646{
     647    if (!qwidget)
     648        return [super hitTest:aPoint];
     649
    612650    if (qwidget->testAttribute(Qt::WA_TransparentForMouseEvents))
    613651        return nil; // You cannot hit a transparent for mouse event widget.
     
    617655- (void)updateTrackingAreas
    618656{
     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
    619664    QMacCocoaAutoReleasePool pool;
    620665    if (NSArray *trackingArray = [self trackingAreas]) {
     
    646691- (void)mouseEntered:(NSEvent *)event
    647692{
     693    if (!qwidget)
     694        return;
    648695    if (qwidgetprivate->data.in_destructor)
    649696        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
    654698    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];
    655703        QApplication::sendEvent(qwidget, &enterEvent);
    656704        qt_mouseover = qwidget;
    657705
    658         // Update cursor and dispatch hover events.
     706        // Update cursor icon:
    659707        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            }
    664723        }
    665724    }
     
    668727- (void)mouseExited:(NSEvent *)event
    669728{
     729    if (!qwidget)
     730        return;
     731
    670732    QEvent leaveEvent(QEvent::Leave);
    671733    NSPoint globalPoint = [[event window] convertBaseToScreen:[event locationInWindow]];
     
    686748- (void)flagsChanged:(NSEvent *)theEvent
    687749{
     750    if (!qwidget)
     751        return;
     752
    688753    QWidget *widgetToGetKey = qwidget;
    689754
     
    697762- (void)mouseMoved:(NSEvent *)theEvent
    698763{
     764    if (!qwidget)
     765        return;
     766
    699767    // We always enable mouse tracking for all QCocoaView-s. In cases where we have
    700768    // child views, we will receive mouseMoved for both parent & the child (if
     
    816884        // Since deviceDelta is delivered as pixels rather than degrees, we need to
    817885        // 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;
    823892    } else {
    824893        // carbonEventKind == kEventMouseWheelMoved
     
    871940    }
    872941#endif //QT_NO_WHEELEVENT
    873 
    874     if (!wheelOK) {
    875         return [super scrollWheel:theEvent];
    876     }
    877942}
    878943
     
    919984        return;
    920985
     986#ifndef QT_NO_GESTURES
    921987    QNativeGestureEvent qNGEvent;
    922988    qNGEvent.gestureType = QNativeGestureEvent::Zoom;
     
    925991    qNGEvent.percentage = [event magnification];
    926992    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     993#endif // QT_NO_GESTURES
    927994}
    928995
     
    932999        return;
    9331000
     1001#ifndef QT_NO_GESTURES
    9341002    QNativeGestureEvent qNGEvent;
    9351003    qNGEvent.gestureType = QNativeGestureEvent::Rotate;
     
    9381006    qNGEvent.percentage = -[event rotation];
    9391007    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     1008#endif // QT_NO_GESTURES
    9401009}
    9411010
     
    9451014        return;
    9461015
     1016#ifndef QT_NO_GESTURES
    9471017    QNativeGestureEvent qNGEvent;
    9481018    qNGEvent.gestureType = QNativeGestureEvent::Swipe;
     
    9581028        qNGEvent.angle = 270.0f;
    9591029    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     1030#endif // QT_NO_GESTURES
    9601031}
    9611032
     
    9651036        return;
    9661037
     1038#ifndef QT_NO_GESTURES
    9671039    QNativeGestureEvent qNGEvent;
    9681040    qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
     
    9701042    qNGEvent.position = flipPoint(p).toPoint();
    9711043    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     1044#endif // QT_NO_GESTURES
    9721045}
    9731046
     
    9771050        return;
    9781051
     1052#ifndef QT_NO_GESTURES
    9791053    QNativeGestureEvent qNGEvent;
    9801054    qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
     
    9821056    qNGEvent.position = flipPoint(p).toPoint();
    9831057    qt_sendSpontaneousEvent(qwidget, &qNGEvent);
     1058#endif // QT_NO_GESTURES
    9841059}
    9851060
     
    9871062{
    9881063    Q_UNUSED(note);
     1064    if (!qwidget)
     1065        return;
    9891066    if (qwidget->isWindow())
    9901067        return;
     
    10101087    QMacCocoaAutoReleasePool pool;
    10111088    [super setEnabled:flag];
    1012     if (qwidget->isEnabled() != flag)
     1089    if (qwidget && qwidget->isEnabled() != flag)
    10131090        qwidget->setEnabled(flag);
    10141091}
     
    10211098- (BOOL)acceptsFirstResponder
    10221099{
    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)) {
    10241110        return YES;  // Always do it, so that windows can accept key press events.
     1111    }
    10251112    return qwidget->focusPolicy() != Qt::NoFocus;
    10261113}
     
    10281115- (BOOL)resignFirstResponder
    10291116{
     1117    if (!qwidget)
     1118        return NO;
    10301119    // Seems like the following test only triggers if this
    10311120    // view is inside a QMacNativeWidget:
    10321121    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);
    10341133    return YES;
    10351134}
     
    10631162}
    10641163
     1164- (void) qt_clearQWidget
     1165{
     1166    qwidget = 0;
     1167    qwidgetprivate = 0;
     1168}
     1169
    10651170- (BOOL)qt_leftButtonIsRightButton
    10661171{
     
    10991204    if (sendKeyEvents && !composing) {
    11001205        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        }
    11031215    }
    11041216}
     
    11091221    if (sendKeyEvents) {
    11101222        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        }
    11131230    }
    11141231}
     
    11161233- (void)viewWillMoveToWindow:(NSWindow *)window
    11171234{
     1235    if (qwidget == 0)
     1236        return;
     1237
    11181238    if (qwidget->windowFlags() & Qt::MSWindowsOwnDC
    11191239          && (window != [self window])) { // OpenGL Widget
    1120         // Create a stupid ClearDrawable Event
    11211240        QEvent event(QEvent::MacGLClearDrawable);
    11221241        qApp->sendEvent(qwidget, &event);
     
    11261245- (void)viewDidMoveToWindow
    11271246{
     1247    if (qwidget == 0)
     1248        return;
     1249
    11281250    if (qwidget->windowFlags() & Qt::MSWindowsOwnDC && [self window]) {
    11291251        // call update paint event
     
    13211443- (NSArray*) validAttributesForMarkedText
    13221444{
     1445    if (qwidget == 0)
     1446        return nil;
     1447
    13231448    if (!qwidget->testAttribute(Qt::WA_InputMethodEnabled))
    13241449        return nil;  // Not sure if that's correct, but it's saves a malloc.
     
    14711596    [dndParams.view release];
    14721597    [image release];
    1473     dragPrivate()->executed_action = Qt::IgnoreAction;
     1598    if (dragPrivate())
     1599        dragPrivate()->executed_action = Qt::IgnoreAction;
    14741600    object = 0;
    14751601    Qt::DropAction performedAction(qt_mac_mapNSDragOperation(qMacDnDParams()->performedAction));
     
    14931619        }
    14941620    }
     1621    o->setMimeData(0);
     1622    o->deleteLater();
    14951623    return performedAction;
    14961624}
  • trunk/src/gui/kernel/qcocoaview_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8888    bool sendKeyEvents;
    8989    QString *composingText;
    90     QStringList *currentCustomTypes;
    9190    NSInteger dragEnterSequence;
    9291}
     
    9897- (void)draggingExited:(id < NSDraggingInfo >)sender;
    9998- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
    100 - (void)registerDragTypes;
    10199- (void)removeDropData;
    102100- (void)addDropData:(id <NSDraggingInfo>)sender;
     
    106104- (BOOL)isComposing;
    107105- (QWidget *)qt_qwidget;
     106- (void) qt_clearQWidget;
    108107- (BOOL)qt_leftButtonIsRightButton;
    109108- (void)qt_setLeftButtonIsRightButton:(BOOL)isSwapped;
     109- (void)changeDraggingCursor:(NSDragOperation)newOperation;
    110110+ (DnDParams*)currentMouseEvent;
    111111
  • trunk/src/gui/kernel/qcocoawindow_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#import <private/qt_cocoa_helpers_mac_p.h>
    4848#import <private/qcocoawindowcustomthemeframe_mac_p.h>
     49#import <private/qcocoaapplication_mac_p.h>
    4950
    5051#include <QtGui/QWidget>
  • trunk/src/gui/kernel/qcocoawindow_mac_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7474@interface QT_MANGLE_NAMESPACE(QCocoaWindow) : NSWindow {
    7575    bool leftButtonIsRightButton;
     76    QStringList *currentCustomDragTypes;
    7677}
    7778
    7879+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
     80- (void)registerDragTypes;
     81
    7982@end
    8083#endif
  • trunk/src/gui/kernel/qcocoawindowcustomthemeframe_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qcocoawindowcustomthemeframe_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qcocoawindowdelegate_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    203203                                                   & ~Qt::WindowMaximized));
    204204        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);
    205210    }
    206211    NSRect rect = [[window contentView] frame];
     
    270275    QWidget *qwidget = m_windowHash->value([notification object]);
    271276    Q_ASSERT(qwidget);
    272     if (qwidget->isActiveWindow())
    273         return;  // Widget is already active, no need to go through re-activation.
    274 
    275277    onApplicationWindowChangedActivation(qwidget, true);
    276278}
     
    289291    QWidget *qwidget = m_windowHash->value([notification object]);
    290292    Q_ASSERT(qwidget);
    291     if (qwidget->isActiveWindow())
    292         return;  // Widget is already active, no need to go through re-activation
    293 
    294 
    295293    onApplicationWindowChangedActivation(qwidget, true);
    296294}
     
    313311    // saving the current window geometry before the window is maximized
    314312    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        }
    318326    }
    319327    return YES;
     
    387395    return NO;
    388396}
     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
    389417@end
    390418#endif// QT_MAC_USE_COCOA
  • trunk/src/gui/kernel/qcocoawindowdelegate_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    106106        window:(NSWindow *)window withNewSize:(NSSize)proposedSize;
    107107- (QWidget *)qt_qwidgetForWindow:(NSWindow *)window;
     108- (void)syncContentViewFrame: (NSNotification *)notification;
    108109@end
    109110#endif
  • trunk/src/gui/kernel/qcursor.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    142142         \o \inlineimage      cursor-closedhand.png
    143143         \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
    144150    \endtable
    145151
     
    224230    Writes the \a cursor to the \a stream.
    225231
    226     \sa {Format of the QDataStream operators}
     232    \sa {Serializing Qt Data Types}
    227233*/
    228234
     
    251257    Reads the \a cursor from the \a stream.
    252258
    253     \sa {Format of the QDataStream operators}
     259    \sa {Serializing Qt Data Types}
    254260*/
    255261
  • trunk/src/gui/kernel/qcursor.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qcursor_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    115115    c->handle(); //force the cursor to get loaded, if it's not
    116116
    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);
    138129        }
    139130    }
     
    234225void QCursor::setPos(int x, int y)
    235226{
     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
    236236    CGWarpMouseCursorPosition(CGPointMake(x, y));
    237237
     
    250250        qt_sendSpontaneousEvent(widget, &me);
    251251    }
     252#endif
    252253}
    253254
     
    425426        curs.cp.nscursor = [NSCursor closedHandCursor];
    426427        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;
    427440#define QT_USE_APPROXIMATE_CURSORS
    428441#ifdef QT_USE_APPROXIMATE_CURSORS
     
    520533        curs.tc.curs = kThemeClosedHandCursor;
    521534        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;
    522547#define QT_USE_APPROXIMATE_CURSORS
    523548#ifdef QT_USE_APPROXIMATE_CURSORS
  • trunk/src/gui/kernel/qcursor_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qcursor_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qcursor_s60.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4545#include <coecntrl.h>
    4646#include <qcursor.h>
    47 #include <qt_s60_p.h>
     47#include <private/qt_s60_p.h>
    4848#include <qbitmap.h>
    4949#include <w32std.h>
     
    473473        RWsPointerCursor *pcurs = reinterpret_cast<RWsPointerCursor *> (handle);
    474474        node.SetCustomPointerCursor(*pcurs);
    475     }
     475    } else
    476476#ifdef Q_SYMBIAN_HAS_SYSTEM_CURSORS
    477     else {
     477    {
    478478        TInt shape = qt_symbian_translate_cursor_shape(cursor.shape());
    479479        node.SetPointerCursor(shape);
  • trunk/src/gui/kernel/qcursor_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4848#include <qimage.h>
    4949#include <qt_windows.h>
     50#include <private/qapplication_p.h>
    5051
    5152QT_BEGIN_NAMESPACE
     
    471472        return;
    472473    }
     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    }
    473480    default:
    474481        qWarning("QCursor::update: Invalid cursor shape %d", cshape);
  • trunk/src/gui/kernel/qcursor_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4040****************************************************************************/
    4141
     42#include <qdebug.h>
    4243#include <qdatastream.h>
    4344#include <private/qcursor_p.h>
    4445#include <private/qt_x11_p.h>
     46#include <private/qapplication_p.h>
    4547#include <qbitmap.h>
    4648#include <qcursor.h>
     
    5860
    5961#include "qx11info_x11.h"
     62#include <private/qpixmap_x11_p.h>
    6063
    6164QT_BEGIN_NAMESPACE
     
    263266        "left_ptr_watch",
    264267        "openhand",
    265         "closedhand"
     268        "closedhand",
     269        "copy",
     270        "move",
     271        "link"
    266272    };
    267273
    268274#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    }
    271293    if (hcurs)
    272294        return;
    273295#endif // QT_NO_XCURSOR
    274296
    275     static const char cur_blank_bits[] = {
     297    static const uchar cur_blank_bits[] = {
    276298        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    277299        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     
    281303
    282304#ifndef QT_USE_APPROXIMATE_CURSORS
    283     static const char cur_ver_bits[] = {
     305    static const uchar cur_ver_bits[] = {
    284306        0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
    285307        0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
    286308        0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
    287     static const char mcur_ver_bits[] = {
     309    static const uchar mcur_ver_bits[] = {
    288310        0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
    289311        0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
    290312        0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
    291     static const char cur_hor_bits[] = {
     313    static const uchar cur_hor_bits[] = {
    292314        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
    293315        0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
    294316        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    295     static const char mcur_hor_bits[] = {
     317    static const uchar mcur_hor_bits[] = {
    296318        0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
    297319        0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
    298320        0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
    299     static const char cur_bdiag_bits[] = {
     321    static const uchar cur_bdiag_bits[] = {
    300322        0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
    301323        0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
    302324        0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    303     static const char mcur_bdiag_bits[] = {
     325    static const uchar mcur_bdiag_bits[] = {
    304326        0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
    305327        0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
    306328        0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
    307     static const char cur_fdiag_bits[] = {
     329    static const uchar cur_fdiag_bits[] = {
    308330        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
    309331        0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
    310332        0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
    311     static const char mcur_fdiag_bits[] = {
     333    static const uchar mcur_fdiag_bits[] = {
    312334        0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
    313335        0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
    314336        0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
    315     static const char *cursor_bits16[] = {
     337    static const uchar *cursor_bits16[] = {
    316338        cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits,
    317339        cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits,
    318340        0, 0, cur_blank_bits, cur_blank_bits };
    319341
    320     static const char vsplit_bits[] = {
     342    static const uchar vsplit_bits[] = {
    321343        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    322344        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     
    330352        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    331353        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    332     static const char vsplitm_bits[] = {
     354    static const uchar vsplitm_bits[] = {
    333355        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    334356        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
     
    342364        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    343365        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    344     static const char hsplit_bits[] = {
     366    static const uchar hsplit_bits[] = {
    345367        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    346368        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     
    354376        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    355377        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    356     static const char hsplitm_bits[] = {
     378    static const uchar hsplitm_bits[] = {
    357379        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    358380        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     
    366388        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    367389        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    368     static const char whatsthis_bits[] = {
     390    static const uchar whatsthis_bits[] = {
    369391        0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
    370392        0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
     
    378400        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    379401        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
    380     static const char whatsthism_bits[] = {
     402    static const uchar whatsthism_bits[] = {
    381403        0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
    382404        0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
     
    390412        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    391413        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
    392     static const char busy_bits[] = {
     414    static const uchar busy_bits[] = {
    393415        0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
    394416        0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
     
    402424        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    403425        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    404     static const char busym_bits[] = {
     426    static const uchar busym_bits[] = {
    405427        0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
    406428        0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
     
    415437        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    416438
    417     static const char * const cursor_bits32[] = {
     439    static const uchar * const cursor_bits32[] = {
    418440        vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
    419441        0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
    420442    };
    421443
    422     static const char forbidden_bits[] = {
     444    static const uchar forbidden_bits[] = {
    423445        0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
    424446        0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
     
    426448        0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
    427449
    428     static const char forbiddenm_bits[] = {
     450    static const uchar forbiddenm_bits[] = {
    429451        0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
    430452        0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
     
    432454        0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
    433455
    434     static const char openhand_bits[] = {
     456    static const uchar openhand_bits[] = {
    435457        0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
    436458        0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
    437459        0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
    438     static const char openhandm_bits[] = {
     460    static const uchar openhandm_bits[] = {
    439461       0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
    440462       0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
    441463       0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
    442     static const char closedhand_bits[] = {
     464    static const uchar closedhand_bits[] = {
    443465        0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
    444466        0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
    445467        0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
    446     static const char closedhandm_bits[] = {
     468    static const uchar closedhandm_bits[] = {
    447469        0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
    448470        0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
    449471        0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
    450472
    451     static const char * const cursor_bits20[] = {
     473    static const uchar * const cursor_bits20[] = {
    452474        forbidden_bits, forbiddenm_bits
    453475    };
     
    463485        fg.blue  = 0;
    464486        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);
    467489        hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
    468490    } else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor)
     
    476498        fg.blue  = 0;
    477499        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);
    480502        int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor
    481503                  || cshape == Qt::BusyCursor) ? 0 : 16;
     
    490512        fg.blue  = 0;
    491513        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);
    494516        hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 10, 10);
    495517    } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
     
    502524        fg.blue  = 0;
    503525        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));
    506541        hcurs = XCreatePixmapCursor(dpy, pm, pmm, &fg, &bg, 8, 8);
    507542    }
     
    578613        sh = XC_watch;
    579614        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;
    580624#endif /* QT_USE_APPROXIMATE_CURSORS */
    581625    default:
  • trunk/src/gui/kernel/qdesktopwidget.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qdesktopwidget.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qdesktopwidget.qdoc

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    77** This file is part of the documentation of the Qt Toolkit.
    88**
    9 ** $QT_BEGIN_LICENSE:LGPL$
     9** $QT_BEGIN_LICENSE:FDL$
    1010** Commercial Usage
    1111** Licensees holding valid Qt Commercial licenses may use this file in
    1212** 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.
    3521**
    3622** If you have questions regarding the use of this file, please contact
  • trunk/src/gui/kernel/qdesktopwidget_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qdesktopwidget_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qdesktopwidget_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qdesktopwidget_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    104104    rects->resize(QDesktopWidgetPrivate::screenCount);
    105105    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());
    106110}
    107111
     
    147151}
    148152
    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
     153const QRect QDesktopWidget::availableGeometry(int screen) const
    156154{
    157155    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
     162const 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}
    160170
    161171int QDesktopWidget::screenNumber(const QWidget * /* widget */) const
  • trunk/src/gui/kernel/qdesktopwidget_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4343#include "qt_windows.h"
    4444#include "qapplication_p.h"
    45 #include "qlibrary.h"
     45#include <private/qsystemlibrary_p.h>
    4646#include <qvector.h>
    4747#include <limits.h>
     
    7777
    7878    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);
    8080    typedef BOOL (WINAPI *EnumFunc)(HDC, LPCRECT, EnumProc, LPARAM);
    8181
     
    108108
    109109
    110 BOOL CALLBACK enumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM)
     110BOOL QT_WIN_CALLBACK enumCallback(HMONITOR hMonitor, HDC, LPRECT, LPARAM)
    111111{
    112112    QDesktopWidgetPrivate::screenCount++;
     
    156156
    157157#ifndef Q_OS_WINCE
    158     QLibrary user32Lib(QLatin1String("user32"));
     158    QSystemLibrary user32Lib(QLatin1String("user32"));
    159159    if (user32Lib.load()) {
    160160        enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors");
     
    174174    getMonitorInfo = 0;
    175175#else
    176     QLibrary coreLib(QLatin1String("coredll"));
     176    QSystemLibrary coreLib(QLatin1String("coredll"));
    177177    if (coreLib.load()) {
    178178        // CE >= 4.0 case
  • trunk/src/gui/kernel/qdesktopwidget_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qdnd.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6161#include <ctype.h>
    6262
     63#include <private/qapplication_p.h>
     64
    6365#ifndef QT_NO_DRAGANDDROP
    6466
    6567QT_BEGIN_NAMESPACE
    66 
    67 // These pixmaps approximate the images in the Windows User Interface Guidelines.
    68 
    69 // XPM
    70 
    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 white
    77 #else
    78 "a        c #FFFFFF",
    79 "X        c #000000", // X11 cursor is traditionally black
    80 #endif
    81 "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 white
    110 #else
    111 "a        c #FFFFFF",
    112 "X        c #000000", // OS/2 cursor is traditionally black
    113 #endif
    114 "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 #endif
    145 
    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 white
    153 "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 #else
    174 "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 #endif
    195 ".............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 white
    213 "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 #else
    234 "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 #endif
    255 ".............aXXXXXXXXXa",
    256 ".............aXXXaaaaXXa",
    257 ".............aXXXXaaaXXa",
    258 ".............aXXXaaaaXXa",
    259 ".............aXXaaaXaXXa",
    260 ".............aXXaaXXXXXa",
    261 ".............aXXaXXXXXXa",
    262 ".............aXXXaXXXXXa",
    263 ".............aXXXXXXXXXa",
    264 ".............aaaaaaaaaaa"};
    26568
    26669#ifndef QT_NO_DRAGANDDROP
     
    332135    Q_ASSERT(!instance);
    333136
    334 #if defined(Q_WS_WIN) || defined(Q_WS_PM)
    335     n_cursor = 4;
    336 #else
    337     n_cursor = 3;
    338 #endif
    339 
    340137#ifdef Q_WS_QWS
    341138    currentActionForOverrideCursor = Qt::IgnoreAction;
    342 #endif
    343     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);
    349139#endif
    350140    object = 0;
     
    374164#endif
    375165    instance = 0;
    376     delete [] pm_cursor;
    377166    delete dropData;
    378167}
     
    391180        return d->customCursors[action];
    392181    else if (action == Qt::MoveAction)
    393         return pm_cursor[0];
     182        return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragMoveCursor);
    394183    else if (action == Qt::CopyAction)
    395         return pm_cursor[1];
     184        return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragCopyCursor);
    396185    else if (action == Qt::LinkAction)
    397         return pm_cursor[2];
     186        return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragLinkCursor);
    398187#ifdef Q_WS_WIN
    399188    else if (action == Qt::IgnoreAction)
    400         return pm_cursor[3];
     189        return QApplicationPrivate::instance()->getPixmapCursor(Qt::ForbiddenCursor);
    401190#endif
    402191    return QPixmap();
  • trunk/src/gui/kernel/qdnd_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    676676            if (atleastOne){
    677677                DisposeDrag(dragRef);
     678                o->setMimeData(0);
     679                o->deleteLater();
    678680                return action;
    679681            }
     
    683685        GetDragDropAction(dragRef, &ret);
    684686        DisposeDrag(dragRef); //cleanup
     687        o->setMimeData(0);
     688        o->deleteLater();
    685689        return qt_mac_dnd_map_mac_default_action(ret);
    686690    }
  • trunk/src/gui/kernel/qdnd_p.h

    r786 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    283283
    284284private:
    285     QPixmap *pm_cursor;
    286     int n_cursor;
    287285#ifdef Q_WS_QWS
    288286    Qt::DropAction currentActionForOverrideCursor;
  • trunk/src/gui/kernel/qdnd_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    193193
    194194    switch(e->type()) {
     195        case QEvent::ShortcutOverride:
     196            // prevent accelerators from firing while dragging
     197            e->accept();
     198            return true;
    195199
    196200        case QEvent::KeyPress:
  • trunk/src/gui/kernel/qdnd_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qdnd_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    516516//                    IDropSource Methods
    517517//---------------------------------------------------------------------
    518 STDMETHODIMP
     518QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP
    519519QOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
    520520{
     
    525525    if (fEscapePressed) {
    526526        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
    528532        return ResultFromScode(DRAGDROP_S_DROP);
    529533    } 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)
    539535        if (currentButtons == Qt::NoButton) {
    540536            currentButtons = keystate_to_mousebutton(grfKeyState);
     
    550546}
    551547
    552 STDMETHODIMP
     548QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP
    553549QOleDropSource::GiveFeedback(DWORD dwEffect)
    554550{
     
    631627//---------------------------------------------------------------------
    632628
    633 STDMETHODIMP
     629QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP
    634630QOleDropTarget::DragEnter(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
    635631{
     
    693689}
    694690
    695 STDMETHODIMP
     691QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP
    696692QOleDropTarget::DragOver(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
    697693{
     
    763759}
    764760
    765 STDMETHODIMP
     761QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP
    766762QOleDropTarget::DragLeave()
    767763{
     
    790786#define KEY_STATE_BUTTON_MASK (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)
    791787
    792 STDMETHODIMP
     788QT_ENSURE_STACK_ALIGNED_FOR_SSE STDMETHODIMP
    793789QOleDropTarget::Drop(LPDATAOBJECT /*pDataObj*/, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
    794790{
  • trunk/src/gui/kernel/qdnd_x11.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5252#include "qdesktopwidget.h"
    5353#include "qevent.h"
    54 #include "qdatetime.h"
    5554#include "qiodevice.h"
    5655#include "qpointer.h"
    5756#include "qcursor.h"
     57#include "qelapsedtimer.h"
    5858#include "qvariant.h"
    5959#include "qvector.h"
     
    6565
    6666#include "qdnd_p.h"
     67#include "qapplication_p.h"
    6768#include "qt_x11_p.h"
    6869#include "qx11info_x11.h"
     
    11121113}
    11131114
    1114 
     1115// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8.
     1116static 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}
    11151129
    11161130void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
     
    11591173        if (!dropData)
    11601174            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        }
    11611180
    11621181        QDropEvent de(qt_xdnd_current_position, possible_actions, dropData,
     
    13001319    }
    13011320
     1321    if (e->type() == QEvent::ShortcutOverride) {
     1322        // prevent accelerators from firing while dragging
     1323        e->accept();
     1324        return true;
     1325    }
     1326
    13021327    if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
    13031328        QKeyEvent *ke = ((QKeyEvent*)e);
     
    13411366#ifndef QT_NO_CURSOR
    13421367        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);
    13461371#endif
    13471372    }
     
    18631888        Atom type;
    18641889
    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)) {
    18661891            if (type == ATOM(INCR)) {
    18671892                int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0;
     
    19121937        QApplication::flush();
    19131938
    1914         QTime started = QTime::currentTime();
    1915         QTime now = started;
     1939        QElapsedTimer timer;
     1940        timer.start();
    19161941        do {
    19171942            XEvent event;
    19181943            if (XCheckTypedEvent(X11->display, ClientMessage, &event))
    19191944                qApp->x11ProcessEvent(&event);
    1920 
    1921             now = QTime::currentTime();
    1922             if (started > now) // crossed midnight
    1923                 started = now;
    19241945
    19251946            // sleep 50 ms, so we don't use up CPU cycles all the time.
     
    19281949            usleep_tv.tv_usec = 50000;
    19291950            select(0, 0, 0, 0, &usleep_tv);
    1930         } while (object && started.msecsTo(now) < 1000);
     1951        } while (object && timer.hasExpired(1000));
    19311952    }
    19321953
  • trunk/src/gui/kernel/qdrag.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    254254    loop. Other events are still delivered to the application while
    255255    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.
    257259*/
    258260
  • trunk/src/gui/kernel/qdrag.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qevent.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    19711971  Z-axis, pass zero here.
    19721972
    1973   The \a tangentialPressure paramater contins the tangential pressure of an air
     1973  The \a tangentialPressure parameter contins the tangential pressure of an air
    19741974  brush. If the device does not support tangential pressure, pass 0 here.
    19751975
     
    34223422        dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
    34233423        return dbg.space();
     3424#ifndef QT_NO_GESTURES
    34243425    case QEvent::Gesture:
    34253426        n = "Gesture";
    34263427        break;
     3428#endif
    34273429    default:
    34283430        dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
     
    36263628    \since 4.6
    36273629    \ingroup events
    3628     \ingroup multitouch
     3630    \ingroup touch
    36293631
    36303632    \section1 Enabling Touch Events
     
    36403642    Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
    36413643    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 multiple touch points, and that
     3644    Note that it is possible for a widget to receive events for numerous touch points, and that
    36433645    multiple widgets may be receiving touch events at the same time.
    36443646
     
    37163718    \i As mentioned above, enabling touch events means multiple widgets can be receiving touch
    37173719    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 the
     3720    this gives you great flexibility in designing touch user interfaces. Be aware of the
    37193721    implications. For example, it is possible that the user is moving a QSlider with one finger and
    37203722    pressing a QPushButton with another. The signals emitted by these widgets will be
     
    37283730    \i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
    37293731    \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 multiple active touch
     3732    undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
    37313733    points.
    37323734
     
    42554257}
    42564258
     4259#ifndef QT_NO_GESTURES
    42574260/*!
    42584261    \class QGestureEvent
     
    42784281    QGestureEvent::accept() for each of them, or an event filter consumes the
    42794282    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.
    42804288
    42814289    \sa QGesture, QGestureRecognizer,
     
    45594567#endif
    45604568
     4569#endif // QT_NO_GESTURES
     4570
    45614571QT_END_NAMESPACE
  • trunk/src/gui/kernel/qevent.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6363
    6464class QAction;
     65#ifndef QT_NO_GESTURES
    6566class QGesture;
     67#endif
    6668
    6769class Q_GUI_EXPORT QInputEvent : public QEvent
     
    825827};
    826828
     829#ifndef QT_NO_GESTURES
    827830class QGesture;
    828831class QGestureEventPrivate;
     
    876879    friend class QGestureManager;
    877880};
     881#endif // QT_NO_GESTURES
    878882
    879883QT_END_NAMESPACE
  • trunk/src/gui/kernel/qevent_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    121121};
    122122
     123#ifndef QT_NO_GESTURES
    123124class QNativeGestureEvent : public QEvent
    124125{
     
    165166    QMap<Qt::GestureType, QWidget *> targetWidgets;
    166167};
    167 
     168#endif // QT_NO_GESTURES
    168169
    169170class QFileOpenEventPrivate
  • trunk/src/gui/kernel/qeventdispatcher_glib_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qeventdispatcher_glib_qws_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qeventdispatcher_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9191#ifndef QT_NO_THREAD
    9292#  include "qmutex.h"
     93#endif
    9394
    9495QT_BEGIN_NAMESPACE
    9596
    9697QT_USE_NAMESPACE
    97 #endif
    9898
    9999/*****************************************************************************
     
    493493        case NSOtherMouseUp:     
    494494        case NSOtherMouseDragged:
     495#ifndef QT_NO_GESTURES
    495496#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
    496497        case NSEventTypeGesture: // touch events
     
    501502        case NSEventTypeEndGesture:
    502503#endif
     504#endif // QT_NO_GESTURES
    503505            result    = true;
    504506        break;
     
    549551    Q_D(QEventDispatcherMac);
    550552    d->interrupt = false;
     553
     554#ifdef QT_MAC_USE_COCOA
     555    bool interruptLater = false;
     556    QtMacInterruptDispatcherHelp::cancelInterruptLater();
     557#endif
     558
    551559    // In case we end up recursing while we now process events, make sure
    552560    // that we send remaining posted Qt events before this call returns:
     
    563571        NSEvent* event = 0;
    564572
    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;
    572592
    573593        if (canExec_Qt && canExec_3rdParty) {
    574594            // 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.
    578597            if (NSModalSession session = d->currentModalSession()) {
    579598                QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
    580599                while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
    581600                    qt_mac_waitForMoreModalSessionEvents();
     601
    582602                if (!d->interrupt && session == d->currentModalSessionCached) {
    583                     // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event
     603                    // Someone called [NSApp stopModal:] from outside the event
    584604                    // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
    585605                    // 'session' as well. As a result, we need to restart all internal sessions:
     
    592612            }
    593613            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).
    596616            // 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;
    630641                        }
    631642                    }
     643                    if (!filterEvent(event) && qt_mac_send_event(flags, event, 0))
     644                        retVal = true;
    632645                }
    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        }
    642655#else
    643656        do {
     
    691704    }
    692705
     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
    693714#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
    711718
    712719    return retVal;
     
    738745MacTimerHash QEventDispatcherMacPrivate::macTimerHash;
    739746bool QEventDispatcherMacPrivate::blockSendPostedEvents = false;
     747bool QEventDispatcherMacPrivate::interrupt = false;
    740748
    741749#ifdef QT_MAC_USE_COCOA
     
    743751bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
    744752bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
     753bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false;
    745754NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0;
    746755
    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;
     756void 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];
    758774}
    759775
    760776void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
    761777{
    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:
    765787    int stackSize = cocoaModalSessionStack.size();
    766     for (int i=stackSize-1; i>=0; --i) {
     788    for (int i=0; i<stackSize; ++i) {
    767789        QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
    768790        if (info.session) {
     
    783805    if (cocoaModalSessionStack.isEmpty())
    784806        return 0;
    785 
    786     // Since this code will end up calling our Qt event handler
    787     // (also from beginModalSessionForWindow), we need to block
    788     // 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 flush
    793         // to stop dialogs from blinking/poping in front if a
    794         // modal session restart was needed:
    795         while (NSEvent *event = [NSApp nextEventMatchingMask:0
    796                 untilDate:nil
    797                 inMode:NSDefaultRunLoopMode
    798                 dequeue: YES]) {
    799             qt_mac_send_event(0, event, 0);
    800         }
    801     }
    802807
    803808    int sessionCount = cocoaModalSessionStack.size();
     
    813818            if (!window)
    814819                continue;
     820
     821            ensureNSAppInitialized();
     822            QBoolBlocker block1(blockSendPostedEvents, true);
     823            info.nswindow = window;
     824            [(NSWindow*) info.nswindow retain];
     825            int levelBeforeEnterModal = [window level];
    815826            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];
    816831        }
    817832        currentModalSessionCached = info.session;
    818     }
    819 
     833        cleanupModalSessionsNeeded = false;
     834    }
    820835    return currentModalSessionCached;
    821836}
     
    830845        if (window && [window isKindOfClass:[NSPanel class]]) {
    831846            [static_cast<NSPanel *>(window) setWorksWhenModal:worksWhenModal];
    832             if (worksWhenModal && dialogs[i]->isVisible()){
     847            if (worksWhenModal && [window isVisible]){
    833848                [window orderFront:window];
    834849            }
     
    842857    // active. And make the dialog children of
    843858    // the previous modal dialog unactive again:
     859    QMacCocoaAutoReleasePool pool;
    844860    int size = cocoaModalSessionStack.size();
    845861    if (size > 0){
     
    853869}
    854870
     871void 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
    855905void QEventDispatcherMacPrivate::beginModalSession(QWidget *widget)
    856906{
     
    861911    // currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if
    862912    // 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};
    865915    cocoaModalSessionStack.push(info);
    866916    updateChildrenWorksWhenModal();
     
    878928    for (int i=stackSize-1; i>=0; --i) {
    879929        QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
    880         if (info.widget == widget)
     930        if (info.widget == widget) {
    881931            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    }
    906941}
    907942
     
    909944
    910945QEventDispatcherMacPrivate::QEventDispatcherMacPrivate()
    911     : interrupt(false)
    912946{
    913947}
     
    9681002inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, const bool blockSendPostedEvents)
    9691003{
    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:
    9711009        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);
    9771037    }
    9781038}
     
    9841044    Q_UNUSED(ref);
    9851045    Q_UNUSED(activity);
     1046#ifdef QT_MAC_USE_COCOA
     1047    QApplicationPrivate::qt_initAfterNSAppStarted();
     1048#endif
    9861049    processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
    9871050}
     
    9911054    processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
    9921055}
     1056
     1057#ifdef QT_MAC_USE_COCOA
     1058void 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
    9931068
    9941069void QEventDispatcherMac::interrupt()
     
    10011076    CFRunLoopStop(mainRunLoop());
    10021077#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();
    10171086#endif
    10181087}
     
    10551124}
    10561125
    1057 /////////////////////////////////////////////////////////////////////////////
    1058 
    10591126#ifdef QT_MAC_USE_COCOA
    10601127
     
    10631130QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(false)
    10641131{
    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.
    10681138    deleteLater();
    10691139}
     
    10731143    if (cancelled)
    10741144        return;
    1075 
    10761145    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 NSApp
    1082             // if a session is active; it will stop the session instead.
    1083             // So to stop NSApp, we need to temporarily stop all the
    1084             // sessions, then stop NSApp, then restart the session on top again.
    1085             // We need to do this to ensure that we're not stuck inside
    1086             // [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 changed
    1091     // while processEvents was called manually from within the application:
    10921146    QEventDispatcherMac::instance()->interrupt();
    10931147}
    10941148
    1095 void QtMacInterruptDispatcherHelp::interruptLater() {
    1096     if (instance) {
    1097         instance->cancelled = true;
    1098         delete instance;
    1099     }
     1149void QtMacInterruptDispatcherHelp::cancelInterruptLater()
     1150{
     1151    if (!instance)
     1152        return;
     1153    instance->cancelled = true;
     1154    delete instance;
     1155    instance = 0;
     1156}
     1157
     1158void QtMacInterruptDispatcherHelp::interruptLater()
     1159{
     1160    cancelInterruptLater();
    11001161    instance = new QtMacInterruptDispatcherHelp;
    11011162}
     
    11041165
    11051166QT_END_NAMESPACE
     1167
  • trunk/src/gui/kernel/qeventdispatcher_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    101101    QPointer<QWidget> widget;
    102102    NSModalSession session;
     103    void *nswindow;
    103104} QCocoaModalSessionInfo;
    104105#endif
     
    175176    static bool currentExecIsNSAppRun;
    176177    static bool nsAppRunCalledByQt;
     178    static bool cleanupModalSessionsNeeded;
    177179    static NSModalSession currentModalSessionCached;
     180    static NSModalSession currentModalSession();
    178181    static void updateChildrenWorksWhenModal();
    179     static NSModalSession currentModalSession();
    180     static int activeModalSessionCount();
    181182    static void temporarilyStopAllModalSessions();
    182183    static void beginModalSession(QWidget *widget);
    183184    static void endModalSession(QWidget *widget);
     185    static void cancelWaitForMoreEvents();
     186    static void cleanupModalSessions();
     187    static void ensureNSAppInitialized();
    184188#endif
    185189
     
    191195    QAtomicInt serialNumber;
    192196    int lastSerial;
    193     bool interrupt;
     197    static bool interrupt;
    194198private:
    195199    static Boolean postedEventSourceEqualCallback(const void *info1, const void *info2);
     
    212216    public:
    213217    static void interruptLater();
     218    static void cancelInterruptLater();
    214219};
    215220#endif
  • trunk/src/gui/kernel/qeventdispatcher_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qeventdispatcher_qws_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qeventdispatcher_s60.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4545
    4646QT_BEGIN_NAMESPACE
     47
     48QtEikonEnv::QtEikonEnv()
     49    : m_lastIterationCount(0)
     50    , m_savedStatusCode(KRequestPending)
     51    , m_hasAlreadyRun(false)
     52{
     53}
     54
     55QtEikonEnv::~QtEikonEnv()
     56{
     57}
     58
     59void 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
     85void QtEikonEnv::DoCancel()
     86{
     87    complete();
     88
     89    CEikonEnv::DoCancel();
     90}
     91
     92void 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}
    47103
    48104QEventDispatcherS60::QEventDispatcherS60(QObject *parent)
     
    128184}
    129185
     186// reimpl
     187void QEventDispatcherS60::reactivateDeferredActiveObjects()
     188{
     189    if (S60->qtOwnsS60Environment) {
     190        static_cast<QtEikonEnv *>(CCoeEnv::Static())->complete();
     191    }
     192
     193    QEventDispatcherSymbian::reactivateDeferredActiveObjects();
     194}
     195
    130196QT_END_NAMESPACE
  • trunk/src/gui/kernel/qeventdispatcher_s60_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5757#include "qt_s60_p.h"
    5858
     59#include <eikenv.h>
     60
    5961QT_BEGIN_NAMESPACE
     62
     63class QEventDispatcherS60;
     64
     65class QtEikonEnv : public CEikonEnv
     66{
     67public:
     68    QtEikonEnv();
     69    ~QtEikonEnv();
     70
     71    // from CActive.
     72    void RunL();
     73    void DoCancel();
     74
     75    void complete();
     76
     77private:
     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
     84private:
     85    int m_lastIterationCount;
     86    TInt m_savedStatusCode;
     87    bool m_hasAlreadyRun;
     88};
    6089
    6190class Q_GUI_EXPORT QEventDispatcherS60 : public QEventDispatcherSymbian
     
    73102
    74103    void saveInputEvent(QSymbianControl *control, QWidget *widget, QInputEvent *event);
     104
     105    void reactivateDeferredActiveObjects();
    75106
    76107private:
  • trunk/src/gui/kernel/qeventdispatcher_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qeventdispatcher_x11_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qformlayout.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qformlayout.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qgesture.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4242#include "qgesture.h"
    4343#include "private/qgesture_p.h"
     44#include "private/qstandardgestures_p.h"
     45
     46#ifndef QT_NO_GESTURES
    4447
    4548QT_BEGIN_NAMESPACE
     
    5659    the QGestureRecognizer object that is registered with the application; see
    5760    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.
    5864
    5965    \section1 Gesture Properties
     
    217223    \image pangesture.png
    218224
    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
    220229*/
    221230
     
    252261/*!
    253262    \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
    254284*/
    255285
     
    304334    \since 4.6
    305335    \brief The QPinchGesture class describes a pinch gesture made my the user.
    306     \ingroup multitouch
     336    \ingroup touch
    307337    \ingroup gestures
    308338
    309     A pinch gesture is a form of multitouch user input in which the user typically
     339    A pinch gesture is a form of touch user input in which the user typically
    310340    touches two points on the input device with a thumb and finger, before moving
    311341    them closer together or further apart to change the scale factor, zoom, or level
    312342    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.
    313346
    314347    \image pinchgesture.png
     
    320353    of QPinchGesture in the Qt::GestureUpdated state.
    321354
    322     \sa {Gestures Programming}, QPanGesture, QSwipeGesture
     355    \sa QPanGesture, QSwipeGesture
    323356*/
    324357
     
    387420
    388421    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.
    390423
    391424    \sa totalScaleFactor, lastScaleFactor
     
    570603    \image swipegesture.png
    571604
    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
    573609*/
    574610
     
    613649    swipe angle describes the angle between the direction of motion and the
    614650    x-axis as defined using the standard widget
    615     \l{The Coordinate System}{coordinate system}.
     651    \l{Coordinate System}{coordinate system}.
    616652
    617653    \sa horizontalDirection, verticalDirection
     654*/
     655
     656/*!
     657    \property QSwipeGesture::velocity
     658    \since 4.7.1
     659    \internal
    618660*/
    619661
     
    665707    \ingroup gestures
    666708
    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
    668713*/
    669714
     
    698743    \ingroup gestures
    699744
    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
    701749*/
    702750
     
    725773}
    726774
     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
     783void 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
     796int QTapAndHoldGesture::timeout()
     797{
     798    return QTapAndHoldGesturePrivate::Timeout;
     799}
     800
     801int QTapAndHoldGesturePrivate::Timeout = 700; // in ms
     802
    727803QT_END_NAMESPACE
     804
     805#include <moc_qgesture.cpp>
     806
     807#endif // QT_NO_GESTURES
  • trunk/src/gui/kernel/qgesture.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5050#include <QtCore/qmetatype.h>
    5151
     52#ifndef QT_NO_GESTURES
     53
    5254QT_BEGIN_HEADER
    5355
    5456Q_DECLARE_METATYPE(Qt::GestureState)
     57Q_DECLARE_METATYPE(Qt::GestureType)
    5558
    5659QT_BEGIN_NAMESPACE
     
    111114    Q_PROPERTY(QPointF delta READ delta STORED false)
    112115    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)
    113118
    114119public:
     
    133138    Q_OBJECT
    134139    Q_DECLARE_PRIVATE(QPinchGesture)
     140    Q_FLAGS(ChangeFlags ChangeFlag)
    135141
    136142public:
     
    190196};
    191197
     198Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags)
     199
    192200QT_END_NAMESPACE
    193201
     
    206214    Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false)
    207215    Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle)
     216    Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity)
    208217
    209218public:
     
    251260    void setPosition(const QPointF &pos);
    252261
     262    static void setTimeout(int msecs);
     263    static int timeout();
     264
    253265    friend class QTapAndHoldGestureRecognizer;
    254266};
     
    259271QT_END_HEADER
    260272
     273#endif // QT_NO_GESTURES
     274
    261275#endif // QGESTURE_H
  • trunk/src/gui/kernel/qgesture_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5656#include "qrect.h"
    5757#include "qpoint.h"
    58 #include "qdatetime.h"
    5958#include "qgesture.h"
     59#include "qelapsedtimer.h"
    6060#include "private/qobject_p.h"
     61
     62#ifndef QT_NO_GESTURES
    6163
    6264QT_BEGIN_NAMESPACE
     
    7072        : gestureType(Qt::CustomGesture), state(Qt::NoGesture),
    7173          isHotSpotSet(false), gestureCancelPolicy(0)
    72 
    7374    {
    7475    }
     
    7778    Qt::GestureState state;
    7879    QPointF hotSpot;
     80    QPointF sceneHotSpot;
    7981    uint isHotSpotSet : 1;
    8082    uint gestureCancelPolicy : 2;
     
    8789public:
    8890    QPanGesturePrivate()
    89         : acceleration(0)
     91        : acceleration(0), xVelocity(0), yVelocity(0)
    9092    {
    9193    }
     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; }
    9299
    93100    QPointF lastOffset;
     
    95102    QPoint startPosition;
    96103    qreal acceleration;
     104    qreal xVelocity;
     105    qreal yVelocity;
    97106};
    98107
     
    104113    QPinchGesturePrivate()
    105114        : totalChangeFlags(0), changeFlags(0),
    106           totalScaleFactor(0), lastScaleFactor(0), scaleFactor(0),
     115          totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
    107116          totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0),
    108117          isNewSequence(true)
     
    138147          verticalDirection(QSwipeGesture::NoDirection),
    139148          swipeAngle(0),
    140           started(false), speed(0)
     149          started(false), velocityValue(0)
    141150    {
    142151    }
     152
     153    qreal velocity() const { return velocityValue; }
     154    void setVelocity(qreal value) { velocityValue = value; }
    143155
    144156    QSwipeGesture::SwipeDirection horizontalDirection;
     
    148160    QPoint lastPositions[3];
    149161    bool started;
    150     qreal speed;
    151     QTime time;
     162    qreal velocityValue;
     163    QElapsedTimer time;
    152164};
    153165
     
    176188    QPointF position;
    177189    int timerId;
     190    static int Timeout;
    178191};
    179192
    180193QT_END_NAMESPACE
    181194
     195#endif // QT_NO_GESTURES
     196
    182197#endif // QGESTURE_P_H
  • trunk/src/gui/kernel/qgesturemanager.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6767#endif
    6868
     69#ifndef QT_NO_GESTURES
     70
    6971QT_BEGIN_NAMESPACE
    7072
    7173QGestureManager::QGestureManager(QObject *parent)
    72     : QObject(parent), state(NotGesture), m_lastCustomGestureId(0)
     74    : QObject(parent), state(NotGesture), m_lastCustomGestureId(Qt::CustomGesture)
    7375{
    7476    qRegisterMetaType<Qt::GestureState>();
     
    118120        // generate a new custom gesture id
    119121        ++m_lastCustomGestureId;
    120         type = Qt::GestureType(Qt::CustomGesture + m_lastCustomGestureId);
     122        type = Qt::GestureType(m_lastCustomGestureId);
    121123    }
    122124    m_recognizers.insertMulti(type, recognizer);
     
    128130{
    129131    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    }
    131138    foreach (QGesture *g, m_gestureToRecognizer.keys()) {
    132139        QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g);
    133140        if (list.contains(recognizer)) {
    134141            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;
    149157    }
    150158}
     
    155163    while (iter != m_objectGestures.end()) {
    156164        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
    159181            iter = m_objectGestures.erase(iter);
    160182        } else {
     
    167189QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recognizer, Qt::GestureType type)
    168190{
    169     // if the widget is being deleted we should be carefull and not to
    170     // create a new state, as it will create QWeakPointer which doesnt work
     191    // 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
    171193    // from the destructor.
    172194    if (object->isWidgetType()) {
     
    178200    } else {
    179201        Q_ASSERT(qobject_cast<QGraphicsObject *>(object));
     202        QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(object);
     203        if (graphicsObject->QGraphicsItem::d_func()->inDestructor)
     204            return 0;
    180205#endif
    181206    }
     
    272297    QSet<QGesture *> activeToMaybeGestures = m_activeGestures & newMaybeGestures;
    273298
     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
    274302    // check if a running gesture switched back to not gesture state,
    275303    // i.e. were canceled
    276304    QSet<QGesture *> canceledGestures = m_activeGestures & notGestures;
    277305
    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
    285310    QSet<QGesture *> notMaybeGestures = (startedGestures | triggeredGestures
    286311                                         | finishedGestures | canceledGestures
    287312                                         | 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;
    296314
    297315    Q_ASSERT((startedGestures & finishedGestures).isEmpty());
     
    337355        DEBUG() << "QGestureManager::filterEventThroughContexts:"
    338356                << "\n\tactiveGestures:" << m_activeGestures
    339                 << "\n\tmaybeGestures:" << m_maybeGestures.keys()
     357                << "\n\tmaybeGestures:" << m_maybeGestures
    340358                << "\n\tstarted:" << startedGestures
    341359                << "\n\ttriggered:" << triggeredGestures
    342360                << "\n\tfinished:" << finishedGestures
    343                 << "\n\tcanceled:" << canceledGestures;
     361                << "\n\tcanceled:" << canceledGestures
     362                << "\n\tmaybe-canceled:" << maybeToCanceledGestures;
    344363    }
    345364
     
    362381    // reset gestures that ended
    363382    QSet<QGesture *> endedGestures =
    364             finishedGestures + canceledGestures + undeliveredGestures;
     383            finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures;
    365384    foreach (QGesture *gesture, endedGestures) {
    366385        recycle(gesture);
    367386        m_gestureTargets.remove(gesture);
    368387    }
     388
     389    //Clean up the Gestures
     390    qDeleteAll(m_gesturesToDelete);
     391    m_gesturesToDelete.clear();
     392
    369393    return ret;
    370394}
     
    429453{
    430454    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;
    432457    m_deletedRecognizers.remove(gesture);
    433458    if (m_deletedRecognizers.keys(recognizer).isEmpty()) {
     
    582607                // guess the target widget using the hotspot of the gesture
    583608                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;
    586612                }
    587613            } else {
     
    676702}
    677703
    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 
    698704void QGestureManager::recycle(QGesture *gesture)
    699705{
     
    702708        gesture->setGestureCancelPolicy(QGesture::CancelNone);
    703709        recognizer->reset(gesture);
     710        m_activeGestures.remove(gesture);
    704711    } else {
    705712        cleanupGesturesForRemovedRecognizer(gesture);
     
    709716QT_END_NAMESPACE
    710717
     718#endif // QT_NO_GESTURES
     719
    711720#include "moc_qgesturemanager_p.cpp"
  • trunk/src/gui/kernel/qgesturemanager_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5959#include "qgesturerecognizer.h"
    6060
     61#ifndef QT_NO_GESTURES
     62
    6163QT_BEGIN_NAMESPACE
    6264
     
    8688
    8789protected:
    88     void timerEvent(QTimerEvent *event);
    8990    bool filterEventThroughContexts(const QMultiMap<QObject *, Qt::GestureType> &contexts,
    9091                                    QEvent *event);
     
    9495
    9596    QSet<QGesture *> m_activeGestures;
    96     QHash<QGesture *, QBasicTimer> m_maybeGestures;
     97    QSet<QGesture *> m_maybeGestures;
    9798
    9899    enum State {
     
    101102        MaybeGesture // this means timers are up and waiting for some
    102103                     // more events, and input events are handled by
    103                      // gesture recognizer explicitely
     104                     // gesture recognizer explicitly
    104105    } state;
    105106
    106107    struct ObjectGesture
    107108    {
    108         QWeakPointer<QObject> object;
     109        QObject* object;
    109110        Qt::GestureType gesture;
    110111
     
    112113        inline bool operator<(const ObjectGesture &rhs) const
    113114        {
    114             if (object.data() < rhs.object.data())
     115            if (object < rhs.object)
    115116                return true;
    116117            if (object == rhs.object)
     
    128129    int m_lastCustomGestureId;
    129130
    130     QHash<QGestureRecognizer *, QList<QGesture *> > m_obsoleteGestures;
     131    QHash<QGestureRecognizer *, QSet<QGesture *> > m_obsoleteGestures;
    131132    QHash<QGesture *, QGestureRecognizer *> m_deletedRecognizers;
     133    QSet<QGesture *> m_gesturesToDelete;
    132134    void cleanupGesturesForRemovedRecognizer(QGesture *gesture);
    133135
     
    145147QT_END_NAMESPACE
    146148
     149#endif // QT_NO_GESTURES
     150
    147151#endif // QGESTUREMANAGER_P_H
  • trunk/src/gui/kernel/qgesturerecognizer.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4545#include "private/qgesturemanager_p.h"
    4646
     47#ifndef QT_NO_GESTURES
     48
    4749QT_BEGIN_NAMESPACE
    4850
     
    6062   need to use this class directly. Instances will be created behind the scenes by the
    6163   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.
    6267
    6368   \section1 Recognizing Gestures
     
    162167    Reimplement this function to create a custom QGesture-derived gesture
    163168    object if necessary.
     169
     170    The application takes ownership of the created gesture object.
    164171*/
    165172QGesture *QGestureRecognizer::create(QObject *target)
     
    182189        d->state = Qt::NoGesture;
    183190        d->hotSpot = QPointF();
     191        d->sceneHotSpot = QPointF();
    184192        d->isHotSpotSet = false;
    185193    }
     
    229237
    230238QT_END_NAMESPACE
     239
     240#endif // QT_NO_GESTURES
  • trunk/src/gui/kernel/qgesturerecognizer.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4545#include <QtCore/qglobal.h>
    4646#include <QtCore/qnamespace.h>
     47
     48#ifndef QT_NO_GESTURES
    4749
    4850QT_BEGIN_HEADER
     
    9698QT_END_HEADER
    9799
     100#endif // QT_NO_GESTURES
     101
    98102#endif // QGESTURERECOGNIZER_H
  • trunk/src/gui/kernel/qgridlayout.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qgridlayout.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qguieventdispatcher_glib.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    217217}
    218218
     219void QGuiEventDispatcherGlib::flush()
     220{
     221    XFlush(X11->display);
     222}
     223
    219224QT_END_NAMESPACE
  • trunk/src/gui/kernel/qguieventdispatcher_glib_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7272
    7373    void startingUp();
     74    void flush();
    7475};
    7576
  • trunk/src/gui/kernel/qguifunctions_wince.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7777#endif
    7878
     79#ifndef SHDB_HIDE
     80#define SHDB_HIDE 0x0002
     81#endif
     82
    7983#ifndef SHFS_SHOWTASKBAR
    8084#define SHFS_SHOWTASKBAR 0x0001
     
    113117typedef BOOL (*AygFullScreen)(HWND, DWORD);
    114118typedef BOOL (*AygSHSipInfo)(UINT, UINT, PVOID, UINT);
     119typedef BOOL (*AygSHDoneButton)(HWND, DWORD);
    115120
    116121static AygInitDialog ptrAygInitDialog = 0;
    117122static AygFullScreen ptrAygFullScreen = 0;
    118123static AygSHSipInfo  ptrAygSHSipInfo  = 0;
     124static AygSHDoneButton ptrAygSHDoneButton = 0;
    119125static bool aygResolved = false;
    120126
     
    129135        ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen");
    130136        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}
    142140
    143141int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint)
     
    324322        if (widget->windowFlags() & Qt::WindowOkButtonHint)
    325323            shidi.dwFlags |= SHIDIF_DONEBUTTON;
     324        if (!(widget->windowFlags() & (Qt::WindowCancelButtonHint | Qt::WindowOkButtonHint)))
     325            shidi.dwFlags |= SHIDIF_CANCELBUTTON;
    326326        resolveAygLibs();
    327327        if (ptrAygInitDialog)
     
    332332        MoveWindow(hwnd, r.top, r.left, r.right - r.left, r.bottom - r.top, true);
    333333        SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong (hwnd, GWL_EXSTYLE) | WS_EX_NODRAG);
     334    }
     335}
     336
     337void 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);
    334344    }
    335345}
  • trunk/src/gui/kernel/qguifunctions_wince.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qguiplatformplugin.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8282    if (!plugin)
    8383    {
    84 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
     84#ifndef QT_NO_LIBRARY
    8585
    8686        QString key = QString::fromLocal8Bit(qgetenv("QT_PLATFORM_PLUGIN"));
     
    190190}
    191191
    192 /* return an aditional default palette  (only work on X11) */
     192/* return an additional default palette  (only work on X11) */
    193193QPalette QGuiPlatformPlugin::palette()
    194194{
  • trunk/src/gui/kernel/qguiplatformplugin_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qguivariant.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qkde.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qkde_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qkeymapper.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qkeymapper_mac.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    324324};
    325325
     326static 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
    326352static int qt_mac_get_key(int modif, const QChar &key, int virtualKey)
    327353{
     
    378404            return qt_mac_keyvkey_symbols[i].qt_code;
    379405        }
     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
    380419    }
    381420
     
    634673    if (iso639Code) {
    635674        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();
    653676    } else {
    654677        keyboardInputLocale = QLocale::c();
     
    718741    }
    719742
    720     if (qApp->inputContext() && qApp->inputContext()->isComposing()) {
     743    QInputContext *currentContext = qApp->inputContext();
     744    if (currentContext && currentContext->isComposing()) {
    721745        if (ekind == kEventRawKeyDown) {
    722             QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
     746            QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext);
    723747            if (context)
    724748                context->setLastKeydownEvent(event);
     
    726750        return false;
    727751    }
     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
    728760    //get modifiers
    729761    Qt::KeyboardModifiers modifiers;
     
    734766        return handled_event;
    735767    QString text(ourChar);
    736     /* This is actually wrong - but unfortunatly it is the best that can be
     768    /* This is actually wrong - but unfortunately it is the best that can be
    737769       done for now because of the Control/Meta mapping problems */
    738770    if (modifiers & (Qt::ControlModifier | Qt::MetaModifier)
     
    835867        GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
    836868                          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
    837879        handled_event = QKeyMapper::sendKeyEvent(widget, grab,
    838880                                                 (ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress,
     
    840882                                                 macScanCode, macVirtualKey, macModifiers
    841883#ifdef QT_MAC_USE_COCOA
    842                                                  ,static_cast<bool *>(info)
     884                                                 ,&isAccepted
    843885#endif
    844886                                                 );
     887#ifdef QT_MAC_USE_COCOA
     888        *unicodeKey = (unsigned int)isAccepted;
     889#endif
    845890    }
    846891    return handled_event;
     
    848893
    849894void
    850 QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *)
     895QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *
     896#if defined(QT_MAC_USE_COCOA)
     897                                unicodeKey // unicode character from NSEvent (modifiers applied)
     898#endif
     899                                )
    851900{
    852901    UInt32 macVirtualKey = 0;
     
    876925                keyLayout[macVirtualKey]->qtKey[i] = qtkey;
    877926            }
     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
    878936#ifdef Q_WS_MAC32           
    879937        } else {
  • trunk/src/gui/kernel/qkeymapper_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    193193                           bool grab);
    194194
    195     bool useXKB;
     195    int xkb_currentGroup;
    196196    QXCoreDesc coreDesc;
    197197
  • trunk/src/gui/kernel/qkeymapper_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5353{
    5454    keyboardInputLocale = QLocale::system();
    55     keyboardInputDirection = Qt::RightToLeft;
     55    keyboardInputDirection = keyboardInputLocale.textDirection();
    5656}
    5757
  • trunk/src/gui/kernel/qkeymapper_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    145145    {EKeyDevice1, EStdKeyDevice1, Key_Context2}, // Found by manual testing.
    146146    {EKeyDevice3, EStdKeyDevice3, Key_Select},
    147 //    {EKeyDevice7, EStdKeyDevice7, Key_Camera},  //not supported by qt yet
     147    {EKeyDevice7, EStdKeyDevice7, Key_Camera}, 
    148148    {EKeyApplication0, EStdKeyApplication0, Key_Menu}, // Found by manual testing.
    149149    {EKeyApplication1, EStdKeyApplication1, Key_Launch1}, // Found by manual testing.
     
    162162    {EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE},
    163163    {EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF},
    164 //    {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus},  //not supported by qt yet
     164    {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus},
    165165    {EKeyYes, EStdKeyYes, Key_Yes},
    166166    {EKeyNo, EStdKeyNo, Key_No},
  • trunk/src/gui/kernel/qkeymapper_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5757
    5858// Implemented elsewhere
    59 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
     59extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
    6060
    6161extern Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id);
     
    620620     * returns a DWORD. */
    621621
    622     LCID newLCID = MAKELCID((DWORD)GetKeyboardLayout(0), SORT_DEFAULT);
     622    LCID newLCID = MAKELCID((quintptr)GetKeyboardLayout(0), SORT_DEFAULT);
    623623//    keyboardInputLocale = qt_localeFromLCID(newLCID);
    624624
  • trunk/src/gui/kernel/qkeymapper_x11.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6262#include <ctype.h>
    6363
    64 QT_BEGIN_NAMESPACE
    65 
    66 #ifndef QT_NO_XKB
    67 
    68 // bring in the auto-generated xkbLayoutData
    69 #include "qkeymapper_x11_p.cpp"
    70 
    7164#ifdef QT_LINUXBASE
    7265// LSB's IsKeypadKey define is wrong - see
     
    8174#endif
    8275
    83 static void getLocaleAndDirection(QLocale *locale,
    84                                   Qt::LayoutDirection *direction,
    85                                   const QByteArray &layoutName,
    86                                   const QByteArray &variantName)
     76QT_BEGIN_NAMESPACE
     77
     78#ifndef QT_NO_XKB
     79
     80// bring in the auto-generated xkbLayoutData
     81#include "qkeymapper_x11_p.cpp"
     82
     83QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName)
    8784{
    8885    int i = 0;
    8986    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);
    9589        ++i;
    9690    }
    97     *locale = QLocale::c();
    98     *direction = Qt::LeftToRight;
     91    return QLocale::c();
    9992}
    10093#endif // QT_NO_XKB
    101 
    10294
    10395// from qapplication_x11.cpp
     
    249241
    250242QKeyMapperPrivate::QKeyMapperPrivate()
    251     : keyboardInputDirection(Qt::LeftToRight), useXKB(false)
     243    : keyboardInputDirection(Qt::LeftToRight), xkb_currentGroup(0)
    252244{
    253245    memset(&coreDesc, 0, sizeof(coreDesc));
    254246
    255247#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    }
    267254#endif
    268255}
     
    277264{
    278265#ifndef QT_NO_XKB
    279     if (useXKB)
     266    if (X11->use_xkb)
    280267        return possibleKeysXKB(event);
    281268#endif
     
    487474{
    488475#ifndef QT_NO_XKB
    489     if (useXKB) {
     476    if (X11->use_xkb) {
    490477        // try to determine the layout name and input direction by reading the _XKB_RULES_NAMES property off
    491478        // the root window
     
    516503            } while (p < end);
    517504
    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);
    520512        }
    521513
     
    524516        //     qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ?
    525517
    526         getLocaleAndDirection(&keyboardInputLocale,
    527                               &keyboardInputDirection,
    528                               layoutName,
    529                               variantName);
     518        keyboardInputLocale = q_getKeyboardLocale(layoutName, variantName);
     519        keyboardInputDirection = keyboardInputLocale.textDirection();
    530520
    531521#if 0
     
    535525                 << keyboardInputDirection;
    536526#endif
    537 
    538527        if (data)
    539528            XFree(data);
     
    575564    // look at the modifier mapping, and get the correct masks for alt, meta, super, hyper, and mode_switch
    576565#ifndef QT_NO_XKB
    577     if (useXKB) {
     566    if (X11->use_xkb) {
    578567        XkbDescPtr xkbDesc = XkbGetMap(X11->display, XkbAllClientInfoMask, XkbUseCoreKbd);
    579568        for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) {
     
    11871176    XF86XK_LaunchC,             Qt::Key_LaunchE,
    11881177    XF86XK_LaunchD,             Qt::Key_LaunchF,
     1178    XF86XK_LaunchE,             Qt::Key_LaunchG,
     1179    XF86XK_LaunchF,             Qt::Key_LaunchH,
    11891180
    11901181    // Qtopia keys
  • trunk/src/gui/kernel/qkeymapper_x11_p.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    272272    { "is", "nodeadkeys", Qt::LeftToRight, QLocale::Icelandic, QLocale::Iceland },
    273273    // name = il, description = Israel
    274     { "il", "", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
     274    { "il", "", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
    275275    // name = il:lyx, description = Israel
    276     { "il", "lyx", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
     276    { "il", "lyx", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
    277277    // name = il:si1452, description = Israel
    278     { "il", "si1452", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
     278    { "il", "si1452", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
    279279    // name = il:phonetic, description = Israel
    280     { "il", "phonetic", Qt::LeftToRight, QLocale::Hebrew, QLocale::Israel },
     280    { "il", "phonetic", Qt::RightToLeft, QLocale::Hebrew, QLocale::Israel },
    281281    // name = it, description = Italy
    282282    { "it", "", Qt::LeftToRight, QLocale::Italian, QLocale::Italy },
     
    420420    { "ch", "fr_sundeadkeys", Qt::LeftToRight, QLocale::French, QLocale::Switzerland },
    421421    // name = sy, description = Syria
    422     { "sy", "", Qt::RightToLeft, QLocale::Arabic, QLocale::SyrianArabRepublic },
     422    { "sy", "", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
    423423    // name = sy:syc, description = Syria
    424     { "sy", "syc", Qt::RightToLeft, QLocale::Arabic, QLocale::SyrianArabRepublic },
     424    { "sy", "syc", Qt::RightToLeft, QLocale::Syriac, QLocale::SyrianArabRepublic },
    425425    // 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 },
    427427    // name = tj, description = Tajikistan
    428428    { "tj", "", Qt::LeftToRight, QLocale::Tajik, QLocale::Tajikistan },
  • trunk/src/gui/kernel/qkeysequence.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    391391    const char* name;
    392392} 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.
    393396    { Qt::Key_Space,        QT_TRANSLATE_NOOP("QShortcut", "Space") },
    394397    { Qt::Key_Escape,       QT_TRANSLATE_NOOP("QShortcut", "Esc") },
     
    437440    { Qt::Key_MediaNext,                  QT_TRANSLATE_NOOP("QShortcut", "Media Next") },
    438441    { 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") },
    439446    { Qt::Key_HomePage,                   QT_TRANSLATE_NOOP("QShortcut", "Home Page") },
    440447    { Qt::Key_Favorites,                  QT_TRANSLATE_NOOP("QShortcut", "Favorites") },
     
    573580    // --------------------------------------------------------------
    574581    // 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") },
    583637
    584638    { 0, 0 }
     
    697751    {QKeySequence::PreviousChild,           1,          Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
    698752    {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},
    699754    {QKeySequence::SelectStartOfDocument,   0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Home,    QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
    700755    {QKeySequence::SelectEndOfDocument,     0,          Qt::CTRL | Qt::SHIFT | Qt::Key_End,     QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
     
    862917    commas, e.g. "Alt+X,Ctrl+S,Q".
    863918
     919    \a key should be in NativeText format.
     920
    864921    This constructor is typically used with \link QObject::tr() tr
    865922    \endlink(), so that shortcut keys can be replaced in
     
    875932    d = new QKeySequencePrivate();
    876933    assign(key);
     934}
     935
     936/*!
     937    \since 4.x
     938    Creates a key sequence from the \a key string based on \a format.
     939*/
     940QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format)
     941{
     942    d = new QKeySequencePrivate();
     943    assign(key, format);
    877944}
    878945
     
    10391106                    found = true;
    10401107                } else {
    1041                     qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurences of '&'", qPrintable(text));
     1108                    qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'", qPrintable(text));
    10421109#endif
    10431110                }
     
    10561123    comma; for example, "Alt+X,Ctrl+S,Z". The return value is the
    10571124    number of key codes added.
     1125    \a keys should be in NativeText format.
    10581126*/
    10591127int 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*/
     1141int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)
    10601142{
    10611143    QString keyseq = ks;
     
    10871169        part = keyseq.left(-1 == p ? keyseq.length() : p - diff);
    10881170        keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));
    1089         d->key[n] = decodeString(part);
     1171        d->key[n] = QKeySequencePrivate::decodeString(part, format);
    10901172        ++n;
    10911173    }
     
    15581640QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format)
    15591641{
    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);
    15661643}
    15671644
  • trunk/src/gui/kernel/qkeysequence.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    142142     };
    143143
     144    enum SequenceFormat {
     145        NativeText,
     146        PortableText
     147    };
     148
    144149    QKeySequence();
    145150    QKeySequence(const QString &key);
     151    QKeySequence(const QString &key, SequenceFormat format);
    146152    QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
    147153    QKeySequence(const QKeySequence &ks);
     
    159165        , Identical = ExactMatch
    160166#endif
    161     };
    162 
    163     enum SequenceFormat {
    164         NativeText,
    165         PortableText
    166167    };
    167168
     
    195196    static QString encodeString(int key);
    196197    int assign(const QString &str);
     198    int assign(const QString &str, SequenceFormat format);
    197199    void setKey(int key, int index);
    198200
  • trunk/src/gui/kernel/qkeysequence_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qlayout.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qlayout.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qlayout_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qlayoutengine.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qlayoutengine_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qlayoutitem.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qlayoutitem.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qmacdefines_mac.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qmacgesturerecognizer_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#include "qwidget.h"
    4848#include "qdebug.h"
     49
     50#ifndef QT_NO_GESTURES
    4951
    5052QT_BEGIN_NAMESPACE
     
    261263
    262264QT_END_NAMESPACE
     265
     266#endif // QT_NO_GESTURES
  • trunk/src/gui/kernel/qmacgesturerecognizer_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5858#include "qgesturerecognizer.h"
    5959
     60#ifndef QT_NO_GESTURES
     61
    6062QT_BEGIN_NAMESPACE
    6163
     
    100102QT_END_NAMESPACE
    101103
     104#endif // QT_NO_GESTURES
     105
    102106#endif // QMACSWIPEGESTURERECOGNIZER_MAC_P_H
  • trunk/src/gui/kernel/qmime.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qmime.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qmime_mac.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    155155    \i public.file-url - converts to "text/uri-list"
    156156    \i public.tiff - converts to "application/x-qt-image"
     157    \i public.vcard - converts to "text/plain"
    157158    \i com.apple.traditional-mac-plain-text - converts to "text/plain"
    158159    \i com.apple.pict - converts to "application/x-qt-image"
     
    910911}
    911912
     913class QMacPasteboardMimeVCard : public QMacPasteboardMime
     914{
     915public:
     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
     926QString QMacPasteboardMimeVCard::convertorName()
     927{
     928    return QString("VCard");
     929}
     930
     931bool QMacPasteboardMimeVCard::canConvert(const QString &mime, QString flav)
     932{
     933    return mimeFor(flav) == mime;
     934}
     935
     936QString QMacPasteboardMimeVCard::flavorFor(const QString &mime)
     937{
     938    if(mime.startsWith(QLatin1String("text/plain")))
     939        return QLatin1String("public.vcard");
     940    return QString();
     941}
     942
     943QString QMacPasteboardMimeVCard::mimeFor(QString flav)
     944{
     945    if (flav == QLatin1String("public.vcard"))
     946        return QLatin1String("text/plain");
     947    return QString();
     948}
     949
     950QVariant 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
     960QList<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
    912968#ifdef QT3_SUPPORT
    913969class QMacPasteboardMimeQt3Any : public QMacPasteboardMime {
     
    11171173        new QMacPasteboardMimeUrl;
    11181174        new QMacPasteboardMimeTypeName;
     1175        new QMacPasteboardMimeVCard;
    11191176        //make sure our "non-standard" types are always last! --Sam
    11201177        new QMacPasteboardMimeAny;
  • trunk/src/gui/kernel/qmime_win.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    953953        s.setByteOrder(QDataStream::LittleEndian);// Intel byte order ####
    954954        if (cf == CF_DIB) {
     955            if (img.format() > QImage::Format_ARGB32)
     956                img = img.convertToFormat(QImage::Format_RGB32);
    955957            if (qt_write_dib(s, img))
    956958                return setData(ba, pmedium);
  • trunk/src/gui/kernel/qmotifdnd_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    386386                                     unsigned char protocol_style)
    387387{
    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));
    389392
    390393    receiver_prop.byte_order = DndByteOrder() ;
     
    767770        Atom type;
    768771
    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)) {
    770773        }
    771774    }
  • trunk/src/gui/kernel/qmultitouch_mac.mm

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qmultitouch_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qnsframeview_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qnsthemeframe_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    158158- (char)shouldBeTreatedAsInkEvent:fp8;
    159159- (char)_shouldBeTreatedAsInkEventInInactiveWindow:fp8;
    160 - hitTest:(struct _NSPoint)fp8;
     160//- hitTest:(struct _NSPoint)fp8; // collides with hittest in qcocoasharedwindowmethods_mac_p.h
    161161- (NSRect)_leftGroupRect;
    162162- (NSRect)_rightGroupRect;
  • trunk/src/gui/kernel/qnstitledframe_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qole_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qpalette.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    796796    \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color)
    797797
    798     Sets the brush in the specified color \a group, used for the given
     798    Sets the color in the specified color \a group, used for the given
    799799    color \a role, to the specified solid \a color.
    800800
     
    869869    Returns true (slowly) if this palette is different from \a p;
    870870    otherwise returns false (usually quickly).
     871
     872    \note The current ColorGroup is not taken into account when
     873    comparing palettes
     874
     875    \sa operator==()
    871876*/
    872877
     
    874879    Returns true (usually quickly) if this palette is equal to \a p;
    875880    otherwise returns false (slowly).
     881
     882    \note The current ColorGroup is not taken into account when
     883    comparing palettes
     884
     885    \sa operator!=()
    876886*/
    877887bool QPalette::operator==(const QPalette &p) const
  • trunk/src/gui/kernel/qpalette.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsessionmanager.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsessionmanager_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qshortcut.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qshortcut.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qshortcutmap.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qshortcutmap_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsizepolicy.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsizepolicy.qdoc

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    77** This file is part of the documentation of the Qt Toolkit.
    88**
    9 ** $QT_BEGIN_LICENSE:LGPL$
     9** $QT_BEGIN_LICENSE:FDL$
    1010** Commercial Usage
    1111** Licensees holding valid Qt Commercial licenses may use this file in
    1212** 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.
     13** Software or, alternatively, in accordance with the terms contained in a
     14** written agreement between you and Nokia.
    1515**
    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.
    3521**
    3622** If you have questions regarding the use of this file, please contact
  • trunk/src/gui/kernel/qsoftkeymanager.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4444#include "qbitmap.h"
    4545#include "private/qsoftkeymanager_p.h"
    46 #include "private/qobject_p.h"
     46#include "private/qaction_p.h"
    4747#include "private/qsoftkeymanager_common_p.h"
    4848
     
    105105    switch (standardKey) {
    106106    case MenuSoftKey: // FALL-THROUGH
    107         action->setProperty(MENU_ACTION_PROPERTY, QVariant(true)); // TODO: can be refactored away to use _q_action_menubar
     107        QActionPrivate::get(action)->menuActionSoftkeys = true;
    108108    case OkSoftKey:
    109109    case SelectSoftKey:
     
    163163void QSoftKeyManager::updateSoftKeys()
    164164{
     165    QSoftKeyManager::instance()->d_func()->pendingUpdate = true;
    165166    QEvent *event = new QEvent(QEvent::UpdateSoftKeys);
    166167    QApplication::postEvent(QSoftKeyManager::instance(), event);
     
    251252
    252253    d->updateSoftKeys_sys();
     254    d->pendingUpdate = false;
    253255    return true;
    254256}
     
    256258void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action)
    257259{
    258     action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true));
     260    QActionPrivate::get(action)->forceEnabledInSoftkeys = true;
    259261}
    260262
    261263bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action)
    262264{
    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;
    268266}
    269267
     
    280278bool QSoftKeyManager::handleCommand(int command)
    281279{
     280    if (QSoftKeyManager::instance()->d_func()->pendingUpdate)
     281        (void)QSoftKeyManager::instance()->handleUpdateSoftKeys();
     282
    282283    return static_cast<QSoftKeyManagerPrivateS60*>(QSoftKeyManager::instance()->d_func())->handleCommand(command);
    283284}
  • trunk/src/gui/kernel/qsoftkeymanager_common_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7272    QMultiHash<int, QAction*> requestedSoftKeyActions;
    7373    QWidget *initialSoftKeySource;
    74 
     74    bool pendingUpdate;
    7575};
    7676
  • trunk/src/gui/kernel/qsoftkeymanager_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6464class QSoftKeyManagerPrivate;
    6565
    66 const char MENU_ACTION_PROPERTY[] = "_q_menuAction";
    67 const char FORCE_ENABLED_PROPERTY[] = "_q_forceEnabledInSoftkeys";
    68 
    6966class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject
    7067{
  • trunk/src/gui/kernel/qsoftkeymanager_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747#include "private/qt_s60_p.h"
    4848#include "private/qmenu_p.h"
     49#include "private/qaction_p.h"
    4950#include "private/qsoftkeymanager_p.h"
    5051#include "private/qsoftkeymanager_s60_p.h"
     
    265266
    266267            CEikImage* myimage = new (ELeave) CEikImage;
    267             myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transfered
     268            myimage->SetPicture( nBitmap, nMask ); // nBitmap and nMask ownership transferred
    268269
    269270            EikSoftkeyImage::SetImage(cba, *myimage, left); // Takes myimage ownership
     
    385386    QAction *action = realSoftKeyActions.value(command);
    386387    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) {
    389390            QT_TRAP_THROWING(tryDisplayMenuBarL());
    390391        } else if (action->menu()) {
     
    401402                    QMenu *menu = menuAction->menu();
    402403                    if(menu)
    403                         menuBar->addMenu(action->menu());
     404                        menuBar->addMenu(menu);
    404405                    else
    405406                        menuBar->addAction(menuAction);
  • trunk/src/gui/kernel/qsoftkeymanager_s60_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsound.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsound.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsound_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8989QT_USE_NAMESPACE
    9090
    91 @interface QMacSoundDelegate : NSObject<NSSoundDelegate> {
     91@interface QT_MANGLE_NAMESPACE(QMacSoundDelegate) : NSObject<NSSoundDelegate> {
    9292    QSound *qSound; // may be null.
    9393    QAuServerMac* server;
     
    9696@end
    9797
    98 @implementation QMacSoundDelegate
     98@implementation QT_MANGLE_NAMESPACE(QMacSoundDelegate)
    9999-(id)initWithQSound:(QSound*)s:(QAuServerMac*)serv {
    100100    self = [super init];
     
    173173    NSString *nsFileName = const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(fileName)));
    174174    NSSound * const nsSound = [[NSSound alloc] initWithContentsOfFile: nsFileName byReference:YES];
    175     QMacSoundDelegate * const delegate = [[QMacSoundDelegate alloc] initWithQSound:qSound:this];
     175    QT_MANGLE_NAMESPACE(QMacSoundDelegate) * const delegate = [[QT_MANGLE_NAMESPACE(QMacSoundDelegate) alloc] initWithQSound:qSound:this];
    176176    [nsSound setDelegate:delegate];
    177177    [nsFileName release];
  • trunk/src/gui/kernel/qsound_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsound_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsound_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    151151        // We don't have a way to inform about errors -> just decrement loops
    152152        // in order that QSound::isFinished will return true;
    153         while (decLoop(sound)) {}
     153        while (decLoop(sound) > 0) {}
    154154        if (staticPlayingSounds.removeAll(sound))
    155155            delete sound;
  • trunk/src/gui/kernel/qsound_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qsound_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qstackedlayout.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qstackedlayout.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qstandardgestures.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4646#include "qwidget.h"
    4747#include "qabstractscrollarea.h"
     48#include <qgraphicssceneevent.h>
    4849#include "qdebug.h"
     50
     51#ifndef QT_NO_GESTURES
    4952
    5053QT_BEGIN_NAMESPACE
     
    111114            if (d->offset.x() > 10  || d->offset.y() > 10 ||
    112115                d->offset.x() < -10 || d->offset.y() < -10) {
     116                q->setHotSpot(p1.startScreenPos());
    113117                result = QGestureRecognizer::TriggerGesture;
    114118            } else {
     
    191195            d->isHotSpotSet = true;
    192196
     197            QPointF centerPoint = (p1.screenPos() + p2.screenPos()) / 2.0;
    193198            if (d->isNewSequence) {
    194199                d->startPosition[0] = p1.screenPos();
    195200                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            }
    203205            d->centerPoint = centerPoint;
     206
    204207            d->changeFlags |= QPinchGesture::CenterPointChanged;
    205208
    206             const qreal scaleFactor =
    207                     QLineF(p1.screenPos(), p2.screenPos()).length()
    208                     / QLineF(d->startPosition[0],  d->startPosition[1]).length();
    209209            if (d->isNewSequence) {
    210                 d->lastScaleFactor = scaleFactor;
     210                d->scaleFactor = 1.0;
     211                d->lastScaleFactor = 1.0;
    211212            } else {
    212213                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;
    216219            d->changeFlags |= QPinchGesture::ScaleFactorChanged;
    217220
     
    224227            const qreal rotationAngle = startAngle - angle;
    225228            if (d->isNewSequence)
    226                 d->lastRotationAngle = rotationAngle;
     229                d->lastRotationAngle = 0.0;
    227230            else
    228231                d->lastRotationAngle = d->rotationAngle;
     
    263266
    264267    d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF();
    265     d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 0;
     268    d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1;
    266269    d->totalRotationAngle = d->lastRotationAngle = d->rotationAngle = 0;
    267270
     
    301304    switch (event->type()) {
    302305    case QEvent::TouchBegin: {
    303         d->speed = 1;
    304         d->time = QTime::currentTime();
     306        d->velocityValue = 1;
     307        d->time.start();
    305308        d->started = true;
    306309        result = QGestureRecognizer::MayBeGesture;
     
    339342
    340343            const int distance = xDistance >= yDistance ? xDistance : yDistance;
    341             int elapsedTime = d->time.msecsTo(QTime::currentTime());
     344            int elapsedTime = d->time.restart();
    342345            if (!elapsedTime)
    343346                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;
    346348            d->swipeAngle = QLineF(p1.startScreenPos(), p1.screenPos()).angle();
    347349
     
    405407    d->lastPositions[0] = d->lastPositions[1] = d->lastPositions[2] = QPoint();
    406408    d->started = false;
    407     d->speed = 0;
    408     d->time = QTime();
     409    d->velocityValue = 0;
     410    d->time.invalidate();
    409411
    410412    QGestureRecognizer::reset(state);
     
    441443    case QEvent::TouchBegin: {
    442444        d->position = ev->touchPoints().at(0).pos();
     445        q->setHotSpot(ev->touchPoints().at(0).screenPos());
    443446        result = QGestureRecognizer::TriggerGesture;
    444447        break;
     
    507510        q->killTimer(d->timerId);
    508511        d->timerId = 0;
    509         return QGestureRecognizer::Ignore | QGestureRecognizer::ConsumeEventHint;
     512        return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
    510513    }
    511514
    512515    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
    517521    enum { TapRadius = 40 };
    518522
    519523    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);
    522528        if (d->timerId)
    523529            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:
    527551    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
    533553    case QEvent::TouchUpdate:
    534         if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
     554        if (d->timerId && ev->touchPoints().size() == 1) {
    535555            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
    536556            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
    537557            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
    546575    default:
    547         result = QGestureRecognizer::Ignore;
    548         break;
    549     }
    550     return result;
     576        return QGestureRecognizer::Ignore;
     577    }
    551578}
    552579
     
    565592
    566593QT_END_NAMESPACE
     594
     595#endif // QT_NO_GESTURES
  • trunk/src/gui/kernel/qstandardgestures_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5757#include "private/qgesture_p.h"
    5858
     59#ifndef QT_NO_GESTURES
     60
    5961QT_BEGIN_NAMESPACE
    6062
     
    111113QT_END_NAMESPACE
    112114
     115#endif // QT_NO_GESTURES
     116
    113117#endif // QSTANDARDGESTURES_P_H
  • trunk/src/gui/kernel/qt_cocoa_helpers_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    8484#include <private/qt_mac_p.h>
    8585#include <private/qapplication_p.h>
     86#include <private/qcocoaapplication_mac_p.h>
    8687#include <private/qcocoawindow_mac_p.h>
    8788#include <private/qcocoaview_mac_p.h>
     
    138139
    139140extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp;
    140 extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
    141141extern QWidget * mac_mouse_grabber;
    142 extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
     142extern QWidget *qt_button_down; //qapplication_mac.cpp
    143143
    144144void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds)
     
    194194    }
    195195#else
     196    qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
    196197    ShowHideWindowToolbar(wnd, show, false);
    197198#endif
     
    370371
    371372#ifdef QT_MAC_USE_COCOA
     373
     374// Clears the QWidget pointer that each QCocoaView holds.
     375void 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
    372383void qt_dispatchTabletProximityEvent(void * /*NSEvent * */ tabletEvent)
    373384{
     
    643654    QKeyEventEx ke(cocoaEvent2QtEvent([event type]), qtKey, keyMods, text, [event isARepeat], qMax(1, keyLength),
    644655                   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
     660Qt::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}
    649674
    650675// Helper to share code between QCocoaWindow and QCocoaView
     
    659684    EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef]));
    660685    Q_ASSERT(key_event);
     686    unsigned int info = 0;
    661687    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
    664701    if (widgetToGetEvent == 0)
    665702        return false;
     
    670707    if (mustUseCocoaKeyEvent())
    671708        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);
    675711#endif
    676712}
     
    851887    }
    852888
    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);
    854898    qt_sendSpontaneousEvent(widgetToGetEvent, &qme);
    855899
     
    916960        }
    917961    } else {
    918         extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
     962        extern QWidget * qt_button_down; //qapplication_mac.cpp
    919963        QPoint pos;
    920964        widgetToGetMouse = QApplicationPrivate::pickMouseReceiver(qwidget, qglobalPoint,
     
    928972
    929973    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    }
    931988
    932989    EventRef carbonEvent = static_cast<EventRef>(const_cast<void *>([theEvent eventRef]));
     
    938995    NSInteger clickCount = [theEvent clickCount];
    939996    Qt::MouseButtons buttons = 0;
     997    static Qt::MouseButton previousButton = Qt::NoButton;
    940998    {
    941999        UInt32 mac_buttons;
     
    9561014        Q_ASSERT(clickCount > 0);
    9571015#endif
    958         if (clickCount % 2 == 0)
     1016        if (clickCount % 2 == 0 && (previousButton == Qt::NoButton || previousButton == button))
    9591017            eventType = QEvent::MouseButtonDblClick;
    9601018        if (button == Qt::LeftButton && (keyMods & Qt::MetaModifier)) {
     
    9681026            [theView qt_setLeftButtonIsRightButton: false];
    9691027        }
     1028        qt_button_down = 0;
    9701029        break;
    9711030    }
    9721031    [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->localPoint = localPoint;
    9731032    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
    9751046    if (eventType == QEvent::MouseButtonPress && button == Qt::RightButton) {
    9761047        QContextMenuEvent qcme(QContextMenuEvent::Mouse, qlocalPoint, qglobalPoint, keyMods);
    9771048        qt_sendSpontaneousEvent(widgetToGetMouse, &qcme);
    9781049    }
     1050    previousButton = button;
    9791051    return true;
    9801052#endif
     
    10981170}
    10991171
     1172#if QT_MAC_USE_COCOA
     1173void 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
     1214void 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
    11001237void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show)
    11011238{
     1239    if(!window)
     1240        return;
    11021241#if QT_MAC_USE_COCOA
    11031242    QMacCocoaAutoReleasePool pool;
    11041243    OSWindowRef theWindow = static_cast<OSWindowRef>(window);
    11051244    NSToolbar *macToolbar = [theWindow toolbar];
    1106     if (macToolbar)
    1107         [macToolbar setShowsBaselineSeparator: show];
    1108 #endif
     1245    [macToolbar setShowsBaselineSeparator:show];
     1246#endif // QT_MAC_USE_COCOA
    11091247}
    11101248
     
    12911429    [static_cast<NSCursor *>(qt_mac_nsCursorForQCursor(cursor)) set];
    12921430}
     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.
     1436bool 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}
    12931466#endif
    12941467
     
    13061479}
    13071480
     1481void 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.
     1493void 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.
     1519void 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
     1536void 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
    13081553QT_END_NAMESPACE
  • trunk/src/gui/kernel/qt_cocoa_helpers_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7373**
    7474****************************************************************************/
     75
     76#ifndef QT_COCOA_HELPERS_MAC_P_H
     77#define QT_COCOA_HELPERS_MAC_P_H
    7578
    7679//
     
    115118
    116119QT_BEGIN_NAMESPACE
     120
     121enum {
     122    QtCocoaEventSubTypeWakeup       = SHRT_MAX,
     123    QtCocoaEventSubTypePostMessage  = SHRT_MAX-1
     124};
     125
    117126Qt::MouseButtons qt_mac_get_buttons(int buttons);
    118127Qt::MouseButton qt_mac_get_button(EventMouseButton button);
     
    126135void macSendToolbarChangeEvent(QWidget *widget);
    127136void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::HIContentBorderMetrics &metrics);
     137void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widget);
     138void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivate *widget);
    128139void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show);
    129140void * /*NSImage */qt_mac_create_nsimage(const QPixmap &pm);
     
    135146bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent);
    136147void qt_cocoaChangeOverrideCursor(const QCursor &cursor);
     148// These methods exists only for supporting unified mode.
     149void macDrawRectOnTop(void * /*OSWindowRef */ window);
     150void macSyncDrawingOnFirstInvocation(void * /*OSWindowRef */window);
     151void qt_cocoaStackChildWindowOnTopOfOtherChildren(QWidget *widget);
    137152#endif
    138153void qt_mac_menu_collapseSeparators(void * /*NSMenu */ menu, bool collapse);
     
    182197inline NSString *qt_mac_QStringToNSString(const QString &qstr)
    183198{ return [reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr)) autorelease]; }
    184 #endif
     199
     200#ifdef QT_MAC_USE_COCOA
     201class QCocoaPostMessageArgs {
     202public:
     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};
     215bool qt_cocoaPostMessage(id target, SEL selector);
     216#endif
     217
     218#endif
     219
     220void qt_mac_post_retranslateAppMenu();
    185221
    186222QT_END_NAMESPACE
     223
     224#endif // QT_COCOA_HELPERS_MAC_P_H
  • trunk/src/gui/kernel/qt_gui_pch.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qt_mac.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qt_mac_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5858#ifdef __OBJC__
    5959#include <Cocoa/Cocoa.h>
     60#ifdef QT_MAC_USE_COCOA
     61#include <objc/runtime.h>
     62#endif // QT_MAC_USE_COCOA
    6063#endif
    6164
  • trunk/src/gui/kernel/qt_s60_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6363#include "qpointer.h"
    6464#include "qapplication.h"
     65#include "qelapsedtimer.h"
     66#include "QtCore/qthreadstorage.h"
    6567#include <w32std.h>
    6668#include <coecntrl.h>
     
    8688#define Q_SYMBIAN_ECOLOR16MAP TDisplayMode(13)
    8789
     90class Q_AUTOTEST_EXPORT QS60ThreadLocalData
     91{
     92public:
     93    QS60ThreadLocalData();
     94    ~QS60ThreadLocalData();
     95    bool usingCONEinstances;
     96    RWsSession wsSession;
     97    CWsScreenDevice *screenDevice;
     98};
     99
    88100class QS60Data
    89101{
    90102public:
    91103    QS60Data();
     104    QThreadStorage<QS60ThreadLocalData *> tls;
    92105    TUid uid;
    93106    int screenDepth;
     
    103116    int defaultDpiY;
    104117    WId curWin;
    105     int virtualMouseLastKey;
    106118    enum PressedKeys {
    107119        Select = 0x1,
     
    109121        Down = 0x4,
    110122        Left = 0x8,
    111         Up = 0x10
     123        Up = 0x10,
     124        LeftUp = 0x20,
     125        RightUp = 0x40,
     126        RightDown = 0x80,
     127        LeftDown = 0x100
    112128    };
    113129    int virtualMousePressedKeys; // of the above type, but avoids casting problems
    114     int virtualMouseAccel;
     130    int virtualMouseAccelDX;
     131    int virtualMouseAccelDY;
     132    QElapsedTimer virtualMouseAccelTimeout;
    115133    int virtualMouseMaxAccel;
    116134#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
     
    124142    int avkonComponentsSupportTransparency : 1;
    125143    int menuBeingConstructed : 1;
     144    int orientationSet : 1;
    126145    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
    127155    static inline void updateScreenSize();
    128     static inline RWsSession& wsSession();
     156    inline RWsSession& wsSession();
    129157    static inline RWindowGroup& windowGroup();
    130     static inline CWsScreenDevice* screenDevice();
     158    inline CWsScreenDevice* screenDevice();
    131159    static inline CCoeAppUi* appUi();
    132160    static inline CEikMenuBar* menuBar();
     
    137165    static inline CAknContextPane* contextPane();
    138166    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
    140173    TTrapHandler *s60InstalledTrapHandler;
    141174#endif
    142175};
    143176
    144 QS60Data* qGlobalS60Data();
     177Q_AUTOTEST_EXPORT QS60Data* qGlobalS60Data();
    145178#define S60 qGlobalS60Data()
    146179
     
    182215    void setFocusSafely(bool focus);
    183216
     217    bool isControlActive();
     218
    184219#ifdef Q_WS_S60
    185220    void FadeBehindPopup(bool fade){ popupFader.FadeBehindPopup( this, this, fade); }
     
    190225    CCoeControl* FadedComponent(TInt /*aIndex*/) {return this;}
    191226#else
    192     #warning No fallback implementation for QSymbianControl::FadeBehindPopup
     227    // #warning No fallback implementation for QSymbianControl::FadeBehindPopup
    193228    void FadeBehindPopup(bool /*fade*/){ }
    194229#endif
     
    203238    void HandlePointerEvent(const TPointerEvent& aPointerEvent);
    204239    TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType);
     240    TKeyResponse sendSymbianKeyEvent(const TKeyEvent &keyEvent, QEvent::Type type);
    205241    TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent);
     242    TKeyResponse handleVirtualMouse(const TKeyEvent& keyEvent,TEventCode type);
    206243    bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent);
    207244    void sendMouseEvent(
     
    211248            Qt::MouseButton button,
    212249            Qt::KeyboardModifiers modifiers);
     250    void processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure);
    213251    void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
    214252#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
    215253    void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event);
    216254#endif
     255
     256public:
    217257    void handleClientAreaChange();
    218258
     
    223263    QWidget *qwidget;
    224264    QLongTapTimer* m_longTapDetector;
     265    QElapsedTimer m_doubleClickTimer;
    225266    bool m_ignoreFocusChanged : 1;
    226267    bool m_symbianPopupIsOpen : 1;
     
    233274
    234275inline 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{
    237305}
    238306
     
    247315    S60->screenHeightInTwips = params.iTwipsSize.iHeight;
    248316
    249     S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20;
     317    S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 10;
    250318
    251319    TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch;
     
    257325inline RWsSession& QS60Data::wsSession()
    258326{
    259     return CCoeEnv::Static()->WsSession();
     327    if(!tls.hasLocalData()) {
     328        tls.setLocalData(new QS60ThreadLocalData);
     329    }
     330    return tls.localData()->wsSession;
    260331}
    261332
     
    267338inline CWsScreenDevice* QS60Data::screenDevice()
    268339{
    269     return CCoeEnv::Static()->ScreenDevice();
     340    if(!tls.hasLocalData()) {
     341        tls.setLocalData(new QS60ThreadLocalData);
     342    }
     343    return tls.localData()->screenDevice;
    270344}
    271345
     
    314388inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer()
    315389{
    316     return CEikonEnv::Static()->AppUiFactory()->Cba();
     390    return QS60Data::cba;
     391}
     392
     393inline void QS60Data::setButtonGroupContainer(CEikButtonGroupContainer *newCba)
     394{
     395    QS60Data::cba = newCba;
    317396}
    318397#endif // Q_WS_S60
  • trunk/src/gui/kernel/qt_x11_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    332332
    333333struct QX11Data;
    334 extern QX11Data *qt_x11Data;
     334extern Q_GUI_EXPORT QX11Data *qt_x11Data;
    335335
    336336enum DesktopEnvironment {
     
    339339    DE_GNOME,
    340340    DE_CDE,
     341    DE_MEEGO_COMPOSITOR,
    341342    DE_4DWM
    342343};
     
    351352    bool clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout);
    352353    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);
    354355    QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm);
    355356
     
    439440    int xinput_eventbase;
    440441    int xinput_errorbase;
     442
     443    // for XKEYBOARD support
     444    bool use_xkb;
     445    int xkb_major;
     446    int xkb_eventbase;
     447    int xkb_errorbase;
    441448
    442449    QList<QWidget *> deferred_map;
     
    565572
    566573        DTWM_IS_RUNNING,
    567         KDE_FULL_SESSION,
    568         KWIN_RUNNING,
    569         KWM_RUNNING,
    570         GNOME_BACKGROUND_PROPERTIES,
    571574        ENLIGHTENMENT_DESKTOP,
     575        _DT_SAVE_MODE,
    572576        _SGI_DESKS_MANAGER,
    573577
     
    629633
    630634        _NET_SYSTEM_TRAY_VISUAL,
     635
     636        _NET_ACTIVE_WINDOW,
    631637
    632638        // Property formats
  • trunk/src/gui/kernel/qtooltip.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qtooltip.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwhatsthis.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    144144*/
    145145
    146 Q_DECL_IMPORT extern void qDeleteInEventHandler(QObject *o);
     146Q_CORE_EXPORT void qDeleteInEventHandler(QObject *o);
    147147
    148148class QWhatsThat : public QWidget
  • trunk/src/gui/kernel/qwhatsthis.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwidget.cpp

    r786 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6868# include "qt_cocoa_helpers_mac_p.h"
    6969# include "qmainwindow.h"
     70# include "qtoolbar.h"
     71# include <private/qmainwindowlayout_p.h>
    7072#endif
    7173#if defined(Q_WS_QWS)
     
    127129#endif // QT_KEYPAD_NAVIGATION
    128130
     131#ifdef Q_WS_S60
     132#include <aknappui.h>
     133#endif
     134
    129135// widget/widget data creation count
    130136//#define QWIDGET_EXTRA_DEBUG
     
    165171extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
    166172extern 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
     184QWidgetBackingStoreTracker::QWidgetBackingStoreTracker()
     185    :   m_ptr(0)
     186{
     187
     188}
     189
     190QWidgetBackingStoreTracker::~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 */
     201void 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 */
     212void 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 */
     224void 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 */
     239void 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 */
     251void 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}
    167258
    168259QWidgetPrivate::QWidgetPrivate(int version)
     
    203294      , isGLWidget(0)
    204295      , usesDoubleBufferedGLContext(0)
     296#ifndef QT_NO_IM
     297      , inheritsInputMethodHints(0)
     298#endif
    205299#if defined(Q_WS_X11)
    206300      , picture(0)
     
    209303#elif defined(Q_WS_WIN)
    210304      , noPaintOnScreen(0)
     305  #ifndef QT_NO_GESTURES
    211306      , nativeGesturePanEnabled(0)
     307  #endif
    212308#elif defined(Q_WS_MAC)
    213309      , needWindowChange(0)
     310      , hasAlienChildren(0)
    214311      , window_event(0)
    215312      , qd_hd(0)
     
    226323    isWidget = true;
    227324    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
    228330#ifdef QWIDGET_EXTRA_DEBUG
    229331    static int count = 0;
     
    246348}
    247349
     350class QDummyWindowSurface : public QWindowSurface
     351{
     352public:
     353    QDummyWindowSurface(QWidget *window) : QWindowSurface(window) {}
     354    QPaintDevice *paintDevice() { return window(); }
     355    void flush(QWidget *, const QRegion &, const QPoint &) {}
     356};
     357
    248358QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
    249359{
    250360    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;
    254373}
    255374
     
    286405    if (ic)
    287406        return ic;
    288 #endif
    289407    return qApp->inputContext();
     408#else
     409    return 0;
     410#endif
    290411}
    291412
     
    312433  This function sets the input context \a context
    313434  on this widget.
     435
     436  Qt takes ownership of the given input \a context.
    314437
    315438  \sa inputContext()
     
    321444    if (!testAttribute(Qt::WA_InputMethodEnabled))
    322445        return;
     446    if (context == d->ic)
     447        return;
    323448    if (d->ic)
    324449        delete d->ic;
    325450    d->ic = context;
     451    if (d->ic)
     452        d->ic->setParent(this);
    326453#endif
    327454}
     
    639766        \i  mouseMoveEvent() is called whenever the mouse moves while a mouse
    640767            button is held down. This can be useful during drag and drop
    641             operations. If you call setMouseTracking(true), you get mouse move
    642             events even when no buttons are held down. (See also the \l{Drag
    643             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.)
    644771        \i  keyReleaseEvent() is called whenever a key is released and while it
    645772            is held down (if the key is auto-repeating). In that case, the
     
    671798    one of the more specialized handlers above.
    672799
    673     Events and the mechanism used to deliver them are covered in the
    674     \l{Events and Event Filters} document.
     800    Events and the mechanism used to deliver them are covered in
     801    \l{The Event System}.
    675802
    676803    \section1 Groups of Functions and Properties
     
    10111138    \sa windowFlags
    10121139*/
    1013 
    10141140QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
    10151141    : QObject(*new QWidgetPrivate, 0), QPaintDevice()
     
    11061232    }
    11071233    if (customize)
    1108         ; // don't modify window flags if the user explicitely set them.
     1234        ; // don't modify window flags if the user explicitly set them.
    11091235    else if (type == Qt::Dialog || type == Qt::Sheet)
    11101236#ifndef Q_WS_WINCE
     
    11281254
    11291255    Q_ASSERT(allWidgets);
    1130     allWidgets->insert(q);
     1256    if (allWidgets)
     1257        allWidgets->insert(q);
    11311258
    11321259    QWidget *desktopWidget = 0;
     
    11751302        q->setAttribute(Qt::WA_NativeWindow);
    11761303
     1304#ifdef Q_WS_MAC
     1305    q->setAttribute(Qt::WA_NativeWindow);
     1306#endif
     1307
    11771308    q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute()
    11781309    adjustQuitOnCloseAttribute();
     
    11811312
    11821313    //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
    11831322    data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
     1323#endif
    11841324
    11851325    focus_next = focus_prev = q;
     
    12701410
    12711411    if (QWidget *parent = parentWidget()) {
     1412#ifdef Q_WS_MAC
     1413        if (testAttribute(Qt::WA_NativeWindow) == false)
     1414            parent->d_func()->hasAlienChildren = true;
     1415#endif
    12721416        if (type & Qt::Window) {
    12731417            if (!parent->testAttribute(Qt::WA_WState_Created))
     
    13311475    // a real toplevel window needs a backing store
    13321476    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();
    13361478        if (hasBackingStoreSupport())
    1337             d->topData()->backingStore = new QWidgetBackingStore(this);
     1479            d->topData()->backingStore.create(this);
    13381480    }
    13391481
     
    13781520    if (paintingActive())
    13791521        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);
    13801527#endif
    13811528
     
    14401587    }
    14411588
    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)
    14431590    else if (!internalWinId() && isVisible()) {
    14441591        qApp->d_func()->sendSyntheticEnterLeave(this);
     
    14581605        // not have a reference to this widget that will be used later to
    14591606        // 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();
    14621608    }
    14631609#endif
     
    14751621
    14761622    if (d->declarativeData) {
    1477         d->declarativeData->destroyed(this);
     1623        QAbstractDeclarativeData::destroyed(d->declarativeData, this);
    14781624        d->declarativeData = 0;                 // don't activate again in ~QObject
    14791625    }
     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
    14801635
    14811636    if (!d->children.isEmpty())
     
    15291684
    15301685    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);
    15381688    }
    15391689}
     
    15471697        x->icon = 0;
    15481698        x->iconPixmap = 0;
    1549         x->backingStore = 0;
    15501699        x->windowSurface = 0;
    15511700        x->sharedPainter = 0;
     
    15611710        x->inRepaint = false;
    15621711        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
    15631717        createTLSysExtra();
    15641718#ifdef QWIDGET_EXTRA_DEBUG
     
    16261780        if (extra->topextra) {
    16271781            deleteTLSysExtra();
    1628             delete extra->topextra->backingStore;
     1782            extra->topextra->backingStore.destroy();
    16291783            delete extra->topextra->icon;
    16301784            delete extra->topextra->iconPixmap;
     
    23082462{
    23092463    if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
     2464#ifdef ALIEN_DEBUG
     2465        qDebug() << "QWidget::winId: creating native window for" << this;
     2466#endif
    23102467        QWidget *that = const_cast<QWidget*>(this);
    23112468        that->setAttribute(Qt::WA_NativeWindow);
     
    23202477{
    23212478    Q_Q(QWidget);
     2479
     2480#ifdef ALIEN_DEBUG
     2481    qDebug() << "QWidgetPrivate::createWinId for" << q << winid;
     2482#endif
    23222483    const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow);
    23232484    if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
     
    23622523{
    23632524    Q_D(QWidget);
     2525#ifdef ALIEN_DEBUG
     2526    qDebug()  << "QWidget::createWinId" << this;
     2527#endif
    23642528//    qWarning("QWidget::createWinId is obsolete, please fix your code.");
    23652529    d->createWinId();
     
    25082672    QStyle *oldStyle  = q->style();
    25092673#ifndef QT_NO_STYLE_STYLESHEET
    2510     QStyle *origStyle = 0;
     2674    QWeakPointer<QStyle> origStyle;
    25112675#endif
    25122676
     
    25222686
    25232687#ifndef QT_NO_STYLE_STYLESHEET
    2524         origStyle = extra->style;
     2688        origStyle = extra->style.data();
    25252689#endif
    25262690        extra->style = newStyle;
     
    25512715    }
    25522716
     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
    25532725    QEvent e(QEvent::StyleChange);
    25542726    QApplication::sendEvent(q, &e);
     
    25582730
    25592731#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 #endif
    2566 
    2567 #ifndef QT_NO_STYLE_STYLESHEET
    25682732    // dereference the old stylesheet style
    2569     if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle))
     2733    if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data()))
    25702734        proxy->deref();
    25712735#endif
     
    28683032void QWidget::showFullScreen()
    28693033{
     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
    28703043    ensurePolished();
    28713044#ifdef QT3_SUPPORT
     
    29003073    setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen))
    29013074                   | 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
    29023087    show();
    29033088}
     
    29213106                                     | Qt::WindowMaximized
    29223107                                     | 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
    29233120    show();
    29243121}
     
    47334930    direction.
    47344931
     4932    This method no longer affects text layout direction since Qt 4.7.
     4933
    47354934    \sa QApplication::layoutDirection
    47364935*/
     
    47384937{
    47394938    Q_D(QWidget);
     4939
     4940    if (direction == Qt::LayoutDirectionAuto) {
     4941        unsetLayoutDirection();
     4942        return;
     4943    }
    47404944
    47414945    setAttribute(Qt::WA_SetLayoutDirection);
     
    48915095                     const QRegion &sourceRegion, RenderFlags renderFlags)
    48925096{
    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);
    49775098}
    49785099
     
    53345455            if (paintEngine) {
    53355456                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
    53375466                if (sharedPainter)
    53385467                    paintEngine->d_func()->systemClip = toBePainted;
     
    53755504            //restore
    53765505            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
    53775510                restoreRedirected();
    53785511                if (!sharedPainter)
     
    54185551                                , sharedPainter, backingStore);
    54195552    }
     5553}
     5554
     5555void 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
    54205643}
    54215644
     
    55375760    }
    55385761
    5539 
    55405762    QRect effectRect;
    55415763
    5542     if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
     5764    if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)
    55435765        effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
    5544 
    5545     } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
     5766    else if (mode == QGraphicsEffect::PadToTransparentBorder)
    55465767        effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect();
    5547 
    5548     } else {
     5768    else
    55495769        effectRect = sourceRect.toAlignedRect();
    5550 
    5551     }
    55525770
    55535771    if (offset)
    55545772        *offset = effectRect.topLeft();
    55555773
    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 
    55805774    pixmapOffset -= effectRect.topLeft();
    55815775
    55825776    QPixmap pixmap(effectRect.size());
    55835777    pixmap.fill(Qt::transparent);
    5584     m_widget->render(&pixmap, pixmapOffset);
     5778    m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren);
    55855779    return pixmap;
    55865780}
     
    61866380                }
    61876381                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
    61886388                    // Send event to self
    61896389                    QFocusEvent event(QEvent::FocusIn, reason);
     
    64656665    QWidget *fn = first->d_func()->focus_next;
    64666666
    6467     if (fn == second)
     6667    if (fn == second || first == second)
    64686668        return;
    64696669
     
    66946894QByteArray QWidget::saveGeometry() const
    66956895{
     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
    66966908    QByteArray array;
    66976909    QDataStream stream(&array, QIODevice::WriteOnly);
     
    67036915           << majorVersion
    67046916           << minorVersion
     6917#ifdef QT_MAC_USE_COCOA
     6918           << newFramePosition
     6919           << newNormalPosition
     6920#else
    67056921           << frameGeometry()
    67066922           << normalGeometry()
     6923#endif // QT_MAC_USE_COCOA
    67076924           << qint32(QApplication::desktop()->screenNumber(this))
    67086925           << quint8(windowState() & Qt::WindowMaximized)
     
    72817498    bool isEmbedded = false;
    72827499#if !defined QT_NO_GRAPHICSVIEW
    7283     isEmbedded = q->isWindow() && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
     7500    isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
    72847501#else
    72857502    Q_UNUSED(isEmbedded);
     
    73187535    // hidden.
    73197536    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)
    73217538        qApp->d_func()->sendSyntheticEnterLeave(q);
    73227539#endif
     
    73497566    it. It will not be automatically shown when the parent is shown.
    73507567
    7351     To check visiblity, use !isVisible() instead (notice the exclamation mark).
     7568    To check visibility, use !isVisible() instead (notice the exclamation mark).
    73527569
    73537570    isHidden() implies !isVisible(), but a widget can be not visible
     
    74507667            d->show_helper();
    74517668
    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)
    74537670            qApp->d_func()->sendSyntheticEnterLeave(this);
    74547671#endif
     
    75827799            }
    75837800        }
    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)
    75857802        qApp->d_func()->sendSyntheticEnterLeave(widget);
    75867803#endif
     
    76267843        QApplication::quit();
    76277844#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());
    76317847
    76327848    if (quitOnClose) {
    7633         // If there is no non-withdrawn primary window left (except
    7634         // the ones without QuitOnClose or with WA_DontShowOnScreen),
    7635         // we emit the lastWindowClosed signal
     7849        /* if there is no non-withdrawn primary window left (except
     7850           the ones without QuitOnClose), we emit the lastWindowClosed
     7851           signal */
    76367852        QWidgetList list = QApplication::topLevelWidgets();
    76377853        bool lastWindowClosed = true;
    76387854        for (int i = 0; i < list.size(); ++i) {
    76397855            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;
    76457860        }
    76467861        if (lastWindowClosed)
     
    84848699        break;
    84858700    }
     8701#ifndef QT_NO_GESTURES
    84868702    case QEvent::Gesture:
    84878703        event->ignore();
    84888704        break;
     8705#endif
    84898706#ifndef QT_NO_PROPERTIES
    84908707    case QEvent::DynamicPropertyChange: {
     
    85138730  This event handler can be reimplemented to handle state changes.
    85148731
    8515   The state being changed in this event can be retrieved through event \a
    8516   event.
     8732  The state being changed in this event can be retrieved through the \a event
     8733  supplied.
    85178734
    85188735  Change events include: QEvent::ToolBarChange,
     
    86258842        while ((w = QApplication::activePopupWidget()) && w != this){
    86268843            w->close();
    8627             if (QApplication::activePopupWidget() == w) // widget does not want to dissappear
     8844            if (QApplication::activePopupWidget() == w) // widget does not want to disappear
    86288845                w->hide(); // hide at least
    86298846        }
     
    90789295{
    90799296#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;
    90829303#else //QT_NO_IM
    90839304    return 0;
     
    90909311    Q_D(QWidget);
    90919312    d->imHints = hints;
    9092     // Optimisation to update input context only it has already been created.
     9313    // Optimization to update input context only it has already been created.
    90939314    if (d->ic || qApp->d_func()->inputContext) {
    90949315        QInputContext *ic = inputContext();
     
    96349855QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
    96359856{
     9857    if (children.isEmpty())
     9858        return 0;
     9859
     9860#ifdef Q_WS_MAC
    96369861    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
    96389864    bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
    96399865                        && 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
     9875QWidget *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;
    96439889#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;
    96769909    }
    96779910    return 0;
     
    983010063    bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
    983110064
    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)
    983310066    if (newParent && parent && !desktopWidget) {
    983410067        if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings))
     
    985210085        focusWidget()->clearFocus();
    985310086
     10087    QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData();
     10088    QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStore : 0;
     10089
    985410090    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
    985510097    if (desktopWidget)
    985610098        parent = 0;
     
    1031510557#endif // QT3_SUPPORT
    1031610558
    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 */
     10564static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data,
     10565                                  QWidgetPrivate *d)
     10566{
    1034310567    if (attribute < int(8*sizeof(uint))) {
    1034410568        if (on)
     
    1035410578            d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint))));
    1035510579    }
     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*/
     10588void 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);
    1035610609
    1035710610    switch (attribute) {
     
    1041210665        {
    1041310666            // 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);
    1042210672            }
    1042310673            d->macUpdateSizeAttribute();
     
    1048610736    case Qt::WA_PaintOnScreen:
    1048710737        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)
    1048910739        // Recreate the widget if it's already created as an alien widget and
    1049010740        // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
     
    1054210792        d->updateIsOpaque();
    1054310793        break;
     10794    case Qt::WA_X11DoNotAcceptFocus:
     10795        if (testAttribute(Qt::WA_WState_Created))
     10796            d->updateX11AcceptFocus();
     10797        break;
    1054410798#endif
    1054510799    case Qt::WA_DontShowOnScreen: {
     
    1059710851        break;
    1059810852    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)
    1060010854        if (on)
    1060110855            d->registerTouchWindow();
    1060210856#endif
    1060310857        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    }
    1060410894    default:
    1060510895        break;
     
    1095911249#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
    1096011250    Q_D(QWidget);
    10961     // and optimisation to update input context only it has already been created.
     11251    // and optimization to update input context only it has already been created.
    1096211252    if (d->ic || qApp->d_func()->inputContext) {
    1096311253        QInputContext *ic = inputContext();
     
    1178512075    Tells us if it there is currently a reachable widget by keypad navigation in
    1178612076    a certain \a orientation.
    11787     If no navigation is possible, occuring key events in that \a orientation may
    11788     be used to interact with the value in the focussed widget, even though it
     12077    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
    1178912079    currently has not the editFocus.
    1179012080
     
    1180612096    navigation. If there is no QTabWidget, the horizontal key events can be used
    1180712097to
    11808     interact with the value in the focussed widget, even though it currently has
     12098    interact with the value in the focused widget, even though it currently has
    1180912099    not the editFocus.
    1181012100
     
    1200612296*/
    1200712297
     12298#ifndef QT_NO_GESTURES
    1200812299/*!
    1200912300    Subscribes the widget to a given \a gesture with specific \a flags.
     
    1202912320    Q_D(QWidget);
    1203012321    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
    1203612327
    1203712328/*!
     
    1235712648#endif
    1235812649
     12650#if QT_MAC_USE_COCOA
     12651void 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
    1235912672QT_END_NAMESPACE
    1236012673
  • trunk/src/gui/kernel/qwidget.h

    r705 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    361361#endif //QT_NO_GRAPHICSEFFECT
    362362
     363#ifndef QT_NO_GESTURES
    363364    void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
    364365    void ungrabGesture(Qt::GestureType type);
     366#endif
    365367
    366368public Q_SLOTS:
     
    757759    friend class QStyleSheetStyle;
    758760    friend struct QWidgetExceptionCleaner;
     761#ifndef QT_NO_GESTURES
    759762    friend class QGestureManager;
    760763    friend class QWinNativePanGestureRecognizer;
     764#endif // QT_NO_GESTURES
    761765    friend class QWidgetEffectSourcePrivate;
    762766
     
    788792    friend void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp);
    789793    friend void qt_net_remove_user_time(QWidget *tlw);
     794    friend void qt_set_winid_on_widget(QWidget*, Qt::HANDLE);
    790795#endif
    791796
  • trunk/src/gui/kernel/qwidget_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    115115QT_BEGIN_NAMESPACE
    116116
     117// qmainwindow.cpp
     118extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
     119
    117120#define XCOORD_MAX 16383
    118121#define WRECT_MAX 8191
     
    461464bool qt_isGenuineQWidget(const QWidget *window)
    462465{
    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()));
    464473}
    465474
     
    747756}
    748757
     758#ifndef QT_NO_GESTURES
    749759#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
    750760/* We build the release package against the 10.4 SDK.
     
    763773};
    764774#endif
     775#endif // QT_NO_GESTURES
    765776
    766777// window events
     
    10711082        break; }
    10721083
     1084#ifndef QT_NO_GESTURES
    10731085    case kEventClassGesture: {
    10741086        // First, find the widget that was under
     
    11371149        QApplication::sendSpontaneousEvent(widget, &qNGEvent);
    11381150    break; }
     1151#endif // QT_NO_GESTURES
    11391152
    11401153    default:
     
    15901603        QWidget *widget = static_cast<QWidget*>(object);
    15911604        if(qt_mac_is_macdrawer(widget)) {
     1605            bool oldState = widget->testAttribute(Qt::WA_WState_ExplicitShowHide);
    15921606            if(visible) {
    15931607                if (!widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
     
    15951609            } else {
    15961610                widget->hide();
    1597                 widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false);
     1611                if(!oldState)
     1612                    widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false);
    15981613            }
    15991614        }
     
    19131928    else if(popup || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 && type == Qt::SplashScreen))
    19141929        wclass = kModalWindowClass;
    1915     else if(q->testAttribute(Qt::WA_ShowModal) || type == Qt::Dialog)
     1930    else if(type == Qt::Dialog)
    19161931        wclass = kMovableModalWindowClass;
    19171932    else if(type == Qt::ToolTip)
     
    19201935                                 && type == Qt::SplashScreen))
    19211936        wclass = kFloatingWindowClass;
     1937    else if(q->testAttribute(Qt::WA_ShowModal))
     1938        wclass = kMovableModalWindowClass;
    19221939    else
    19231940        wclass = kDocumentWindowClass;
     
    20232040            if((tmp_wattr & known_attribs[i].tag) == known_attribs[i].tag) {
    20242041                tmp_wattr ^= known_attribs[i].tag;
    2025                 qDebug("Qt: internal: * %s %s", known_attribs[i].name,
    2026                         (GetAvailableWindowAttributes(wclass) & known_attribs[i].tag) ? "" : "(*)");
    20272042            }
    20282043        }
     
    22192234}
    22202235#else  // QT_MAC_USE_COCOA
     2236
     2237void 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
    22212271void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWindowRef)
    22222272{
     
    22602310            registerDropSite(true);
    22612311        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];
    22622318    }
    22632319
     
    22912347    }
    22922348
     2349    if (qApp->overrideCursor())
     2350        [windowRef disableCursorRects];
     2351
     2352    setWindowLevel();
    22932353    macUpdateHideOnSuspend();
    22942354    macUpdateOpaqueSizeGrip();
     
    23192379    determineWindowClass();
    23202380    createWindow_sys();
    2321     if (QMainWindowLayout *mwl = qobject_cast<QMainWindowLayout *>(q->layout())) {
     2381
     2382    if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) {
    23222383        mwl->updateHIToolBarStatus();
    23232384    }
     
    25652626    } else {
    25662627        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))) {
    25682638#ifndef QT_MAC_USE_COCOA
    25692639            HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height());
     
    26252695{
    26262696    Q_D(QWidget);
     2697    d->aboutToDestroy();
    26272698    if (!isWindow() && parentWidget())
    26282699        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
     
    27212792}
    27222793
     2794#ifdef QT_MAC_USE_COCOA
     2795void 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
    27232859void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
    27242860{
     
    27682904        if (wasWindow) {
    27692905            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            }
    27732911        }
    27742912#endif
     
    27812919    //recreate and setup flags
    27822920    QObjectPrivate::setParent_helper(parent);
    2783     QPoint pt = q->pos();
    27842921    bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
    27852922    if (wasCreated && !qt_isGenuineQWidget(q))
    27862923        return;
    27872924
    2788     if ((data.window_flags & Qt::Sheet) && topData && topData->opacity == 242)
     2925    if (!q->testAttribute(Qt::WA_WState_WindowOpacitySet)) {
    27892926        q->setWindowOpacity(1.0f);
     2927        q->setAttribute(Qt::WA_WState_WindowOpacitySet, false);
     2928    }
    27902929
    27912930    setWinId(0); //do after the above because they may want the id
     
    27962935    q->setAttribute(Qt::WA_WState_Hidden, false);
    27972936    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) {
    28012943        createWinId();
    28022944        if (q->isWindow()) {
     
    28052947            // (only for performance, it gets called a lot anyway).
    28062948            if (!wasCreated) {
    2807                 if (QMainWindowLayout *mwl = qobject_cast<QMainWindowLayout *>(q->layout())) {
     2949                if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) {
    28082950                    mwl->updateHIToolBarStatus();
    28092951                }
     
    28302972        // So redo the status one more time. It apparently is not an issue with Cocoa.
    28312973        if (q->isWindow()) {
    2832             if (QMainWindowLayout *mwl = qobject_cast<QMainWindowLayout *>(q->layout())) {
     2974            if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) {
    28332975                mwl->updateHIToolBarStatus();
    28342976            }
     
    28753017        }
    28763018    }
    2877 
    28783019    invalidateBuffer(q->rect());
    28793020    qt_event_request_window_change(q);
     
    28833024{
    28843025    Q_D(const QWidget);
    2885     if (!testAttribute(Qt::WA_WState_Created)) {
     3026    if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
    28863027        QPoint p = pos + data->crect.topLeft();
    28873028        return isWindow() ?  p : parentWidget()->mapToGlobal(p);
     
    29103051{
    29113052    Q_D(const QWidget);
    2912     if (!testAttribute(Qt::WA_WState_Created)) {
     3053    if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
    29133054        QPoint p = isWindow() ?  pos : parentWidget()->mapFromGlobal(pos);
    29143055        return p - data->crect.topLeft();
     
    31813322#ifndef QT_MAC_USE_COCOA
    31823323        ActivateWindow(win, true);
     3324        qApp->setActiveWindow(tlw);
    31833325#else
    31843326        [win makeKeyWindow];
    31853327#endif
    3186         qApp->setActiveWindow(tlw);
    31873328    } else if(!isMinimized()) {
    31883329#ifndef QT_MAC_USE_COCOA
     
    32093350            HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true);
    32103351#else
    3211             [qt_mac_nativeview_for(q) setNeedsDisplay:YES];
     3352            qt_mac_set_needs_display(q, QRegion());
    32123353#endif
    32133354        return;
     
    32473388    }
    32483389#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    }
    32543408#endif
    32553409}
     
    32753429
    32763430    bool realWindow = isRealWindow();
     3431#ifndef QT_MAC_USE_COCOA
    32773432    if (realWindow && !q->testAttribute(Qt::WA_Moved)) {
     3433        if (qt_mac_is_macsheet(q))
     3434            recreateMacWindow();
    32783435        q->createWinId();
    32793436        if (QWidget *p = q->parentWidget()) {
    32803437            p->createWinId();
    3281 #ifndef QT_MAC_USE_COCOA
    32823438            RepositionWindow(qt_mac_window_for(q), qt_mac_window_for(p), kWindowCenterOnParentWindow);
    3283 #else
    3284             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 #endif
    32913439        } else {
    3292 #ifndef QT_MAC_USE_COCOA
    32933440            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
    33093445    data.fstrut_dirty = true;
    33103446    if (realWindow) {
     
    33373473            // sync the opacity value back (in case of a fade).
    33383474            [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);
    33463494#endif
    33473495            if (q->windowType() == Qt::Popup) {
     
    33623510#ifndef QT_MAC_USE_COCOA
    33633511            qt_event_request_activate(q);
    3364 #else
    3365             [qt_mac_window_for(q) makeKeyWindow];
    33663512#endif
    33673513        }
     
    34053551    QMacCocoaAutoReleasePool pool;
    34063552    if(q->isWindow()) {
     3553#ifdef QT_MAC_USE_COCOA
     3554        setSubWindowStacking(false);
     3555#endif
    34073556        OSWindowRef window = qt_mac_window_for(q);
    34083557        if(qt_mac_is_macsheet(q)) {
     
    34703619#endif
    34713620        }
    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)) {
    34733626            QWidget *w = 0;
    34743627            if(q->parentWidget())
    34753628                w = q->parentWidget()->window();
    34763629            if(!w || (!w->isVisible() && !w->isMinimized())) {
    3477 #ifndef QT_MAC_USE_COCOA
    34783630                for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true);
    34793631                    wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) {
     
    34953647                    }
    34963648                }
    3497 #else
    3498                 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 #endif
    35063649            }
    35073650            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
    35153655    } else {
    35163656         invalidateBuffer(q->rect());
     
    37343874    QMacCocoaAutoReleasePool pool;
    37353875    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.
    37373885        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];
    37393905        }
    37403906        if (qt_mac_raise_process) { //we get to be the active process now
     
    38494015    flag
    38504016*/
    3851 static void qt_mac_update_widget_posisiton(QWidget *q, QRect oldRect, QRect newRect)
     4017static void qt_mac_update_widget_position(QWidget *q, QRect oldRect, QRect newRect)
    38524018{
    38534019#ifndef QT_MAC_USE_COCOA
     
    38744040
    38754041        // 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
    38804046    ){
    38814047        HIViewSetFrame(view, &bounds);
     
    39464112    Q_UNUSED(oldRect);
    39474113    NSRect bounds = NSMakeRect(newRect.x(), newRect.y(),
    3948                                newRect.width(), newRect.height());
     4114            newRect.width(), newRect.height());
    39494115    [qt_mac_nativeview_for(q) setFrame:bounds];
    39504116#endif
     
    39834149
    39844150    QRect parentWRect;
    3985     if (q->isWindow() && topData()->embedded) {
     4151    bool isEmbeddedWindow = (q->isWindow() && topData()->embedded);
     4152    if (isEmbeddedWindow) {
    39864153#ifndef QT_MAC_USE_COCOA
    39874154        HIViewRef parentView = HIViewGetSuperview(qt_mac_nativeview_for(q));
     
    40084175    if (parentWRect.isValid()) {
    40094176        // 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) {
    40114178            xrect &= parentWRect;
    40124179            wrect = xrect;
     
    41104277    }
    41114278
    4112     qt_mac_update_widget_posisiton(q, oldRect, xrect);
     4279    qt_mac_update_widget_position(q, oldRect, xrect);
    41134280
    41144281    if  (jump)
     
    41824349    QMacCocoaAutoReleasePool pool;
    41834350    bool realWindow = isRealWindow();
     4351    BOOL needDisplay = realWindow ? YES : NO;
    41844352
    41854353    if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)){
     
    41964364        }
    41974365#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
    41984382        QSize  olds = q->size();
    41994383        const bool isResize = (olds != QSize(w, h));
     
    42134397                && cocoaFrameRect.size.width != 0
    42144398                && cocoaFrameRect.size.height != 0) {
    4215             [window setFrame:cocoaFrameRect display:NO];
     4399            [window setFrame:cocoaFrameRect display:needDisplay];
    42164400        } else {
    42174401            // The window is moved and resized (or resized to zero).
     
    42224406            // window back and forth inbetween.
    42234407            cocoaFrameRect.origin.y += 1;
    4224             [window setFrame:cocoaFrameRect display:NO];
     4408            [window setFrame:cocoaFrameRect display:needDisplay];
    42254409            cocoaFrameRect.origin.y -= 1;
    42264410            [window setFrameOrigin:cocoaFrameRect.origin];
     
    42484432
    42494433    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    }
    42504441    data.crect = QRect(x, y, w, h);
    42514442
     
    46124803    SetControlDragTrackingEnabled(qt_mac_nativeview_for(q), on);
    46134804#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];
    46174811    }
    46184812#endif
     
    47304924        [window invalidateShadow];
    47314925    }
    4732     [qt_mac_nativeview_for(q) setNeedsDisplay:YES];
     4926    qt_mac_set_needs_display(q, QRegion());
    47334927}
    47344928#endif
     
    47704964
    47714965    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).
    47734967        if (!alreadySheet) {
    47744968            // NB: the following call will call setModal_sys recursivly:
     
    47874981        }
    47884982    } 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).
    47904984        if (alreadySheet){
    47914985            // NB: the following call will call setModal_sys recursivly:
     
    47934987            windowRef = qt_mac_window_for(q);
    47944988        }
    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:
    48024994            if ([windowRef isKindOfClass:[NSPanel class]])
    48034995                [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];
    48304996        }
    48314997    }
     
    50075173        recreateMacWindow();
    50085174#else
    5009         QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(q->layout());
     5175        QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q));
    50105176        if (q->testAttribute(Qt::WA_MacBrushedMetal)) {
    50115177            if (layout)
  • trunk/src/gui/kernel/qwidget_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    115115class QStyle;
    116116
     117class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
     118{
     119
     120public:
     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
     151private:
     152    Q_DISABLE_COPY(QWidgetBackingStoreTracker)
     153
     154private:
     155    QWidgetBackingStore* m_ptr;
     156    QSet<QWidget *> m_widgets;
     157};
     158
    117159struct QTLWExtra {
    118160    // *************************** Cross-platform variables *****************************
     
    121163    QIcon *icon; // widget icon
    122164    QPixmap *iconPixmap;
    123     QWidgetBackingStore *backingStore;
     165    QWidgetBackingStoreTracker backingStore;
    124166    QWindowSurface *windowSurface;
    125167    QPainter *sharedPainter;
     
    163205#endif
    164206#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
     207    uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered.
    165208    HICON winIconBig; // internal big Windows icon
    166209    HICON winIconSmall; // internal small Windows icon
     
    174217    IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
    175218    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
    176227#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
    177228#ifndef QT_NO_QWS_MANAGER
     
    180231#elif defined(Q_OS_SYMBIAN)
    181232    uint inExpose : 1; // Prevents drawing recursion
     233    uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
    182234#elif defined(Q_WS_PM)
    183235    HWND fId;
     
    396448    void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
    397449                       QWidget::RenderFlags renderFlags);
     450    void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
     451                QWidget::RenderFlags renderFlags, bool readyToRender);
    398452    void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
    399453                    QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
     
    502556    bool setMaximumSize_helper(int &maxw, int &maxh);
    503557    void setConstraints_sys();
     558    bool pointInsideRectAndMask(const QPoint &) const;
    504559    QWidget *childAt_helper(const QPoint &, bool) const;
     560    QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const;
    505561    void updateGeometry_helper(bool forceUpdate);
    506562
     
    508564    void setLayoutItemMargins(int left, int top, int right, int bottom);
    509565    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() {}
    510571
    511572    QInputContext *inputContext() const;
     
    685746    QList<QAction*> actions;
    686747#endif
     748#ifndef QT_NO_GESTURES
    687749    QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
     750#endif
    688751
    689752    // Bit fields.
    690     uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
     753    uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
    691754    QPalette::ColorRole fg_role : 8;
    692755    QPalette::ColorRole bg_role : 8;
     
    698761    uint isGLWidget : 1;
    699762    uint usesDoubleBufferedGLContext : 1;
     763#ifndef QT_NO_IM
     764    uint inheritsInputMethodHints : 1;
     765#endif
    700766
    701767    // *************************** Platform specific ************************************
     
    711777    void x11UpdateIsOpaque();
    712778    bool isBackgroundInherited() const;
     779    void updateX11AcceptFocus();
    713780#elif defined(Q_WS_PM) // <----------------------------------------------------------- PM
    714781    uint noPaintOnScreen : 1; // see qwidget_pm.cpp ::paintEngine()
     
    722789#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
    723790    uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
     791#ifndef QT_NO_GESTURES
    724792    uint nativeGesturePanEnabled : 1;
    725 
     793#endif
    726794    bool shouldShowMaximizeButton();
    727795    void winUpdateIsOpaque();
     
    737805    // This is new stuff
    738806    uint needWindowChange : 1;
     807    uint hasAlienChildren : 1;
    739808
    740809    // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
     
    783852    void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
    784853#else
     854    void setSubWindowStacking(bool set);
     855    void setWindowLevel();
    785856    void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
    786857    void syncCocoaMask();
    787858    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;
    788866#endif
    789867    void determineWindowClass();
     
    9231001}
    9241002
     1003inline 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
    9251010inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
    9261011{
    9271012    Q_Q(const QWidget);
    9281013    QTLWExtra *x = q->window()->d_func()->maybeTopData();
    929     return x ? x->backingStore : 0;
     1014    return x ? x->backingStore.data() : 0;
    9301015}
    9311016
  • trunk/src/gui/kernel/qwidget_qws.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    257257{
    258258    Q_D(QWidget);
    259 
     259    d->aboutToDestroy();
    260260    if (!isWindow() && parentWidget())
    261261        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
     
    10181018        const QScreen *screen = d->getScreen();
    10191019        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;
    10201044    } else {
    10211045        val = QPaintDevice::metric(m);// XXX
  • trunk/src/gui/kernel/qwidget_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5555#ifdef Q_WS_S60
    5656#include <aknappui.h>
     57#include <eikbtgpc.h>
    5758#endif
    5859
    59 // This is necessary in order to be able to perform delayed invokation on slots
     60// This is necessary in order to be able to perform delayed invocation on slots
    6061// which take arguments of type WId.  One example is
    6162// QWidgetPrivate::_q_delayedDestroy, which is used to delay destruction of
     
    6364Q_DECLARE_METATYPE(WId)
    6465
     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.
     69class CAknToolbar : public CAknControl,
     70                    public MCoeControlObserver,
     71                    public MCoeControlBackground,
     72                    public MEikCommandObserver,
     73                    public MAknFadedComponent
     74{
     75public:
     76    IMPORT_C void SetToolbarVisibility(const TBool visible);
     77};
     78
    6579QT_BEGIN_NAMESPACE
    6680
     
    6983QWidget *QWidgetPrivate::mouseGrabber = 0;
    7084QWidget *QWidgetPrivate::keyboardGrabber = 0;
     85CEikButtonGroupContainer *QS60Data::cba = 0;
    7186
    7287static bool isEqual(const QList<QAction*>& a, const QList<QAction*>& b)
     
    366381        // Symbian windows are always created in an inactive state
    367382        // We perform this assignment for the case where the window is being re-created
    368         // as aa result of a call to setParent_sys, on either this widget or one of its
     383        // as a result of a call to setParent_sys, on either this widget or one of its
    369384        // ancestors.
    370385        extra->activated = 0;
     
    410425        // Symbian windows are always created in an inactive state
    411426        // We perform this assignment for the case where the window is being re-created
    412         // as aa result of a call to setParent_sys, on either this widget or one of its
     427        // as a result of a call to setParent_sys, on either this widget or one of its
    413428        // ancestors.
    414429        extra->activated = 0;
     
    434449        drawableWindow->PointerFilter(EPointerFilterEnterExit
    435450            | EPointerFilterMove | EPointerFilterDrag, 0);
     451        drawableWindow->EnableVisibilityChangeEvents();
    436452
    437453        if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) {
     
    481497
    482498         QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId());
     499         const bool isFullscreen = q->windowState() & Qt::WindowFullScreen;
     500         const TBool cbaRequested = q->windowFlags() & Qt::WindowSoftkeysVisibleHint;
    483501
    484502#ifdef Q_WS_S60
    485503        // 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)
    487505                && !S60->buttonGroupContainer() && !S60->statusPane()) {
    488 
    489             bool isFullscreen = q->windowState() & Qt::WindowFullScreen;
    490506
    491507            if (!q->testAttribute(Qt::WA_DontShowOnScreen)) {
     
    494510                CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi());
    495511                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                )
    499547
    500548                if (S60->statusPane()) {
     
    503551                    QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId());
    504552                    S60->statusPane()->SetObserver(desktopControl);
    505 
    506                     // Hide the status pane if fullscreen OR
    507                     // Fill client area if maximized OR
    508                     // Put window below status pane unless the window has an explicit position.
    509553                    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);
    516556                    }
    517557                }
     
    520560#endif
    521561
     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
    522573        id->MakeVisible(true);
    523574
    524         if(q->isWindow())
     575        if(q->isWindow()&&!q->testAttribute(Qt::WA_ShowWithoutActivating))
    525576            id->setFocusSafely(true);
    526577    }
     
    555606
    556607    if (id) {
    557         //Incorrect optimisation - for popup windows, Qt's focus is moved before
     608        //Incorrect optimization - for popup windows, Qt's focus is moved before
    558609        //hide_sys is called, resulting in the popup window keeping its elevated
    559610        //position in the CONE control stack.
     
    683734    if ((q->windowType() == Qt::Desktop))
    684735        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
    685743    setWinId(0);
    686744
     
    738796        return;
    739797
    740     if ((data.window_flags & Qt::FramelessWindowHint) == 0)
    741         return;
     798    createTLExtra();
    742799
    743800    RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow());
     
    745802#ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE
    746803    window->SetSurfaceTransparency(!isOpaque);
     804    extra->topextra->nativeWindowTransparencyEnabled = !isOpaque;
    747805#else
    748806    if (!isOpaque) {
    749807        const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA));
    750         if (window->SetTransparencyAlphaChannel() == KErrNone)
     808        if (window->SetTransparencyAlphaChannel() == KErrNone) {
    751809            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) {
    753821        window->SetTransparentRegion(TRegionFix<1>());
     822        extra->topextra->nativeWindowTransparencyEnabled = 0;
     823    }
    754824#endif
    755825}
     
    909979void QWidgetPrivate::createTLSysExtra()
    910980{
    911     extra->topextra->backingStore = 0;
    912981    extra->topextra->inExpose = 0;
     982    extra->topextra->nativeWindowTransparencyEnabled = 0;
    913983}
    914984
    915985void QWidgetPrivate::deleteTLSysExtra()
    916986{
    917     delete extra->topextra->backingStore;
    918     extra->topextra->backingStore = 0;
     987    extra->topextra->backingStore.destroy();
    919988}
    920989
     
    9521021    if (q->testAttribute(Qt::WA_WState_Created) && q->windowType() != Qt::Desktop) {
    9531022        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();
    9551027    }
    9561028#endif
     
    10871159
    10881160    const TBool isFullscreen = newstate & Qt::WindowFullScreen;
     1161#ifdef Q_WS_S60
    10891162    const TBool cbaRequested = windowFlags() & Qt::WindowSoftkeysVisibleHint;
    10901163    const TBool cbaVisible = CEikButtonGroupContainer::Current() ? true : false;
     
    10931166    if (oldstate == newstate && !softkeyVisibilityChange)
    10941167        return;
     1168#endif // Q_WS_S60
    10951169
    10961170    if (isWindow()) {
     
    11111185
    11121186#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);
    11251197        }
    11261198#endif // Q_WS_S60
     
    11351207        const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint;
    11361208        if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) {
     1209            setAttribute(Qt::WA_OutsideWSRange, false);
    11371210            window->SetExtentToWholeScreen();
    11381211        } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) {
     1212            setAttribute(Qt::WA_OutsideWSRange, false);
    11391213            TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this));
    11401214            window->SetExtent(maxExtent.iTl, maxExtent.Size());
     
    11451219            // normal mode after showing the status pane, the geometry would overlap so we should
    11461220            // move it if it never had an explicit position.
    1147             if (!wasMoved && statusPane && visible) {
     1221            if (!wasMoved && S60->statusPane() && decorationsVisible) {
    11481222                TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl;
    11491223                normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY));
     
    11791253{
    11801254    Q_D(QWidget);
     1255    d->aboutToDestroy();
    11811256    if (!isWindow() && parentWidget())
    11821257        parentWidget()->d_func()->invalidateBuffer(geometry());
     
    12261301        // so we flush the command buffer to ensure that the freeing of
    12271302        // those resources and deleting the window can happen "atomically"
    1228         S60->wsSession().Flush();
     1303        if (qApp)
     1304            S60->wsSession().Flush();
    12291305    }
    12301306}
  • trunk/src/gui/kernel/qwidget_win.cpp

    r807 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4848#include "qimage.h"
    4949#include "qlayout.h"
    50 #include "qlibrary.h"
    5150#include "qpainter.h"
    5251#include "qstack.h"
     
    6665#include <private/qwininputcontext_p.h>
    6766#include <private/qpaintengine_raster_p.h>
     67#include <private/qsystemlibrary_p.h>
    6868
    6969#if defined(Q_WS_WINCE)
     
    7171QT_USE_NAMESPACE
    7272extern void qt_wince_maximize(QWidget *widget);                          //defined in qguifunctions_wince.cpp
     73extern void qt_wince_unmaximize(QWidget *widget);                        //defined in qguifunctions_wince.cpp
    7374extern void qt_wince_minimize(HWND hwnd);                                //defined in qguifunctions_wince.cpp
    7475extern void qt_wince_full_screen(HWND hwnd, bool fullScreen, UINT swpf); //defined in qguifunctions_wince.cpp
     
    124125static PtrWTQueueSizeGet ptrWTQueueSizeGet = 0;
    125126static PtrWTQueueSizeSet ptrWTQueueSizeSet = 0;
     127#ifndef QT_NO_TABLETEVENT
    126128static void init_wintab_functions();
    127129static void qt_tablet_init();
    128130static void qt_tablet_cleanup();
     131#endif // QT_NO_TABLETEVENT
    129132extern HCTX qt_tablet_context;
    130133extern bool qt_tablet_tilt_support;
     
    137140
    138141extern bool qt_is_gui_used;
     142
     143#ifndef QT_NO_TABLETEVENT
    139144static void init_wintab_functions()
    140145{
     
    144149    if (!qt_is_gui_used)
    145150        return;
    146     QLibrary library(QLatin1String("wintab32"));
     151    QSystemLibrary library(QLatin1String("wintab32"));
    147152    ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW");
    148153    ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
     
    162167    qt_tablet_widget->createWinId();
    163168    qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget"));
    164     // We dont need this internal widget to appear in QApplication::topLevelWidgets()
     169    // We don't need this internal widget to appear in QApplication::topLevelWidgets()
    165170    if (QWidgetPrivate::allWidgets)
    166171        QWidgetPrivate::allWidgets->remove(qt_tablet_widget);
     
    228233    qt_tablet_widget = 0;
    229234}
     235#endif // QT_NO_TABLETEVENT
    230236
    231237const QString qt_reg_winclass(QWidget *w);                // defined in qapplication_win.cpp
     
    244250static HHOOK   journalRec  = 0;
    245251
    246 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
     252extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
    247253
    248254#define XCOORD_MAX 16383
     
    513519    }
    514520
     521#ifndef QT_NO_TABLETEVENT
    515522    if (q != qt_tablet_widget && QWidgetPrivate::mapper)
    516523        qt_tablet_init();
     524#endif // QT_NO_TABLETEVENT
    517525
    518526    if (q->testAttribute(Qt::WA_DropSiteRegistered))
     
    538546{
    539547    Q_D(QWidget);
     548    d->aboutToDestroy();
    540549    if (!isWindow() && parentWidget())
    541550        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
     
    826835// The procedure does nothing, but is required for mousegrabbing to work
    827836#ifndef Q_WS_WINCE
    828 LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam)
     837LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam)
    829838{
    830839    return CallNextHookEx(journalRec, nCode, wParam, lParam);
     
    10931102        invalidateBuffer(q->rect());
    10941103        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        }
    10951119    }
    10961120
     
    11421166        if (IsZoomed(q->internalWinId()))
    11431167            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();
    11441173    }
    11451174
     
    15191548    if (data.window_flags & Qt::MSWindowsFixedSizeDialogHint)
    15201549        return false;
    1521     // if the user explicitely asked for the maximize button, we try to add
     1550    // if the user explicitly asked for the maximize button, we try to add
    15221551    // it even if the window has fixed size.
    15231552    if (data.window_flags & Qt::CustomizeWindowHint &&
     
    16881717void QWidgetPrivate::createTLSysExtra()
    16891718{
     1719    extra->topextra->hotkeyRegistered = 0;
    16901720    extra->topextra->savedFlags = 0;
    16911721    extra->topextra->winIconBig = 0;
     
    18611891    if (!function_resolved) {
    18621892        ptrSetLayeredWindowAttributes =
    1863             (PtrSetLayeredWindowAttributes) QLibrary::resolve(QLatin1String("user32"),
     1893            (PtrSetLayeredWindowAttributes) QSystemLibrary::resolve(QLatin1String("user32"),
    18641894                                                              "SetLayeredWindowAttributes");
    18651895        function_resolved = true;
     
    20482078void QWidgetPrivate::winSetupGestures()
    20492079{
    2050 #if !defined(QT_NO_NATIVE_GESTURES)
     2080#if !defined(QT_NO_GESTURES) && !defined(QT_NO_NATIVE_GESTURES)
    20512081    Q_Q(QWidget);
    20522082    if (!q || !q->isVisible() || !nativeGesturePanEnabled)
  • trunk/src/gui/kernel/qwidget_wince.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4747
    4848const QString qt_reg_winclass(QWidget *w);                // defined in qapplication_win.cpp
    49 extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
     49extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
    5050
    5151//#define TABLET_DEBUG
     
    6464typedef BOOL    (API *PtrWTQueueSizeSet)(HCTX, int);
    6565
     66#ifndef QT_NO_TABLETEVENT
    6667static void qt_tablet_init_wce();
    6768static void qt_tablet_cleanup_wce();
     
    136137    qt_tablet_widget = 0;
    137138}
     139#endif // QT_NO_TABLETEVENT
    138140
    139141
     
    359361    }
    360362
     363#ifndef QT_NO_TABLETEVENT
    361364    if (q != qt_tablet_widget && QWidgetPrivate::mapper)
    362365        qt_tablet_init_wce();
     366#endif // QT_NO_TABLETEVENT
    363367
    364368    if (q->testAttribute(Qt::WA_DropSiteRegistered))
     
    495499                SetWindowLong(internalWinId(), GWL_STYLE, style);
    496500                SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG);
     501                qt_wince_unmaximize(this);
    497502            }
    498503            if (isVisible() && newstate & Qt::WindowMaximized)
     
    587592
    588593// The procedure does nothing, but is required for mousegrabbing to work
    589 LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) {
     594LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) {
    590595    Q_UNUSED(nCode);
    591596    Q_UNUSED(wParam);
  • trunk/src/gui/kernel/qwidget_x11.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5050#include "qlayout.h"
    5151#include "qtextcodec.h"
    52 #include "qdatetime.h"
     52#include "qelapsedtimer.h"
    5353#include "qcursor.h"
    5454#include "qstack.h"
     
    353353    QApplication::flush();
    354354    XEvent ev;
    355     QTime t;
     355    QElapsedTimer t;
    356356    t.start();
    357357    static const int maximumWaitTime = 2000;
     
    781781        memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
    782782        wm_hints.flags = InputHint | StateHint | WindowGroupHint;
    783         wm_hints.input = True;
     783        wm_hints.input = q->testAttribute(Qt::WA_X11DoNotAcceptFocus) ? False : True;
    784784        wm_hints.initial_state = NormalState;
    785785        wm_hints.window_group = X11->wm_client_leader;
     
    890890
    891891        }
    892     } else if (q->testAttribute(Qt::WA_SetCursor) && q->internalWinId()) {
     892    } else if (q->internalWinId()) {
    893893        qt_x11_enforce_cursor(q);
     894        if (QWidget *p = q->parentWidget()) // reset the cursor on the native parent
     895            qt_x11_enforce_cursor(p);
    894896    }
    895897
     
    10241026{
    10251027    Q_D(QWidget);
     1028    d->aboutToDestroy();
    10261029    if (!isWindow() && parentWidget())
    10271030        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
     
    11671170    // keep compatibility with previous versions, we need to preserve the created state
    11681171    // (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)
    11701173        createWinId();
    11711174    if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden)
     
    16421645            X11->userTime = X11->time;
    16431646        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        }
    16451670    }
    16461671}
     
    19091934            if (flags & Qt::WindowStaysOnBottomHint)
    19101935                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));
    19131940        } 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));
    19151943        }
    19161944        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));
    19181947        }
    19191948        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));
    19221953        }
    19231954        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));
    19251957        }
    19261958
     
    29793011    }
    29803012    // none found, replace one
    2981     int i = rand() % 16;
     3013    int i = qrand() % 16;
    29823014
    29833015    if (X11->solid_fills[i].screen != screen && X11->solid_fills[i].picture) {
     
    30313063}
    30323064
     3065void 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
    30333085QT_END_NAMESPACE
  • trunk/src/gui/kernel/qwidgetaction.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwidgetaction.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwidgetaction_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwidgetcreate_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwindowdefs.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwindowdefs_win.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5050#include "private/qapplication_p.h"
    5151#include "private/qwidget_p.h"
     52
     53#ifndef QT_NO_GESTURES
    5254
    5355QT_BEGIN_NAMESPACE
     
    128130
    129131QT_END_NAMESPACE
     132
     133#endif // QT_NO_GESTURES
  • trunk/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5555
    5656#include <QGestureRecognizer>
    57 #include <objbase.h>
    5857
    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
    8959
    9060QT_BEGIN_NAMESPACE
     
    10676QT_END_NAMESPACE
    10777
     78#endif // QT_NO_GESTURES
     79
    10880#endif // QWINNATIVEPANGESTURERECOGNIZER_WIN_P_H
  • trunk/src/gui/kernel/qx11embed_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4848#include <qstyle.h>
    4949#include <qstyleoption.h>
    50 #include <qdatetime.h>
     50#include <qelapsedtimer.h>
    5151#include <qpointer.h>
    5252#include <qdebug.h>
     
    10711071    d->focusProxy->setAttribute(Qt::WA_NativeWindow);
    10721072    d->focusProxy->setAttribute(Qt::WA_DontCreateNativeAncestors);
     1073    d->focusProxy->createWinId();
    10731074    d->focusProxy->setGeometry(-1, -1, 1, 1);
    10741075
     
    11361137/*! \internal
    11371138
    1138     Returns wether or not the windows' embedded flag is set.
     1139    Returns whether or not the windows' embedded flag is set.
    11391140*/
    11401141bool QX11EmbedContainerPrivate::isEmbedded() const
     
    12321233      preemptively workaround buggy window managers.
    12331234    */
    1234     QTime t;
     1235    QElapsedTimer t;
    12351236    t.start();
    12361237
  • trunk/src/gui/kernel/qx11embed_x11.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qx11info_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/gui/kernel/qx11info_x11.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
Note: See TracChangeset for help on using the changeset viewer.