summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri13
-rw-r--r--src/gui/kernel/qaction.cpp48
-rw-r--r--src/gui/kernel/qaction.h8
-rw-r--r--src/gui/kernel/qaction_p.h1
-rw-r--r--src/gui/kernel/qapplication.cpp120
-rw-r--r--src/gui/kernel/qapplication.h9
-rw-r--r--src/gui/kernel/qapplication_mac.mm41
-rw-r--r--src/gui/kernel/qapplication_p.h99
-rw-r--r--src/gui/kernel/qapplication_qws.cpp8
-rw-r--r--src/gui/kernel/qapplication_win.cpp621
-rw-r--r--src/gui/kernel/qapplication_x11.cpp64
-rw-r--r--src/gui/kernel/qclipboard_mac.cpp14
-rw-r--r--src/gui/kernel/qclipboard_win.cpp10
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm6
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm19
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm6
-rw-r--r--src/gui/kernel/qcursor_win.cpp48
-rw-r--r--src/gui/kernel/qdesktopwidget.h8
-rw-r--r--src/gui/kernel/qdesktopwidget_mac.mm64
-rw-r--r--src/gui/kernel/qdesktopwidget_mac_p.h3
-rw-r--r--src/gui/kernel/qdesktopwidget_win.cpp139
-rw-r--r--src/gui/kernel/qdesktopwidget_x11.cpp25
-rw-r--r--src/gui/kernel/qdirectionrecognizer.cpp182
-rw-r--r--src/gui/kernel/qdirectionrecognizer_p.h105
-rw-r--r--src/gui/kernel/qdirectionsimplificator_p.h172
-rw-r--r--src/gui/kernel/qdnd_mac.mm4
-rw-r--r--src/gui/kernel/qdnd_p.h2
-rw-r--r--src/gui/kernel/qdnd_win.cpp75
-rw-r--r--src/gui/kernel/qevent.cpp279
-rw-r--r--src/gui/kernel/qevent.h35
-rw-r--r--src/gui/kernel/qevent_p.h16
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm12
-rw-r--r--src/gui/kernel/qgesture.cpp297
-rw-r--r--src/gui/kernel/qgesture.h94
-rw-r--r--src/gui/kernel/qgesture_p.h35
-rw-r--r--src/gui/kernel/qgesturemanager.cpp644
-rw-r--r--src/gui/kernel/qgesturemanager_p.h126
-rw-r--r--src/gui/kernel/qgesturerecognizer.cpp159
-rw-r--r--src/gui/kernel/qgesturestandardrecognizers.cpp306
-rw-r--r--src/gui/kernel/qgesturestandardrecognizers_p.h131
-rw-r--r--src/gui/kernel/qguifunctions_wince.cpp24
-rw-r--r--src/gui/kernel/qguifunctions_wince.h8
-rw-r--r--src/gui/kernel/qguivariant.cpp161
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp4
-rw-r--r--src/gui/kernel/qkeymapper_win.cpp130
-rw-r--r--src/gui/kernel/qlayout.cpp5
-rw-r--r--src/gui/kernel/qmime_win.cpp148
-rw-r--r--src/gui/kernel/qmultitouch_mac.mm6
-rw-r--r--src/gui/kernel/qmultitouch_mac_p.h4
-rw-r--r--src/gui/kernel/qsound_win.cpp40
-rw-r--r--src/gui/kernel/qstandardgestures.cpp254
-rw-r--r--src/gui/kernel/qstandardgestures.h (renamed from src/gui/kernel/qgesturerecognizer.h)72
-rw-r--r--src/gui/kernel/qstandardgestures_p.h (renamed from src/gui/kernel/qgesturerecognizer_p.h)35
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm92
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac_p.h10
-rw-r--r--src/gui/kernel/qwhatsthis.cpp9
-rw-r--r--src/gui/kernel/qwidget.cpp243
-rw-r--r--src/gui/kernel/qwidget.h7
-rw-r--r--src/gui/kernel/qwidget_mac.mm61
-rw-r--r--src/gui/kernel/qwidget_p.h7
-rw-r--r--src/gui/kernel/qwidget_win.cpp129
-rw-r--r--src/gui/kernel/qwidget_wince.cpp46
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp6
63 files changed, 1913 insertions, 3636 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index a8d09b0..530b146 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -44,12 +44,8 @@ HEADERS += \
kernel/qkeymapper_p.h \
kernel/qgesture.h \
kernel/qgesture_p.h \
- kernel/qgesturemanager_p.h \
- kernel/qgesturerecognizer_p.h \
- kernel/qgesturerecognizer.h \
- kernel/qgesturestandardrecognizers_p.h \
- kernel/qdirectionrecognizer_p.h \
- kernel/qdirectionsimplificator_p.h
+ kernel/qstandardgestures.h \
+ kernel/qstandardgestures_p.h
SOURCES += \
kernel/qaction.cpp \
@@ -80,10 +76,7 @@ SOURCES += \
kernel/qwidgetaction.cpp \
kernel/qkeymapper.cpp \
kernel/qgesture.cpp \
- kernel/qgesturemanager.cpp \
- kernel/qgesturerecognizer.cpp \
- kernel/qgesturestandardrecognizers.cpp \
- kernel/qdirectionrecognizer.cpp
+ kernel/qstandardgestures.cpp
win32 {
DEFINES += QT_NO_DIRECTDRAW
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index fe40ea8..afe6269 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -82,7 +82,7 @@ static QString qt_strippedText(QString s)
QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false),
menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::OptionsSoftKey),
- iconVisibleInMenu(-1)
+ priority(QAction::NormalPriority), iconVisibleInMenu(-1)
{
#ifdef QT3_SUPPORT
static int qt_static_action_id = -1;
@@ -910,6 +910,52 @@ QString QAction::whatsThis() const
return d->whatsthis;
}
+/*!
+ \enum QAction::Priority
+ \since 4.6
+
+ This enum defines priorities for actions in user interface.
+
+ \value LowPriority The action should not be prioritized in
+ the user interface.
+
+ \value NormalPriority
+
+ \value HighPriority The action should be prioritized in
+ the user interface.
+
+ \sa priority
+*/
+
+
+/*!
+ \property QAction::priority
+ \since 4.6
+
+ \brief the actions's priority in the user interface.
+
+ This property can be set to indicate how the action should be prioritized
+ in the user interface.
+
+ For instance, when toolbars have the Qt::ToolButtonTextBesideIcon
+ mode set, then actions with LowPriority will not show the text
+ labels.
+*/
+void QAction::setPriority(Priority priority)
+{
+ Q_D(QAction);
+ if (d->priority == priority)
+ return;
+
+ d->priority = priority;
+ d->sendDataChanged();
+}
+
+QAction::Priority QAction::priority() const
+{
+ Q_D(const QAction);
+ return d->priority;
+}
/*!
\property QAction::checkable
diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h
index b9bdcf1..3fd80b9 100644
--- a/src/gui/kernel/qaction.h
+++ b/src/gui/kernel/qaction.h
@@ -68,6 +68,7 @@ class Q_GUI_EXPORT QAction : public QObject
Q_ENUMS(MenuRole)
Q_ENUMS(SoftKeyRole)
+ Q_ENUMS(Priority)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
@@ -87,6 +88,7 @@ class Q_GUI_EXPORT QAction : public QObject
Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole)
Q_PROPERTY(SoftKeyRole softKeyRole READ softKeyRole WRITE setSoftKeyRole)
Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu)
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority)
public:
enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
@@ -95,6 +97,9 @@ public:
OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey,
EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey,
MenuSoftKey, ContextMenuSoftKey, ExitSoftKey };
+ enum Priority { LowPriority = 0,
+ NormalPriority = 128,
+ HighPriority = 256};
explicit QAction(QObject* parent);
QAction(const QString &text, QObject* parent);
QAction(const QIcon &icon, const QString &text, QObject* parent);
@@ -129,6 +134,9 @@ public:
void setWhatsThis(const QString &what);
QString whatsThis() const;
+ void setPriority(Priority priority);
+ Priority priority() const;
+
#ifndef QT_NO_MENU
QMenu *menu() const;
void setMenu(QMenu *menu);
diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h
index 516b89c..4e3651e 100644
--- a/src/gui/kernel/qaction_p.h
+++ b/src/gui/kernel/qaction_p.h
@@ -103,6 +103,7 @@ public:
uint fontSet : 1;
QAction::MenuRole menuRole;
QAction::SoftKeyRole softKeyRole;
+ QAction::Priority priority;
int iconVisibleInMenu : 3; // Only has values -1, 0, and 1
QList<QWidget *> widgets;
#ifndef QT_NO_GRAPHICSVIEW
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 2f1ab0e..700af43 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -93,8 +93,6 @@
#include "qapplication.h"
-#include <private/qgesturemanager_p.h>
-
#ifdef Q_WS_WINCE
#include "qdatetime.h"
#include "qguifunctions_wince.h"
@@ -131,7 +129,7 @@ int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly
QApplication::Type qt_appType=QApplication::Tty;
QApplicationPrivate *QApplicationPrivate::self = 0;
-QInputContext *QApplicationPrivate::inputContext;
+QInputContext *QApplicationPrivate::inputContext = 0;
bool QApplicationPrivate::quitOnLastWindowClosed = true;
@@ -142,14 +140,6 @@ bool QApplicationPrivate::autoSipEnabled = false;
bool QApplicationPrivate::autoSipEnabled = true;
#endif
-QGestureManager* QGestureManager::instance()
-{
- QApplicationPrivate *d = qApp->d_func();
- if (!d->gestureManager)
- d->gestureManager = new QGestureManager(qApp);
- return d->gestureManager;
-}
-
QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type)
: QCoreApplicationPrivate(argc, argv)
{
@@ -173,8 +163,6 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T
directPainters = 0;
#endif
- gestureManager = 0;
-
if (!self)
self = this;
}
@@ -846,6 +834,12 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv,
#endif // Q_WS_X11
extern void qInitDrawhelperAsm();
+extern int qRegisterGuiVariant();
+extern int qUnregisterGuiVariant();
+#ifndef QT_NO_STATEMACHINE
+extern int qRegisterGuiStateMachine();
+extern int qUnregisterGuiStateMachine();
+#endif
/*!
\fn void QApplicationPrivate::initialize()
@@ -859,11 +853,9 @@ void QApplicationPrivate::initialize()
if (qt_appType != QApplication::Tty)
(void) QApplication::style(); // trigger creation of application style
// trigger registering of QVariant's GUI types
- extern int qRegisterGuiVariant();
qRegisterGuiVariant();
#ifndef QT_NO_STATEMACHINE
// trigger registering of QStateMachine's GUI types
- extern int qRegisterGuiStateMachine();
qRegisterGuiStateMachine();
#endif
@@ -878,12 +870,6 @@ void QApplicationPrivate::initialize()
if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0)
q->setAttribute(Qt::AA_NativeWindows);
-#if defined(Q_WS_WIN)
- // Alien is not currently working on Windows 98
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- q->setAttribute(Qt::AA_NativeWindows);
-#endif
-
#ifdef Q_WS_WINCE
#ifdef QT_AUTO_MAXIMIZE_THRESHOLD
autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD;
@@ -1095,11 +1081,9 @@ QApplication::~QApplication()
#ifndef QT_NO_STATEMACHINE
// trigger unregistering of QStateMachine's GUI types
- extern int qUnregisterGuiStateMachine();
qUnregisterGuiStateMachine();
#endif
// trigger unregistering of QVariant's GUI types
- extern int qUnregisterGuiVariant();
qUnregisterGuiVariant();
}
@@ -3669,14 +3653,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
#endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
}
- if (!d->grabbedGestures.isEmpty() && e->spontaneous() && receiver->isWidgetType()) {
- const QEvent::Type t = e->type();
- if (t != QEvent::Gesture && t != QEvent::GraphicsSceneGesture) {
- if (QGestureManager::instance()->filterEvent(static_cast<QWidget*>(receiver), e))
- return true;
- }
- }
-
// User input and window activation makes tooltips sleep
switch (e->type()) {
case QEvent::Wheel:
@@ -4164,6 +4140,19 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
res = d->notify_helper(receiver, e);
break;
+ case QEvent::WinGesture:
+ {
+ // only propagate the first gesture event (after the GID_BEGIN)
+ QWidget *w = static_cast<QWidget *>(receiver);
+ while (w) {
+ e->ignore();
+ res = d->notify_helper(w, e);
+ if ((res && e->isAccepted()) || w->isWindow())
+ break;
+ w = w->parentWidget();
+ }
+ break;
+ }
default:
res = d->notify_helper(receiver, e);
break;
@@ -4511,13 +4500,13 @@ HRESULT qt_CoCreateGuid(GUID* guid)
{
// We will use the following information to create the GUID
// 1. absolute path to application
- wchar_t tempFilename[512];
- if (!GetModuleFileNameW(0, tempFilename, 512))
+ wchar_t tempFilename[MAX_PATH];
+ if (!GetModuleFileName(0, tempFilename, MAX_PATH))
return S_FALSE;
- unsigned int hash = qHash(QString::fromUtf16((const unsigned short *) tempFilename));
+ unsigned int hash = qHash(QString::fromWCharArray(tempFilename));
guid->Data1 = hash;
// 2. creation time of file
- QFileInfo info(QString::fromUtf16((const unsigned short *) tempFilename));
+ QFileInfo info(QString::fromWCharArray(tempFilename));
guid->Data2 = qHash(info.created().toTime_t());
// 3. current system time
guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t());
@@ -4551,10 +4540,10 @@ QSessionManager::QSessionManager(QApplication * app, QString &id, QString &key)
GUID guid;
CoCreateGuid(&guid);
StringFromGUID2(guid, guidstr, 40);
- id = QString::fromUtf16((ushort*)guidstr);
+ id = QString::fromWCharArray(guidstr);
CoCreateGuid(&guid);
StringFromGUID2(guid, guidstr, 40);
- key = QString::fromUtf16((ushort*)guidstr);
+ key = QString::fromWCharArray(guidstr);
#endif
d->sessionId = id;
d->sessionKey = key;
@@ -5166,57 +5155,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
return true;
}
-/*!
- \since 4.6
-
- Adds custom gesture \a recognizer object.
-
- Qt takes ownership of the provided \a recognizer.
-
- \sa Qt::AA_EnableGestures, QGestureEvent
-*/
-void QApplication::addGestureRecognizer(QGestureRecognizer *recognizer)
-{
- QGestureManager::instance()->addRecognizer(recognizer);
-}
-
-/*!
- \since 4.6
-
- Removes custom gesture \a recognizer object.
-
- \sa Qt::AA_EnableGestures, QGestureEvent
-*/
-void QApplication::removeGestureRecognizer(QGestureRecognizer *recognizer)
-{
- Q_D(QApplication);
- if (!d->gestureManager)
- return;
- d->gestureManager->removeRecognizer(recognizer);
-}
-
-/*!
- \property QApplication::eventDeliveryDelayForGestures
- \since 4.6
-
- Specifies the \a delay before input events are delivered to the
- gesture enabled widgets.
-
- The delay allows to postpone widget's input event handling until
- gestures framework can successfully recognize a gesture.
-
- \sa QWidget::grabGesture
-*/
-void QApplication::setEventDeliveryDelayForGestures(int delay)
-{
- QGestureManager::instance()->setEventDeliveryDelay(delay);
-}
-
-int QApplication::eventDeliveryDelayForGestures()
-{
- return QGestureManager::instance()->eventDeliveryDelay();
-}
-
/*! \fn QDecoration &QApplication::qwsDecoration()
Return the QWSDecoration used for decorating windows.
@@ -5400,8 +5338,6 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
const QList<QTouchEvent::TouchPoint> &touchPoints)
{
QApplicationPrivate *d = self;
- QApplication *q = self->q_func();
-
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
@@ -5423,7 +5359,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
if (!widget) {
// determine which widget this event will go to
if (!window)
- window = q->topLevelAt(touchPoint.screenPos().toPoint());
+ window = QApplication::topLevelAt(touchPoint.screenPos().toPoint());
if (!window)
continue;
widget = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint()));
@@ -5523,7 +5459,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
QTouchEvent touchEvent(eventType,
deviceType,
- q->keyboardModifiers(),
+ QApplication::keyboardModifiers(),
it.value().first,
it.value().second);
updateTouchPointsForWidget(widget, &touchEvent);
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
index 4b447b5..fcb3a7c 100644
--- a/src/gui/kernel/qapplication.h
+++ b/src/gui/kernel/qapplication.h
@@ -75,7 +75,6 @@ class QStyle;
class QEventLoop;
class QIcon;
class QInputContext;
-class QGestureRecognizer;
template <typename T> class QList;
class QLocale;
#if defined(Q_WS_QWS)
@@ -114,7 +113,6 @@ class Q_GUI_EXPORT QApplication : public QCoreApplication
Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
#endif
Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
- Q_PROPERTY(int eventDeliveryDelayForGestures READ eventDeliveryDelayForGestures WRITE setEventDeliveryDelayForGestures)
public:
enum Type { Tty, GuiClient, GuiServer };
@@ -280,12 +278,6 @@ public:
static bool keypadNavigationEnabled();
#endif
- void addGestureRecognizer(QGestureRecognizer *recognizer);
- void removeGestureRecognizer(QGestureRecognizer *recognizer);
-
- void setEventDeliveryDelayForGestures(int delay);
- int eventDeliveryDelayForGestures();
-
Q_SIGNALS:
void lastWindowClosed();
void focusChanged(QWidget *old, QWidget *now);
@@ -396,7 +388,6 @@ private:
friend class QDirectPainter;
friend class QDirectPainterPrivate;
#endif
- friend class QGestureManager;
#if defined(Q_WS_WIN)
friend QApplicationPrivate* getQApplicationPrivateInternal();
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index b1aa75f..beccfb0 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1069,7 +1069,7 @@ void qt_init(QApplicationPrivate *priv, int)
if (GetCurrentProcess(&psn) == noErr) {
// Jambi needs to transform itself since most people aren't "used"
// to putting things in bundles, but other people may actually not
- // want to tranform the process (running as a helper or somethng)
+ // want to tranform the process (running as a helper or something)
// so don't do that for them. This means checking both LSUIElement
// and LSBackgroundOnly. If you set them both... well, you
// shouldn't do that.
@@ -1377,29 +1377,6 @@ QWidget *QApplication::topLevelAt(const QPoint &p)
#endif
}
-static QWidget *qt_mac_recursive_widgetAt(QWidget *widget, int x, int y)
-{
- if (!widget)
- return 0;
- const QObjectList kids = widget->children();
- for(int i = kids.size()-1; i >= 0; --i) {
- if ( QWidget *kid = qobject_cast<QWidget*>(kids.at(i)) ) {
- if (kid->isVisible() && !kid->isTopLevel() &&
- !kid->testAttribute(Qt::WA_TransparentForMouseEvents)) {
- const int wx=kid->x(), wy=kid->y(),
- wx2=wx+kid->width(), wy2=wy+kid->height();
- if (x >= wx && y >= wy && x < wx2 && y < wy2) {
- const QRegion mask = kid->mask();
- if (!mask.isEmpty() && !mask.contains(QPoint(x-wx, y-wy)))
- continue;
- return qt_mac_recursive_widgetAt(kid, x-wx, y-wy);
- }
- }
- }
- }
- return widget;
-}
-
/*****************************************************************************
Main event loop
*****************************************************************************/
@@ -1770,7 +1747,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
if(window) {
HIViewRef hiview;
if(HIViewGetViewForMouseEvent(HIViewGetRoot(window), event, &hiview) == noErr) {
- widget = QWidget::find((WId)hiview);;
+ widget = QWidget::find((WId)hiview);
if (widget) {
// Make sure we didn't pass over a widget with a "fake hole" in it.
QWidget *otherWidget = QApplication::widgetAt(where.h, where.v);
@@ -1887,9 +1864,10 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
tablet_button_state = new_tablet_button_state;
QMacTabletHash *tabletHash = qt_mac_tablet_hash();
- if (!tabletHash->contains(tabletPointRec.deviceID)) {
- qWarning("QCocoaView handleTabletEvent: This tablet device is unknown"
- " (received no proximity event for it). Discarding event.");
+ if (!tabletHash->contains(tabletPointRec.deviceID) && t != QEvent::TabletRelease) {
+ // Never discard TabletRelease events as they may be delivered *after* TabletLeaveProximity events
+ qWarning("handleTabletEvent: This tablet device is unknown"
+ " (received no proximity event for it). Discarding event.");
return false;
}
QTabletDeviceData &deviceData = tabletHash->operator[](tabletPointRec.deviceID);
@@ -1931,8 +1909,13 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
tp, rotation, z, modifiers, deviceData.tabletUniqueID);
QApplication::sendSpontaneousEvent(widget, &e);
if (e.isAccepted()) {
+ if (t == QEvent::TabletPress) {
+ qt_button_down = widget;
+ } else if (t == QEvent::TabletRelease) {
+ qt_button_down = 0;
+ }
#if defined(DEBUG_MOUSE_MAPS)
- qDebug("Bail out early due to table acceptance");
+ qDebug("Bail out early due to tablet acceptance");
#endif
break;
}
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index e9e8d45..0cd93b9 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -159,17 +159,19 @@ inline QPointF QTabletDeviceData::scaleCoord(int coordX, int coordY,
int outOriginY, int outExtentY) const
{
QPointF ret;
+
if (sign(outExtentX) == sign(maxX))
- ret.setX(((coordX - minX) * qAbs(outExtentX) / qAbs(qreal(maxX))) + outOriginX);
+ ret.setX(((coordX - minX) * qAbs(outExtentX) / qAbs(qreal(maxX - minX))) + outOriginX);
else
- ret.setX(((qAbs(maxX) - (coordX - minX)) * qAbs(outExtentX) / qAbs(qreal(maxX)))
+ ret.setX(((qAbs(maxX) - (coordX - minX)) * qAbs(outExtentX) / qAbs(qreal(maxX - minX)))
+ outOriginX);
if (sign(outExtentY) == sign(maxY))
- ret.setY(((coordY - minY) * qAbs(outExtentY) / qAbs(qreal(maxY))) + outOriginY);
+ ret.setY(((coordY - minY) * qAbs(outExtentY) / qAbs(qreal(maxY - minY))) + outOriginY);
else
- ret.setY(((qAbs(maxY) - (coordY - minY)) * qAbs(outExtentY) / qAbs(qreal(maxY)))
+ ret.setY(((qAbs(maxY) - (coordY - minY)) * qAbs(outExtentY) / qAbs(qreal(maxY - minY)))
+ outOriginY);
+
return ret;
}
#endif
@@ -191,10 +193,68 @@ extern "C" {
#endif
#if defined(Q_WS_WIN)
-typedef BOOL (WINAPI *qt_RegisterTouchWindowPtr)(HWND, ULONG);
-typedef BOOL (WINAPI *qt_GetTouchInputInfoPtr)(HANDLE, UINT, PVOID, int);
-typedef BOOL (WINAPI *qt_CloseTouchInputHandlePtr)(HANDLE);
-#endif
+typedef BOOL (WINAPI *PtrRegisterTouchWindow)(HWND, ULONG);
+typedef BOOL (WINAPI *PtrGetTouchInputInfo)(HANDLE, UINT, PVOID, int);
+typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE);
+
+typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID);
+typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE);
+typedef BOOL (WINAPI *PtrCloseGestureInfoHandle)(HANDLE);
+typedef BOOL (WINAPI *PtrSetGestureConfig)(HWND, DWORD, UINT, PVOID, UINT);
+typedef BOOL (WINAPI *PtrGetGestureConfig)(HWND, DWORD, DWORD, PUINT, PVOID, UINT);
+
+typedef BOOL (WINAPI *PtrBeginPanningFeedback)(HWND);
+typedef BOOL (WINAPI *PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
+typedef BOOL (WINAPI *PtrEndPanningFeedback)(HWND, BOOL);
+
+#ifndef WM_GESTURE
+# define WM_GESTURE 0x0119
+
+# define GID_BEGIN 1
+# define GID_END 2
+# define GID_ZOOM 3
+# define GID_PAN 4
+# define GID_ROTATE 5
+# define GID_TWOFINGERTAP 6
+# define GID_ROLLOVER 7
+
+typedef struct tagGESTUREINFO
+{
+ UINT cbSize;
+ DWORD dwFlags;
+ DWORD dwID;
+ HWND hwndTarget;
+ POINTS ptsLocation;
+ DWORD dwInstanceID;
+ DWORD dwSequenceID;
+ ULONGLONG ullArguments;
+ UINT cbExtraArgs;
+} GESTUREINFO;
+
+# define GC_PAN 0x00000001
+# define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
+# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
+
+typedef struct tagGESTURECONFIG
+{
+ DWORD dwID;
+ DWORD dwWant;
+ DWORD dwBlock;
+} GESTURECONFIG;
+
+#endif // WM_GESTURE
+
+#endif // Q_WS_WIN
+
+class QPanGesture;
+class QPinchGesture;
+struct StandardGestures
+{
+ QPanGesture *pan;
+ QPinchGesture *pinch;
+ StandardGestures() : pan(0), pinch(0) { }
+};
+
class QScopedLoopLevelCounter
{
@@ -445,10 +505,6 @@ public:
void sendSyntheticEnterLeave(QWidget *widget);
#endif
- QGestureManager *gestureManager;
- // map<gesture name -> number of widget subscribed to it>
- QMap<QString, int> grabbedGestures;
-
QMap<int, QWidget *> widgetForTouchPointId;
QMap<int, QTouchEvent::TouchPoint> appCurrentTouchPoints;
static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
@@ -464,13 +520,26 @@ public:
const QList<QTouchEvent::TouchPoint> &touchPoints);
#if defined(Q_WS_WIN)
- static qt_RegisterTouchWindowPtr RegisterTouchWindow;
- static qt_GetTouchInputInfoPtr GetTouchInputInfo;
- static qt_CloseTouchInputHandlePtr CloseTouchInputHandle;
+ static PtrRegisterTouchWindow RegisterTouchWindow;
+ static PtrGetTouchInputInfo GetTouchInputInfo;
+ static PtrCloseTouchInputHandle CloseTouchInputHandle;
QHash<DWORD, int> touchInputIDToTouchPointID;
QList<QTouchEvent::TouchPoint> appAllTouchPoints;
bool translateTouchEvent(const MSG &msg);
+
+ typedef QMap<QWidget*, StandardGestures> WidgetStandardGesturesMap;
+ WidgetStandardGesturesMap widgetGestures;
+ ulong lastGestureId;
+
+ PtrGetGestureInfo GetGestureInfo;
+ PtrGetGestureExtraArgs GetGestureExtraArgs;
+ PtrCloseGestureInfoHandle CloseGestureInfoHandle;
+ PtrSetGestureConfig SetGestureConfig;
+ PtrGetGestureConfig GetGestureConfig;
+ PtrBeginPanningFeedback BeginPanningFeedback;
+ PtrUpdatePanningFeedback UpdatePanningFeedback;
+ PtrEndPanningFeedback EndPanningFeedback;
#endif
#ifdef QT_RX71_MULTITOUCH
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
index 92fe5f5..83b2861 100644
--- a/src/gui/kernel/qapplication_qws.cpp
+++ b/src/gui/kernel/qapplication_qws.cpp
@@ -668,10 +668,14 @@ void QWSDisplay::Data::sendSynchronousCommand(QWSCommand & cmd)
int QWSDisplay::Data::takeId()
{
- if (unused_identifiers.count() == 10)
+ int unusedIdCount = unused_identifiers.count();
+ if (unusedIdCount == 10)
create(15);
- if (unused_identifiers.count() == 0)
+ if (unusedIdCount == 0) {
+ create(1); // Make sure we have an incoming id to wait for, just in case we're recursive
waitForCreation();
+ }
+
return unused_identifiers.takeFirst();
}
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index bb7d931..d5c820c 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -89,6 +89,8 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
#include <private/qkeymapper_p.h>
#include <private/qlocale_p.h>
#include "qevent_p.h"
+#include "qstandardgestures.h"
+#include "qstandardgestures_p.h"
//#define ALIEN_DEBUG
@@ -105,7 +107,6 @@ extern void qt_wince_hide_taskbar(HWND hwnd); //defined in qguifunctions_wince.c
#endif
#endif // QT_NO_ACCESSIBILITY
-#include <winuser.h>
#if !defined(WINABLEAPI)
# if defined(Q_WS_WINCE)
# include <bldver.h>
@@ -145,24 +146,6 @@ typedef struct tagTOUCHINPUT
#endif
-#ifndef FLASHW_STOP
-typedef struct {
- UINT cbSize;
- HWND hwnd;
- DWORD dwFlags;
- UINT uCount;
- DWORD dwTimeout;
-} FLASHWINFO, *PFLASHWINFO;
-#define FLASHW_STOP 0
-#define FLASHW_CAPTION 0x00000001
-#define FLASHW_TRAY 0x00000002
-#define FLASHW_ALL (FLASHW_CAPTION | FLASHW_TRAY)
-#define FLASHW_TIMER 0x00000004
-#define FLASHW_TIMERNOFG 0x0000000C
-#endif /* FLASHW_STOP */
-typedef BOOL (WINAPI *PtrFlashWindowEx)(PFLASHWINFO pfwi);
-static PtrFlashWindowEx pFlashWindowEx = 0;
-
#include <windowsx.h>
#include <limits.h>
#include <string.h>
@@ -272,10 +255,6 @@ QTabletDeviceData currentTabletPointer;
// from qregion_win.cpp
extern HRGN qt_tryCreateRegion(QRegion::RegionType type, int left, int top, int right, int bottom);
-Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin,
- UINT wMsgFilterMax, UINT wRemoveMsg);
-Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
// support for on-the-fly changes of the XP theme engine
#ifndef WM_THEMECHANGED
#define WM_THEMECHANGED 0x031A
@@ -290,22 +269,24 @@ Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
#define WM_XBUTTONDOWN 0x020B
#define WM_XBUTTONUP 0x020C
#define WM_XBUTTONDBLCLK 0x020D
+#endif
+#ifndef GET_KEYSTATE_WPARAM
#define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
#define XBUTTON1 0x0001
#define XBUTTON2 0x0002
+#endif
+#ifndef MK_XBUTTON1
#define MK_XBUTTON1 0x0020
#define MK_XBUTTON2 0x0040
#endif
-#ifdef Q_WS_WINCE
-#define GET_KEYSTATE_WPARAM(wParam) (LOWORD(wParam))
-#endif
-
-// support for multi-media-keys on ME/2000/XP
+// support for multi-media-keys
#ifndef WM_APPCOMMAND
#define WM_APPCOMMAND 0x0319
+#endif
+#ifndef FAPPCOMMAND_MOUSE
#define FAPPCOMMAND_MOUSE 0x8000
#define FAPPCOMMAND_KEY 0
#define FAPPCOMMAND_OEM 0x1000
@@ -373,9 +354,7 @@ Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
#define APPCOMMAND_MEDIA_CHANNEL_DOWN 52
#endif // APPCOMMAND_MICROPHONE_VOLUME_MUTE
-#endif // WM_APPCOMMAND
-
-static UINT WM95_MOUSEWHEEL = 0;
+#endif // FAPPCOMMAND_MOUSE
#if (_WIN32_WINNT < 0x0400)
// This struct is defined in winuser.h if the _WIN32_WINNT >= 0x0400 -- in the
@@ -475,6 +454,7 @@ public:
bool translateConfigEvent(const MSG &msg);
bool translateCloseEvent(const MSG &msg);
bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf, int numPackets);
+ bool translateGestureEvent(const MSG &msg);
void repolishStyle(QStyle &style);
inline void showChildren(bool spontaneous) { d_func()->showChildren(spontaneous); }
inline void hideChildren(bool spontaneous) { d_func()->hideChildren(spontaneous); }
@@ -543,14 +523,13 @@ static void qt_set_windows_color_resources()
pal.setColor(QPalette::Inactive, QPalette::Light, pal.light().color());
pal.setColor(QPalette::Inactive, QPalette::Dark, pal.dark().color());
- if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95) {
- if (pal.midlight() == pal.button())
- pal.setColor(QPalette::Midlight, pal.button().color().lighter(110));
- if (pal.background() != pal.base()) {
- pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Inactive, QPalette::Window));
- pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Inactive, QPalette::Text));
- }
+ if (pal.midlight() == pal.button())
+ pal.setColor(QPalette::Midlight, pal.button().color().lighter(110));
+ if (pal.background() != pal.base()) {
+ pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Inactive, QPalette::Window));
+ pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Inactive, QPalette::Text));
}
+
const QColor bg = pal.background().color();
const QColor fg = pal.foreground().color(), btn = pal.button().color();
QColor disabled((fg.red()+btn.red())/2,(fg.green()+btn.green())/2,
@@ -601,35 +580,18 @@ static void qt_set_windows_color_resources()
static void qt_set_windows_font_resources()
{
#ifndef Q_WS_WINCE
- QFont menuFont;
- QFont messageFont;
- QFont statusFont;
- QFont titleFont;
- QFont iconTitleFont;
- QT_WA({
- NONCLIENTMETRICS ncm;
- ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONTW);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0);
- menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont,true);
- messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont,true);
- statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont,true);
- titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont,true);
- LOGFONTW lfIconTitleFont;
- SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
- iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont,true);
- } , {
- // A version
- NONCLIENTMETRICSA ncm;
- ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, lfMessageFont) + sizeof(LOGFONTA);
- SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- menuFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMenuFont,true);
- messageFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfMessageFont,true);
- statusFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfStatusFont,true);
- titleFont = qt_LOGFONTtoQFont((LOGFONT&)ncm.lfCaptionFont,true);
- LOGFONTA lfIconTitleFont;
- SystemParametersInfoA(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
- iconTitleFont = qt_LOGFONTtoQFont((LOGFONT&)lfIconTitleFont,true);
- });
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0);
+
+ QFont menuFont = qt_LOGFONTtoQFont(ncm.lfMenuFont, true);
+ QFont messageFont = qt_LOGFONTtoQFont(ncm.lfMessageFont, true);
+ QFont statusFont = qt_LOGFONTtoQFont(ncm.lfStatusFont, true);
+ QFont titleFont = qt_LOGFONTtoQFont(ncm.lfCaptionFont, true);
+
+ LOGFONT lfIconTitleFont;
+ SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
+ QFont iconTitleFont = qt_LOGFONTtoQFont(lfIconTitleFont, true);
QApplication::setFont(menuFont, "QMenu");
QApplication::setFont(menuFont, "QMenuBar");
@@ -657,26 +619,13 @@ static void qt_set_windows_font_resources()
static void qt_win_read_cleartype_settings()
{
+ UINT result = 0;
#ifdef Q_OS_WINCE
- UINT result;
- BOOL ok;
- ok = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &result, 0);
- if (ok)
- qt_cleartype_enabled = result;
+ if (SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &result, 0))
+ qt_cleartype_enabled = result;
#else
- QT_WA({
- UINT result;
- BOOL ok;
- ok = SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0);
- if (ok)
- qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
- }, {
- UINT result;
- BOOL ok;
- ok = SystemParametersInfoA(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0);
- if (ok)
- qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
- });
+ if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0))
+ qt_cleartype_enabled = (result == FE_FONTSMOOTHINGCLEARTYPE);
#endif
}
@@ -694,10 +643,10 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
QPalette pal = *QApplicationPrivate::sys_pal;
QColor menuCol(qt_colorref2qrgb(GetSysColor(COLOR_MENU)));
QColor menuText(qt_colorref2qrgb(GetSysColor(COLOR_MENUTEXT)));
- BOOL isFlat = 0;
+ BOOL isFlat = false;
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- SystemParametersInfo(0x1022 /*SPI_GETFLATMENU*/, 0, &isFlat, 0);
+ SystemParametersInfo(SPI_GETFLATMENU, 0, &isFlat, 0);
QPalette menu(pal);
// we might need a special color group for the menu.
menu.setColor(QPalette::Active, QPalette::Button, menuCol);
@@ -712,8 +661,7 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
QColor(qt_colorref2qrgb(GetSysColor(
(QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
- && isFlat ? COLOR_MENUHILIGHT
- : COLOR_HIGHLIGHT))));
+ && isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT))));
menu.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled);
menu.setColor(QPalette::Disabled, QPalette::Button,
menu.color(QPalette::Active, QPalette::Button));
@@ -729,10 +677,8 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
menu.color(QPalette::Active, QPalette::Highlight));
menu.setColor(QPalette::Inactive, QPalette::HighlightedText,
menu.color(QPalette::Active, QPalette::HighlightedText));
-
- if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95)
- menu.setColor(QPalette::Inactive, QPalette::ButtonText,
- pal.color(QPalette::Inactive, QPalette::Dark));
+ menu.setColor(QPalette::Inactive, QPalette::ButtonText,
+ pal.color(QPalette::Inactive, QPalette::Dark));
QApplication::setPalette(menu, "QMenu");
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
@@ -749,15 +695,10 @@ void QApplicationPrivate::initializeWidgetPaletteHash()
qt_init() - initializes Qt for Windows
*****************************************************************************/
-typedef BOOL (WINAPI *PtrUpdateLayeredWindow)(HWND hwnd, HDC hdcDst, const POINT *pptDst,
- const SIZE *psize, HDC hdcSrc, const POINT *pptSrc, COLORREF crKey,
- const Q_BLENDFUNCTION *pblend, DWORD dwflags);
-
typedef BOOL (WINAPI *PtrSetProcessDPIAware) (VOID);
-
-static PtrUpdateLayeredWindow ptrUpdateLayeredWindow = 0;
static PtrSetProcessDPIAware ptrSetProcessDPIAware = 0;
-
+PtrUpdateLayeredWindow ptrUpdateLayeredWindow = 0;
+PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect = 0;
static BOOL WINAPI qt_updateLayeredWindowIndirect(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *info)
{
return (*ptrUpdateLayeredWindow)(hwnd, info->hdcDst, info->pptDst, info->psize, info->hdcSrc,
@@ -822,46 +763,30 @@ void qt_init(QApplicationPrivate *priv, int)
#endif
qApp->setObjectName(priv->appName());
-#if !defined(Q_WS_WINCE)
// default font
- HFONT hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- QFont f(QLatin1String("MS Sans Serif"),8);
- int result = 0;
- QT_WA({
- LOGFONT lf;
- if (result = GetObject(hfont, sizeof(lf), &lf))
- f = qt_LOGFONTtoQFont((LOGFONT&)lf,true);
- } , {
- LOGFONTA lf;
- if (result = GetObjectA(hfont, sizeof(lf), &lf))
- f = qt_LOGFONTtoQFont((LOGFONT&)lf,true);
- });
- if (result
- && QSysInfo::WindowsVersion >= QSysInfo::WV_2000
- && QSysInfo::WindowsVersion <= QSysInfo::WV_NT_based
- && f.family() == QLatin1String("MS Shell Dlg"))
- f.setFamily(QLatin1String("MS Shell Dlg 2"));
- QApplicationPrivate::setSystemFont(f);
-#else //Q_WS_WINCE
- LOGFONT lf;
- HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT);
- int result = 0;
- result = GetObject(stockFont, sizeof(lf), &lf);
- QFont font = qt_LOGFONTtoQFont(lf, true);
- if (result)
- QApplicationPrivate::setSystemFont(font);
-#endif //Q_WS_WINCE
+#ifndef Q_WS_WINCE
+ HGDIOBJ stockFont = GetStockObject(DEFAULT_GUI_FONT);
+#else
+ HGDIOBJ stockFont = GetStockObject(SYSTEM_FONT);
+#endif
+
+ LOGFONT lf;
+ GetObject(stockFont, sizeof(lf), &lf);
+ QFont systemFont = qt_LOGFONTtoQFont(lf, true);
+
+#ifndef Q_WS_WINCE
+ if (systemFont.family() == QLatin1String("MS Shell Dlg")) {
+ systemFont.setFamily(QLatin1String("MS Shell Dlg 2"));
+ }
+#endif
+
+ QApplicationPrivate::setSystemFont(systemFont);
// QFont::locale_init(); ### Uncomment when it does something on Windows
if (QApplication::desktopSettingsAware())
qt_set_windows_resources();
- QT_WA({
- WM95_MOUSEWHEEL = RegisterWindowMessage(L"MSWHEEL_ROLLMSG");
- } , {
- WM95_MOUSEWHEEL = RegisterWindowMessageA("MSWHEEL_ROLLMSG");
- });
initWinTabFunctions();
QApplicationPrivate::inputContext = new QWinInputContext(0);
@@ -884,10 +809,38 @@ void qt_init(QApplicationPrivate *priv, int)
ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect;
// Notify Vista and Windows 7 that we support highter DPI settings
- if (ptrSetProcessDPIAware = (PtrSetProcessDPIAware)
- QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware"))
- ptrSetProcessDPIAware();
-#endif
+ ptrSetProcessDPIAware = (PtrSetProcessDPIAware)
+ QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
+ if (ptrSetProcessDPIAware)
+ ptrSetProcessDPIAware();
+#endif
+
+ priv->lastGestureId = 0;
+
+ priv->GetGestureInfo =
+ (PtrGetGestureInfo)QLibrary::resolve(QLatin1String("user32"),
+ "GetGestureInfo");
+ priv->GetGestureExtraArgs =
+ (PtrGetGestureExtraArgs)QLibrary::resolve(QLatin1String("user32"),
+ "GetGestureExtraArgs");
+ priv->CloseGestureInfoHandle =
+ (PtrCloseGestureInfoHandle)QLibrary::resolve(QLatin1String("user32"),
+ "CloseGestureInfoHandle");
+ priv->SetGestureConfig =
+ (PtrSetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
+ "SetGestureConfig");
+ priv->GetGestureConfig =
+ (PtrGetGestureConfig)QLibrary::resolve(QLatin1String("user32"),
+ "GetGestureConfig");
+ priv->BeginPanningFeedback =
+ (PtrBeginPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
+ "BeginPanningFeedback");
+ priv->UpdatePanningFeedback =
+ (PtrUpdatePanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
+ "UpdatePanningFeedback");
+ priv->EndPanningFeedback =
+ (PtrEndPanningFeedback)QLibrary::resolve(QLatin1String("uxtheme"),
+ "EndPanningFeedback");
}
/*****************************************************************************
@@ -963,7 +916,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) {
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)) {
- style |= 0x00020000; // CS_DROPSHADOW
+ style |= CS_DROPSHADOW;
}
cname = QLatin1String("QToolTip");
} else {
@@ -981,7 +934,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class
#endif
if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
&& QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- style |= 0x00020000; // CS_DROPSHADOW
+ style |= CS_DROPSHADOW;
icon = false;
} else {
cname = QLatin1String("QWidget");
@@ -1001,10 +954,10 @@ const QString qt_reg_winclass(QWidget *w) // register window class
// unique ID on WinCE to make sure we can
// move the windows to the front when starting
// a second instance.
- wchar_t uniqueAppID[256];
- GetModuleFileNameW(0, uniqueAppID, 255);
- cname = QString::number(RegisterWindowMessageW(
- (const wchar_t *) QString::fromUtf16((const ushort *)uniqueAppID).toLower().replace(QLatin1Char('\\'),
+ wchar_t uniqueAppID[MAX_PATH];
+ GetModuleFileName(0, uniqueAppID, MAX_PATH);
+ cname = QString::number(RegisterWindowMessage(
+ (const wchar_t *) QString::fromWCharArray(uniqueAppID).toLower().replace(QLatin1Char('\\'),
QLatin1Char('_')).utf16()));
#endif
@@ -1016,15 +969,9 @@ const QString qt_reg_winclass(QWidget *w) // register window class
static int classExists = -1;
if (classExists == -1) {
- QT_WA({
- WNDCLASS wcinfo;
- classExists = GetClassInfo(qWinAppInst(), (TCHAR*)cname.utf16(), &wcinfo);
- classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
- }, {
- WNDCLASSA wcinfo;
- classExists = GetClassInfoA(qWinAppInst(), cname.toLatin1(), &wcinfo);
- classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
- });
+ WNDCLASS wcinfo;
+ classExists = GetClassInfo((HINSTANCE)qWinAppInst(), (wchar_t*)cname.utf16(), &wcinfo);
+ classExists = classExists && wcinfo.lpfnWndProc != QtWndProc;
}
if (classExists)
@@ -1033,73 +980,37 @@ const QString qt_reg_winclass(QWidget *w) // register window class
if (winclassNames()->contains(cname)) // already registered in our list
return cname;
- ATOM atom;
+ WNDCLASS wc;
+ wc.style = style;
+ wc.lpfnWndProc = (WNDPROC)QtWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = qWinAppInst();
+ if (icon) {
+ wc.hIcon = (HICON)LoadImage(qWinAppInst(), L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
#ifndef Q_WS_WINCE
- HBRUSH bgBrush = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
- QT_WA({
- WNDCLASS wc;
- wc.style = style;
- wc.lpfnWndProc = (WNDPROC)QtWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = qWinAppInst();
- if (icon) {
- wc.hIcon = LoadIcon(qWinAppInst(), L"IDI_ICON1");
- if (!wc.hIcon)
- wc.hIcon = LoadIcon(0, IDI_APPLICATION);
- } else {
- wc.hIcon = 0;
- }
- wc.hCursor = 0;
- wc.hbrBackground= bgBrush;
- wc.lpszMenuName = 0;
- wc.lpszClassName= (TCHAR*)cname.utf16();
- atom = RegisterClass(&wc);
- } , {
- WNDCLASSA wc;
- wc.style = style;
- wc.lpfnWndProc = (WNDPROC)QtWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = qWinAppInst();
- if (icon) {
- wc.hIcon = LoadIconA(qWinAppInst(), (char*)"IDI_ICON1");
- if (!wc.hIcon)
- wc.hIcon = LoadIconA(0, (char*)IDI_APPLICATION);
- } else {
- wc.hIcon = 0;
- }
- wc.hCursor = 0;
- wc.hbrBackground= bgBrush;
- wc.lpszMenuName = 0;
- QByteArray tempArray = cname.toLatin1();
- wc.lpszClassName= tempArray;
- atom = RegisterClassA(&wc);
- });
+ if (!wc.hIcon)
+ wc.hIcon = (HICON)LoadImage(0, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+#endif
+ } else {
+ wc.hIcon = 0;
+ }
+ wc.hCursor = 0;
+#ifndef Q_WS_WINCE
+ wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
#else
- WNDCLASS wc;
- wc.style = style;
- wc.lpfnWndProc = (WNDPROC)QtWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = qWinAppInst();
- if (icon) {
- wc.hIcon = LoadIcon(qWinAppInst(), L"IDI_ICON1");
-// if (!wc.hIcon)
-// wc.hIcon = LoadIcon(0, IDI_APPLICATION);
- } else {
- wc.hIcon = 0;
- }
- wc.hCursor = 0;
- wc.hbrBackground= 0;
- wc.lpszMenuName = 0;
- wc.lpszClassName= (TCHAR*)cname.utf16();
- atom = RegisterClass(&wc);
+ wc.hbrBackground = 0;
#endif
+ wc.lpszMenuName = 0;
+ wc.lpszClassName = (wchar_t*)cname.utf16();
+
+ ATOM atom = RegisterClass(&wc);
#ifndef QT_NO_DEBUG
if (!atom)
qErrnoWarning("QApplication::regClass: Registering window class failed.");
+#else
+ Q_UNUSED(atom);
#endif
winclassNames()->insert(cname, 1);
@@ -1117,11 +1028,7 @@ static void unregWinClasses()
WinClassNameHash *hash = winclassNames();
QHash<QString, int>::ConstIterator it = hash->constBegin();
while (it != hash->constEnd()) {
- QT_WA({
- UnregisterClass((TCHAR*)it.key().utf16(), qWinAppInst());
- } , {
- UnregisterClassA(it.key().toLatin1(), qWinAppInst());
- });
+ UnregisterClass((wchar_t*)it.key().utf16(), qWinAppInst());
++it;
}
hash->clear();
@@ -1338,16 +1245,10 @@ void QApplication::beep()
static void alert_widget(QWidget *widget, int duration)
{
- bool stopFlash = duration < 0;
-
- if (!pFlashWindowEx) {
#ifndef Q_OS_WINCE
- QLibrary themeLib(QLatin1String("user32"));
- pFlashWindowEx = (PtrFlashWindowEx)themeLib.resolve("FlashWindowEx");
-#endif
- }
+ bool stopFlash = duration < 0;
- if (pFlashWindowEx && widget && (!widget->isActiveWindow() || stopFlash)) {
+ if (widget && (!widget->isActiveWindow() || stopFlash)) {
DWORD timeOut = GetCaretBlinkTime();
if (timeOut <= 0)
timeOut = 250;
@@ -1365,8 +1266,9 @@ static void alert_widget(QWidget *widget, int duration)
info.dwTimeout = stopFlash ? 0 : timeOut;
info.uCount = stopFlash ? 0 : flashCount;
- pFlashWindowEx(&info);
+ FlashWindowEx(&info);
}
+#endif
}
void QApplication::alert(QWidget *widget, int duration)
@@ -1454,13 +1356,13 @@ static int inputcharset = CP_ACP;
static bool qt_is_translatable_mouse_event(UINT message)
{
- return (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST ||
- message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK)
+ return (((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) ||
+ (message >= WM_XBUTTONDOWN && message <= WM_XBUTTONDBLCLK))
&& message != WM_MOUSEWHEEL
- && message != WM_MOUSEHWHEEL
+ && message != WM_MOUSEHWHEEL)
#ifndef Q_WS_WINCE
- || message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK
+ || (message >= WM_NCMOUSEMOVE && message <= WM_NCMBUTTONDBLCLK)
#endif
;
}
@@ -1727,7 +1629,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
// Sometimes we only get a WM_MOUSEMOVE message
// and sometimes we get both a WM_MOUSEMOVE and
// a WM_LBUTTONDOWN/UP, this creates a spurious mouse
- // press/release event, using the winPeekMessage
+ // press/release event, using the PeekMessage
// will help us fix this. This leaves us with a
// question:
// This effectively kills using the mouse AND the
@@ -1737,16 +1639,14 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
bool is_mouse_move = (message == WM_MOUSEMOVE);
if (is_mouse_move) {
MSG msg1;
- if (winPeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST,
- WM_MOUSELAST, PM_NOREMOVE))
+ if (PeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST,
+ WM_MOUSELAST, PM_NOREMOVE))
next_is_button = (msg1.message == WM_LBUTTONUP
|| msg1.message == WM_LBUTTONDOWN);
}
if (!is_mouse_move || (is_mouse_move && !next_is_button))
qt_tabletChokeMouse = false;
}
- } else if (message == WM95_MOUSEWHEEL) {
- result = widget->translateWheelEvent(msg);
} else {
switch (message) {
case WM_TOUCH:
@@ -1777,7 +1677,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
case WM_IME_KEYDOWN:
case WM_CHAR: {
MSG msg1;
- bool anyMsg = winPeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE);
+ bool anyMsg = PeekMessage(&msg1, msg.hwnd, 0, 0, PM_NOREMOVE);
if (anyMsg && msg1.message == WM_DEADCHAR) {
result = true; // consume event since there is a dead char next
break;
@@ -1977,11 +1877,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#ifndef QT_NO_WHATSTHIS
QWhatsThis::enterWhatsThisMode();
#endif
- QT_WA({
- DefWindowProc(hwnd, WM_NCPAINT, 1, 0);
- } , {
- DefWindowProcA(hwnd, WM_NCPAINT, 1, 0);
- });
+ DefWindowProc(hwnd, WM_NCPAINT, 1, 0);
break;
#if defined(QT_NON_COMMERCIAL)
QT_NC_SYSCOMMAND
@@ -2043,8 +1939,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
if (!msg.wParam) {
- QString area = QT_WA_INLINE(QString::fromUtf16((unsigned short *)msg.lParam),
- QString::fromLocal8Bit((char*)msg.lParam));
+ QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
if (area == QLatin1String("intl")) {
QLocalePrivate::updateSystemPrivate();
if (!widget->testAttribute(Qt::WA_SetLocale))
@@ -2422,11 +2317,7 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
text = widget->objectName();
ret = qMin<int>(wParam - 1, text.size());
text.resize(ret);
- QT_WA({
- memcpy((void *)lParam, text.utf16(), (text.size() + 1) * 2);
- }, {
- memcpy((void *)lParam, text.toLocal8Bit().data(), text.size() + 1);
- });
+ memcpy((void *)lParam, text.utf16(), (text.size() + 1) * sizeof(ushort));
delete acc;
}
if (!ret) {
@@ -2514,11 +2405,11 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
#ifndef Q_WS_WINCE
case WM_INPUTLANGCHANGE: {
- char info[7];
- if (!GetLocaleInfoA(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {
+ wchar_t info[7];
+ if (!GetLocaleInfo(MAKELCID(lParam, SORT_DEFAULT), LOCALE_IDEFAULTANSICODEPAGE, info, 6)) {
inputcharset = CP_ACP;
} else {
- inputcharset = QString::fromLatin1(info).toInt();
+ inputcharset = QString::fromWCharArray(info).toInt();
}
QKeyMapper::changeKeyboard();
break;
@@ -2612,6 +2503,10 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
result = false;
break;
+ case WM_GESTURE:
+ widget->translateGestureEvent(msg);
+ result = true;
+ break;
default:
result = false; // event was not processed
break;
@@ -2711,11 +2606,10 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret)
bool block_event = false;
#ifndef Q_WS_WINCE
- if (type != WM_NCHITTEST)
+ if (type != WM_NCHITTEST) {
#endif
if ((type >= WM_MOUSEFIRST && type <= WM_MOUSELAST) ||
- type == WM_MOUSEWHEEL || type == (int)WM95_MOUSEWHEEL ||
- type == WM_MOUSEHWHEEL ||
+ type == WM_MOUSEWHEEL || type == WM_MOUSEHWHEEL ||
type == WM_MOUSELEAVE ||
(type >= WM_KEYFIRST && type <= WM_KEYLAST)
#ifndef Q_WS_WINCE
@@ -2742,17 +2636,18 @@ bool qt_try_modal(QWidget *widget, MSG *msg, int& ret)
block_event = true;
}
#ifndef Q_WS_WINCE
- else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){
- if (!top->isActiveWindow()) {
- top->activateWindow();
- } else {
- QApplication::beep();
- }
- block_event = true;
- ret = MA_NOACTIVATEANDEAT;
- } else if (type == WM_SYSCOMMAND) {
- if (!(msg->wParam == SC_RESTORE && widget->isMinimized()))
+ else if (type == WM_MOUSEACTIVATE || type == WM_NCLBUTTONDOWN){
+ if (!top->isActiveWindow()) {
+ top->activateWindow();
+ } else {
+ QApplication::beep();
+ }
block_event = true;
+ ret = MA_NOACTIVATEANDEAT;
+ } else if (type == WM_SYSCOMMAND) {
+ if (!(msg->wParam == SC_RESTORE && widget->isMinimized()))
+ block_event = true;
+ }
}
#endif
@@ -2954,20 +2849,11 @@ void qt_win_eatMouseMove()
// remove all those messages (usually 1) and post the last one with a
// reset button state
- MSG msg = {0, 0, 0, 0, 0, 0, 0};
- QT_WA( {
- while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
- ;
- if (msg.message == WM_MOUSEMOVE)
- PostMessage(msg.hwnd, msg.message, 0, msg.lParam);
- }, {
- MSG msg;
- msg.message = 0;
- while (PeekMessageA(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
- ;
- if (msg.message == WM_MOUSEMOVE)
- PostMessageA(msg.hwnd, msg.message, 0, msg.lParam);
- } );
+ MSG msg = {0, 0, 0, 0, 0, {0, 0} };
+ while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
+ ;
+ if (msg.message == WM_MOUSEMOVE)
+ PostMessage(msg.hwnd, msg.message, 0, msg.lParam);
}
// In DnD, the mouse release event never appears, so the
@@ -3002,8 +2888,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
// Compress mouse move events
if (msg.message == WM_MOUSEMOVE) {
MSG mouseMsg;
- while (winPeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEFIRST,
- WM_MOUSELAST, PM_NOREMOVE)) {
+ while (PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEFIRST,
+ WM_MOUSELAST, PM_NOREMOVE)) {
if (mouseMsg.message == WM_MOUSEMOVE) {
#define PEEKMESSAGE_IS_BROKEN 1
#ifdef PEEKMESSAGE_IS_BROKEN
@@ -3014,12 +2900,12 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
// key release events (kls 2003-05-13):
MSG keyMsg;
bool done = false;
- while (winPeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST,
- PM_NOREMOVE)) {
+ while (PeekMessage(&keyMsg, 0, WM_KEYFIRST, WM_KEYLAST,
+ PM_NOREMOVE)) {
if (keyMsg.time < mouseMsg.time) {
if ((keyMsg.lParam & 0xC0000000) == 0x40000000) {
- winPeekMessage(&keyMsg, 0, keyMsg.message,
- keyMsg.message, PM_REMOVE);
+ PeekMessage(&keyMsg, 0, keyMsg.message,
+ keyMsg.message, PM_REMOVE);
} else {
done = true;
break;
@@ -3045,8 +2931,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
msgPtr->wParam = mouseMsg.wParam;
msgPtr->pt = mouseMsg.pt;
// Remove the mouse move message
- winPeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE,
- WM_MOUSEMOVE, PM_REMOVE);
+ PeekMessage(&mouseMsg, msg.hwnd, WM_MOUSEMOVE,
+ WM_MOUSEMOVE, PM_REMOVE);
} else {
break; // there was no more WM_MOUSEMOVE event
}
@@ -3075,7 +2961,9 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
if (alienWidget && alienWidget->internalWinId())
alienWidget = 0;
- if (type == QEvent::MouseMove || type == QEvent::NonClientAreaMouseMove) {
+ if (type == QEvent::MouseMove || type == QEvent::NonClientAreaMouseMove
+ || type == QEvent::TabletMove) {
+
if (!(state & Qt::MouseButtonMask))
qt_button_down = 0;
#ifndef QT_NO_CURSOR
@@ -3206,6 +3094,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
popupButtonFocus = popupChild;
break;
case QEvent::MouseButtonRelease:
+ case QEvent::TabletRelease:
+
releaseAfter = true;
break;
default:
@@ -3260,7 +3150,7 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
POINT widgetpt = gpos;
ScreenToClient(hwndTarget, &widgetpt);
LPARAM lParam = MAKELPARAM(widgetpt.x, widgetpt.y);
- winPostMessage(hwndTarget, msg.message, msg.wParam, lParam);
+ PostMessage(hwndTarget, msg.message, msg.wParam, lParam);
}
} else if (type == QEvent::MouseButtonRelease && button == Qt::RightButton
&& QApplication::activePopupWidget() == activePopupWidget) {
@@ -3443,17 +3333,19 @@ static void tabletInit(UINT wActiveCsr, HCTX hTab)
tdd.minTanPressure = int(np.axMin);
tdd.maxTanPressure = int(np.axMax);
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_X, &np);
- tdd.minX = int(np.axMin);
- tdd.maxX = int(np.axMax);
+ LOGCONTEXT lcMine;
+
+ /* get default region */
+ ptrWTInfo(WTI_DEFCONTEXT, 0, &lcMine);
+
+ tdd.minX = 0;
+ tdd.maxX = int(lcMine.lcInExtX) - int(lcMine.lcInOrgX);
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_Y, &np);
- tdd.minY = int(np.axMin);
- tdd.maxY = int(np.axMax);
+ tdd.minY = 0;
+ tdd.maxY = int(lcMine.lcInExtY) - int(lcMine.lcInOrgY);
- ptrWTInfo(WTI_DEVICES + lc.lcDevice, DVC_Z, &np);
- tdd.minZ = int(np.axMin);
- tdd.maxZ = int(np.axMax);
+ tdd.minZ = 0;
+ tdd.maxZ = int(lcMine.lcInExtZ) - int(lcMine.lcInOrgZ);
int csr_type,
csr_physid;
@@ -3563,13 +3455,34 @@ bool QETWidget::translateTabletEvent(const MSG &msg, PACKET *localPacketBuf,
}
QPoint globalPos(qRound(hiResGlobal.x()), qRound(hiResGlobal.y()));
+ if (t == QEvent::TabletPress)
+ {
+ qt_button_down = QApplication::widgetAt(globalPos);
+ }
+
// make sure the tablet event get's sent to the proper widget...
- QWidget *w = QApplication::widgetAt(globalPos);
+ QWidget *w = 0;
+
if (qt_button_down)
w = qt_button_down; // Pass it to the thing that's grabbed it.
+ else
+ w = QApplication::widgetAt(globalPos);
if (!w)
w = this;
+
+ if (t == QEvent::TabletRelease)
+ {
+ if (qt_win_ignoreNextMouseReleaseEvent) {
+ qt_win_ignoreNextMouseReleaseEvent = false;
+ if (qt_button_down && qt_button_down->internalWinId() == autoCaptureWnd) {
+ releaseAutoCapture();
+ qt_button_down = 0;
+ }
+ }
+
+ }
+
QPoint localPos = w->mapFromGlobal(globalPos);
#ifndef QT_NO_TABLETEVENT
if (currentTabletPointer.currentDevice == QTabletEvent::Airbrush) {
@@ -3627,14 +3540,8 @@ static void initWinTabFunctions()
QLibrary library(QLatin1String("wintab32"));
if (library.load()) {
- QT_WA({
- ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
- ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
- } , {
- ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoA");
- ptrWTGet = (PtrWTGet)library.resolve("WTGetA");
- });
-
+ ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
+ ptrWTGet = (PtrWTGet)library.resolve("WTGetW");
ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable");
ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap");
ptrWTPacketsGet = (PtrWTPacketsGet)library.resolve("WTPacketsGet");
@@ -3808,6 +3715,60 @@ bool QETWidget::translateCloseEvent(const MSG &)
return d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
}
+bool QETWidget::translateGestureEvent(const MSG &msg)
+{
+ GESTUREINFO gi;
+ gi.cbSize = sizeof(GESTUREINFO);
+ gi.dwFlags = 0;
+ gi.ptsLocation.x = 0;
+ gi.ptsLocation.y = 0;
+ gi.dwID = 0;
+ gi.dwInstanceID = 0;
+ gi.dwSequenceID = 0;
+
+ QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ BOOL bResult = qAppPriv->GetGestureInfo((HANDLE)msg.lParam, &gi);
+
+ const QPoint widgetPos = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
+ QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos);
+ if (alienWidget && alienWidget->internalWinId())
+ alienWidget = 0;
+ QWidget *widget = alienWidget ? alienWidget : this;
+
+ QWinGestureEvent event;
+ event.sequenceId = gi.dwSequenceID;
+ event.position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
+ if (bResult) {
+ switch (gi.dwID) {
+ case GID_BEGIN:
+ // we are not interested in this type of event.
+ break;
+ case GID_END:
+ event.gestureType = QWinGestureEvent::GestureEnd;
+ break;
+ case GID_ZOOM:
+ event.gestureType = QWinGestureEvent::Pinch;
+ break;
+ case GID_PAN:
+ event.gestureType = QWinGestureEvent::Pan;
+ break;
+ case GID_ROTATE:
+ case GID_TWOFINGERTAP:
+ case GID_ROLLOVER:
+ default:
+ break;
+ }
+ if (event.gestureType != QWinGestureEvent::None)
+ qt_sendSpontaneousEvent(widget, &event);
+ } else {
+ DWORD dwErr = GetLastError();
+ if (dwErr > 0)
+ qWarning() << "translateGestureEvent: error = " << dwErr;
+ }
+ qAppPriv->CloseGestureInfoHandle((HANDLE)msg.lParam);
+ return true;
+}
+
void QApplication::setCursorFlashTime(int msecs)
{
@@ -3861,11 +3822,7 @@ void QApplication::setWheelScrollLines(int n)
#ifdef SPI_SETWHEELSCROLLLINES
if (n < 0)
n = 0;
- QT_WA({
- SystemParametersInfo(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0);
- } , {
- SystemParametersInfoA(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0);
- });
+ SystemParametersInfo(SPI_SETWHEELSCROLLLINES, (uint)n, 0, 0);
#else
QApplicationPrivate::wheel_scroll_lines = n;
#endif
@@ -3875,11 +3832,7 @@ int QApplication::wheelScrollLines()
{
#ifdef SPI_GETWHEELSCROLLLINES
uint i = 3;
- QT_WA({
- SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0);
- } , {
- SystemParametersInfoA(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0);
- });
+ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, sizeof(uint), &i, 0);
if (i > INT_MAX)
i = INT_MAX;
return i;
@@ -3924,8 +3877,7 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect)
if (QColormap::instance().depth() < 16)
return false;
- if (!effect_override && desktopSettingsAware()
- && !(QSysInfo::WindowsVersion == QSysInfo::WV_95 || QSysInfo::WindowsVersion == QSysInfo::WV_NT)) {
+ if (!effect_override && desktopSettingsAware()) {
// we know that they can be used when we are here
BOOL enabled = false;
UINT api;
@@ -3934,33 +3886,22 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect)
api = SPI_GETMENUANIMATION;
break;
case Qt::UI_FadeMenu:
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- return false;
api = SPI_GETMENUFADE;
break;
case Qt::UI_AnimateCombo:
api = SPI_GETCOMBOBOXANIMATION;
break;
case Qt::UI_AnimateTooltip:
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- api = SPI_GETMENUANIMATION;
- else
- api = SPI_GETTOOLTIPANIMATION;
+ api = SPI_GETTOOLTIPANIMATION;
break;
case Qt::UI_FadeTooltip:
- if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- return false;
api = SPI_GETTOOLTIPFADE;
break;
default:
api = SPI_GETUIEFFECTS;
break;
}
- QT_WA({
- SystemParametersInfo(api, 0, &enabled, 0);
- } , {
- SystemParametersInfoA(api, 0, &enabled, 0);
- });
+ SystemParametersInfo(api, 0, &enabled, 0);
return enabled;
}
@@ -4009,16 +3950,18 @@ void QSessionManager::cancel()
#endif //QT_NO_SESSIONMANAGER
-qt_RegisterTouchWindowPtr QApplicationPrivate::RegisterTouchWindow = 0;
-qt_GetTouchInputInfoPtr QApplicationPrivate::GetTouchInputInfo = 0;
-qt_CloseTouchInputHandlePtr QApplicationPrivate::CloseTouchInputHandle = 0;
+
+PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0;
+PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0;
+PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0;
void QApplicationPrivate::initializeMultitouch_sys()
{
QLibrary library(QLatin1String("user32"));
- RegisterTouchWindow = static_cast<qt_RegisterTouchWindowPtr>(library.resolve("RegisterTouchWindow"));
- GetTouchInputInfo = static_cast<qt_GetTouchInputInfoPtr>(library.resolve("GetTouchInputInfo"));
- CloseTouchInputHandle = static_cast<qt_CloseTouchInputHandlePtr>(library.resolve("CloseTouchInputHandle"));
+ // MinGW (g++ 3.4.5) accepts only C casts.
+ RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
+ GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
+ CloseTouchInputHandle = (PtrCloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
touchInputIDToTouchPointID.clear();
}
@@ -4030,13 +3973,11 @@ void QApplicationPrivate::cleanupMultitouch_sys()
bool QApplicationPrivate::translateTouchEvent(const MSG &msg)
{
- Q_Q(QApplication);
-
QWidget *widgetForHwnd = QWidget::find(msg.hwnd);
if (!widgetForHwnd)
return false;
- QRect screenGeometry = q->desktop()->screenGeometry(widgetForHwnd);
+ QRect screenGeometry = QApplication::desktop()->screenGeometry(widgetForHwnd);
QList<QTouchEvent::TouchPoint> touchPoints;
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 5ef6b2e..4016563 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -117,7 +117,9 @@ extern "C" {
#define XK_MISCELLANY
#include <X11/keysymdef.h>
+#if !defined(QT_NO_XINPUT)
#include <X11/extensions/XI.h>
+#endif
#include <stdlib.h>
#include <string.h>
@@ -655,11 +657,13 @@ static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
break;
default:
+#if !defined(QT_NO_XINPUT)
if (err->request_code == X11->xinput_major
&& err->error_code == (X11->xinput_errorbase + XI_BadDevice)
&& err->minor_code == 3 /* X_OpenDevice */) {
return 0;
}
+#endif
break;
}
@@ -1392,6 +1396,18 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
color = kdeColor(QLatin1String("Colors:Button/ForegroundNormal"), theKdeSettings);
if (color.isValid())
pal.setColor(QPalette::ButtonText, color);
+
+ color = kdeColor(QLatin1String("linkColor"), theKdeSettings);
+ if (!color.isValid())
+ color = kdeColor(QLatin1String("Colors:View/ForegroundLink"), theKdeSettings);
+ if (color.isValid())
+ pal.setColor(QPalette::Link, color);
+
+ color = kdeColor(QLatin1String("visitedLinkColor"), theKdeSettings);
+ if (!color.isValid())
+ color = kdeColor(QLatin1String("Colors:View/ForegroundVisited"), theKdeSettings);
+ if (color.isValid())
+ pal.setColor(QPalette::LinkVisited, color);
}
if (highlight.isValid() && highlightText.isValid()) {
@@ -3230,48 +3246,43 @@ int QApplication::x11ProcessEvent(XEvent* event)
#ifdef ALIEN_DEBUG
//qDebug() << "QApplication::x11ProcessEvent:" << event->type;
#endif
- Time time = 0, userTime = 0;
switch (event->type) {
case ButtonPress:
pressed_window = event->xbutton.window;
- userTime = event->xbutton.time;
+ X11->userTime = event->xbutton.time;
// fallthrough intended
case ButtonRelease:
- time = event->xbutton.time;
+ X11->time = event->xbutton.time;
break;
case MotionNotify:
- time = event->xmotion.time;
+ X11->time = event->xmotion.time;
break;
case XKeyPress:
- userTime = event->xkey.time;
+ X11->userTime = event->xkey.time;
// fallthrough intended
case XKeyRelease:
- time = event->xkey.time;
+ X11->time = event->xkey.time;
break;
case PropertyNotify:
- time = event->xproperty.time;
+ X11->time = event->xproperty.time;
break;
case EnterNotify:
case LeaveNotify:
- time = event->xcrossing.time;
+ X11->time = event->xcrossing.time;
break;
case SelectionClear:
- time = event->xselectionclear.time;
+ X11->time = event->xselectionclear.time;
break;
default:
-#ifndef QT_NO_XFIXES
- if (X11->use_xfixes && event->type == (X11->xfixes_eventbase + XFixesSelectionNotify)) {
- XFixesSelectionNotifyEvent *req =
- reinterpret_cast<XFixesSelectionNotifyEvent *>(event);
- time = req->selection_timestamp;
- }
-#endif
break;
}
- if (time > X11->time)
- X11->time = time;
- if (userTime > X11->userTime)
- X11->userTime = userTime;
+#ifndef QT_NO_XFIXES
+ if (X11->use_xfixes && event->type == (X11->xfixes_eventbase + XFixesSelectionNotify)) {
+ XFixesSelectionNotifyEvent *req =
+ reinterpret_cast<XFixesSelectionNotifyEvent *>(event);
+ X11->time = req->selection_timestamp;
+ }
+#endif
QETWidget *widget = (QETWidget*)QWidget::find((WId)event->xany.window);
@@ -3437,19 +3448,10 @@ int QApplication::x11ProcessEvent(XEvent* event)
QSize oldSize(w->size());
w->data->crect.setWidth(DisplayWidth(X11->display, scr));
w->data->crect.setHeight(DisplayHeight(X11->display, scr));
- QVarLengthArray<QRect> oldSizes(desktop->numScreens());
- for (int i = 0; i < desktop->numScreens(); ++i)
- oldSizes[i] = desktop->screenGeometry(i);
QResizeEvent e(w->size(), oldSize);
QApplication::sendEvent(w, &e);
- for (int i = 0; i < qMin(oldSizes.count(), desktop->numScreens()); ++i) {
- if (oldSizes[i] != desktop->screenGeometry(i))
- emit desktop->resized(i);
- }
- for (int i = oldSizes.count(); i < desktop->numScreens(); ++i)
- emit desktop->resized(i); // added
- for (int i = desktop->numScreens(); i < oldSizes.count(); ++i)
- emit desktop->resized(i); // removed
+ if (w != desktop)
+ QApplication::sendEvent(desktop, &e);
}
#endif // QT_NO_XRANDR
diff --git a/src/gui/kernel/qclipboard_mac.cpp b/src/gui/kernel/qclipboard_mac.cpp
index b7b57b8..45050b2 100644
--- a/src/gui/kernel/qclipboard_mac.cpp
+++ b/src/gui/kernel/qclipboard_mac.cpp
@@ -50,6 +50,7 @@
#include "qurl.h"
#include <stdlib.h>
#include <string.h>
+#include "qt_cocoa_helpers_mac_p.h"
QT_BEGIN_NAMESPACE
@@ -525,8 +526,17 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const
QString c_flavor = c->flavorFor(format);
if(!c_flavor.isEmpty()) {
// Handle text/plain a little differently. Try handling Unicode first.
- if((c_flavor == QLatin1String("com.apple.traditional-mac-plain-text") || c_flavor == QLatin1String("public.utf8-plain-text")) &&
- hasFlavor(QLatin1String("public.utf16-plain-text")))
+ bool checkForUtf16 = (c_flavor == QLatin1String("com.apple.traditional-mac-plain-text")
+ || c_flavor == QLatin1String("public.utf8-plain-text"));
+ if (checkForUtf16 || c_flavor == QLatin1String("public.utf16-plain-text")) {
+ // Try to get the NSStringPboardType from NSPasteboard, newlines are mapped
+ // correctly (as '\n') in this data. The 'public.utf16-plain-text' type
+ // usually maps newlines to '\r' instead.
+ QString str = qt_mac_get_pasteboardString();
+ if (!str.isEmpty())
+ return str;
+ }
+ if (checkForUtf16 && hasFlavor(QLatin1String("public.utf16-plain-text")))
c_flavor = QLatin1String("public.utf16-plain-text");
QVariant ret;
diff --git a/src/gui/kernel/qclipboard_win.cpp b/src/gui/kernel/qclipboard_win.cpp
index 09b5448..f5aa088 100644
--- a/src/gui/kernel/qclipboard_win.cpp
+++ b/src/gui/kernel/qclipboard_win.cpp
@@ -200,7 +200,7 @@ HRESULT QtCeGetClipboard(IDataObject** obj)
if (clipData == 0) {
clipData = GetClipboardData(CF_UNICODETEXT);
if (clipData != 0)
- clipText = QString::fromUtf16((unsigned short *)clipData);
+ clipText = QString::fromWCharArray((wchar_t *)clipData);
} else {
clipText = QString::fromLatin1((const char*)clipData);
}
@@ -325,13 +325,7 @@ bool QClipboard::event(QEvent *e)
}
if (propagate && d->nextClipboardViewer) {
- QT_WA({
- SendMessage(d->nextClipboardViewer, m->message,
- m->wParam, m->lParam);
- } , {
- SendMessageA(d->nextClipboardViewer, m->message,
- m->wParam, m->lParam);
- });
+ SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
}
return true;
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index bdc7ecb..1e0bbdf 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -85,6 +85,12 @@ QT_USE_NAMESPACE
last resort (i.e., this is code that can potentially be removed).
*/
+- (void)toggleToolbarShown:(id)sender
+{
+ macSendToolbarChangeEvent([self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ [super toggleToolbarShown:sender];
+}
+
- (void)keyDown:(NSEvent *)theEvent
{
bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 52685ca..3bc348c 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -550,15 +550,7 @@ extern "C" {
qwidget->objectName().local8Bit().data());
#endif
QPainter p(qwidget);
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(qwidget->parent());
- QPoint scrollAreaOffset;
- if (scrollArea && scrollArea->viewport() == qwidget) {
- QAbstractScrollAreaPrivate *priv
- = static_cast<QAbstractScrollAreaPrivate *>(qt_widget_private(scrollArea));
- scrollAreaOffset = priv->contentsOffset();
- p.translate(-scrollAreaOffset);
- }
- qwidgetprivate->paintBackground(&p, qrgn, scrollAreaOffset,
+ qwidgetprivate->paintBackground(&p, qrgn,
qwidget->isWindow() ? QWidgetPrivate::DrawAsRoot : 0);
p.end();
}
@@ -1047,7 +1039,7 @@ extern "C" {
- (void) insertText:(id)aString
{
- if ([aString length]) {
+ if ([aString length] && composing) {
// Send the commit string to the widget.
QString commitText;
if ([aString isKindOfClass:[NSAttributedString class]]) {
@@ -1060,7 +1052,14 @@ extern "C" {
QInputMethodEvent e;
e.setCommitString(commitText);
qt_sendSpontaneousEvent(qwidget, &e);
+ } else {
+ // The key sequence "`q" on a French Keyboard will generate two calls to insertText before
+ // it returns from interpretKeyEvents. The first call will turn off 'composing' and accept
+ // the "`" key. The last keyDown event needs to be processed by the widget to get the
+ // character "q". The string parameter is ignored for the second call.
+ sendKeyEvents = true;
}
+
composingText->clear();
}
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 7084416..eb08982 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -104,6 +104,12 @@ QT_USE_NAMESPACE
last resort (i.e., this is code that can potentially be removed).
*/
+- (void)toggleToolbarShown:(id)sender
+{
+ macSendToolbarChangeEvent([self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ [super toggleToolbarShown:sender];
+}
+
- (void)keyDown:(NSEvent *)theEvent
{
bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
diff --git a/src/gui/kernel/qcursor_win.cpp b/src/gui/kernel/qcursor_win.cpp
index f0dc108..26e395c 100644
--- a/src/gui/kernel/qcursor_win.cpp
+++ b/src/gui/kernel/qcursor_win.cpp
@@ -317,54 +317,50 @@ void QCursorData::update()
phand_bits, phandm_bits
};
- unsigned short *sh;
+ wchar_t *sh = 0;
switch (cshape) { // map to windows cursor
case Qt::ArrowCursor:
- sh = (unsigned short*)IDC_ARROW;
+ sh = IDC_ARROW;
break;
case Qt::UpArrowCursor:
- sh = (unsigned short*)IDC_UPARROW;
+ sh = IDC_UPARROW;
break;
case Qt::CrossCursor:
- sh = (unsigned short*)IDC_CROSS;
+ sh = IDC_CROSS;
break;
case Qt::WaitCursor:
- sh = (unsigned short*)IDC_WAIT;
+ sh = IDC_WAIT;
break;
case Qt::IBeamCursor:
- sh = (unsigned short*)IDC_IBEAM;
+ sh = IDC_IBEAM;
break;
case Qt::SizeVerCursor:
- sh = (unsigned short*)IDC_SIZENS;
+ sh = IDC_SIZENS;
break;
case Qt::SizeHorCursor:
- sh = (unsigned short*)IDC_SIZEWE;
+ sh = IDC_SIZEWE;
break;
case Qt::SizeBDiagCursor:
- sh = (unsigned short*)IDC_SIZENESW;
+ sh = IDC_SIZENESW;
break;
case Qt::SizeFDiagCursor:
- sh = (unsigned short*)IDC_SIZENWSE;
+ sh = IDC_SIZENWSE;
break;
case Qt::SizeAllCursor:
- sh = (unsigned short*)IDC_SIZEALL;
+ sh = IDC_SIZEALL;
break;
case Qt::ForbiddenCursor:
- sh = (unsigned short*)IDC_NO;
+ sh = IDC_NO;
break;
case Qt::WhatsThisCursor:
- sh = (unsigned short*)IDC_HELP;
+ sh = IDC_HELP;
break;
case Qt::BusyCursor:
- sh = (unsigned short*)IDC_APPSTARTING;
+ sh = IDC_APPSTARTING;
break;
case Qt::PointingHandCursor:
- if ((QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) > QSysInfo::WV_95 ||
- (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) > QSysInfo::WV_NT) {
- sh = (unsigned short*)IDC_HAND;
- break;
- }
- // fall through
+ sh = IDC_HAND;
+ break;
case Qt::BlankCursor:
case Qt::SplitVCursor:
case Qt::SplitHCursor:
@@ -480,13 +476,11 @@ void QCursorData::update()
qWarning("QCursor::update: Invalid cursor shape %d", cshape);
return;
}
- // ### From MSDN:
- // ### LoadCursor has been superseded by the LoadImage function.
- QT_WA({
- hcurs = LoadCursorW(0, reinterpret_cast<const TCHAR *>(sh));
- } , {
- hcurs = LoadCursorA(0, reinterpret_cast<const char*>(sh));
- });
+#ifdef Q_WS_WINCE
+ hcurs = LoadCursor(0, sh);
+#else
+ hcurs = (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+#endif
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdesktopwidget.h b/src/gui/kernel/qdesktopwidget.h
index 470f10a..a21ae9d 100644
--- a/src/gui/kernel/qdesktopwidget.h
+++ b/src/gui/kernel/qdesktopwidget.h
@@ -56,6 +56,9 @@ class QDesktopWidgetPrivate;
class Q_GUI_EXPORT QDesktopWidget : public QWidget
{
Q_OBJECT
+ Q_PROPERTY(bool virtualDesktop READ isVirtualDesktop)
+ Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged)
+ Q_PROPERTY(int primaryScreen READ primaryScreen)
public:
QDesktopWidget();
~QDesktopWidget();
@@ -63,6 +66,7 @@ public:
bool isVirtualDesktop() const;
int numScreens() const;
+ int screenCount() const;
int primaryScreen() const;
int screenNumber(const QWidget *widget = 0) const;
@@ -85,6 +89,7 @@ public:
Q_SIGNALS:
void resized(int);
void workAreaResized(int);
+ void screenCountChanged(int);
protected:
void resizeEvent(QResizeEvent *e);
@@ -97,6 +102,9 @@ private:
friend class QApplicationPrivate;
};
+inline int QDesktopWidget::screenCount() const
+{ return numScreens(); }
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qdesktopwidget_mac.mm b/src/gui/kernel/qdesktopwidget_mac.mm
index 2489fe4..705387d 100644
--- a/src/gui/kernel/qdesktopwidget_mac.mm
+++ b/src/gui/kernel/qdesktopwidget_mac.mm
@@ -97,15 +97,13 @@ QT_USE_NAMESPACE
Q_GLOBAL_STATIC(QDesktopWidgetImplementation, qdesktopWidgetImplementation)
QDesktopWidgetImplementation::QDesktopWidgetImplementation()
- : appScreen(0), displays(0)
+ : appScreen(0)
{
onResize();
}
QDesktopWidgetImplementation::~QDesktopWidgetImplementation()
{
- if (displays)
- [displays release];
}
QDesktopWidgetImplementation *QDesktopWidgetImplementation::instance()
@@ -118,13 +116,7 @@ QRect QDesktopWidgetImplementation::availableRect(int screenIndex) const
if (screenIndex < 0 || screenIndex >= screenCount)
screenIndex = appScreen;
- NSRect r = [[displays objectAtIndex:screenIndex] visibleFrame];
- NSRect primaryRect = [[displays objectAtIndex:0] frame];
-
- const int flippedY = - r.origin.y + // account for position offset and
- primaryRect.size.height - r.size.height; // height difference.
- return QRectF(r.origin.x, flippedY,
- r.size.width, r.size.height).toRect();
+ return availableRects[screenIndex].toRect();
}
QRect QDesktopWidgetImplementation::screenRect(int screenIndex) const
@@ -132,22 +124,28 @@ QRect QDesktopWidgetImplementation::screenRect(int screenIndex) const
if (screenIndex < 0 || screenIndex >= screenCount)
screenIndex = appScreen;
- NSRect r = [[displays objectAtIndex:screenIndex] frame];
- NSRect primaryRect = [[displays objectAtIndex:0] frame];
-
- const int flippedY = - r.origin.y + // account for position offset and
- primaryRect.size.height - r.size.height; // height difference.
- return QRectF(r.origin.x, flippedY,
- r.size.width, r.size.height).toRect();
+ return screenRects[screenIndex].toRect();
}
void QDesktopWidgetImplementation::onResize()
{
- if (displays)
- [displays release];
-
- displays = [[NSScreen screens] retain];
- screenCount = [displays count];
+ QMacCocoaAutoReleasePool pool;
+ NSArray *displays = [NSScreen screens];
+ screenCount = [displays count];
+
+ screenRects.clear();
+ availableRects.clear();
+ NSRect primaryRect = [[displays objectAtIndex:0] frame];
+ for (int i = 0; i<screenCount; i++) {
+ NSRect r = [[displays objectAtIndex:i] frame];
+ const int flippedY = - r.origin.y + // account for position offset and
+ primaryRect.size.height - r.size.height; // height difference.
+ screenRects.append(QRectF(r.origin.x, flippedY,
+ r.size.width, r.size.height));
+ r = [[displays objectAtIndex:i] visibleFrame];
+ availableRects.append(QRectF(r.origin.x, flippedY,
+ r.size.width, r.size.height));
+ }
}
@@ -195,7 +193,7 @@ const QRect QDesktopWidget::screenGeometry(int screen) const
int QDesktopWidget::screenNumber(const QWidget *widget) const
{
- QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
+ QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
if (!widget)
return d->appScreen;
QRect frame = widget->frameGeometry();
@@ -216,7 +214,7 @@ int QDesktopWidget::screenNumber(const QWidget *widget) const
int QDesktopWidget::screenNumber(const QPoint &point) const
{
- QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
+ QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
int closestScreen = -1;
int shortestDistance = INT_MAX;
for (int i = 0; i < d->screenCount; ++i) {
@@ -232,13 +230,25 @@ int QDesktopWidget::screenNumber(const QPoint &point) const
void QDesktopWidget::resizeEvent(QResizeEvent *)
{
- QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
+ QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
+
+ const int oldScreenCount = d->screenCount;
+ const QVector<QRectF> oldRects(d->screenRects);
+ const QVector<QRectF> oldWorks(d->availableRects);
d->onResize();
- for (int i = 0; i < d->screenCount; ++i) {
- emit resized(i);
+ for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
+ if (oldRects.at(i) != d->screenRects.at(i))
+ emit resized(i);
+ }
+ for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
+ if (oldWorks.at(i) != d->availableRects.at(i))
+ emit workAreaResized(i);
}
+
+ if (oldScreenCount != d->screenCount)
+ emit screenCountChanged(d->screenCount);
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdesktopwidget_mac_p.h b/src/gui/kernel/qdesktopwidget_mac_p.h
index 0fdc455..e9d5d9f 100644
--- a/src/gui/kernel/qdesktopwidget_mac_p.h
+++ b/src/gui/kernel/qdesktopwidget_mac_p.h
@@ -64,7 +64,8 @@ public:
int appScreen;
int screenCount;
- NSArray *displays;
+ QVector<QRectF> availableRects;
+ QVector<QRectF> screenRects;
QRect availableRect(int screenIndex) const;
QRect screenRect(int screenIndex) const;
diff --git a/src/gui/kernel/qdesktopwidget_win.cpp b/src/gui/kernel/qdesktopwidget_win.cpp
index aa290c4..a89e08f 100644
--- a/src/gui/kernel/qdesktopwidget_win.cpp
+++ b/src/gui/kernel/qdesktopwidget_win.cpp
@@ -152,41 +152,27 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that)
rects = new QVector<QRect>();
workrects = new QVector<QRect>();
+ screenCount = 0;
#ifndef Q_OS_WINCE
- if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) {
- screenCount = 0;
- // Trying to get the function pointers to Win98/2000 only functions
- QLibrary user32Lib(QLatin1String("user32"));
- if (!user32Lib.load())
- return;
+ QLibrary user32Lib(QLatin1String("user32"));
+ if (user32Lib.load()) {
enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors");
- QT_WA({
- getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW");
- } , {
- getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoA");
- });
-
- if (!enumDisplayMonitors || !getMonitorInfo) {
- screenCount = GetSystemMetrics(80); // SM_CMONITORS
- rects->resize(screenCount);
- for (int i = 0; i < screenCount; ++i)
- rects->replace(i, that->rect());
- return;
- }
- // Calls enumCallback
- enumDisplayMonitors(0, 0, enumCallback, 0);
- enumDisplayMonitors = 0;
- getMonitorInfo = 0;
- } else {
- rects->resize(1);
- rects->replace(0, that->rect());
- workrects->resize(1);
- workrects->replace(0, that->rect());
+ getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW");
}
-#else
- screenCount = 0;
+ if (!enumDisplayMonitors || !getMonitorInfo) {
+ screenCount = GetSystemMetrics(80); // SM_CMONITORS
+ rects->resize(screenCount);
+ for (int i = 0; i < screenCount; ++i)
+ rects->replace(i, that->rect());
+ return;
+ }
+ // Calls enumCallback
+ enumDisplayMonitors(0, 0, enumCallback, 0);
+ enumDisplayMonitors = 0;
+ getMonitorInfo = 0;
+#else
QLibrary coreLib(QLatin1String("coredll"));
if (coreLib.load()) {
// CE >= 4.0 case
@@ -307,80 +293,69 @@ const QRect QDesktopWidget::availableGeometry(int screen) const
for(int i=0; i < d->workrects->size(); ++i)
qt_get_sip_info((*d->workrects)[i]);
#endif
- if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) {
- if (screen < 0 || screen >= d->screenCount)
- screen = d->primaryScreen;
+ if (screen < 0 || screen >= d->screenCount)
+ screen = d->primaryScreen;
- return d->workrects->at(screen);
- } else {
- return d->workrects->at(d->primaryScreen);
- }
+ return d->workrects->at(screen);
}
const QRect QDesktopWidget::screenGeometry(int screen) const
{
const QDesktopWidgetPrivate *d = d_func();
- if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) {
- if (screen < 0 || screen >= d->screenCount)
- screen = d->primaryScreen;
+ if (screen < 0 || screen >= d->screenCount)
+ screen = d->primaryScreen;
- return d->rects->at(screen);
- } else {
- return d->rects->at(d->primaryScreen);
- }
+ return d->rects->at(screen);
}
int QDesktopWidget::screenNumber(const QWidget *widget) const
{
Q_D(const QDesktopWidget);
- if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) {
- if (!widget)
- return d->primaryScreen;
- QRect frame = widget->frameGeometry();
- if (!widget->isWindow())
- frame.moveTopLeft(widget->mapToGlobal(QPoint(0,0)));
-
- int maxSize = -1;
- int maxScreen = -1;
-
- for (int i = 0; i < d->screenCount; ++i) {
- QRect sect = d->rects->at(i).intersected(frame);
- int size = sect.width() * sect.height();
- if (size > maxSize && sect.width() > 0 && sect.height() > 0) {
- maxSize = size;
- maxScreen = i;
- }
- }
- return maxScreen;
- } else {
+ if (!widget)
return d->primaryScreen;
+
+ QRect frame = widget->frameGeometry();
+ if (!widget->isWindow())
+ frame.moveTopLeft(widget->mapToGlobal(QPoint(0,0)));
+
+ int maxSize = -1;
+ int maxScreen = -1;
+
+ for (int i = 0; i < d->screenCount; ++i) {
+ QRect sect = d->rects->at(i).intersected(frame);
+ int size = sect.width() * sect.height();
+ if (size > maxSize && sect.width() > 0 && sect.height() > 0) {
+ maxSize = size;
+ maxScreen = i;
+ }
}
+
+ return maxScreen;
}
int QDesktopWidget::screenNumber(const QPoint &point) const
{
Q_D(const QDesktopWidget);
+
int closestScreen = -1;
- if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) {
- int shortestDistance = INT_MAX;
- for (int i = 0; i < d->screenCount; ++i) {
- int thisDistance = d->pointToRect(point, d->rects->at(i));
- if (thisDistance < shortestDistance) {
- shortestDistance = thisDistance;
- closestScreen = i;
- }
+ int shortestDistance = INT_MAX;
+
+ for (int i = 0; i < d->screenCount; ++i) {
+ int thisDistance = d->pointToRect(point, d->rects->at(i));
+ if (thisDistance < shortestDistance) {
+ shortestDistance = thisDistance;
+ closestScreen = i;
}
}
+
return closestScreen;
}
void QDesktopWidget::resizeEvent(QResizeEvent *)
{
Q_D(QDesktopWidget);
- QVector<QRect> oldrects;
- oldrects = *d->rects;
- QVector<QRect> oldworkrects;
- oldworkrects = *d->workrects;
+ const QVector<QRect> oldrects(*d->rects);
+ const QVector<QRect> oldworkrects(*d->workrects);
int oldscreencount = d->screenCount;
QDesktopWidgetPrivate::cleanup();
@@ -391,18 +366,22 @@ void QDesktopWidget::resizeEvent(QResizeEvent *)
#endif
for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) {
- QRect oldrect = oldrects[i];
- QRect newrect = d->rects->at(i);
+ const QRect oldrect = oldrects[i];
+ const QRect newrect = d->rects->at(i);
if (oldrect != newrect)
emit resized(i);
}
for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) {
- QRect oldrect = oldworkrects[j];
- QRect newrect = d->workrects->at(j);
+ const QRect oldrect = oldworkrects[j];
+ const QRect newrect = d->workrects->at(j);
if (oldrect != newrect)
emit workAreaResized(j);
}
+
+ if (oldscreencount != d->screenCount) {
+ emit screenCountChanged(d->screenCount);
+ }
}
#ifdef Q_CC_MSVC
diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp
index 59d3239..1555fc0 100644
--- a/src/gui/kernel/qdesktopwidget_x11.cpp
+++ b/src/gui/kernel/qdesktopwidget_x11.cpp
@@ -372,7 +372,32 @@ int QDesktopWidget::screenNumber(const QPoint &point) const
void QDesktopWidget::resizeEvent(QResizeEvent *event)
{
Q_D(QDesktopWidget);
+ int oldScreenCount = d->screenCount;
+ QVector<QRect> oldRects(oldScreenCount);
+ QVector<QRect> oldWorks(oldScreenCount);
+ for (int i = 0; i < oldScreenCount; ++i) {
+ oldRects[i] = d->rects[i];
+ oldWorks[i] = d->workareas[i];
+ }
+
d->init();
+
+ for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
+ if (oldRects.at(i) != d->rects[i])
+ emit resized(i);
+ }
+
+ // ### workareas are just reset by init, not filled with new values
+ // ### so this will not work correctly
+ for (int j = 0; j < qMin(oldScreenCount, d->screenCount); ++j) {
+ if (oldWorks.at(j) != d->workareas[j])
+ emit workAreaResized(j);
+ }
+
+ if (oldScreenCount != d->screenCount) {
+ emit screenCountChanged(d->screenCount);
+ }
+
qt_desktopwidget_workarea_dirty = true;
QWidget::resizeEvent(event);
}
diff --git a/src/gui/kernel/qdirectionrecognizer.cpp b/src/gui/kernel/qdirectionrecognizer.cpp
deleted file mode 100644
index a1bc5b1..0000000
--- a/src/gui/kernel/qdirectionrecognizer.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectionrecognizer_p.h"
-
-#include <math.h>
-
-#ifndef M_PI
-#define M_PI 3.141592653589793238462643
-#endif
-
-QT_BEGIN_NAMESPACE
-
-enum {
- DistanceDelta = 20
-};
-
-QDirectionSimpleRecognizer::QDirectionSimpleRecognizer()
-{
-}
-
-Direction QDirectionSimpleRecognizer::addPosition(const QPoint &pos)
-{
- if (!directions.isEmpty()) {
- const QPoint tmp = pos - directions.back().point;
- if (tmp.manhattanLength() < 5)
- return Direction();
- }
- if (lastPoint.isNull()) {
- lastPoint = pos;
- return Direction();
- }
- int dx = pos.x() - lastPoint.x();
- int dy = pos.y() - lastPoint.y();
- Qt::DirectionType direction = Qt::NoDirection;
- if (dx < 0) {
- if (-1*dx >= DistanceDelta/2)
- direction = Qt::LeftDirection;
- } else {
- if (dx >= DistanceDelta/2)
- direction = Qt::RightDirection;
- }
- if (dy < 0) {
- if (-1*dy >= DistanceDelta/2)
- direction = Qt::UpDirection;
- } else {
- if (dy >= DistanceDelta/2)
- direction = Qt::DownDirection;
- }
- if (direction == Qt::NoDirection)
- return Direction();
-
- lastPoint = pos;
- directions.push_back(Direction(direction, pos));
- return Direction(direction, pos);
-}
-
-
-DirectionList QDirectionSimpleRecognizer::getDirections() const
-{
- return directions;
-}
-
-void QDirectionSimpleRecognizer::reset()
-{
- directions.clear();
- lastPoint = QPoint();
-}
-
-
-/// QDirectionDiagonalRecognizer
-
-QDirectionDiagonalRecognizer::QDirectionDiagonalRecognizer()
-{
-}
-
-Direction QDirectionDiagonalRecognizer::addPosition(const QPoint &pos)
-{
- if (!directions.isEmpty()) {
- const QPoint tmp = pos - directions.back().point;
- if (tmp.manhattanLength() < 5)
- return Direction();
- }
- if (lastPoint.isNull()) {
- lastPoint = pos;
- return Direction();
- }
- int dx = pos.x() - lastPoint.x();
- int dy = pos.y() - lastPoint.y();
- int distance = sqrt(static_cast<double>(dx*dx + dy*dy));
- if (distance < DistanceDelta/2)
- return Direction();
-
- Qt::DirectionType direction = Qt::NoDirection;
- double angle = atan(1.0*qAbs(lastPoint.y() - pos.y())/qAbs(pos.x() - lastPoint.x())) * 180. / M_PI;
- if (dx < 0 && dy <= 0) {
- angle = 180 - angle;
- } else if (dx <= 0 && dy > 0) {
- angle += 180;
- } else if (dx > 0 && dy > 0) {
- angle = 360-angle;
- }
- if (angle < 0)
- angle += 360;
- if (angle <= 20)
- direction = Qt::RightDirection;
- else if (angle <= 65)
- direction = Qt::RightUpDirection;
- else if (angle <= 110)
- direction = Qt::UpDirection;
- else if (angle <= 155)
- direction = Qt::LeftUpDirection;
- else if (angle <= 200)
- direction = Qt::LeftDirection;
- else if (angle <= 245)
- direction = Qt::LeftDownDirection;
- else if (angle <= 290)
- direction = Qt::DownDirection;
- else if (angle <= 335)
- direction = Qt::RightDownDirection;
- else
- direction = Qt::RightDirection;
-
- if (direction == Qt::NoDirection)
- return Direction();
-
- lastPoint = pos;
- directions.push_back(Direction(direction, pos));
- return Direction(direction, pos);
-}
-
-
-DirectionList QDirectionDiagonalRecognizer::getDirections() const
-{
- return directions;
-}
-
-void QDirectionDiagonalRecognizer::reset()
-{
- directions.clear();
- lastPoint = QPoint();
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdirectionrecognizer_p.h b/src/gui/kernel/qdirectionrecognizer_p.h
deleted file mode 100644
index 12307c6..0000000
--- a/src/gui/kernel/qdirectionrecognizer_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTIONRECOGNIZER_P_H
-#define QDIRECTIONRECOGNIZER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qpoint.h"
-#include "qlist.h"
-
-QT_BEGIN_NAMESPACE
-
-struct Direction
-{
- Qt::DirectionType direction;
- QPoint point;
-
- Direction(Qt::DirectionType dir, const QPoint &pt)
- : direction(dir), point(pt) { }
- Direction()
- : direction(Qt::NoDirection) { }
-
- inline bool isEmpty() const { return direction == Qt::NoDirection; }
- inline bool isNull() const { return direction == Qt::NoDirection; }
-};
-
-typedef QList<Direction> DirectionList;
-
-class QDirectionSimpleRecognizer
-{
-public:
- QDirectionSimpleRecognizer();
- Direction addPosition(const QPoint &pos);
- DirectionList getDirections() const;
- void reset();
-
-private:
- QPoint lastPoint;
- DirectionList directions;
-};
-
-class QDirectionDiagonalRecognizer
-{
-public:
- QDirectionDiagonalRecognizer();
- Direction addPosition(const QPoint &pos);
- DirectionList getDirections() const;
- void reset();
-
-private:
- QPoint lastPoint;
- DirectionList directions;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDIRECTIONRECOGNIZER_P_H
diff --git a/src/gui/kernel/qdirectionsimplificator_p.h b/src/gui/kernel/qdirectionsimplificator_p.h
deleted file mode 100644
index d7491dc..0000000
--- a/src/gui/kernel/qdirectionsimplificator_p.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTIONSIMPLIFICATOR_P_H
-#define QDIRECTIONSIMPLIFICATOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qdirectionrecognizer_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QDirectionSimplificator
-{
-public:
- QDirectionSimplificator(const DirectionList &dir);
-
- bool simplify(DirectionList *result);
-
-private:
- DirectionList directions;
- DirectionList lastResult;
- enum State {
- None,
- Trim, // remove first and last element
- AccidentalMoves, // 66866 => 6666
- ComplexAccidentalMoves, // 778788 => 777888 (swapping elements without changing direction)
- ShortMoves, // (moves of length 1)
- } state;
-
- struct SimplifyTrim
- {
- SimplifyTrim() : state(0) { }
- bool operator()(DirectionList &directions)
- {
- if (state == 0) {
- directions.removeFirst();
- state = 1;
- } else if (state == 1) {
- directions.removeLast();
- state = 2;
- } else if (state == 2 && directions.size() >= 2) {
- directions.removeFirst();
- directions.removeLast();
- state = 3;
- } else {
- return false;
- }
- return true;
- }
- int state;
- };
- struct SimplifyAccidentalMoves
- {
- SimplifyAccidentalMoves() : state(0) { }
- bool operator()(DirectionList &directions)
- {
- return false;
- }
- int state;
- };
- struct SimplifyComplexAccidentalMoves
- {
- SimplifyComplexAccidentalMoves() : state(0) { }
- bool operator()(DirectionList &directions)
- {
- return false;
- }
- int state;
- };
-
- SimplifyTrim trim;
- SimplifyAccidentalMoves accidentalMoves;
- SimplifyComplexAccidentalMoves complexAccidentalMoves;
- //SimplifyShortMoves shortMoves;
-};
-
-QDirectionSimplificator::QDirectionSimplificator(const DirectionList &dir)
- : directions(dir), state(None)
-{
-}
-
-bool QDirectionSimplificator::simplify(DirectionList *result)
-{
- if (directions.isEmpty() || !result)
- return false;
- *result = directions;
- switch(state) {
- case None:
- state = Trim;
- trim = SimplifyTrim();
- case Trim:
- if (trim(*result))
- break;
- *result = lastResult;
- state = AccidentalMoves;
- accidentalMoves = SimplifyAccidentalMoves();
- case AccidentalMoves:
- if (accidentalMoves(*result))
- break;
- *result = lastResult;
- state = ComplexAccidentalMoves;
- complexAccidentalMoves = SimplifyComplexAccidentalMoves();
- case ComplexAccidentalMoves:
- if (complexAccidentalMoves(*result))
- break;
- *result = lastResult;
- // state = ShortMoves;
- // shortMoves = SimplifyShortMoves();
- // case ShortMoves:
- // if (shortMoves(*result))
- // break;
- // state = None;
- default:
- return false;
- }
- lastResult = *result;
- if (lastResult.isEmpty())
- return false;
- return true;
-}
-
-QT_END_NAMESPACE
-
-#endif // QDIRECTIONSIMPLIFICATOR_P_H
diff --git a/src/gui/kernel/qdnd_mac.mm b/src/gui/kernel/qdnd_mac.mm
index b244d84..99399da 100644
--- a/src/gui/kernel/qdnd_mac.mm
+++ b/src/gui/kernel/qdnd_mac.mm
@@ -405,12 +405,12 @@ bool QWidgetPrivate::qt_mac_dnd_event(uint kind, DragRef dragRef)
SetDragDropAction(dragRef, qt_mac_dnd_map_qt_actions(qDEEvent.dropAction()));
if (!qDEEvent.isAccepted())
- // The widget is simply not interrested in this
+ // The widget is simply not interested in this
// drag. So tell carbon this by returning 'false'. We will then
// not receive any further move, drop or leave events for this widget.
return false;
else {
- // Documentation states that a drag move event is sendt immidiatly after
+ // Documentation states that a drag move event is sent immediately after
// a drag enter event. So we do that. This will honor widgets overriding
// 'dragMoveEvent' only, and not 'dragEnterEvent'
QDragMoveEvent qDMEvent(q->mapFromGlobal(QPoint(mouse.h, mouse.v)), qtAllowed, dropdata,
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index deb52a7..852c86c 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -65,7 +65,7 @@
#endif
#if defined(Q_WS_WIN)
-# include <windows.h>
+# include <qt_windows.h>
# include <objidl.h>
#endif
diff --git a/src/gui/kernel/qdnd_win.cpp b/src/gui/kernel/qdnd_win.cpp
index 99c960c..70f89d2 100644
--- a/src/gui/kernel/qdnd_win.cpp
+++ b/src/gui/kernel/qdnd_win.cpp
@@ -154,9 +154,9 @@ QOleDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium)
#ifdef QDND_DEBUG
qDebug("QOleDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium)");
#ifndef Q_OS_WINCE
- char buf[256] = {0};
- GetClipboardFormatNameA(pformatetc->cfFormat, buf, 255);
- qDebug("CF = %d : %s", pformatetc->cfFormat, buf);
+ wchar_t buf[256] = {0};
+ GetClipboardFormatName(pformatetc->cfFormat, buf, 255);
+ qDebug("CF = %d : %s", pformatetc->cfFormat, QString::fromWCharArray(buf));
#endif
#endif
@@ -398,52 +398,47 @@ void QOleDropSource::createCursors()
int h = cpm.height();
if (!pm.isNull()) {
- int x1 = qMin(-hotSpot.x(),0);
- int x2 = qMax(pm.width()-hotSpot.x(),cpm.width());
- int y1 = qMin(-hotSpot.y(),0);
- int y2 = qMax(pm.height()-hotSpot.y(),cpm.height());
+ int x1 = qMin(-hotSpot.x(), 0);
+ int x2 = qMax(pm.width() - hotSpot.x(), cpm.width());
+ int y1 = qMin(-hotSpot.y(), 0);
+ int y2 = qMax(pm.height() - hotSpot.y(), cpm.height());
- w = x2-x1+1;
- h = y2-y1+1;
+ w = x2 - x1 + 1;
+ h = y2 - y1 + 1;
}
QRect srcRect = pm.rect();
QPoint pmDest = QPoint(qMax(0, -hotSpot.x()), qMax(0, -hotSpot.y()));
QPoint newHotSpot = hotSpot;
-#if !defined(Q_OS_WINCE) || defined(GWES_ICONCURS)
- bool limitedCursorSize = (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
- || (QSysInfo::WindowsVersion == QSysInfo::WV_NT)
- || (QSysInfo::WindowsVersion == QSysInfo::WV_CE);
-
- if (limitedCursorSize) {
- // Limited cursor size
- int reqw = GetSystemMetrics(SM_CXCURSOR);
- int reqh = GetSystemMetrics(SM_CYCURSOR);
-
- QPoint hotspotInPM = newHotSpot - pmDest;
- if (reqw < w) {
- // Not wide enough - move objectpm right
- qreal r = qreal(newHotSpot.x()) / w;
- newHotSpot = QPoint(int(r * reqw), newHotSpot.y());
- if (newHotSpot.x() + cpm.width() > reqw)
- newHotSpot.setX(reqw - cpm.width());
-
- srcRect = QRect(QPoint(hotspotInPM.x() - newHotSpot.x(), srcRect.top()), QSize(reqw, srcRect.height()));
- }
- if (reqh < h) {
- qreal r = qreal(newHotSpot.y()) / h;
- newHotSpot = QPoint(newHotSpot.x(), int(r * reqh));
- if (newHotSpot.y() + cpm.height() > reqh)
- newHotSpot.setY(reqh - cpm.height());
-
- srcRect = QRect(QPoint(srcRect.left(), hotspotInPM.y() - newHotSpot.y()), QSize(srcRect.width(), reqh));
- }
- // Always use system cursor size
- w = reqw;
- h = reqh;
+#if defined(Q_OS_WINCE)
+ // Limited cursor size
+ int reqw = GetSystemMetrics(SM_CXCURSOR);
+ int reqh = GetSystemMetrics(SM_CYCURSOR);
+
+ QPoint hotspotInPM = newHotSpot - pmDest;
+ if (reqw < w) {
+ // Not wide enough - move objectpm right
+ qreal r = qreal(newHotSpot.x()) / w;
+ newHotSpot = QPoint(int(r * reqw), newHotSpot.y());
+ if (newHotSpot.x() + cpm.width() > reqw)
+ newHotSpot.setX(reqw - cpm.width());
+
+ srcRect = QRect(QPoint(hotspotInPM.x() - newHotSpot.x(), srcRect.top()), QSize(reqw, srcRect.height()));
}
+ if (reqh < h) {
+ qreal r = qreal(newHotSpot.y()) / h;
+ newHotSpot = QPoint(newHotSpot.x(), int(r * reqh));
+ if (newHotSpot.y() + cpm.height() > reqh)
+ newHotSpot.setY(reqh - cpm.height());
+
+ srcRect = QRect(QPoint(srcRect.left(), hotspotInPM.y() - newHotSpot.y()), QSize(srcRect.width(), reqh));
+ }
+ // Always use system cursor size
+ w = reqw;
+ h = reqh;
#endif
+
QPixmap newCursor(w, h);
if (!pm.isNull()) {
newCursor.fill(QColor(0, 0, 0, 0));
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 8e92243..a6a87b7 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -53,8 +53,6 @@
QT_BEGIN_NAMESPACE
-QString qt_getStandardGestureTypeName(Qt::GestureType type);
-
/*!
\class QInputEvent
\ingroup events
@@ -116,8 +114,12 @@ QInputEvent::~QInputEvent()
propagated up the parent widget chain until a widget accepts it
with accept(), or an event filter consumes it.
+ \note If a mouse event is propagated to a \l{QWidget}{widget} for
+ which Qt::WA_NoMousePropagation has been set, that mouse event
+ will not be propagated further up the parent widget chain.
+
The state of the keyboard modifier keys can be found by calling the
- \l{QInputEvent::modifiers()}{modifiers()} function, inhertied from
+ \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
QInputEvent.
The functions pos(), x(), and y() give the cursor position
@@ -3343,9 +3345,6 @@ QDebug operator<<(QDebug dbg, const QEvent *e) {
case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
return dbg.space();
- case QEvent::Gesture:
- n = "Gesture";
- break;
default:
dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
return dbg.space();
@@ -3542,167 +3541,24 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
#endif
-/*!
- \class QGestureEvent
- \since 4.6
- \ingroup events
-
- \brief The QGestureEvent class provides the parameters used for
- gesture recognition.
-
- The QGestureEvent class contains a list of gestures that are being
- executed right now (\l{QGestureEvent::}{gestureTypes()}) and a
- list of gestures that are cancelled (the gesture might be
- cancelled because the window lost focus, or because of timeout,
- etc).
-
- \sa QGesture
-*/
-
-/*!
- Creates new QGestureEvent containing a list of \a gestures that
- are being executed and a list of gesture that were cancelled (\a
- cancelledGestures).
-*/
-QGestureEvent::QGestureEvent(const QSet<QGesture*> &gestures,
- const QSet<QString> &cancelledGestures)
- : QEvent(QEvent::Gesture), m_cancelledGestures(cancelledGestures)
-{
- setAccepted(false);
- foreach(QGesture *r, gestures)
- m_gestures.insert(r->type(), r);
-}
-
-/*!
- Destroys the QGestureEvent object.
-*/
-QGestureEvent::~QGestureEvent()
-{
-}
-
-/*!
- Returns true if the gesture event contains gesture of specific \a
- type; returns false otherwise.
-*/
-bool QGestureEvent::contains(Qt::GestureType type) const
-{
- return contains(qt_getStandardGestureTypeName(type));
-}
-
-/*!
- Returns true if the gesture event contains gesture of specific \a
- type; returns false otherwise.
-*/
-bool QGestureEvent::contains(const QString &type) const
-{
- return gesture(type) != 0;
-}
-
-/*!
- Returns a list of gesture names that this event contains.
-*/
-QList<QString> QGestureEvent::gestureTypes() const
-{
- return m_gestures.keys();
-}
-
-/*!
- Returns extended information about a gesture of specific \a type.
-*/
-const QGesture* QGestureEvent::gesture(Qt::GestureType type) const
-{
- return gesture(qt_getStandardGestureTypeName(type));
-}
-
-/*!
- Returns extended information about a gesture of specific \a type.
-*/
-const QGesture* QGestureEvent::gesture(const QString &type) const
-{
- return m_gestures.value(type, 0);
-}
-
-/*!
- Returns extended information about all gestures in the event.
-*/
-QList<QGesture*> QGestureEvent::gestures() const
-{
- return m_gestures.values();
-}
-
-/*!
- Returns a set of gesture names that used to be executed, but were
- cancelled (i.e. they were not finished properly).
-*/
-QSet<QString> QGestureEvent::cancelledGestures() const
-{
- return m_cancelledGestures;
-}
-
-/*!
- Sets the accept flag of the all gestures inside the event object,
- the equivalent of calling \l{QEvent::accept()}{accept()} or
- \l{QEvent::setAccepted()}{setAccepted(true)}.
-
- Setting the accept parameter indicates that the event receiver
- wants the gesture. Unwanted gestures might be propagated to the parent
- widget.
-*/
-void QGestureEvent::acceptAll()
-{
- QHash<QString, QGesture*>::iterator it = m_gestures.begin(),
- e = m_gestures.end();
- for(; it != e; ++it)
- it.value()->accept();
- setAccepted(true);
-}
-
-/*!
- Sets the accept flag of the specified gesture inside the event
- object, the equivalent of calling
- \l{QGestureEvent::gesture()}{gesture(type)}->\l{QGesture::accept()}{accept()}
-
- Setting the accept parameter indicates that the event receiver
- wants the gesture. Unwanted gestures might be propagated to the parent
- widget.
-*/
-void QGestureEvent::accept(Qt::GestureType type)
-{
- if (QGesture *g = m_gestures.value(qt_getStandardGestureTypeName(type), 0))
- g->accept();
-}
-
-/*!
- Sets the accept flag of the specified gesture inside the event
- object, the equivalent of calling
- \l{QGestureEvent::gesture()}{gesture(type)}->\l{QGesture::accept()}{accept()}
-
- Setting the accept parameter indicates that the event receiver
- wants the gesture. Unwanted gestures might be propagated to the parent
- widget.
-*/
-void QGestureEvent::accept(const QString &type)
-{
- if (QGesture *g = m_gestures.value(type, 0))
- g->accept();
-}
-
/*! \class QTouchEvent
- \brief The QTouchEvent class contains parameters that describe a touch event
-.
+ \brief The QTouchEvent class contains parameters that describe a touch event.
\since 4.6
\ingroup events
Touch events occur when pressing, releasing, or moving one or more
touch points on a touch device (such as a touch-screen or
- track-pad), and if the widget has the Qt::WA_AcceptTouchEvents
- attribute.
+ track-pad). To receive touch events, widgets have to have the
+ Qt::WA_AcceptTouchEvents attribute set and graphics items need to have
+ the \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents}
+ attribute set to true.
All touch events are of type QEvent::TouchBegin,
QEvent::TouchUpdate, or QEvent::TouchEnd. The touchPoints()
function returns a list of all touch points contained in the event.
- Information about each touch point can be retreived using the
- QTouchEvent::TouchPoint class.
+ Information about each touch point can be retrieved using the
+ QTouchEvent::TouchPoint class. The Qt::TouchPointState enum
+ describes the different states that a touch point may have.
Similar to QMouseEvent, Qt automatically grabs each touch point on
the first press inside a widget; the widget will receive all
@@ -3720,10 +3576,11 @@ void QGestureEvent::accept(const QString &type)
then mouse events are simulated from the state of the first touch
point.
- The Qt::TouchPointState enum describes the different states that a
- touch point may have.
+ Reimplement QWidget::event() for widgets and QGraphicsItem::sceneEvent()
+ for items in a graphics view to receive touch events.
- QTouchEvent::TouchPoint Qt::TouchPointState Qt::WA_AcceptTouchEvents
+ \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
+ QGraphicsItem::acceptTouchEvents()
*/
/*! \enum Qt::TouchPointState
@@ -3741,13 +3598,7 @@ void QGestureEvent::accept(const QString &type)
\omitvalue TouchPointPrimary
*/
-/*! \class QTouchEvent::TouchPoint
- \brief The QTouchEvent::TouchPoint class provide information about a touch point in a QTouchEvent.
- \since 4.6
-*/
-
/*! \enum QTouchEvent::DeviceType
- \since 4.6
This enum represents the type of device that generated a QTouchEvent.
@@ -3826,6 +3677,11 @@ QTouchEvent::~QTouchEvent()
Sets the list of touch points for this event.
*/
+/*! \class QTouchEvent::TouchPoint
+ \brief The QTouchEvent::TouchPoint class provides information about a touch point in a QTouchEvent.
+ \since 4.6
+*/
+
/*! \internal
Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
@@ -3885,7 +3741,9 @@ bool QTouchEvent::TouchPoint::isPrimary() const
/*!
Returns the position of this touch point, relative to the widget
- or item that received the event.
+ or QGraphicsItem that received the event.
+
+ \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
*/
QPointF QTouchEvent::TouchPoint::pos() const
{
@@ -3894,6 +3752,13 @@ QPointF QTouchEvent::TouchPoint::pos() const
/*!
Returns the scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa startScenePos(), lastScenePos(), pos()
*/
QPointF QTouchEvent::TouchPoint::scenePos() const
{
@@ -3902,6 +3767,8 @@ QPointF QTouchEvent::TouchPoint::scenePos() const
/*!
Returns the screen position of this touch point.
+
+ \sa startScreenPos(), lastScreenPos(), pos()
*/
QPointF QTouchEvent::TouchPoint::screenPos() const
{
@@ -3909,8 +3776,12 @@ QPointF QTouchEvent::TouchPoint::screenPos() const
}
/*!
- Returns the position of this touch point. The coordinates are normalized to size of the touch
- device, i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+ Returns the normalized position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa startNormalizedPos(), lastNormalizedPos(), pos()
*/
QPointF QTouchEvent::TouchPoint::normalizedPos() const
{
@@ -3919,7 +3790,9 @@ QPointF QTouchEvent::TouchPoint::normalizedPos() const
/*!
Returns the starting position of this touch point, relative to the
- widget that received the event.
+ widget or QGraphicsItem that received the event.
+
+ \sa pos(), lastPos()
*/
QPointF QTouchEvent::TouchPoint::startPos() const
{
@@ -3928,6 +3801,13 @@ QPointF QTouchEvent::TouchPoint::startPos() const
/*!
Returns the starting scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), lastScenePos()
*/
QPointF QTouchEvent::TouchPoint::startScenePos() const
{
@@ -3936,6 +3816,8 @@ QPointF QTouchEvent::TouchPoint::startScenePos() const
/*!
Returns the starting screen position of this touch point.
+
+ \sa screenPos(), lastScreenPos()
*/
QPointF QTouchEvent::TouchPoint::startScreenPos() const
{
@@ -3943,8 +3825,12 @@ QPointF QTouchEvent::TouchPoint::startScreenPos() const
}
/*!
- Returns the starting position of this touch point. The coordinates are normalized to size of
- the touch device, i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+ Returns the normalized starting position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), lastNormalizedPos()
*/
QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
{
@@ -3953,7 +3839,9 @@ QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
/*!
Returns the position of this touch point from the previous touch
- event, relative to the widget that received the event.
+ event, relative to the widget or QGraphicsItem that received the event.
+
+ \sa pos(), startPos()
*/
QPointF QTouchEvent::TouchPoint::lastPos() const
{
@@ -3963,6 +3851,13 @@ QPointF QTouchEvent::TouchPoint::lastPos() const
/*!
Returns the scene position of this touch point from the previous
touch event.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), startScenePos()
*/
QPointF QTouchEvent::TouchPoint::lastScenePos() const
{
@@ -3972,6 +3867,8 @@ QPointF QTouchEvent::TouchPoint::lastScenePos() const
/*!
Returns the screen position of this touch point from the previous
touch event.
+
+ \sa screenPos(), startScreenPos()
*/
QPointF QTouchEvent::TouchPoint::lastScreenPos() const
{
@@ -3979,9 +3876,13 @@ QPointF QTouchEvent::TouchPoint::lastScreenPos() const
}
/*!
- Returns the position of this touch point from the previous touch event. The coordinates are
- normalized to size of the touch device, i.e. (0,0) is the top-left corner and (1,1) is the
- bottom-right corner.
+ Returns the normalized position of this touch point from the
+ previous touch event.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), startNormalizedPos()
*/
QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
{
@@ -3989,8 +3890,11 @@ QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
}
/*!
- Returns the rect for this touch point. The rect is centered around the point returned by pos().
- Note this function returns an empty rect if the device does not report touch point sizes.
+ Returns the rect for this touch point, relative to the widget
+ or QGraphicsItem that received the event. The rect is centered
+ around the point returned by pos().
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
*/
QRectF QTouchEvent::TouchPoint::rect() const
{
@@ -3999,6 +3903,10 @@ QRectF QTouchEvent::TouchPoint::rect() const
/*!
Returns the rect for this touch point in scene coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa scenePos(), rect()
*/
QRectF QTouchEvent::TouchPoint::sceneRect() const
{
@@ -4007,6 +3915,10 @@ QRectF QTouchEvent::TouchPoint::sceneRect() const
/*!
Returns the rect for this touch point in screen coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa screenPos(), rect()
*/
QRectF QTouchEvent::TouchPoint::screenRect() const
{
@@ -4176,4 +4088,15 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T
return *this;
}
+/*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
+ Returns the touch device Type, which is of type
+ \l {QTouchEvent::DeviceType} {DeviceType}.
+ */
+
+/*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType)
+ Sets the device type to \a deviceType, which is of type
+ \l {QTouchEvent::DeviceType} {DeviceType}.
+ */
+
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 3c5fc90..a1cfbe5 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -715,41 +715,6 @@ private:
};
#endif
-class Q_GUI_EXPORT QGestureEvent : public QEvent
-{
-public:
- QGestureEvent(const QSet<QGesture*> &gestures,
- const QSet<QString> &cancelledGestures = QSet<QString>());
- ~QGestureEvent();
-
- bool contains(Qt::GestureType type) const;
- bool contains(const QString &type) const;
-
- QList<QString> gestureTypes() const;
-
- const QGesture* gesture(Qt::GestureType type) const;
- const QGesture* gesture(const QString &type) const;
- QList<QGesture*> gestures() const;
-
- QSet<QString> cancelledGestures() const;
-
- void acceptAll();
-#ifndef Q_NO_USING_KEYWORD
- using QEvent::accept;
-#else
- inline void accept() { QEvent::accept(); }
-#endif
- void accept(Qt::GestureType type);
- void accept(const QString &type);
-
-protected:
- QHash<QString, QGesture*> m_gestures;
- QSet<QString> m_cancelledGestures;
-
- friend class QApplication;
- friend class QGestureManager;
-};
-
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
#endif
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 8a2bb05..67441ea 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -119,6 +119,22 @@ public:
qreal pressure;
};
+class QWinGestureEvent : public QEvent
+{
+public:
+ enum Type {
+ None,
+ GestureEnd,
+ Pan,
+ Pinch
+ };
+
+ QWinGestureEvent() : QEvent(QEvent::WinGesture), gestureType(None), sequenceId(0) { }
+ Type gestureType;
+ QPoint position;
+ ulong sequenceId;
+};
+
QT_END_NAMESPACE
#endif // QEVENT_P_H
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index 99a1fc1..cde0c47 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -264,12 +264,16 @@ void qt_mac_socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CF
int nativeSocket = CFSocketGetNative(s);
MacSocketInfo *socketInfo = eventDispatcher->macSockets.value(nativeSocket);
QEvent notifierEvent(QEvent::SockAct);
+
+ // There is a race condition that happen where we disable the notifier and
+ // the kernel still has a notification to pass on. We then get this
+ // notification after we've successfully disabled the CFSocket, but our Qt
+ // notifier is now gone. The upshot is we have to check the notifier
+ // everytime.
if (callbackType == kCFSocketReadCallBack) {
- Q_ASSERT(socketInfo->readNotifier);
- QApplication::sendEvent(socketInfo->readNotifier, &notifierEvent);
+ if (socketInfo->readNotifier)
+ QApplication::sendEvent(socketInfo->readNotifier, &notifierEvent);
} else if (callbackType == kCFSocketWriteCallBack) {
- // ### Bug in Apple socket notifiers seems to send write even
- // ### after the notifier has been disabled, need to investigate further.
if (socketInfo->writeNotifier)
QApplication::sendEvent(socketInfo->writeNotifier, &notifierEvent);
}
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index d7b2d1b..d53b419 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -41,190 +41,173 @@
#include "qgesture.h"
#include <private/qgesture_p.h>
+#include "qgraphicsitem.h"
QT_BEGIN_NAMESPACE
-QString qt_getStandardGestureTypeName(Qt::GestureType type);
+
+class QEventFilterProxyGraphicsItem : public QGraphicsItem
+{
+public:
+ QEventFilterProxyGraphicsItem(QGesture *g)
+ : gesture(g)
+ {
+ }
+ bool sceneEventFilter(QGraphicsItem *, QEvent *event)
+ {
+ return gesture ? gesture->filterEvent(event) : false;
+ }
+ QRectF boundingRect() const { return QRectF(); }
+ void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) { }
+
+private:
+ QGesture *gesture;
+};
/*!
\class QGesture
\since 4.6
- \brief The QGesture class represents a gesture, containing all
- properties that describe a gesture.
-
- The widget receives a QGestureEvent with a list of QGesture
- objects that represent gestures that are occuring on it. The class
- has a list of properties that can be queried by the user to get
- some gesture-specific arguments (i.e. position of the tap in the
- DoubleTap gesture).
-
- When creating custom gesture recognizers, they might add new
- properties to the gesture object, or custom gesture developers
- might subclass the QGesture objects to provide some extended
- information. However, if the gesture developer wants to add a new
- property to the gesture object that describe coordinate (like a
- QPoint or QRect), it is required to subclass the QGesture and
- re-implement the \l{QGesture::}{translate()} function to make sure
- the coordinates are translated properly when the gesture event is
- propagated to parent widgets.
-
- \sa QGestureEvent, QGestureRecognizer
-*/
+ \brief The QGesture class is the base class for implementing custom
+ gestures.
-/*!
- Creates a new gesture object of type \a type in a \a state and
- marks it as a child of \a parent.
+ This class represents both an object that recognizes a gesture out of a set
+ of input events (a gesture recognizer), and a gesture object itself that
+ can be used to get extended information about the triggered gesture.
- Usually QGesture objects should only be contructed by the
- QGestureRecognizer classes.
-*/
-QGesture::QGesture(QObject *parent, const QString &type, Qt::GestureState state)
- : QObject(*new QGesturePrivate, parent), m_accept(0)
-{
- Q_D(QGesture);
- d->type = type;
- d->state = state;
-}
+ The class has a list of properties that can be queried by the user to get
+ some gesture-specific parameters (for example, an offset of a Pan gesture).
-/*!
- Creates a new gesture object of type \a type in a \a state and
- marks it as a child of \a parent.
-
- This constructor also fills some basic information about the
- gesture like a \a startPos which describes the start point of the
- gesture, \a lastPos - last point where the gesture happened, \a
- pos - a current point, \a rect - a bounding rect of the gesture,
- \a hotSpot - a center point of the gesture, \a startTime - a time
- when the gesture has started, \a duration - how long the gesture
- is going on.
-
- Usually QGesture objects should only be contructed by the
- QGestureRecognizer classes.
-*/
-QGesture::QGesture(QObject *parent, const QString &type, const QPoint &startPos,
- const QPoint &lastPos, const QPoint &pos, const QRect &rect,
- const QPoint &hotSpot, const QDateTime &startTime,
- uint duration, Qt::GestureState state)
- : QObject(*new QGesturePrivate, parent)
-{
- Q_D(QGesture);
- d->type = type;
- d->state = state;
- d->init(startPos, lastPos, pos, rect, hotSpot, startTime, duration);
-}
+ Usually gesture recognizer implements a state machine, storing its state
+ internally in the recognizer object. The recognizer receives input events
+ through the \l{QGesture::}{filterEvent()} virtual function and decides
+ whether the event should change the state of the recognizer by emitting an
+ appropriate signal.
-/*! \internal
+ Input events should be either fed to the recognizer one by one with a
+ filterEvent() function, or the gesture recognizer should be attached to an
+ object it filters events for by specifying it as a parent object. The
+ QGesture object installs itself as an event filter to the parent object
+ automatically, the unsetObject() function should be used to remove an event
+ filter from the parent object. To make a
+ gesture that operates on a QGraphicsItem, both the appropriate QGraphicsView
+ should be passed as a parent object and setGraphicsItem() functions should
+ be used to attach a gesture to a graphics item.
+
+ This is a base class, to create a custom gesture type, you should subclass
+ it and implement its pure virtual functions.
+
+ \sa QPanGesture, QTapAndHoldGesture
*/
-QGesture::QGesture(QGesturePrivate &dd, QObject *parent, const QString &type,
- Qt::GestureState state)
- : QObject(dd, parent)
-{
- Q_D(QGesture);
- d->type = type;
- d->state = state;
-}
-/*!
- Destroys the gesture object.
+/*! \fn bool QGesture::filterEvent(QEvent *event)
+
+ Parses input \a event and emits a signal when detects a gesture.
+
+ In your reimplementation of this function, if you want to filter the \a
+ event out, i.e. stop it being handled further, return true; otherwise
+ return false;
+
+ This is a pure virtual function that needs to be implemented in subclasses.
*/
-QGesture::~QGesture()
-{
-}
-/*!
- \property QGesture::type
+/*! \fn void QGesture::started()
+
+ The signal is emitted when the gesture is started. Extended information
+ about the gesture is contained in the signal sender object.
- \brief The type of the gesture.
+ In addition to started(), a triggered() signal should also be emitted.
*/
-QString QGesture::type() const
-{
- return d_func()->type;
-}
+/*! \fn void QGesture::triggered()
-/*!
- \property QGesture::state
+ The signal is emitted when the gesture is detected. Extended information
+ about the gesture is contained in the signal sender object.
+*/
- \brief The current state of the gesture.
+/*! \fn void QGesture::finished()
+
+ The signal is emitted when the gesture is finished. Extended information
+ about the gesture is contained in the signal sender object.
*/
-Qt::GestureState QGesture::state() const
-{
- return d_func()->state;
-}
-/*!
- Translates the internal gesture properties that represent
- coordinates by \a offset.
+/*! \fn void QGesture::cancelled()
- Custom gesture recognizer developer have to re-implement this
- function if they want to store custom properties that represent
- coordinates.
+ The signal is emitted when the gesture is cancelled, for example the reset()
+ function is called while the gesture was in the process of emitting a
+ triggered() signal. Extended information about the gesture is contained in
+ the sender object.
*/
-void QGesture::translate(const QPoint &offset)
-{
- Q_D(QGesture);
- d->rect.translate(offset);
- d->hotSpot += offset;
- d->startPos += offset;
- d->lastPos += offset;
- d->pos += offset;
-}
+
/*!
- \property QGesture::rect
+ Creates a new gesture handler object and marks it as a child of \a parent.
+
+ The \a parent object is also the default event source for the gesture,
+ meaning that the gesture installs itself as an event filter for the \a
+ parent.
- \brief The bounding rect of a gesture.
+ \sa setGraphicsItem()
*/
-QRect QGesture::rect() const
+QGesture::QGesture(QObject *parent)
+ : QObject(*new QGesturePrivate, parent)
{
- return d_func()->rect;
+ if (parent)
+ installEventFilter(parent);
}
-void QGesture::setRect(const QRect &rect)
+/*! \internal
+ */
+QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
+ : QObject(dd, parent)
{
- d_func()->rect = rect;
+ if (parent)
+ installEventFilter(parent);
}
/*!
- \property QGesture::hotSpot
-
- \brief The center point of a gesture.
+ Destroys the gesture object.
*/
-QPoint QGesture::hotSpot() const
+QGesture::~QGesture()
{
- return d_func()->hotSpot;
}
-void QGesture::setHotSpot(const QPoint &point)
+/*! \internal
+ */
+bool QGesture::eventFilter(QObject *receiver, QEvent *event)
{
- d_func()->hotSpot = point;
+ Q_D(QGesture);
+ if (d->graphicsItem && receiver == parent())
+ return false;
+ return filterEvent(event);
}
/*!
- \property QGesture::startTime
+ \property QGesture::state
- \brief The time when the gesture has started.
+ \brief The current state of the gesture.
*/
-QDateTime QGesture::startTime() const
+
+/*!
+ Returns the gesture recognition state.
+ */
+Qt::GestureState QGesture::state() const
{
- return d_func()->startTime;
+ return d_func()->state;
}
/*!
- \property QGesture::duration
-
- \brief The duration time of a gesture.
-*/
-uint QGesture::duration() const
+ Sets this gesture's recognition state to \a state.
+ */
+void QGesture::setState(Qt::GestureState state)
{
- return d_func()->duration;
+ d_func()->state = state;
}
/*!
\property QGesture::startPos
- \brief The start position of the pointer.
+ \brief The start position of the gesture (if relevant).
*/
QPoint QGesture::startPos() const
{
@@ -239,7 +222,7 @@ void QGesture::setStartPos(const QPoint &point)
/*!
\property QGesture::lastPos
- \brief The last recorded position of the pointer.
+ \brief The last recorded position of the gesture (if relevant).
*/
QPoint QGesture::lastPos() const
{
@@ -254,7 +237,7 @@ void QGesture::setLastPos(const QPoint &point)
/*!
\property QGesture::pos
- \brief The current position of the pointer.
+ \brief The current position of the gesture (if relevant).
*/
QPoint QGesture::pos() const
{
@@ -267,49 +250,47 @@ void QGesture::setPos(const QPoint &point)
}
/*!
- \class QPanningGesture
- \since 4.6
-
- \brief The QPanningGesture class represents a Pan gesture,
- providing additional information related to panning.
+ Sets the \a graphicsItem the gesture is filtering events for.
- This class is provided for convenience, panning direction
- information is also contained in the QGesture object in it's
- properties.
-*/
+ The gesture will install an event filter to the \a graphicsItem and
+ redirect them to the filterEvent() function.
-/*! \internal
+ \sa graphicsItem()
*/
-QPanningGesture::QPanningGesture(QObject *parent)
- : QGesture(*new QPanningGesturePrivate, parent,
- qt_getStandardGestureTypeName(Qt::PanGesture))
-{
-}
-
-/*! \internal
-*/
-QPanningGesture::~QPanningGesture()
+void QGesture::setGraphicsItem(QGraphicsItem *graphicsItem)
{
+ Q_D(QGesture);
+ if (d->graphicsItem && d->eventFilterProxyGraphicsItem)
+ d->graphicsItem->removeSceneEventFilter(d->eventFilterProxyGraphicsItem);
+ d->graphicsItem = graphicsItem;
+ if (!d->eventFilterProxyGraphicsItem)
+ d->eventFilterProxyGraphicsItem = new QEventFilterProxyGraphicsItem(this);
+ if (graphicsItem)
+ graphicsItem->installSceneEventFilter(d->eventFilterProxyGraphicsItem);
}
/*!
- \property QPanningGesture::lastDirection
+ Returns the graphics item the gesture is filtering events for.
- \brief The last recorded direction of panning.
+ \sa setGraphicsItem()
*/
-Qt::DirectionType QPanningGesture::lastDirection() const
+QGraphicsItem* QGesture::graphicsItem() const
{
- return d_func()->lastDirection;
+ return d_func()->graphicsItem;
}
-/*!
- \property QPanningGesture::direction
+/*! \fn void QGesture::reset()
- \brief The current direction of panning.
+ Resets the internal state of the gesture. This function might be called by
+ the filterEvent() implementation in a derived class, or by the user to
+ cancel a gesture. The base class implementation emits the cancelled()
+ signal if the state() of the gesture wasn't empty.
*/
-Qt::DirectionType QPanningGesture::direction() const
+void QGesture::reset()
{
- return d_func()->direction;
+ if (state() != Qt::NoGesture)
+ emit cancelled();
+ setState(Qt::NoGesture);
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index f3c95cc..1cd9cae 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -42,12 +42,12 @@
#ifndef QGESTURE_H
#define QGESTURE_H
-#include "qobject.h"
-#include "qlist.h"
-#include "qdatetime.h"
-#include "qpoint.h"
-#include "qrect.h"
-#include "qmetatype.h"
+#include <QtCore/qobject.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qmetatype.h>
QT_BEGIN_HEADER
@@ -55,50 +55,32 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
+class QGraphicsItem;
class QGesturePrivate;
class Q_GUI_EXPORT QGesture : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QGesture)
- Q_PROPERTY(QString type READ type)
Q_PROPERTY(Qt::GestureState state READ state)
- Q_PROPERTY(QDateTime startTime READ startTime)
- Q_PROPERTY(uint duration READ duration)
-
- Q_PROPERTY(QRect rect READ rect WRITE setRect)
- Q_PROPERTY(QPoint hotSpot READ hotSpot WRITE setHotSpot)
Q_PROPERTY(QPoint startPos READ startPos WRITE setStartPos)
Q_PROPERTY(QPoint lastPos READ lastPos WRITE setLastPos)
Q_PROPERTY(QPoint pos READ pos WRITE setPos)
public:
- QGesture(QObject *parent, const QString &type,
- Qt::GestureState state = Qt::GestureStarted);
- QGesture(QObject *parent,
- const QString &type, const QPoint &startPos,
- const QPoint &lastPos, const QPoint &pos, const QRect &rect,
- const QPoint &hotSpot, const QDateTime &startTime,
- uint duration, Qt::GestureState state);
- virtual ~QGesture();
-
- inline void setAccepted(bool accepted) { m_accept = accepted; }
- inline bool isAccepted() const { return m_accept; }
-
- inline void accept() { m_accept = true; }
- inline void ignore() { m_accept = false; }
-
- QString type() const;
- Qt::GestureState state() const;
+ explicit QGesture(QObject *parent = 0);
+ ~QGesture();
+
+ virtual bool filterEvent(QEvent *event) = 0;
+
+ void setGraphicsItem(QGraphicsItem *);
+ QGraphicsItem *graphicsItem() const;
- QDateTime startTime() const;
- uint duration() const;
+ virtual void reset();
- QRect rect() const;
- void setRect(const QRect &rect);
- QPoint hotSpot() const;
- void setHotSpot(const QPoint &point);
+ Qt::GestureState state() const;
+ void setState(Qt::GestureState state);
QPoint startPos() const;
void setStartPos(const QPoint &point);
@@ -108,45 +90,19 @@ public:
void setPos(const QPoint &point);
protected:
- QGesture(QGesturePrivate &dd, QObject *parent, const QString &type,
- Qt::GestureState state = Qt::GestureStarted);
- virtual void translate(const QPoint &offset);
+ QGesture(QGesturePrivate &dd, QObject *parent);
+ bool eventFilter(QObject*, QEvent*);
-private:
- ushort m_accept : 1;
-
- friend class QGestureManager;
- friend class QApplication;
- friend class QGraphicsScene;
- friend class QGraphicsScenePrivate;
- friend class QGestureRecognizerPan;
- friend class QDoubleTapGestureRecognizer;
- friend class QTapAndHoldGestureRecognizer;
-};
-
-class QPanningGesturePrivate;
-class Q_GUI_EXPORT QPanningGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPanningGesture)
-
- Q_PROPERTY(Qt::DirectionType lastDirection READ lastDirection)
- Q_PROPERTY(Qt::DirectionType direction READ direction)
-
-public:
- Qt::DirectionType lastDirection() const;
- Qt::DirectionType direction() const;
+Q_SIGNALS:
+ void started();
+ void triggered();
+ void finished();
+ void cancelled();
private:
- QPanningGesture(QObject *parent = 0);
- ~QPanningGesture();
-
- friend class QGestureRecognizerPan;
+ friend class QWidget;
};
-Q_DECLARE_METATYPE(Qt::DirectionType)
-Q_DECLARE_METATYPE(Qt::GestureState)
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h
index caf851e..99f572f 100644
--- a/src/gui/kernel/qgesture_p.h
+++ b/src/gui/kernel/qgesture_p.h
@@ -56,10 +56,12 @@
#include "qrect.h"
#include "qpoint.h"
#include "qdatetime.h"
+#include "qgesture.h"
#include "private/qobject_p.h"
QT_BEGIN_NAMESPACE
+class QObject;
class QGraphicsItem;
class QGesturePrivate : public QObjectPrivate
{
@@ -67,47 +69,28 @@ class QGesturePrivate : public QObjectPrivate
public:
QGesturePrivate()
- : state(Qt::NoGesture), graphicsItem(0), singleshot(0), duration(0) { }
+ : graphicsItem(0), eventFilterProxyGraphicsItem(0), state(Qt::NoGesture)
+ {
+ }
void init(const QPoint &startPos, const QPoint &lastPos,
- const QPoint &pos, const QRect &rect,
- const QPoint &hotSpot, const QDateTime &startTime,
- uint duration)
+ const QPoint &pos)
{
- this->rect = rect;
- this->hotSpot = hotSpot;
- this->startTime = startTime;
- this->duration = duration;
this->startPos = startPos;
this->lastPos = lastPos;
this->pos = pos;
}
- QString type;
- Qt::GestureState state;
-
- QPointer<QWidget> widget;
QGraphicsItem *graphicsItem;
- uint singleshot:1;
+ QGraphicsItem *eventFilterProxyGraphicsItem;
+
+ Qt::GestureState state;
- QRect rect;
- QPoint hotSpot;
- QDateTime startTime;
- uint duration;
QPoint startPos;
QPoint lastPos;
QPoint pos;
};
-class QPanningGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QPanningGesture)
-
-public:
- Qt::DirectionType lastDirection;
- Qt::DirectionType direction;
-};
-
QT_END_NAMESPACE
#endif // QGESTURE_P_H
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
deleted file mode 100644
index 20abda9..0000000
--- a/src/gui/kernel/qgesturemanager.cpp
+++ /dev/null
@@ -1,644 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgesturemanager_p.h"
-#include "qgesture.h"
-#include "qgesture_p.h"
-#include "qevent.h"
-
-#include "qapplication.h"
-#include "qapplication_p.h"
-#include "qwidget.h"
-#include "qwidget_p.h"
-
-#include "qgesturestandardrecognizers_p.h"
-
-#include "qdebug.h"
-
-// #define GESTURE_DEBUG
-#ifndef GESTURE_DEBUG
-# define DEBUG if (0) qDebug
-#else
-# define DEBUG qDebug
-#endif
-
-QT_BEGIN_NAMESPACE
-
-bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
-static const unsigned int MaximumGestureRecognitionTimeout = 2000;
-
-QGestureManager::QGestureManager(QObject *parent)
- : QObject(parent), eventDeliveryDelayTimeout(300),
- delayedPressTimer(0), lastMousePressReceiver(0), lastMousePressEvent(QEvent::None, QPoint(), Qt::NoButton, 0, 0),
- lastGestureId(0), state(NotGesture)
-{
- qRegisterMetaType<Qt::DirectionType>();
- qRegisterMetaType<Qt::GestureState>();
-
- recognizers << new QDoubleTapGestureRecognizer(this);
- recognizers << new QTapAndHoldGestureRecognizer(this);
- recognizers << new QGestureRecognizerPan(this);
-
- foreach(QGestureRecognizer *r, recognizers)
- connect(r, SIGNAL(stateChanged(QGestureRecognizer::Result)),
- this, SLOT(recognizerStateChanged(QGestureRecognizer::Result)));
-}
-
-void QGestureManager::addRecognizer(QGestureRecognizer *recognizer)
-{
- recognizer->setParent(this);
- recognizers << recognizer;
-}
-
-void QGestureManager::removeRecognizer(QGestureRecognizer *recognizer)
-{
- recognizers.remove(recognizer);
-}
-
-bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event)
-{
- QPoint currentPos;
- switch (event->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove:
- currentPos = static_cast<QMouseEvent*>(event)->pos(); break;
- default: break;
- }
-
- const QMap<QString, int> &grabbedGestures = qApp->d_func()->grabbedGestures;
-
- bool ret = false;
- QSet<QGestureRecognizer*> startedGestures;
- QSet<QGestureRecognizer*> finishedGestures;
- QSet<QGestureRecognizer*> newMaybeGestures;
- QSet<QGestureRecognizer*> cancelledGestures;
- QSet<QGestureRecognizer*> notGestures;
- if (state == NotGesture || state == MaybeGesture) {
- DEBUG() << "QGestureManager: current event processing state: "
- << (state == NotGesture ? "NotGesture" : "MaybeGesture");
-
- QSet<QGestureRecognizer*> stillMaybeGestures;
- // try other recognizers.
- foreach(QGestureRecognizer *r, recognizers) {
- if (grabbedGestures.value(r->gestureType(), 0) <= 0)
- continue;
- QGestureRecognizer::Result result = r->filterEvent(event);
- if (result == QGestureRecognizer::GestureStarted) {
- DEBUG() << "QGestureManager: gesture started: " << r;
- startedGestures << r;
- } else if (result == QGestureRecognizer::GestureFinished) {
- DEBUG() << "QGestureManager: gesture finished: " << r;
- finishedGestures << r;
- } else if (result == QGestureRecognizer::MaybeGesture) {
- DEBUG() << "QGestureManager: maybe gesture: " << r;
- newMaybeGestures << r;
- } else if (result == QGestureRecognizer::NotGesture) {
- // if it was maybe gesture, but isn't a gesture anymore.
- DEBUG() << "QGestureManager: not gesture: " << r;
- notGestures << r;
- }
- }
- Q_ASSERT(activeGestures.isEmpty());
- activeGestures += startedGestures;
- for(QMap<QGestureRecognizer*, int>::iterator it = maybeGestures.begin();
- it != maybeGestures.end();) {
- QGestureRecognizer *r = it.key();
- if (startedGestures.contains(r) || finishedGestures.contains(r) ||
- notGestures.contains(r)) {
- killTimer(it.value());
- it = maybeGestures.erase(it);
- } else {
- ++it;
- }
- }
- foreach(QGestureRecognizer *r, newMaybeGestures) {
- if (!maybeGestures.contains(r)) {
- int timerId = startTimer(MaximumGestureRecognitionTimeout);
- if (!timerId)
- qWarning("QGestureManager: couldn't start timer!");
- maybeGestures.insert(r, timerId);
- }
- }
- if (!finishedGestures.isEmpty() || !startedGestures.isEmpty()) {
- // gesture found!
- ret = true;
- QSet<QGesture*> started;
- foreach(QGestureRecognizer *r, finishedGestures) {
- if (QGesture *gesture = r->getGesture()) {
- started << gesture;
- gesture->d_func()->singleshot = true;
- }
- }
- foreach(QGestureRecognizer *r, startedGestures) {
- if (QGesture *gesture = r->getGesture()) {
- started << gesture;
- gesture->d_func()->singleshot = false;
- }
- }
-
- if (!activeGestures.isEmpty()) {
- DEBUG() << "QGestureManager: new state = Gesture";
- state = Gesture;
- } else if (!maybeGestures.isEmpty()) {
- DEBUG() << "QGestureManager: new state = Maybe";
- state = MaybeGesture;
- } else {
- DEBUG() << "QGestureManager: new state = NotGesture";
- state = NotGesture;
- }
-
- Q_ASSERT(!started.isEmpty());
- ret = sendGestureEvent(receiver, started, QSet<QGesture*>());
- } else if (!maybeGestures.isEmpty()) {
- if (state != MaybeGesture) {
- // We got a new set of events that look like a start
- // of some gesture, so we switch to state MaybeGesture
- // and wait for more events.
- DEBUG() << "QGestureManager: new state = Maybe. Waiting for events";
- state = MaybeGesture;
- // start gesture timer
- } else {
- // we still not sure if it is a gesture or not.
- }
- } else if (state == MaybeGesture) {
- // last time we thought it looks like gesture, but now we
- // know for sure that it isn't.
- DEBUG() << "QGestureManager: new state = NotGesture";
- state = NotGesture;
- }
- foreach(QGestureRecognizer *r, finishedGestures)
- r->reset();
- foreach(QGestureRecognizer *r, cancelledGestures)
- r->reset();
- foreach(QGestureRecognizer *r, notGestures)
- r->reset();
- } else if (state == Gesture) {
- DEBUG() << "QGestureManager: current event processing state: Gesture";
- Q_ASSERT(!activeGestures.isEmpty());
-
- foreach(QGestureRecognizer *r, recognizers) {
- if (grabbedGestures.value(r->gestureType(), 0) <= 0)
- continue;
- QGestureRecognizer::Result result = r->filterEvent(event);
- if (result == QGestureRecognizer::GestureStarted) {
- DEBUG() << "QGestureManager: gesture started: " << r;
- startedGestures << r;
- } else if (result == QGestureRecognizer::GestureFinished) {
- DEBUG() << "QGestureManager: gesture finished: " << r;
- finishedGestures << r;
- } else if (result == QGestureRecognizer::MaybeGesture) {
- DEBUG() << "QGestureManager: maybe gesture: " << r;
- newMaybeGestures << r;
- } else if (result == QGestureRecognizer::NotGesture) {
- // if it was an active gesture, but isn't a gesture anymore.
- if (activeGestures.contains(r)) {
- DEBUG() << "QGestureManager: cancelled gesture: " << r;
- cancelledGestures << r;
- } else {
- DEBUG() << "QGestureManager: not gesture: " << r;
- notGestures << r;
- }
- }
- }
-
- for(QMap<QGestureRecognizer*, int>::iterator it = maybeGestures.begin();
- it != maybeGestures.end();) {
- QGestureRecognizer *r = it.key();
- if (startedGestures.contains(r) || finishedGestures.contains(r) ||
- notGestures.contains(r)) {
- killTimer(it.value());
- it = maybeGestures.erase(it);
- } else {
- ++it;
- }
- }
- foreach(QGestureRecognizer *r, newMaybeGestures) {
- if (!maybeGestures.contains(r)) {
- int timerId = startTimer(MaximumGestureRecognitionTimeout);
- if (!timerId)
- qWarning("QGestureManager: couldn't start timer!");
- maybeGestures.insert(r, timerId);
- }
- }
- QSet<QGesture*> started, updated;
- if (!finishedGestures.isEmpty() || !startedGestures.isEmpty()) {
- // another gesture found!
- ret = true;
- foreach(QGestureRecognizer *r, finishedGestures) {
- if (QGesture *gesture = r->getGesture()) {
- gesture->d_func()->singleshot = !activeGestures.contains(r);
- if (gesture->d_func()->singleshot)
- started << gesture;
- else
- updated << gesture;
- }
- }
- foreach(QGestureRecognizer *r, startedGestures) {
- if (QGesture *gesture = r->getGesture()) {
- gesture->d_func()->singleshot = !activeGestures.contains(r);
- if (gesture->d_func()->singleshot)
- started << gesture;
- else
- updated << gesture;
- }
- }
- }
- activeGestures -= newMaybeGestures;
- activeGestures -= cancelledGestures;
- activeGestures += startedGestures;
- activeGestures -= finishedGestures;
- QSet<QString> cancelledGestureNames;
- foreach(QGestureRecognizer *r, cancelledGestures)
- cancelledGestureNames << r->gestureType();
- ret = sendGestureEvent(receiver, started, updated, cancelledGestureNames);
-
- foreach(QGestureRecognizer *r, finishedGestures)
- r->reset();
- foreach(QGestureRecognizer *r, cancelledGestures)
- r->reset();
- foreach(QGestureRecognizer *r, notGestures)
- r->reset();
- if (!activeGestures.isEmpty()) {
- // nothing changed, we are still handling a gesture
- } else if (!maybeGestures.isEmpty()) {
- DEBUG() << "QGestureManager: new state = Maybe. Waiting for events: " << maybeGestures;
- state = MaybeGesture;
- } else {
- DEBUG() << "QGestureManager: new state = NotGesture";
- state = NotGesture;
- }
- }
-
- if (delayedPressTimer && state == Gesture) {
- DEBUG() << "QGestureManager: gesture started. Forgetting about postponed mouse press event";
- killTimer(delayedPressTimer);
- delayedPressTimer = 0;
- lastMousePressReceiver = 0;
- } else if (delayedPressTimer && (state == NotGesture ||
- event->type() == QEvent::MouseButtonRelease)) {
- // not a gesture or released button too fast, so replay press
- // event back.
- DEBUG() << "QGestureManager: replaying mouse press event";
- QMap<QGestureRecognizer*, int>::const_iterator it = maybeGestures.begin(),
- e = maybeGestures.end();;
- for (; it != e; ++it) {
- it.key()->reset();
- killTimer(it.value());
- }
- maybeGestures.clear();
- state = NotGesture;
-
- if (lastMousePressReceiver) {
- QApplication::sendEvent(lastMousePressReceiver, &lastMousePressEvent);
- if (event->type() == QEvent::MouseButtonRelease) {
- QMouseEvent *me = static_cast<QMouseEvent*>(event);
- QMouseEvent move(QEvent::MouseMove, me->pos(), me->globalPos(), me->button(),
- me->buttons(), me->modifiers());
- QApplication::sendEvent(lastMousePressReceiver, &move);
- ret = false;
- }
- lastMousePressReceiver = 0;
- }
- lastMousePressReceiver = 0;
- killTimer(delayedPressTimer);
- delayedPressTimer = 0;
- } else if (state == MaybeGesture && event->type() == QEvent::MouseButtonPress
- && eventDeliveryDelayTimeout) {
- // postpone the press event delivery until we know for
- // sure whether it is a gesture.
- DEBUG() << "QGestureManager: postponing mouse press event";
- QMouseEvent *me = static_cast<QMouseEvent*>(event);
- lastMousePressReceiver = receiver;
- lastMousePressEvent = QMouseEvent(QEvent::MouseButtonPress, me->pos(),
- me->globalPos(), me->button(),
- me->buttons(), me->modifiers());
- Q_ASSERT(delayedPressTimer == 0);
- delayedPressTimer = startTimer(eventDeliveryDelayTimeout);
- if (!delayedPressTimer)
- qWarning("QGestureManager: couldn't start delayed press timer!");
- ret = true;
- }
- if (delayedPressTimer && event->type() == QEvent::MouseMove) {
- // if we have postponed a mouse press event, postpone all
- // subsequent mouse move events as well.
- ret = true;
- }
-
- lastPos = currentPos;
- return ret;
-}
-
-void QGestureManager::timerEvent(QTimerEvent *event)
-{
- if (event->timerId() == delayedPressTimer) {
- DEBUG() << "QGestureManager: replaying mouse press event due to timeout";
- // sanity checks
- Q_ASSERT(state != Gesture);
-
- QMap<QGestureRecognizer*, int>::const_iterator it = maybeGestures.begin(),
- e = maybeGestures.end();;
- for (; it != e; ++it) {
- it.key()->reset();
- killTimer(it.value());
- }
- maybeGestures.clear();
- state = NotGesture;
-
- if (lastMousePressReceiver) {
- // we neither received a mouse release event nor gesture
- // started, so we replay stored mouse press event.
- QApplication::sendEvent(lastMousePressReceiver, &lastMousePressEvent);
- lastMousePressReceiver = 0;
- }
-
- lastMousePressReceiver = 0;
- killTimer(delayedPressTimer);
- delayedPressTimer = 0;
- } else {
- // sanity checks, remove later
- Q_ASSERT((state == Gesture && !activeGestures.isEmpty()) || (state != Gesture && activeGestures.isEmpty()));
-
- typedef QMap<QGestureRecognizer*, int> MaybeGestureMap;
- for (MaybeGestureMap::iterator it = maybeGestures.begin(), e = maybeGestures.end();
- it != e; ++it) {
- if (it.value() == event->timerId()) {
- DEBUG() << "QGestureManager: gesture timeout.";
- QGestureRecognizer *r = it.key();
- r->reset();
- maybeGestures.erase(it);
- killTimer(event->timerId());
- break;
- }
- }
-
- if (state == MaybeGesture && maybeGestures.isEmpty()) {
- DEBUG() << "QGestureManager: new state = NotGesture because of timeout";
- state = NotGesture;
- }
- }
-}
-
-bool QGestureManager::inGestureMode()
-{
- return state == Gesture;
-}
-
-void QGestureManager::recognizerStateChanged(QGestureRecognizer::Result result)
-{
- QGestureRecognizer *recognizer = qobject_cast<QGestureRecognizer*>(sender());
- if (!recognizer)
- return;
- if (qApp->d_func()->grabbedGestures.value(recognizer->gestureType(), 0) <= 0) {
- recognizer->reset();
- return;
- }
-
- switch (result) {
- case QGestureRecognizer::GestureStarted:
- case QGestureRecognizer::GestureFinished: {
- if (result == QGestureRecognizer::GestureStarted) {
- DEBUG() << "QGestureManager: gesture started: " << recognizer;
- activeGestures << recognizer;
- DEBUG() << "QGestureManager: new state = Gesture";
- state = Gesture;
- } else {
- DEBUG() << "QGestureManager: gesture finished: " << recognizer;
- }
- if (maybeGestures.contains(recognizer)) {
- killTimer(maybeGestures.value(recognizer));
- maybeGestures.remove(recognizer);
- }
- QSet<QGesture*> gestures;
- if (QGesture *gesture = recognizer->getGesture())
- gestures << gesture;
- if(!gestures.isEmpty()) {
- //FIXME: sendGestureEvent(targetWidget, gestures);
- }
- if (result == QGestureRecognizer::GestureFinished)
- recognizer->reset();
- }
- break;
- case QGestureRecognizer::MaybeGesture: {
- DEBUG() << "QGestureManager: maybe gesture: " << recognizer;
- if (activeGestures.contains(recognizer)) {
- //FIXME: sendGestureEvent(targetWidget, QSet<QGesture*>(), QSet<QString>() << recognizer->gestureType());
- }
- if (!maybeGestures.contains(recognizer)) {
- int timerId = startTimer(MaximumGestureRecognitionTimeout);
- if (!timerId)
- qWarning("QGestureManager: couldn't start timer!");
- maybeGestures.insert(recognizer, timerId);
- }
- }
- break;
- case QGestureRecognizer::NotGesture:
- DEBUG() << "QGestureManager: not gesture: " << recognizer;
- if (maybeGestures.contains(recognizer)) {
- killTimer(maybeGestures.value(recognizer));
- maybeGestures.remove(recognizer);
- }
- recognizer->reset();
- break;
- default:
- Q_ASSERT(false);
- }
-
- if (delayedPressTimer && state == Gesture) {
- killTimer(delayedPressTimer);
- delayedPressTimer = 0;
- }
-}
-
-bool QGestureManager::sendGestureEvent(QWidget *receiver,
- const QSet<QGesture*> &startedGestures,
- const QSet<QGesture*> &updatedGestures,
- const QSet<QString> &cancelled)
-{
- DEBUG() << "QGestureManager::sendGestureEvent: sending to" << receiver
- << "gestures:" << startedGestures << "," << updatedGestures
- << "cancelled:" << cancelled;
- // grouping gesture objects by receiver widgets.
- typedef QMap<QWidget*, QSet<QGesture*> > WidgetGesturesMap;
- WidgetGesturesMap widgetGestures;
- for(QSet<QGesture*>::const_iterator it = startedGestures.begin(), e = startedGestures.end();
- it != e; ++it) {
- QGesture *g = *it;
- QGesturePrivate *gd = g->d_func();
- if (receiver) {
- // find the target widget
- gd->widget = 0;
- gd->graphicsItem = 0;
- QWidget *w = receiver;
- QPoint offset;
- const QString gestureType = g->type();
- while (w) {
- if (w->d_func()->hasGesture(gestureType))
- break;
- if (w->isWindow()) {
- w = 0;
- break;
- }
- offset += w->pos();
- w = w->parentWidget();
- }
- if (w && w != gd->widget) {
- DEBUG() << "QGestureManager::sendGestureEvent:" << g << "propagating to widget" << w << "offset" << offset;
- g->translate(offset);
- }
- gd->widget = w;
- }
- if (!gd->widget) {
- DEBUG() << "QGestureManager: didn't find a widget to send gesture event ("
- << g->type() << ") for tree:" << receiver;
- // TODO: maybe we should reset gesture recognizers when nobody interested in its gestures.
- continue;
- }
- widgetGestures[gd->widget].insert(g);
- }
-
- QSet<QGesture*> ignoredGestures;
- bool ret = false;
- for(WidgetGesturesMap::const_iterator it = widgetGestures.begin(), e = widgetGestures.end();
- it != e; ++it) {
- QWidget *receiver = it.key();
- Q_ASSERT(receiver != 0 /*should be taken care above*/);
- QSet<QGesture*> gestures = it.value();
- // mark all gestures as ignored by default
- for(QSet<QGesture*>::iterator it = gestures.begin(), e = gestures.end(); it != e; ++it)
- (*it)->ignore();
- // TODO: send cancelled gesture event to the widget that received the original gesture!
- QGestureEvent event(gestures, cancelled);
- DEBUG() << "QGestureManager::sendGestureEvent: sending now to" << receiver
- << "gestures" << gestures;
- bool processed = qt_sendSpontaneousEvent(receiver, &event);
- QSet<QGesture*> started = startedGestures & gestures;
- DEBUG() << "QGestureManager::sendGestureEvent:" <<
- (event.isAccepted() ? "" : "not") << "all gestures were accepted";
- if (!started.isEmpty() && !(processed && event.isAccepted())) {
- // there are started gestures events that weren't
- // accepted, so propagating each gesture independently.
- if (event.isAccepted()) {
- foreach(QGesture *g, started)
- g->accept();
- }
- QSet<QGesture*>::const_iterator it = started.begin(),
- e = started.end();
- for(; it != e; ++it) {
- QGesture *g = *it;
- if (processed && g->isAccepted()) {
- ret = true;
- continue;
- }
- // if it wasn't accepted, find the first parent widget
- // that is subscribed to the gesture.
- QGesturePrivate *gd = g->d_func();
- QWidget *w = gd->widget;
- gd->widget = 0;
-
- if (w && !w->isWindow()) {
- g->translate(w->pos());
- w = w->parentWidget();
- QPoint offset;
- const QString gestureType = g->type();
- while (w) {
- if (w->d_func()->hasGesture(gestureType)) {
- DEBUG() << "QGestureManager::sendGestureEvent:" << receiver
- << "didn't accept gesture" << g << "propagating to" << w;
- ignoredGestures.insert(g);
- gd->widget = w;
- break;
- }
- if (w->isWindow()) {
- w = 0;
- break;
- }
- offset += w->pos();
- w = w->parentWidget();
- }
- if (w) {
- g->translate(offset);
- } else {
- DEBUG() << "QGestureManager::sendGestureEvent:" << receiver
- << "didn't accept gesture" << g << "and nobody wants it";
- }
- }
- }
- }
- }
- if (ignoredGestures.isEmpty())
- return ret;
- // try to send all gestures that were ignored to the next parent
- return sendGestureEvent(0, ignoredGestures, QSet<QGesture*>(), cancelled) || ret;
-}
-
-int QGestureManager::eventDeliveryDelay() const
-{
- return eventDeliveryDelayTimeout;
-}
-
-void QGestureManager::setEventDeliveryDelay(int ms)
-{
- eventDeliveryDelayTimeout = ms;
-}
-
-int QGestureManager::makeGestureId(const QString &name)
-{
- gestureIdMap[++lastGestureId] = name;
- return lastGestureId;
-}
-
-void QGestureManager::releaseGestureId(int gestureId)
-{
- gestureIdMap.remove(gestureId);
-}
-
-QString QGestureManager::gestureNameFromId(int gestureId) const
-{
- return gestureIdMap.value(gestureId);
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qgesturemanager_p.cpp"
-
diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h
deleted file mode 100644
index 8656590..0000000
--- a/src/gui/kernel/qgesturemanager_p.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGESTUREMANAGER_P_H
-#define QGESTUREMANAGER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qlist.h"
-#include "qset.h"
-#include "qevent.h"
-#include "qbasictimer.h"
-#include "qpointer.h"
-
-#include "qgesturerecognizer.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWidget;
-class Q_AUTOTEST_EXPORT QGestureManager : public QObject
-{
- Q_OBJECT
-public:
- QGestureManager(QObject *parent);
-
- int eventDeliveryDelay() const;
- void setEventDeliveryDelay(int ms);
-
- void addRecognizer(QGestureRecognizer *recognizer);
- void removeRecognizer(QGestureRecognizer *recognizer);
-
- bool filterEvent(QWidget *receiver, QEvent *event);
- bool inGestureMode();
-
- int makeGestureId(const QString &name);
- void releaseGestureId(int gestureId);
- QString gestureNameFromId(int gestureId) const;
-
- // declared in qapplication.cpp
- static QGestureManager* instance();
-
- bool sendGestureEvent(QWidget *receiver,
- const QSet<QGesture*> &startedGestures,
- const QSet<QGesture*> &updatedGestures,
- const QSet<QString> &cancelled = QSet<QString>());
-
-protected:
- void timerEvent(QTimerEvent *event);
-
-private slots:
- void recognizerStateChanged(QGestureRecognizer::Result);
-
-private:
- QSet<QGestureRecognizer*> activeGestures;
- QMap<QGestureRecognizer*, int> maybeGestures;
- QSet<QGestureRecognizer*> recognizers;
-
- QPoint lastPos;
-
- int eventDeliveryDelayTimeout;
- int delayedPressTimer;
- QPointer<QWidget> lastMousePressReceiver;
- QMouseEvent lastMousePressEvent;
-
- QMap<int, QString> gestureIdMap;
- int lastGestureId;
-
- enum State {
- Gesture,
- NotGesture,
- MaybeGesture // that mean timers are up and waiting for some
- // more events, and input events are handled by
- // gesture recognizer explicitely
- } state;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGESTUREMANAGER_P_H
diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp
deleted file mode 100644
index c330663..0000000
--- a/src/gui/kernel/qgesturerecognizer.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgesturerecognizer.h"
-#include "qgesture.h"
-
-#include <private/qobject_p.h>
-#include <private/qgesturerecognizer_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QString qt_getStandardGestureTypeName(Qt::GestureType gestureType);
-
-/*!
- \class QGestureRecognizer
- \since 4.6
-
- \brief The QGestureRecognizer class is the base class for
- implementing custom gestures.
-
- This is a base class, to create a custom gesture type, you should
- subclass it and implement its pure virtual functions.
-
- Usually gesture recognizer implements state machine, storing its
- state internally in the recognizer object. The recognizer receives
- input events through the \l{QGestureRecognizer::}{filterEvent()}
- virtual function and decides whether the parsed event should
- change the state of the recognizer - i.e. if the event starts or
- ends a gesture or if it isn't related to gesture at all.
-*/
-
-/*!
- \enum QGestureRecognizer::Result
- \since 4.6
-
- This enum type defines the state of the gesture recognizer.
-
- \value Ignore Gesture recognizer ignores the event.
-
- \value NotGesture Not a gesture.
-
- \value GestureStarted The continuous gesture has started. When the
- recognizer is in this state, a \l{QGestureEvent}{gesture event}
- containing QGesture objects returned by the
- \l{QGestureRecognizer::}{getGesture()} will be sent to a widget.
-
- \value GestureFinished The gesture has ended. A
- \l{QGestureEvent}{gesture event} will be sent to a widget.
-
- \value MaybeGesture Gesture recognizer hasn't decided yet if a
- gesture has started, but it might start soon after the following
- events are received by the recognizer. This means that gesture
- manager shouldn't reset() the internal state of the gesture
- recognizer.
-*/
-
-/*! \fn QGestureRecognizer::Result QGestureRecognizer::filterEvent(const QEvent *event)
-
- This is a pure virtual function that needs to be implemented in
- subclasses.
-
- Parses input \a event and returns the result, which specifies if
- the event sequence is a gesture or not.
-*/
-
-/*! \fn QGesture* QGestureRecognizer::getGesture()
-
- Returns a gesture object that will be send to the widget. This
- function is called when the gesture recognizer changed its state
- to QGestureRecognizer::GestureStarted or
- QGestureRecognizer::GestureFinished.
-
- The returned QGesture object must point to the same object in a
- single gesture sequence.
-
- The gesture object is owned by the recognizer itself.
-*/
-
-/*! \fn void QGestureRecognizer::reset()
-
- Resets the internal state of the gesture recognizer.
-*/
-
-/*! \fn void QGestureRecognizer::stateChanged(QGestureRecognizer::Result result)
-
- The gesture recognizer might emit the stateChanged() signal when
- the gesture state changes asynchronously, i.e. without any event
- being filtered through filterEvent().
-*/
-
-QGestureRecognizerPrivate::QGestureRecognizerPrivate()
- : gestureType(Qt::UnknownGesture)
-{
-}
-
-/*!
- Creates a new gesture recognizer object that handles gestures of
- the specific \a gestureType as a child of \a parent.
-
- \sa QApplication::addGestureRecognizer(),
- QApplication::removeGestureRecognizer(),
-*/
-QGestureRecognizer::QGestureRecognizer(const QString &gestureType, QObject *parent)
- : QObject(*new QGestureRecognizerPrivate, parent)
-{
- Q_D(QGestureRecognizer);
- d->customGestureType = gestureType;
-}
-
-/*!
- Returns the name of the gesture that is handled by the recognizer.
-*/
-QString QGestureRecognizer::gestureType() const
-{
- Q_D(const QGestureRecognizer);
- if (d->gestureType == Qt::UnknownGesture)
- return d->customGestureType;
- return qt_getStandardGestureTypeName(d->gestureType);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesturestandardrecognizers.cpp b/src/gui/kernel/qgesturestandardrecognizers.cpp
deleted file mode 100644
index b108994..0000000
--- a/src/gui/kernel/qgesturestandardrecognizers.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgesturestandardrecognizers_p.h"
-#include "qgesture_p.h"
-#include "qgesturerecognizer_p.h"
-
-// #define GESTURE_RECOGNIZER_DEBUG
-#ifndef GESTURE_RECOGNIZER_DEBUG
-# define DEBUG if (0) qDebug
-#else
-# define DEBUG qDebug
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QString qt_getStandardGestureTypeName(Qt::GestureType gestureType)
-{
- switch (gestureType) {
- case Qt::TapGesture:
- return QLatin1String("__QTapGesture");
- case Qt::DoubleTapGesture:
- return QLatin1String("__QDoubleTapGesture");
- case Qt::TrippleTapGesture:
- return QLatin1String("__QTrippleTapGesture");
- case Qt::TapAndHoldGesture:
- return QLatin1String("__QTapAndHoldGesture");
- case Qt::PanGesture:
- return QLatin1String("__QPanGesture");
- case Qt::PinchGesture:
- return QLatin1String("__QPinchGesture");
- case Qt::UnknownGesture:
- break;
- }
- qFatal("QGestureRecognizer::gestureType: got an unhandled gesture type.");
- return QLatin1String("__unknown_gesture");
-}
-
-//
-// QGestureRecognizerPan
-//
-
-QGestureRecognizerPan::QGestureRecognizerPan(QObject *parent)
- : QGestureRecognizer(QString(), parent),
- mousePressed(false), gestureState(Qt::NoGesture),
- lastDirection(Qt::NoDirection), currentDirection(Qt::NoDirection)
-{
- Q_D(QGestureRecognizer);
- d->gestureType = Qt::PanGesture;
-}
-
-QGestureRecognizer::Result QGestureRecognizerPan::filterEvent(const QEvent *event)
-{
- if (event->type() == QEvent::MouseButtonPress) {
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- if (currentDirection != Qt::NoDirection) {
- DEBUG() << "Pan: MouseButtonPress: fail. another press during pan";
- reset();
- return QGestureRecognizer::NotGesture;
- }
- if (ev->button() != Qt::LeftButton) {
- return QGestureRecognizer::NotGesture;
- }
- DEBUG() << "Pan: MouseButtonPress: maybe gesture started";
- mousePressed = true;
- pressedPos = lastPos = currentPos = ev->pos();
- return QGestureRecognizer::MaybeGesture;
- } else if (event->type() == QEvent::MouseButtonRelease) {
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- if (mousePressed && currentDirection != Qt::NoDirection
- && ev->button() == Qt::LeftButton) {
- DEBUG() << "Pan: MouseButtonRelease: pan detected";
- gestureState = Qt::GestureFinished;
- currentPos = ev->pos();
- internalReset();
- return QGestureRecognizer::GestureFinished;
- }
- DEBUG() << "Pan: MouseButtonRelease: some weird release detected, ignoring";
- reset();
- return QGestureRecognizer::NotGesture;
- } else if (event->type() == QEvent::MouseMove) {
- if (!mousePressed)
- return QGestureRecognizer::NotGesture;
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- lastPos = currentPos;
- currentPos = ev->pos();
- Qt::DirectionType newDirection =
- simpleRecognizer.addPosition(ev->pos()).direction;
- DEBUG() << "Pan: MouseMove: simplerecognizer result = " << newDirection;
- QGestureRecognizer::Result result = QGestureRecognizer::NotGesture;
- if (currentDirection == Qt::NoDirection) {
- if (newDirection == Qt::NoDirection) {
- result = QGestureRecognizer::MaybeGesture;
- } else {
- result = QGestureRecognizer::GestureStarted;
- gestureState = Qt::GestureStarted;
- }
- } else {
- result = QGestureRecognizer::GestureStarted;
- gestureState = Qt::GestureUpdated;
- }
- if (newDirection != Qt::NoDirection) {
- if (currentDirection != newDirection)
- lastDirection = currentDirection;
- currentDirection = newDirection;
- }
- return result;
- }
- return QGestureRecognizer::Ignore;
-}
-
-QGesture* QGestureRecognizerPan::getGesture()
-{
- if (currentDirection == Qt::NoDirection)
- return 0;
- QPanningGesturePrivate *d = gesture.d_func();
- d->startPos = pressedPos;
- d->lastPos = lastPos;
- d->pos = currentPos;
- d->hotSpot = pressedPos;
- d->state = gestureState;
- d->lastDirection = lastDirection;
- d->direction = currentDirection;
-
- return &gesture;
-}
-
-void QGestureRecognizerPan::reset()
-{
- mousePressed = false;
- lastDirection = Qt::NoDirection;
- currentDirection = Qt::NoDirection;
- gestureState = Qt::NoGesture;
- diagonalRecognizer.reset();
- simpleRecognizer.reset();
-}
-
-void QGestureRecognizerPan::internalReset()
-{
- mousePressed = false;
- diagonalRecognizer.reset();
- simpleRecognizer.reset();
-}
-
-
-//
-// QDoubleTapGestureRecognizer
-//
-QDoubleTapGestureRecognizer::QDoubleTapGestureRecognizer(QObject *parent)
- : QGestureRecognizer(QString(), parent),
- gesture(0, qt_getStandardGestureTypeName(Qt::DoubleTapGesture))
-{
- Q_D(QGestureRecognizer);
- d->gestureType = Qt::DoubleTapGesture;
-}
-
-QGestureRecognizer::Result QDoubleTapGestureRecognizer::filterEvent(const QEvent *event)
-{
- if (event->type() == QEvent::MouseButtonPress) {
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- if (pressedPosition.isNull()) {
- pressedPosition = ev->pos();
- return QGestureRecognizer::MaybeGesture;
- } else if ((pressedPosition - ev->pos()).manhattanLength() < 10) {
- return QGestureRecognizer::GestureFinished;
- }
- return QGestureRecognizer::NotGesture;
- } else if (event->type() == QEvent::MouseButtonRelease) {
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- if (!pressedPosition.isNull() && (pressedPosition - ev->pos()).manhattanLength() < 10)
- return QGestureRecognizer::MaybeGesture;
- return QGestureRecognizer::NotGesture;
- } else if (event->type() == QEvent::MouseButtonDblClick) {
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- pressedPosition = ev->pos();
- return QGestureRecognizer::GestureFinished;
- }
- return QGestureRecognizer::NotGesture;
-}
-
-QGesture* QDoubleTapGestureRecognizer::getGesture()
-{
- QGesturePrivate *d = gesture.d_func();
- d->startPos = pressedPosition;
- d->lastPos = pressedPosition;
- d->pos = pressedPosition;
- d->hotSpot = pressedPosition;
- d->state = Qt::GestureFinished;
- return &gesture;
-}
-
-void QDoubleTapGestureRecognizer::reset()
-{
- pressedPosition = QPoint();
-}
-
-//
-// QTapAndHoldGestureRecognizer
-//
-const int QTapAndHoldGestureRecognizer::iterationCount = 40;
-const int QTapAndHoldGestureRecognizer::iterationTimeout = 50;
-
-QTapAndHoldGestureRecognizer::QTapAndHoldGestureRecognizer(QObject *parent)
- : QGestureRecognizer(QString(), parent),
- gesture(0, qt_getStandardGestureTypeName(Qt::TapAndHoldGesture)),
- iteration(0)
-{
- Q_D(QGestureRecognizer);
- d->gestureType = Qt::TapAndHoldGesture;
-}
-
-QGestureRecognizer::Result QTapAndHoldGestureRecognizer::filterEvent(const QEvent *event)
-{
- if (event->type() == QEvent::MouseButtonPress) {
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- if (timer.isActive())
- timer.stop();
- timer.start(QTapAndHoldGestureRecognizer::iterationTimeout, this);
- pressedPosition = ev->pos();
- return QGestureRecognizer::MaybeGesture;
- } else if (event->type() == QEvent::MouseMove) {
- const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
- if ((pressedPosition - ev->pos()).manhattanLength() < 15)
- return QGestureRecognizer::GestureStarted;
- else
- return QGestureRecognizer::NotGesture;
- } else if (event->type() == QEvent::MouseButtonRelease) {
- timer.stop();
- return QGestureRecognizer::NotGesture;
- }
- return QGestureRecognizer::Ignore;
-}
-
-void QTapAndHoldGestureRecognizer::timerEvent(QTimerEvent *event)
-{
- if (event->timerId() != timer.timerId())
- return;
- if (iteration == QTapAndHoldGestureRecognizer::iterationCount) {
- timer.stop();
- emit stateChanged(QGestureRecognizer::GestureFinished);
- } else {
- emit stateChanged(QGestureRecognizer::GestureStarted);
- }
- ++iteration;
-}
-
-QGesture* QTapAndHoldGestureRecognizer::getGesture()
-{
- QGesturePrivate *d = gesture.d_func();
- d->startPos = pressedPosition;
- d->lastPos = pressedPosition;
- d->pos = pressedPosition;
- d->hotSpot = pressedPosition;
- if (iteration >= QTapAndHoldGestureRecognizer::iterationCount)
- d->state = Qt::GestureFinished;
- else
- d->state = iteration == 0 ? Qt::GestureStarted : Qt::GestureUpdated;
- return &gesture;
-}
-
-void QTapAndHoldGestureRecognizer::reset()
-{
- pressedPosition = QPoint();
- timer.stop();
- iteration = 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesturestandardrecognizers_p.h b/src/gui/kernel/qgesturestandardrecognizers_p.h
deleted file mode 100644
index 8abc1fb..0000000
--- a/src/gui/kernel/qgesturestandardrecognizers_p.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGESTURESTANDARDRECOGNIZERS_P_H
-#define QGESTURESTANDARDRECOGNIZERS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qevent.h"
-#include "qbasictimer.h"
-#include "qdebug.h"
-
-#include "qgesture.h"
-#include "qgesturerecognizer.h"
-#include "private/qdirectionrecognizer_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGestureRecognizerPan : public QGestureRecognizer
-{
- Q_OBJECT
-public:
- QGestureRecognizerPan(QObject *parent);
-
- QGestureRecognizer::Result filterEvent(const QEvent *event);
- QGesture* getGesture();
- void reset();
-
-private:
- void internalReset();
-
- QPanningGesture gesture;
-
- QPoint pressedPos;
- QPoint lastPos;
- QPoint currentPos;
- bool mousePressed;
- Qt::GestureState gestureState;
- Qt::DirectionType lastDirection;
- Qt::DirectionType currentDirection;
- QDirectionDiagonalRecognizer diagonalRecognizer;
- QDirectionSimpleRecognizer simpleRecognizer;
-};
-
-class QDoubleTapGestureRecognizer : public QGestureRecognizer
-{
- Q_OBJECT
-public:
- QDoubleTapGestureRecognizer(QObject *parent);
-
- QGestureRecognizer::Result filterEvent(const QEvent *event);
- QGesture* getGesture();
- void reset();
-
-private:
- QGesture gesture;
- QPoint pressedPosition;
-};
-
-class QTapAndHoldGestureRecognizer : public QGestureRecognizer
-{
- Q_OBJECT
-public:
- QTapAndHoldGestureRecognizer(QObject *parent);
-
- QGestureRecognizer::Result filterEvent(const QEvent *event);
- QGesture* getGesture();
- void reset();
-
-protected:
- void timerEvent(QTimerEvent *event);
-
-private:
- QGesture gesture;
- QPoint pressedPosition;
- QBasicTimer timer;
- int iteration;
- static const int iterationCount;
- static const int iterationTimeout;
-};
-
-QT_END_NAMESPACE
-
-#endif // QGESTURESTANDARDRECOGNIZERS_P_H
diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp
index c986117..011c726 100644
--- a/src/gui/kernel/qguifunctions_wince.cpp
+++ b/src/gui/kernel/qguifunctions_wince.cpp
@@ -215,13 +215,7 @@ int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID l
return ret;
}
-bool qt_wince_TextOutW(HDC hdc, int x, int y, LPWSTR lpString, UINT c)
-{
- return ExtTextOutW(hdc, x, y, 0, NULL, lpString, c, NULL);
-}
-
-
-HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCTSTR, LPCTSTR file, LPCTSTR params, LPCTSTR dir, int showCmd)
+HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd)
{
SHELLEXECUTEINFO info;
info.hwnd = hwnd;
@@ -253,17 +247,11 @@ COLORREF qt_wince_PALETTEINDEX( WORD /*wPaletteIndex*/)
return 0;
}
-BOOL qt_wince_TextOut( HDC hdc, int nXStart, int nYStart, LPCTSTR lpString, int cbString )
-{
- return ExtTextOut( hdc, nXStart, nYStart - 16, 0, NULL, lpString, cbString, NULL );
-}
-
// Internal Qt -----------------------------------------------------
bool qt_wince_is_platform(const QString &platformString) {
- TCHAR tszPlatform[64];
- if (SystemParametersInfo(SPI_GETPLATFORMTYPE,
- sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0))
- if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
+ wchar_t tszPlatform[64];
+ if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(tszPlatform) / sizeof(wchar_t), tszPlatform, 0))
+ if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
return true;
return false;
}
@@ -316,8 +304,8 @@ void qt_wince_maximize(QWidget *widget)
void qt_wince_minimize(HWND hwnd) {
- uint exstyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
- uint style = GetWindowLongW(hwnd, GWL_STYLE);
+ uint exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
+ uint style = GetWindowLong(hwnd, GWL_STYLE);
RECT rect;
RECT crect = {0,0,0,0};
GetWindowRect(hwnd, &rect);
diff --git a/src/gui/kernel/qguifunctions_wince.h b/src/gui/kernel/qguifunctions_wince.h
index bcf2004..234c8c6 100644
--- a/src/gui/kernel/qguifunctions_wince.h
+++ b/src/gui/kernel/qguifunctions_wince.h
@@ -73,10 +73,6 @@ int qt_wince_GetDIBits(HDC, HBITMAP, uint, uint, void*, LPBITMAPINFO, uint);
// QWidget
#define SW_SHOWMINIMIZED SW_MINIMIZE
-// QPaintEngine
-bool qt_wince_TextOutW(HDC, int, int, LPWSTR, UINT);
-#define TextOutW(a,b,c,d,e) qt_wince_TextOutW(a,b,c,d,e)
-
// QRegion
#define ALTERNATE 0
#define WINDING 1
@@ -128,7 +124,7 @@ typedef struct tagTTPOLYCURVE
#define TT_PRIM_CSPLINE 3
#define ANSI_VAR_FONT 12
-HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCTSTR operation, LPCTSTR file, LPCTSTR params, LPCTSTR dir, int showCmd);
+HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR operation, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd);
#define ShellExecute(a,b,c,d,e,f) qt_wince_ShellExecute(a,b,c,d,e,f)
@@ -150,8 +146,6 @@ HWND qt_wince_SetClipboardViewer(
// Graphics ---------------------------------------------------------
COLORREF qt_wince_PALETTEINDEX( WORD wPaletteIndex );
#define PALETTEINDEX(a) qt_wince_PALETTEINDEX(a)
-BOOL qt_wince_TextOut( HDC hdc, int nXStart, int nYStart, LPCTSTR lpString, int cbString );
-#define TextOut(a,b,c,d,e) qt_wince_TextOut(a,b,c,d,e)
#endif // Q_OS_WINCE
#endif // QGUIFUNCTIONS_WCE_H
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp
index 01df47d..ab69cdf 100644
--- a/src/gui/kernel/qguivariant.cpp
+++ b/src/gui/kernel/qguivariant.cpp
@@ -60,6 +60,11 @@
#include "qregion.h"
#include "qsizepolicy.h"
#include "qtextformat.h"
+#include "qmatrix4x4.h"
+#include "qvector2d.h"
+#include "qvector3d.h"
+#include "qvector4d.h"
+#include "qquaternion.h"
#include "private/qvariant_p.h"
@@ -148,6 +153,31 @@ static void construct(QVariant::Private *x, const void *copy)
v_construct<QColor>(x, &color);
break;
}
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ v_construct<QMatrix4x4>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ v_construct<QVector2D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ v_construct<QVector3D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ v_construct<QVector4D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ v_construct<QQuaternion>(x, copy);
+ break;
+#endif
default:
qcoreVariantHandler()->construct(x, copy);
return;
@@ -221,6 +251,31 @@ static void clear(QVariant::Private *d)
case QVariant::Pen:
v_clear<QPen>(d);
break;
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ v_clear<QMatrix4x4>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ v_clear<QVector2D>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ v_clear<QVector3D>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ v_clear<QVector4D>(d);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ v_clear<QVector4D>(d);
+ break;
+#endif
default:
qcoreVariantHandler()->clear(d);
return;
@@ -266,7 +321,26 @@ static bool isNull(const QVariant::Private *d)
case QVariant::KeySequence:
#endif
case QVariant::Pen:
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+#endif
break;
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ return v_cast<QVector2D>(d)->isNull();
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ return v_cast<QVector3D>(d)->isNull();
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ return v_cast<QVector4D>(d)->isNull();
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ return v_cast<QQuaternion>(d)->isNull();
+#endif
default:
return qcoreVariantHandler()->isNull(d);
}
@@ -326,6 +400,26 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
#endif
case QVariant::Pen:
return *v_cast<QPen>(a) == *v_cast<QPen>(b);
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ return *v_cast<QMatrix4x4>(a) == *v_cast<QMatrix4x4>(b);
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ return *v_cast<QVector2D>(a) == *v_cast<QVector2D>(b);
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ return *v_cast<QVector3D>(a) == *v_cast<QVector3D>(b);
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ return *v_cast<QVector4D>(a) == *v_cast<QVector4D>(b);
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b);
+#endif
default:
break;
}
@@ -513,6 +607,31 @@ static void streamDebug(QDebug dbg, const QVariant &v)
case QVariant::Pen:
dbg.nospace() << qvariant_cast<QPen>(v);
break;
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ dbg.nospace() << qvariant_cast<QMatrix4x4>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ dbg.nospace() << qvariant_cast<QVector2D>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ dbg.nospace() << qvariant_cast<QVector3D>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ dbg.nospace() << qvariant_cast<QVector4D>(v);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ dbg.nospace() << qvariant_cast<QQuaternion>(v);
+ break;
+#endif
default:
qcoreVariantHandler()->debugStream(dbg, v);
break;
@@ -596,6 +715,21 @@ Q_DECL_METATYPE_HELPER(QTextLength)
Q_DECL_METATYPE_HELPER(QTextFormat)
Q_DECL_METATYPE_HELPER(QMatrix)
Q_DECL_METATYPE_HELPER(QTransform)
+#ifndef QT_NO_MATRIX4X4
+Q_DECL_METATYPE_HELPER(QMatrix4x4)
+#endif
+#ifndef QT_NO_VECTOR2D
+Q_DECL_METATYPE_HELPER(QVector2D)
+#endif
+#ifndef QT_NO_VECTOR3D
+Q_DECL_METATYPE_HELPER(QVector3D)
+#endif
+#ifndef QT_NO_VECTOR4D
+Q_DECL_METATYPE_HELPER(QVector4D)
+#endif
+#ifndef QT_NO_QUATERNION
+Q_DECL_METATYPE_HELPER(QQuaternion)
+#endif
#ifdef QT_NO_DATASTREAM
# define Q_IMPL_METATYPE_HELPER(TYPE) \
@@ -645,7 +779,32 @@ static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
Q_IMPL_METATYPE_HELPER(QTextLength),
Q_IMPL_METATYPE_HELPER(QTextFormat),
Q_IMPL_METATYPE_HELPER(QMatrix),
- Q_IMPL_METATYPE_HELPER(QTransform)
+ Q_IMPL_METATYPE_HELPER(QTransform),
+#ifndef QT_NO_MATRIX4X4
+ Q_IMPL_METATYPE_HELPER(QMatrix4x4),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR2D
+ Q_IMPL_METATYPE_HELPER(QVector2D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR3D
+ Q_IMPL_METATYPE_HELPER(QVector3D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR4D
+ Q_IMPL_METATYPE_HELPER(QVector4D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_QUATERNION
+ Q_IMPL_METATYPE_HELPER(QQuaternion)
+#else
+ {0, 0, 0, 0}
+#endif
};
static const QVariant::Handler *qt_guivariant_last_handler = 0;
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 017c13c..8eee665 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -729,8 +729,10 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
QString text(ourChar);
/* This is actually wrong - but unfortunatly it is the best that can be
done for now because of the Control/Meta mapping problems */
- if (modifiers & (Qt::ControlModifier | Qt::MetaModifier))
+ if (modifiers & (Qt::ControlModifier | Qt::MetaModifier)
+ && !qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
text = QString();
+ }
if (widget) {
diff --git a/src/gui/kernel/qkeymapper_win.cpp b/src/gui/kernel/qkeymapper_win.cpp
index e40dfa0..0998631 100644
--- a/src/gui/kernel/qkeymapper_win.cpp
+++ b/src/gui/kernel/qkeymapper_win.cpp
@@ -41,7 +41,7 @@
#include "qkeymapper_p.h"
-#include <windows.h>
+#include <qt_windows.h>
#include <qdebug.h>
#include <private/qevent_p.h>
#include <private/qlocale_p.h>
@@ -57,9 +57,7 @@ QT_BEGIN_NAMESPACE
// Implemented elsewhere
extern "C" LRESULT CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
-Q_CORE_EXPORT bool winPostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-Q_CORE_EXPORT bool winPeekMessage(MSG* msg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax,
- UINT wRemoveMsg);
+
extern Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id);
#ifndef LANG_PASHTO
#define LANG_PASHTO 0x63
@@ -467,12 +465,7 @@ static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer,
Q_ASSERT(vk > 0 && vk < 256);
int code = 0;
QChar unicodeBuffer[5];
- int res = 0;
- if (QSysInfo::WindowsVersion < QSysInfo::WV_NT)
- res = ToAscii(vk, scancode, kbdBuffer, reinterpret_cast<LPWORD>(unicodeBuffer), 0);
- else
- res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
-
+ int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast<LPWSTR>(unicodeBuffer), 5, 0);
if (res)
code = unicodeBuffer[0].toUpper().unicode();
@@ -504,38 +497,6 @@ static inline int asciiToKeycode(char a, int state)
return a & 0xff;
}
-static int inputcharset = CP_ACP;
-static inline QChar wmchar_to_unicode(DWORD c)
-{
- // qt_winMB2QString is the generalization of this function.
- QT_WA({
- return QChar((ushort)c);
- } , {
- char mb[2];
- mb[0] = c & 0xff;
- mb[1] = 0;
- WCHAR wc[1];
- MultiByteToWideChar(inputcharset, MB_PRECOMPOSED, mb, -1, wc, 1);
- return QChar(wc[0]);
- });
-}
-
-static inline QChar imechar_to_unicode(DWORD c)
-{
- // qt_winMB2QString is the generalization of this function.
- QT_WA({
- return QChar((ushort)c);
- } , {
- char mb[3];
- mb[0] = (c >> 8) & 0xff;
- mb[1] = c & 0xff;
- mb[2] = 0;
- WCHAR wc[1];
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, mb, -1, wc, 1);
- return QChar(wc[0]);
- });
-}
-
static inline bool isModifierKey(int code)
{
return (code >= Qt::Key_Shift) && (code <= Qt::Key_ScrollLock);
@@ -635,43 +596,15 @@ void QKeyMapperPrivate::clearMappings()
/* MAKELCID()'s first argument is a WORD, and GetKeyboardLayout()
* returns a DWORD. */
-// LCID newLCID = MAKELCID(DWORD(GetKeyboardLayout(0)), SORT_DEFAULT);
+
+ LCID newLCID = MAKELCID((DWORD)GetKeyboardLayout(0), SORT_DEFAULT);
// keyboardInputLocale = qt_localeFromLCID(newLCID);
- LCID newLCID = MAKELCID(
- reinterpret_cast<long>(GetKeyboardLayout(0)),
- SORT_DEFAULT
- );
- keyboardInputLocale = qt_localeFromLCID(newLCID);
+
bool bidi = false;
-#ifdef UNICODE
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_2000) {
- WCHAR wchLCIDFontSig[16];
- if (GetLocaleInfoW(newLCID,
- LOCALE_FONTSIGNATURE,
- &wchLCIDFontSig[0],
- (sizeof(wchLCIDFontSig)/sizeof(WCHAR)))
- && (wchLCIDFontSig[7] & (WCHAR)0x0800))
+ wchar_t LCIDFontSig[16];
+ if (GetLocaleInfo(newLCID, LOCALE_FONTSIGNATURE, LCIDFontSig, sizeof(LCIDFontSig) / sizeof(wchar_t))
+ && (LCIDFontSig[7] & (wchar_t)0x0800))
bidi = true;
- } else
-#endif //UNICODE
- {
- if (newLCID == 0x0859 || //Sindhi (Arabic script)
- newLCID == 0x0460) //Kashmiri (Arabic script)
- bidi = true;;
-
- switch (PRIMARYLANGID(newLCID))
- {
- case LANG_ARABIC:
- case LANG_HEBREW:
- case LANG_URDU:
- case LANG_FARSI:
- case LANG_PASHTO:
- //case LANG_UIGHUR:
- case LANG_SYRIAC:
- case LANG_DIVEHI:
- bidi = true;
- }
- }
keyboardInputDirection = bidi ? Qt::RightToLeft : Qt::LeftToRight;
}
@@ -760,7 +693,7 @@ void QKeyMapperPrivate::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32
keyLayout[vk_key]->qtKey[8] = fallbackKey;
// If this vk_key a Dead Key
- if (MapVirtualKey(vk_key, 2) & 0x80008000) { // (High-order dead key on Win 95 is 0x8000)
+ if (MapVirtualKey(vk_key, 2) & 0x80000000) {
// Push a Space, then the original key through the low-level ToAscii functions.
// We do this because these functions (ToAscii / ToUnicode) will alter the internal state of
// the keyboard driver By doing the following, we set the keyboard driver state back to what
@@ -837,13 +770,13 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
bool isNumpad = (msg.wParam >= VK_NUMPAD0 && msg.wParam <= VK_NUMPAD9);
quint32 nModifiers = 0;
- if (QSysInfo::WindowsVersion < QSysInfo::WV_NT || QSysInfo::WindowsVersion & QSysInfo::WV_CE_based) {
+#if defined(QT_OS_WINCE)
nModifiers |= (GetKeyState(VK_SHIFT ) < 0 ? ShiftAny : 0);
nModifiers |= (GetKeyState(VK_CONTROL) < 0 ? ControlAny : 0);
nModifiers |= (GetKeyState(VK_MENU ) < 0 ? AltAny : 0);
nModifiers |= (GetKeyState(VK_LWIN ) < 0 ? MetaLeft : 0);
nModifiers |= (GetKeyState(VK_RWIN ) < 0 ? MetaRight : 0);
- } else {
+#else
// Map native modifiers to some bit representation
nModifiers |= (GetKeyState(VK_LSHIFT ) & 0x80 ? ShiftLeft : 0);
nModifiers |= (GetKeyState(VK_RSHIFT ) & 0x80 ? ShiftRight : 0);
@@ -857,7 +790,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
nModifiers |= (GetKeyState(VK_CAPITAL ) & 0x01 ? CapsLock : 0);
nModifiers |= (GetKeyState(VK_NUMLOCK ) & 0x01 ? NumLock : 0);
nModifiers |= (GetKeyState(VK_SCROLL ) & 0x01 ? ScrollLock : 0);
- }
+#endif // QT_OS_WINCE
+
if (msg.lParam & ExtendedKey)
nModifiers |= msg.lParam & ExtendedKey;
@@ -870,12 +804,12 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
// Now we know enough to either have MapVirtualKey or our own keymap tell us if it's a deadkey
bool isDeadKey = isADeadKey(msg.wParam, state)
- || MapVirtualKey(msg.wParam, 2) & 0x80008000; // High-order on 95 is 0x8000
+ || MapVirtualKey(msg.wParam, 2) & 0x80000000;
// A multi-character key not found by our look-ahead
if (msgType == WM_CHAR) {
QString s;
- QChar ch = wmchar_to_unicode(msg.wParam);
+ QChar ch = QChar((ushort)msg.wParam);
if (!ch.isNull())
s += ch;
@@ -886,7 +820,7 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
// Input method characters not found by our look-ahead
else if (msgType == WM_IME_CHAR) {
QString s;
- QChar ch = imechar_to_unicode(msg.wParam);
+ QChar ch = QChar((ushort)msg.wParam);
if (!ch.isNull())
s += ch;
@@ -917,8 +851,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
}
} else if (msgType == WM_KEYUP) {
if (dirStatus == VK_LSHIFT
- && (msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)
- || msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT))) {
+ && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL))
+ || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) {
k0 = q->sendKeyEvent(widget, grab, QEvent::KeyPress, Qt::Key_Direction_L, 0,
QString(), false, 0,
scancode, msg.wParam, nModifiers);
@@ -927,8 +861,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
scancode, msg.wParam, nModifiers);
dirStatus = 0;
} else if (dirStatus == VK_RSHIFT
- && (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)
- || msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT))) {
+ && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL))
+ || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) {
k0 = q->sendKeyEvent(widget, grab, QEvent::KeyPress, Qt::Key_Direction_R,
0, QString(), false, 0,
scancode, msg.wParam, nModifiers);
@@ -1050,11 +984,9 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
: msgType == WM_IME_KEYDOWN ? WM_IME_CHAR : WM_SYSCHAR);
QChar uch;
- if (winPeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) {
+ if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) {
// Found a ?_CHAR
- uch = charType == WM_IME_CHAR
- ? imechar_to_unicode(wm_char.wParam)
- : wmchar_to_unicode(wm_char.wParam);
+ uch = QChar((ushort)wm_char.wParam);
if (msgType == WM_SYSKEYDOWN && uch.isLetter() && (msg.lParam & KF_ALTDOWN))
uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter
if (!code && !uch.row())
@@ -1067,7 +999,7 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
// to find the correct key using the current message parameters & keyboard state.
if (uch.isNull() && msgType == WM_IME_KEYDOWN) {
BYTE keyState[256];
- WCHAR newKey[3] = {0};
+ wchar_t newKey[3] = {0};
GetKeyboardState(keyState);
int val = ToUnicode(vk_key, scancode, keyState, newKey, 2, 0);
if (val == 1) {
@@ -1085,18 +1017,10 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, const MSG &msg, bool
uch = QChar(QLatin1Char(0x7f)); // Windows doesn't know this one.
} else {
if (msgType != WM_SYSKEYDOWN || !code) {
- UINT map;
- QT_WA({
- map = MapVirtualKey(msg.wParam, 2);
- } , {
- map = MapVirtualKeyA(msg.wParam, 2);
- // High-order bit is 0x8000 on '95
- if (map & 0x8000)
- map = (map^0x8000)|0x80000000;
- });
+ UINT map = MapVirtualKey(msg.wParam, 2);
// If the high bit of the return value is set, it's a deadkey
if (!(map & 0x80000000))
- uch = wmchar_to_unicode((DWORD)map);
+ uch = QChar((ushort)map);
}
}
if (!code && !uch.row())
@@ -1237,6 +1161,8 @@ bool QKeyMapper::sendKeyEvent(QWidget *widget, bool grab,
if (QApplicationPrivate::instance()->qt_tryAccelEvent(widget, &a))
return true;
}
+#else
+ Q_UNUSED(grab);
#endif
if (!widget->isEnabled())
return false;
diff --git a/src/gui/kernel/qlayout.cpp b/src/gui/kernel/qlayout.cpp
index 9430f1b..921afce 100644
--- a/src/gui/kernel/qlayout.cpp
+++ b/src/gui/kernel/qlayout.cpp
@@ -61,7 +61,10 @@ static int menuBarHeightForWidth(QWidget *menubar, int w)
int result = menubar->heightForWidth(qMax(w, menubar->minimumWidth()));
if (result != -1)
return result;
- result = menubar->sizeHint().height();
+ result = menubar->sizeHint()
+ .expandedTo(menubar->minimumSize())
+ .expandedTo(menubar->minimumSizeHint())
+ .boundedTo(menubar->maximumSize()).height();
if (result != -1)
return result;
}
diff --git a/src/gui/kernel/qmime_win.cpp b/src/gui/kernel/qmime_win.cpp
index bc15638..acd7cfc 100644
--- a/src/gui/kernel/qmime_win.cpp
+++ b/src/gui/kernel/qmime_win.cpp
@@ -170,7 +170,7 @@ static QByteArray getData(int cf, IDataObject *pDataObj)
if (pDataObj->GetData(&formatetc, &s) == S_OK) {
char szBuffer[4096];
ULONG actualRead = 0;
- LARGE_INTEGER pos = {0, 0};
+ LARGE_INTEGER pos = {{0, 0}};
//Move to front (can fail depending on the data model implemented)
HRESULT hr = s.pstm->Seek(pos, STREAM_SEEK_SET, NULL);
while(SUCCEEDED(hr)){
@@ -281,11 +281,7 @@ QWindowsMime::~QWindowsMime()
*/
int QWindowsMime::registerMimeType(const QString &mime)
{
-#ifdef Q_OS_WINCE
int f = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (mime.utf16()));
-#else
- int f = RegisterClipboardFormatA(mime.toLocal8Bit());
-#endif
if (!f)
qErrnoWarning("QWindowsMime::registerMimeType: Failed to register clipboard format");
@@ -401,9 +397,9 @@ QStringList QWindowsMime::allMimesForFormats(IDataObject *pDataObj)
while (S_OK == fmtenum->Next(1, &fmtetc, 0)) {
#if defined(QMIME_DEBUG) && !defined(Q_OS_WINCE)
qDebug("QWindowsMime::allMimesForFormats()");
- char buf[256] = {0};
- GetClipboardFormatNameA(fmtetc.cfFormat, buf, 255);
- qDebug("CF = %d : %s", fmtetc.cfFormat, buf);
+ wchar_t buf[256] = {0};
+ GetClipboardFormatName(fmtetc.cfFormat, buf, 255);
+ qDebug("CF = %d : %s", fmtetc.cfFormat, QString::fromWCharArray(buf));
#endif
for (int i=mimes.size()-1; i>=0; --i) {
QString format = mimes.at(i)->mimeForFormat(fmtetc);
@@ -504,7 +500,7 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa
++u;
}
res.truncate(ri);
- const int byteLength = res.length()*2;
+ const int byteLength = res.length() * sizeof(ushort);
QByteArray r(byteLength + 2, '\0');
memcpy(r.data(), res.unicode(), byteLength);
r[byteLength] = 0;
@@ -549,7 +545,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData
QString str;
QByteArray data = getData(CF_UNICODETEXT, pDataObj);
if (!data.isEmpty()) {
- str = QString::fromUtf16((const unsigned short *)data.data());
+ str = QString::fromWCharArray((const wchar_t *)data.data());
str.replace(QLatin1String("\r\n"), QLatin1String("\n"));
} else {
data = getData(CF_TEXT, pDataObj);
@@ -620,11 +616,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
for (int i=0; i<urls.size(); i++) {
QString fn = QDir::toNativeSeparators(urls.at(i).toLocalFile());
if (!fn.isEmpty()) {
- QT_WA({
- size += sizeof(TCHAR)*(fn.length()+1);
- } , {
- size += fn.toLocal8Bit().length()+1;
- });
+ size += sizeof(ushort) * (fn.length() + 1);
fileNames.append(fn);
}
}
@@ -636,36 +628,22 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat
d->fNC = true;
char* files = ((char*)d) + d->pFiles;
- QT_WA({
- d->fWide = true;
- TCHAR* f = (TCHAR*)files;
- for (int i=0; i<fileNames.size(); i++) {
- int l = fileNames.at(i).length();
- memcpy(f, fileNames.at(i).utf16(), l*sizeof(TCHAR));
- f += l;
- *f++ = 0;
- }
- *f = 0;
- } , {
- d->fWide = false;
- char* f = files;
- for (int i=0; i<fileNames.size(); i++) {
- QByteArray c = fileNames.at(i).toLocal8Bit();
- if (!c.isEmpty()) {
- int l = c.length();
- memcpy(f, c.constData(), l);
- f += l;
- *f++ = 0;
- }
- }
- *f = 0;
- });
+ d->fWide = true;
+ wchar_t* f = (wchar_t*)files;
+ for (int i=0; i<fileNames.size(); i++) {
+ int l = fileNames.at(i).length();
+ memcpy(f, fileNames.at(i).utf16(), l * sizeof(ushort));
+ f += l;
+ *f++ = 0;
+ }
+ *f = 0;
+
return setData(result, pmedium);
} else if (getCf(formatetc) == CF_INETURL_W) {
QList<QUrl> urls = mimeData->urls();
QByteArray result;
QString url = urls.at(0).toString();
- result = QByteArray((const char *)url.utf16(), url.length() * 2);
+ result = QByteArray((const char *)url.utf16(), url.length() * sizeof(ushort));
result.append('\0');
result.append('\0');
return setData(result, pmedium);
@@ -720,15 +698,15 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
LPDROPFILES hdrop = (LPDROPFILES)data.data();
if (hdrop->fWide) {
- const ushort* filesw = (const ushort*)(data.data() + hdrop->pFiles);
- int i=0;
+ const wchar_t* filesw = (const wchar_t *)(data.data() + hdrop->pFiles);
+ int i = 0;
while (filesw[i]) {
- QString fileurl = QString::fromUtf16(filesw+i);
+ QString fileurl = QString::fromWCharArray(filesw + i);
urls += QUrl::fromLocalFile(fileurl);
i += fileurl.length()+1;
}
} else {
- const char* files = (const char*)data.data() + hdrop->pFiles;
+ const char* files = (const char *)data.data() + hdrop->pFiles;
int i=0;
while (files[i]) {
urls += QUrl::fromLocalFile(QString::fromLocal8Bit(files+i));
@@ -744,7 +722,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
QByteArray data = getData(CF_INETURL_W, pDataObj);
if (data.isEmpty())
return QVariant();
- return QUrl(QString::fromUtf16((const unsigned short *)data.constData()));
+ return QUrl(QString::fromWCharArray((const wchar_t *)data.constData()));
} else if (canGetData(CF_INETURL, pDataObj)) {
QByteArray data = getData(CF_INETURL, pDataObj);
if (data.isEmpty())
@@ -913,11 +891,7 @@ private:
QWindowsMimeImage::QWindowsMimeImage()
{
-#ifdef Q_OS_WINCE
- CF_PNG = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (QString::fromLatin1("PNG").utf16()));
-#else
- CF_PNG = RegisterClipboardFormatA("PNG");
-#endif
+ CF_PNG = RegisterClipboardFormat(L"PNG");
}
QVector<FORMATETC> QWindowsMimeImage::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
@@ -1114,7 +1088,7 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData
++u;
}
res.truncate(ri);
- const int byteLength = res.length()*2;
+ const int byteLength = res.length() * sizeof(ushort);
QByteArray r(byteLength + 2, '\0');
memcpy(r.data(), res.unicode(), byteLength);
r[byteLength] = 0;
@@ -1154,8 +1128,8 @@ QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDat
qDebug("QBuiltInMimes::convertToMime()");
#endif
if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) {
- // text/html is in wide chars on windows (compatible with mozillia)
- val = QString::fromUtf16((const unsigned short *)data.data());
+ // text/html is in wide chars on windows (compatible with Mozilla)
+ val = QString::fromWCharArray((const wchar_t *)data.data());
} else {
val = data; // it should be enough to return the data and let QMimeData do the rest.
}
@@ -1280,11 +1254,7 @@ bool QLastResortMimes::canConvertToMime(const QString &mimeType, IDataObject *pD
{
if (isCustomMimeType(mimeType)) {
QString clipFormat = customMimeType(mimeType);
-#ifdef Q_OS_WINCE
int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
-#else
- int cf = RegisterClipboardFormatA(clipFormat.toLocal8Bit());
-#endif
return canGetData(cf, pDataObj);
} else if (formats.keys(mimeType).isEmpty()) {
// if it is not in there then register it an see if we can get it
@@ -1304,11 +1274,7 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p
QByteArray data;
if (isCustomMimeType(mimeType)) {
QString clipFormat = customMimeType(mimeType);
-#ifdef Q_OS_WINCE
int cf = RegisterClipboardFormat(reinterpret_cast<const wchar_t *> (clipFormat.utf16()));
-#else
- int cf = RegisterClipboardFormatA(clipFormat.toLocal8Bit());
-#endif
data = getData(cf, pDataObj);
} else if (formats.keys(mimeType).isEmpty()) {
int cf = QWindowsMime::registerMimeType(mimeType);
@@ -1325,46 +1291,38 @@ QVariant QLastResortMimes::convertToMime(const QString &mimeType, IDataObject *p
QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const
{
QString format = formats.value(getCf(formatetc));
- if (format.isEmpty()) {
- QByteArray ba;
- QString clipFormat;
- int len;
- QT_WA({
- ba.resize(256*2);
- len = GetClipboardFormatNameW(getCf(formatetc), (TCHAR*)ba.data(), 255);
- if (len)
- clipFormat = QString::fromUtf16((ushort *)ba.data(), len);
- } , {
- ba.resize(256);
- len = GetClipboardFormatNameA(getCf(formatetc), ba.data(), 255);
- if (len)
- clipFormat = QString::fromLocal8Bit(ba.data(), len);
- });
- if (len) {
+ if (!format.isEmpty())
+ return format;
+
+ wchar_t buffer[256];
+ int len = GetClipboardFormatName(getCf(formatetc), buffer, 256);
+
+ if (len) {
+ QString clipFormat = QString::fromWCharArray(buffer, len);
#ifndef QT_NO_DRAGANDDROP
- if (QInternalMimeData::canReadData(clipFormat))
- format = clipFormat;
- else if((formatetc.cfFormat >= 0xC000)){
- //create the mime as custom. not registered.
- if (!excludeList.contains(clipFormat, Qt::CaseInsensitive)) {
- //check if this is a mime type
- bool ianaType = false;
- int sz = ianaTypes.size();
- for (int i = 0; i < sz; i++) {
- if (clipFormat.startsWith(ianaTypes[i], Qt::CaseInsensitive)) {
- ianaType = true;
- break;
- }
+ if (QInternalMimeData::canReadData(clipFormat))
+ format = clipFormat;
+ else if((formatetc.cfFormat >= 0xC000)){
+ //create the mime as custom. not registered.
+ if (!excludeList.contains(clipFormat, Qt::CaseInsensitive)) {
+ //check if this is a mime type
+ bool ianaType = false;
+ int sz = ianaTypes.size();
+ for (int i = 0; i < sz; i++) {
+ if (clipFormat.startsWith(ianaTypes[i], Qt::CaseInsensitive)) {
+ ianaType = true;
+ break;
}
- if (!ianaType)
- format = QLatin1String(x_qt_windows_mime) + clipFormat + QLatin1Char('\"');
- else
- format = clipFormat;
}
+ if (!ianaType)
+ format = QLatin1String(x_qt_windows_mime) + clipFormat + QLatin1Char('\"');
+ else
+ format = clipFormat;
}
-#endif //QT_NO_DRAGANDDROP
}
+#endif //QT_NO_DRAGANDDROP
}
+
return format;
}
diff --git a/src/gui/kernel/qmultitouch_mac.mm b/src/gui/kernel/qmultitouch_mac.mm
index 3fe85a9..3d2eae6 100644
--- a/src/gui/kernel/qmultitouch_mac.mm
+++ b/src/gui/kernel/qmultitouch_mac.mm
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
#ifdef QT_MAC_USE_COCOA
-QHash<int, QCocoaTouch*> QCocoaTouch::_currentTouches;
+QHash<qint64, QCocoaTouch*> QCocoaTouch::_currentTouches;
QPointF QCocoaTouch::_screenReferencePos;
QPointF QCocoaTouch::_trackpadReferencePos;
int QCocoaTouch::_idAssignmentCount = 0;
@@ -62,7 +62,7 @@ QCocoaTouch::QCocoaTouch(NSTouch *nstouch)
_touchPoint.setId(_idAssignmentCount++);
_touchPoint.setPressure(1.0);
- _identity = int([nstouch identity]);
+ _identity = qint64([nstouch identity]);
_currentTouches.insert(_identity, this);
updateTouchData(nstouch, NSTouchPhaseBegan);
}
@@ -100,7 +100,7 @@ void QCocoaTouch::updateTouchData(NSTouch *nstouch, NSTouchPhase phase)
QCocoaTouch *QCocoaTouch::findQCocoaTouch(NSTouch *nstouch)
{
- int identity = int([nstouch identity]);
+ qint64 identity = qint64([nstouch identity]);
if (_currentTouches.contains(identity))
return _currentTouches.value(identity);
return 0;
diff --git a/src/gui/kernel/qmultitouch_mac_p.h b/src/gui/kernel/qmultitouch_mac_p.h
index 3fa8f6c..618e9ca 100644
--- a/src/gui/kernel/qmultitouch_mac_p.h
+++ b/src/gui/kernel/qmultitouch_mac_p.h
@@ -74,7 +74,7 @@ class QCocoaTouch
static void setMouseInDraggingState(bool inDraggingState);
private:
- static QHash<int, QCocoaTouch*> _currentTouches;
+ static QHash<qint64, QCocoaTouch*> _currentTouches;
static QPointF _screenReferencePos;
static QPointF _trackpadReferencePos;
static int _idAssignmentCount;
@@ -82,7 +82,7 @@ class QCocoaTouch
static bool _updateInternalStateOnly;
QTouchEvent::TouchPoint _touchPoint;
- int _identity;
+ qint64 _identity;
QCocoaTouch(NSTouch *nstouch);
~QCocoaTouch();
diff --git a/src/gui/kernel/qsound_win.cpp b/src/gui/kernel/qsound_win.cpp
index 7330d4b..82854ae 100644
--- a/src/gui/kernel/qsound_win.cpp
+++ b/src/gui/kernel/qsound_win.cpp
@@ -77,13 +77,8 @@ public:
QAuServerWindows::QAuServerWindows(QObject* parent) :
QAuServer(parent), current(0)
{
- QT_WA({
- mutex = CreateMutexW(0, 0, 0);
- event = CreateEventW(0, FALSE, FALSE, 0);
- } , {
- mutex = CreateMutexA(0, 0, 0);
- event = CreateEventA(0, FALSE, FALSE, 0);
- });
+ mutex = CreateMutex(0, 0, 0);
+ event = CreateEvent(0, FALSE, FALSE, 0);
}
QAuServerWindows::~QAuServerWindows()
@@ -133,13 +128,9 @@ DWORD WINAPI SoundPlayProc(LPVOID param)
if (loops == -1)
flags |= SND_LOOP;
- QT_WA({
- PlaySoundW((TCHAR*)filename.utf16(), 0, flags);
- } , {
- PlaySoundA(QFile::encodeName(filename).data(), 0, flags);
- });
- if (sound && loops == 1)
- server->decLoop(sound);
+ PlaySound((wchar_t*)filename.utf16(), 0, flags);
+ if (sound && loops == 1)
+ server->decLoop(sound);
// GUI thread continues, but we are done as well.
SetEvent(event);
@@ -148,18 +139,13 @@ DWORD WINAPI SoundPlayProc(LPVOID param)
QPointer<QSound> guarded_sound = sound;
SetEvent(event);
- for (int l = 0; l < loops && server->current; ++l) {
- QT_WA( {
- PlaySoundW( (TCHAR*)filename.utf16(), 0, SND_FILENAME|SND_SYNC );
- } , {
- PlaySoundA( QFile::encodeName(filename).data(), 0,
- SND_FILENAME|SND_SYNC );
- } );
-
- if (guarded_sound)
- server->decLoop(guarded_sound);
- }
- server->current = 0;
+ for (int l = 0; l < loops && server->current; ++l) {
+ PlaySound((wchar_t*)filename.utf16(), 0, SND_FILENAME | SND_SYNC);
+
+ if (guarded_sound)
+ server->decLoop(guarded_sound);
+ }
+ server->current = 0;
}
ReleaseMutex(mutex);
@@ -169,7 +155,7 @@ DWORD WINAPI SoundPlayProc(LPVOID param)
void QAuServerWindows::playHelper(const QString &filename, int loop, QSound *snd)
{
if (loop == 0)
- return;
+ return;
// busy?
if (WaitForSingleObject(mutex, 0) == WAIT_TIMEOUT)
return;
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
new file mode 100644
index 0000000..c8b11c5
--- /dev/null
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -0,0 +1,254 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstandardgestures.h"
+#include "qstandardgestures_p.h"
+
+#include <qabstractscrollarea.h>
+#include <qscrollbar.h>
+#include <private/qapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QPanGesture
+ \since 4.6
+
+ \brief The QPanGesture class represents a Pan gesture,
+ providing additional information related to panning.
+*/
+
+/*!
+ Creates a new Pan gesture handler object and marks it as a child of \a
+ parent.
+
+ On some platform like Windows it's necessary to provide a non-null widget
+ as \a parent to get native gesture support.
+*/
+QPanGesture::QPanGesture(QWidget *parent)
+ : QGesture(*new QPanGesturePrivate, parent)
+{
+#ifdef Q_WS_WIN
+ if (parent) {
+ QApplicationPrivate* getQApplicationPrivateInternal();
+ QApplicationPrivate *qAppPriv = getQApplicationPrivateInternal();
+ qAppPriv->widgetGestures[parent].pan = this;
+ }
+#endif
+}
+
+/*! \internal */
+bool QPanGesture::event(QEvent *event)
+{
+#ifdef Q_WS_WIN
+ QApplicationPrivate* getQApplicationPrivateInternal();
+ switch (event->type()) {
+ case QEvent::ParentAboutToChange:
+ if (QWidget *w = qobject_cast<QWidget*>(parent()))
+ getQApplicationPrivateInternal()->widgetGestures[w].pan = 0;
+ break;
+ case QEvent::ParentChange:
+ if (QWidget *w = qobject_cast<QWidget*>(parent()))
+ getQApplicationPrivateInternal()->widgetGestures[w].pan = this;
+ break;
+ default:
+ break;
+ }
+#endif
+ return QObject::event(event);
+}
+
+/*! \internal */
+bool QPanGesture::filterEvent(QEvent *event)
+{
+ Q_D(QPanGesture);
+ if (!event->spontaneous())
+ return false;
+ const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
+ if (event->type() == QEvent::TouchBegin) {
+ d->touchPoints = ev->touchPoints();
+ const QPoint p = ev->touchPoints().at(0).pos().toPoint();
+ setStartPos(p);
+ setLastPos(p);
+ setPos(p);
+ return false;
+ } else if (event->type() == QEvent::TouchEnd) {
+ if (state() != Qt::NoGesture) {
+ setState(Qt::GestureFinished);
+ setLastPos(pos());
+ setPos(ev->touchPoints().at(0).pos().toPoint());
+ emit triggered();
+ emit finished();
+ }
+ setState(Qt::NoGesture);
+ reset();
+ } else if (event->type() == QEvent::TouchUpdate) {
+ d->touchPoints = ev->touchPoints();
+ QPointF pt = d->touchPoints.at(0).pos() - d->touchPoints.at(0).startPos();
+ setLastPos(pos());
+ setPos(ev->touchPoints().at(0).pos().toPoint());
+ if (pt.x() > 10 || pt.y() > 10 || pt.x() < -10 || pt.y() < -10) {
+ if (state() == Qt::NoGesture)
+ setState(Qt::GestureStarted);
+ else
+ setState(Qt::GestureUpdated);
+ emit triggered();
+ }
+ }
+ return false;
+}
+
+/*! \internal */
+void QPanGesture::reset()
+{
+ Q_D(QPanGesture);
+ d->touchPoints.clear();
+}
+
+/*!
+ \property QPanGesture::totalOffset
+
+ Specifies a total pan offset since the start of the gesture.
+*/
+QSize QPanGesture::totalOffset() const
+{
+ QPoint pt = pos() - startPos();
+ return QSize(pt.x(), pt.y());
+}
+
+/*!
+ \property QPanGesture::lastOffset
+
+ Specifies a pan offset since the last time the gesture was
+ triggered.
+*/
+QSize QPanGesture::lastOffset() const
+{
+ QPoint pt = pos() - lastPos();
+ return QSize(pt.x(), pt.y());
+}
+
+/*!
+ \class QTapAndHoldGesture
+ \since 4.6
+
+ \brief The QTapAndHoldGesture class represents a Tap-and-Hold gesture,
+ providing additional information.
+*/
+
+const int QTapAndHoldGesturePrivate::iterationCount = 40;
+const int QTapAndHoldGesturePrivate::iterationTimeout = 50;
+
+/*!
+ Creates a new Tap and Hold gesture handler object and marks it as a child
+ of \a parent.
+
+ On some platforms like Windows there is a system-wide tap and hold gesture
+ that cannot be overriden, hence the gesture might never trigger and default
+ context menu will be shown instead.
+*/
+QTapAndHoldGesture::QTapAndHoldGesture(QWidget *parent)
+ : QGesture(*new QTapAndHoldGesturePrivate, parent)
+{
+}
+
+/*! \internal */
+bool QTapAndHoldGesture::filterEvent(QEvent *event)
+{
+ Q_D(QTapAndHoldGesture);
+ if (!event->spontaneous())
+ return false;
+ const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
+ switch (event->type()) {
+ case QEvent::TouchBegin: {
+ if (d->timer.isActive())
+ d->timer.stop();
+ d->timer.start(QTapAndHoldGesturePrivate::iterationTimeout, this);
+ const QPoint p = ev->touchPoints().at(0).pos().toPoint();
+ setStartPos(p);
+ setLastPos(p);
+ setPos(p);
+ break;
+ }
+ case QEvent::TouchUpdate:
+ if (ev->touchPoints().size() != 1)
+ reset();
+ else if ((startPos() - ev->touchPoints().at(0).pos().toPoint()).manhattanLength() > 15)
+ reset();
+ break;
+ case QEvent::TouchEnd:
+ reset();
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+/*! \internal */
+void QTapAndHoldGesture::timerEvent(QTimerEvent *event)
+{
+ Q_D(QTapAndHoldGesture);
+ if (event->timerId() != d->timer.timerId())
+ return;
+ if (d->iteration == QTapAndHoldGesturePrivate::iterationCount) {
+ d->timer.stop();
+ setState(Qt::GestureFinished);
+ emit triggered();
+ } else {
+ setState(Qt::GestureStarted);
+ emit triggered();
+ }
+ ++d->iteration;
+}
+
+/*! \internal */
+void QTapAndHoldGesture::reset()
+{
+ Q_D(QTapAndHoldGesture);
+ if (state() != Qt::NoGesture)
+ emit cancelled();
+ setState(Qt::NoGesture);
+ d->timer.stop();
+ d->iteration = 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/gui/kernel/qstandardgestures.h
index 2c1c61b..2234702 100644
--- a/src/gui/kernel/qgesturerecognizer.h
+++ b/src/gui/kernel/qstandardgestures.h
@@ -39,49 +39,63 @@
**
****************************************************************************/
-#ifndef QGESTURERECOGNIZER_H
-#define QGESTURERECOGNIZER_H
+#ifndef QSTANDARDGESTURES_H
+#define QSTANDARDGESTURES_H
-#include "qevent.h"
-#include "qlist.h"
-#include "qset.h"
+#include <QtGui/qevent.h>
+#include <QtCore/qbasictimer.h>
+
+#include <QtGui/qgesture.h>
+
+QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QGesture;
-class QGestureRecognizerPrivate;
-class Q_GUI_EXPORT QGestureRecognizer : public QObject
+QT_MODULE(Gui)
+
+class QPanGesturePrivate;
+class Q_GUI_EXPORT QPanGesture : public QGesture
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QGestureRecognizer)
+ Q_DECLARE_PRIVATE(QPanGesture)
-public:
- enum Result
- {
- Ignore,
- NotGesture,
- GestureStarted, //TODO: rename to just Gesture?
- GestureFinished,
- MaybeGesture
- };
+ Q_PROPERTY(QSize totalOffset READ totalOffset)
+ Q_PROPERTY(QSize lastOffset READ lastOffset)
- explicit QGestureRecognizer(const QString &gestureType, QObject *parent = 0);
+public:
+ QPanGesture(QWidget *parent);
- QString gestureType() const;
+ bool filterEvent(QEvent *event);
+ void reset();
- virtual QGestureRecognizer::Result filterEvent(const QEvent* event) = 0;
- virtual QGesture* getGesture() = 0;
- virtual void reset() = 0;
+ QSize totalOffset() const;
+ QSize lastOffset() const;
-signals:
- void stateChanged(QGestureRecognizer::Result result);
+protected:
+ bool event(QEvent *event);
private:
- friend class QDoubleTapGestureRecognizer;
- friend class QTapAndHoldGestureRecognizer;
- friend class QGestureRecognizerPan;
+ friend class QWidget;
+};
+
+class QTapAndHoldGesturePrivate;
+class Q_GUI_EXPORT QTapAndHoldGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QTapAndHoldGesture)
+
+public:
+ QTapAndHoldGesture(QWidget *parent);
+
+ bool filterEvent(QEvent *event);
+ void reset();
+
+protected:
+ void timerEvent(QTimerEvent *event);
};
QT_END_NAMESPACE
-#endif // QGESTURERECOGNIZER_P_H
+QT_END_HEADER
+
+#endif // QSTANDARDGESTURES_H
diff --git a/src/gui/kernel/qgesturerecognizer_p.h b/src/gui/kernel/qstandardgestures_p.h
index e250201..bb11c9f 100644
--- a/src/gui/kernel/qgesturerecognizer_p.h
+++ b/src/gui/kernel/qstandardgestures_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QGESTURERECOGNIZER_P_H
-#define QGESTURERECOGNIZER_P_H
+#ifndef QSTANDARDGESTURES_P_H
+#define QSTANDARDGESTURES_P_H
//
// W A R N I N G
@@ -53,20 +53,39 @@
// We mean it.
//
-#include <private/qobject_p.h>
+#include "qevent.h"
+#include "qbasictimer.h"
+#include "qdebug.h"
+
+#include "qgesture.h"
+#include "qgesture_p.h"
QT_BEGIN_NAMESPACE
-class QGestureRecognizerPrivate : public QObjectPrivate
+class QPanGesturePrivate : public QGesturePrivate
{
+ Q_DECLARE_PUBLIC(QPanGesture)
+
public:
- QGestureRecognizerPrivate();
+ QPanGesturePrivate() { }
+
+ QList<QTouchEvent::TouchPoint> touchPoints;
+};
+
+class QTapAndHoldGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QTapAndHoldGesture)
public:
- Qt::GestureType gestureType;
- QString customGestureType;
+ QTapAndHoldGesturePrivate()
+ : iteration(0) { }
+
+ QBasicTimer timer;
+ int iteration;
+ static const int iterationCount;
+ static const int iterationTimeout;
};
QT_END_NAMESPACE
-#endif // QGESTURERECOGNIZER_P_H
+#endif // QSTANDARDGESTURES_P_H
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 073a00e..223e36b 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -77,6 +77,7 @@
#include <qwidget.h>
#include <qdesktopwidget.h>
#include <qevent.h>
+#include <qpixmapcache.h>
#include <private/qevent_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
@@ -177,11 +178,10 @@ void macWindowToolbarShow(const QWidget *widget, bool show )
{
OSWindowRef wnd = qt_mac_window_for(widget);
#if QT_MAC_USE_COCOA
- NSToolbar *toolbar = [wnd toolbar];
- if (toolbar) {
+ if (NSToolbar *toolbar = [wnd toolbar]) {
QMacCocoaAutoReleasePool pool;
if (show != [toolbar isVisible]) {
- [wnd toggleToolbarShown:wnd];
+ [toolbar setVisible:show];
} else {
// The toolbar may be in sync, but we are not, update our framestrut.
qt_widget_private(const_cast<QWidget *>(widget))->updateFrameStrut();
@@ -197,22 +197,21 @@ void macWindowToolbarSet( void * /*OSWindowRef*/ window, void *toolbarRef )
{
OSWindowRef wnd = static_cast<OSWindowRef>(window);
#if QT_MAC_USE_COCOA
- [wnd setToolbar:static_cast<NSToolbar *>(toolbarRef)];
+ [wnd setToolbar:static_cast<NSToolbar *>(toolbarRef)];
#else
SetWindowToolbar(wnd, static_cast<HIToolbarRef>(toolbarRef));
#endif
}
-bool macWindowToolbarVisible( void * /*OSWindowRef*/ window )
+bool macWindowToolbarIsVisible( void * /*OSWindowRef*/ window )
{
OSWindowRef wnd = static_cast<OSWindowRef>(window);
#if QT_MAC_USE_COCOA
- NSToolbar *toolbar = [wnd toolbar];
- if (toolbar)
+ if (NSToolbar *toolbar = [wnd toolbar])
return [toolbar isVisible];
return false;
#else
- return IsWindowToolbarVisible(wnd);
+ return IsWindowToolbarVisible(wnd);
#endif
}
@@ -220,12 +219,12 @@ void macWindowSetHasShadow( void * /*OSWindowRef*/ window, bool hasShadow )
{
OSWindowRef wnd = static_cast<OSWindowRef>(window);
#if QT_MAC_USE_COCOA
- [wnd setHasShadow:BOOL(hasShadow)];
+ [wnd setHasShadow:BOOL(hasShadow)];
#else
- if (hasShadow)
- ChangeWindowAttributes(wnd, 0, kWindowNoShadowAttribute);
- else
- ChangeWindowAttributes(wnd, kWindowNoShadowAttribute, 0);
+ if (hasShadow)
+ ChangeWindowAttributes(wnd, 0, kWindowNoShadowAttribute);
+ else
+ ChangeWindowAttributes(wnd, kWindowNoShadowAttribute, 0);
#endif
}
@@ -233,9 +232,9 @@ void macWindowFlush(void * /*OSWindowRef*/ window)
{
OSWindowRef wnd = static_cast<OSWindowRef>(window);
#if QT_MAC_USE_COCOA
- [wnd flushWindowIfNeeded];
+ [wnd flushWindowIfNeeded];
#else
- HIWindowFlush(wnd);
+ HIWindowFlush(wnd);
#endif
}
@@ -352,6 +351,12 @@ Qt::MouseButton qt_mac_get_button(EventMouseButton button)
return Qt::NoButton;
}
+void macSendToolbarChangeEvent(QWidget *widget)
+{
+ QToolBarChangeEvent ev(!(GetCurrentKeyModifiers() & cmdKey));
+ qt_sendSpontaneousEvent(widget, &ev);
+}
+
Q_GLOBAL_STATIC(QMacTabletHash, tablet_hash)
QMacTabletHash *qt_mac_tablet_hash()
{
@@ -1131,4 +1136,61 @@ CGFloat qt_mac_get_scalefactor()
#endif
}
+QString qt_mac_get_pasteboardString()
+{
+ QMacCocoaAutoReleasePool pool;
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+ NSString *text = [pb stringForType:NSStringPboardType];
+ if (text) {
+ return qt_mac_NSStringToQString(text);
+ } else {
+ return QString();
+ }
+}
+
+QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height)
+{
+ QPixmap ret(width, height);
+ ret.fill(QColor(0, 0, 0, 0));
+
+ CGRect rect = CGRectMake(0, 0, width, height);
+
+ CGContextRef ctx = qt_mac_cg_context(&ret);
+ CGAffineTransform old_xform = CGContextGetCTM(ctx);
+ CGContextConcatCTM(ctx, CGAffineTransformInvert(old_xform));
+ CGContextConcatCTM(ctx, CGAffineTransformIdentity);
+
+ ::RGBColor b;
+ b.blue = b.green = b.red = 255*255;
+ PlotIconRefInContext(ctx, &rect, kAlignNone, kTransformNone, &b, kPlotIconRefNormalFlags, icon);
+ CGContextRelease(ctx);
+ return ret;
+}
+
+void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon, QStyle::StandardPixmap standardIcon)
+{
+ int size = 16;
+ while (size <= 128) {
+
+ const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size);
+ QPixmap mainIcon;
+ if (standardIcon >= QStyle::SP_CustomBase) {
+ mainIcon = qt_mac_convert_iconref(icon, size, size);
+ } else if (QPixmapCache::find(cacheKey, mainIcon) == false) {
+ mainIcon = qt_mac_convert_iconref(icon, size, size);
+ QPixmapCache::insert(cacheKey, mainIcon);
+ }
+
+ if (overlayIcon) {
+ int littleSize = size / 2;
+ QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize, littleSize);
+ QPainter painter(&mainIcon);
+ painter.drawPixmap(size - littleSize, size - littleSize, overlayPix);
+ }
+
+ retIcon->addPixmap(mainIcon);
+ size += size; // 16 -> 32 -> 64 -> 128
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index 7b975f5..af3b4cb 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h
+++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
@@ -105,6 +105,8 @@
#include <qpoint.h>
#include "private/qt_mac_p.h"
+struct HIContentBorderMetrics;
+
#ifdef Q_WS_MAC32
typedef struct _NSPoint NSPoint; // Just redefine here so I don't have to pull in all of Cocoa.
#else
@@ -118,10 +120,10 @@ void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds = 0);
bool macWindowIsTextured(void * /*OSWindowRef*/ window);
void macWindowToolbarShow(const QWidget *widget, bool show );
void macWindowToolbarSet( void * /*OSWindowRef*/ window, void* toolbarRef );
-bool macWindowToolbarVisible( void * /*OSWindowRef*/ window );
+bool macWindowToolbarIsVisible( void * /*OSWindowRef*/ window );
void macWindowSetHasShadow( void * /*OSWindowRef*/ window, bool hasShadow );
void macWindowFlush(void * /*OSWindowRef*/ window);
-struct HIContentBorderMetrics;
+void macSendToolbarChangeEvent(QWidget *widget);
void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::HIContentBorderMetrics &metrics);
void * /*NSImage */qt_mac_create_nsimage(const QPixmap &pm);
void qt_mac_update_mouseTracking(QWidget *widget);
@@ -142,6 +144,9 @@ struct ::TabletProximityRec;
void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec);
Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags);
Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations);
+QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height);
+void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon,
+ QStyle::StandardPixmap standardIcon = QStyle::SP_CustomBase);
inline int flipYCoordinate(int y)
{
return QApplication::desktop()->screenGeometry(0).height() - y;
@@ -162,6 +167,7 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list);
void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow);
CGFloat qt_mac_get_scalefactor();
+QString qt_mac_get_pasteboardString();
#ifdef __OBJC__
inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qstrlist)
diff --git a/src/gui/kernel/qwhatsthis.cpp b/src/gui/kernel/qwhatsthis.cpp
index 067c783..62b5863 100644
--- a/src/gui/kernel/qwhatsthis.cpp
+++ b/src/gui/kernel/qwhatsthis.cpp
@@ -226,7 +226,9 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor
text);
}
#if defined(Q_WS_WIN)
- if ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_2000) {
+ if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
+ && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
+ {
BOOL shadow;
SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
shadowWidth = shadow ? 0 : 6;
@@ -302,7 +304,9 @@ void QWhatsThat::paintEvent(QPaintEvent*)
{
bool drawShadow = true;
#if defined(Q_WS_WIN)
- if ((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based) > QSysInfo::WV_2000) {
+ if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
+ && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
+ {
BOOL shadow;
SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
drawShadow = !shadow;
@@ -347,6 +351,7 @@ void QWhatsThat::paintEvent(QPaintEvent*)
rect.translate(-r.x(), -r.y());
p.setClipRect(rect);
QAbstractTextDocumentLayout::PaintContext context;
+ context.palette.setBrush(QPalette::Text, context.palette.toolTipText());
doc->documentLayout()->draw(&p, context);
}
else
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 4c2fe9d..334706d 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -82,6 +82,8 @@
#include "private/qstyle_p.h"
#include "private/qinputcontext_p.h"
#include "qfileinfo.h"
+#include "qstandardgestures.h"
+#include "qstandardgestures_p.h"
#if defined (Q_WS_WIN)
# include <private/qwininputcontext_p.h>
@@ -111,9 +113,9 @@
#include "private/qgraphicsproxywidget_p.h"
#include "QtGui/qabstractscrollarea.h"
#include "private/qabstractscrollarea_p.h"
+#include "private/qevent_p.h"
#include "private/qgraphicssystem_p.h"
-#include "private/qgesturemanager_p.h"
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
@@ -132,8 +134,6 @@ Q_GUI_EXPORT void qt_x11_set_global_double_buffer(bool enable)
}
#endif
-QString qt_getStandardGestureTypeName(Qt::GestureType);
-
static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
{
return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) &&
@@ -869,8 +869,8 @@ void QWidget::setAutoFillBackground(bool enabled)
\list
\o X11: This feature relies on the use of an X server that supports ARGB visuals
and a compositing window manager.
- \o Windows: This feature requires Windows 2000 or later. The widget needs to have
- the Qt::FramelessWindowHint window flag set for the translucency to work.
+ \o Windows: The widget needs to have the Qt::FramelessWindowHint window flag set
+ for the translucency to work.
\endlist
@@ -2035,10 +2035,9 @@ void QPixmap::fill( const QWidget *widget, const QPoint &off )
QPainter p(this);
p.translate(-off);
widget->d_func()->paintBackground(&p, QRect(off, size()));
-
}
-static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush)
+static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush)
{
Q_ASSERT(painter);
@@ -2047,8 +2046,8 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoin
// Optimize pattern filling on mac by using HITheme directly
// when filling with the standard widget background.
// Defined in qmacstyle_mac.cpp
- extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush);
- qt_mac_fill_background(painter, rgn, offset, brush);
+ extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush);
+ qt_mac_fill_background(painter, rgn, brush);
#else
#if !defined(QT_NO_STYLE_S60)
// Defined in qs60style.cpp
@@ -2057,24 +2056,37 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QPoin
if (!qt_s60_fill_background(painter, rgn, offset, brush))
#endif // !defined(QT_NO_STYLE_S60)
{
- const QRegion translated = rgn.translated(offset);
- const QRect rect(translated.boundingRect());
- painter->setClipRegion(translated);
+ const QRect rect(rgn.boundingRect());
+ painter->setClipRegion(rgn);
painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
}
#endif // Q_WS_MAC
} else {
const QVector<QRect> &rects = rgn.rects();
for (int i = 0; i < rects.size(); ++i)
- painter->fillRect(rects.at(i).translated(offset), brush);
+ painter->fillRect(rects.at(i), brush);
}
}
-
-void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, const QPoint &offset, int flags) const
+void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const
{
Q_Q(const QWidget);
+#ifndef QT_NO_SCROLLAREA
+ bool resetBrushOrigin = false;
+ QPointF oldBrushOrigin;
+ //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture
+ QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent);
+ if (scrollArea && scrollArea->viewport() == q) {
+ QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr;
+ QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
+ oldBrushOrigin = painter->brushOrigin();
+ resetBrushOrigin = true;
+ painter->setBrushOrigin(-priv->contentsOffset());
+
+ }
+#endif // QT_NO_SCROLLAREA
+
const QBrush autoFillBrush = q->palette().brush(q->backgroundRole());
if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
@@ -2083,19 +2095,24 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, cons
if (!(flags & DontSetCompositionMode) && painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
painter->setCompositionMode(QPainter::CompositionMode_Source); //copy alpha straight in
#endif
- fillRegion(painter, rgn, offset, bg);
-
+ fillRegion(painter, rgn, bg);
}
if (q->autoFillBackground())
- fillRegion(painter, rgn, offset, autoFillBrush);
+ fillRegion(painter, rgn, autoFillBrush);
+
if (q->testAttribute(Qt::WA_StyledBackground)) {
- painter->setClipRegion(rgn.translated(offset));
+ painter->setClipRegion(rgn);
QStyleOption opt;
opt.initFrom(q);
q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q);
}
+
+#ifndef QT_NO_SCROLLAREA
+ if (resetBrushOrigin)
+ painter->setBrushOrigin(oldBrushOrigin);
+#endif // QT_NO_SCROLLAREA
}
/*
@@ -4619,6 +4636,11 @@ void QWidget::unsetLayoutDirection()
By default, this property contains a cursor with the Qt::ArrowCursor
shape.
+ Some underlying window implementations will reset the cursor if it
+ leaves a widget even if the mouse is grabbed. If you want to have
+ a cursor set for all widgets, even when outside the window, consider
+ QApplication::setOverrideCursor().
+
\sa QApplication::setOverrideCursor()
*/
@@ -5078,19 +5100,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
&& !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
QPainter p(q);
- QPoint scrollAreaOffset;
-
-#ifndef QT_NO_SCROLLAREA
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent);
- if (scrollArea && scrollArea->viewport() == q) {
- QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data();
- QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
- scrollAreaOffset = priv->contentsOffset();
- p.translate(-scrollAreaOffset);
- }
-#endif // QT_NO_SCROLLAREA
-
- paintBackground(&p, toBePainted, scrollAreaOffset, (asRoot || onScreen) ? flags | DrawAsRoot : 0);
+ paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0);
}
if (!sharedPainter)
@@ -5523,8 +5533,6 @@ QString QWidget::windowIconText() const
\list
\o The file name of the specified path, obtained using QFileInfo::fileName().
- \o An optional \c{*} character, if the \l windowModified property is set,
- as per the Apple Human Interface Guidelines.
\endlist
On Windows and X11:
@@ -5573,7 +5581,7 @@ void QWidgetPrivate::setWindowFilePath_helper(const QString &filePath)
{
if (extra->topextra && extra->topextra->caption.isEmpty()) {
#ifdef Q_WS_MAC
- setWindowTitle_helper(filePath);
+ setWindowTitle_helper(QFileInfo(filePath).fileName());
#else
Q_Q(QWidget);
Q_UNUSED(filePath);
@@ -7571,7 +7579,6 @@ bool QWidget::event(QEvent *event)
#ifndef QT_NO_WHEELEVENT
case QEvent::Wheel:
#endif
- case QEvent::Gesture:
return false;
default:
break;
@@ -7972,9 +7979,6 @@ bool QWidget::event(QEvent *event)
d->needWindowChange = false;
break;
#endif
- case QEvent::Gesture:
- event->ignore();
- break;
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
@@ -8018,6 +8022,59 @@ bool QWidget::event(QEvent *event)
#endif
break;
}
+#ifdef Q_WS_WIN
+ case QEvent::WinGesture: {
+ QWinGestureEvent *ev = static_cast<QWinGestureEvent*>(event);
+ QApplicationPrivate *qAppPriv = qApp->d_func();
+ QApplicationPrivate::WidgetStandardGesturesMap::iterator it;
+ it = qAppPriv->widgetGestures.find(this);
+ if (it != qAppPriv->widgetGestures.end()) {
+ Qt::GestureState state = Qt::GestureUpdated;
+ if (qAppPriv->lastGestureId == 0)
+ state = Qt::GestureStarted;
+ QWinGestureEvent::Type type = ev->gestureType;
+ if (ev->gestureType == QWinGestureEvent::GestureEnd) {
+ type = (QWinGestureEvent::Type)qAppPriv->lastGestureId;
+ state = Qt::GestureFinished;
+ }
+
+ QGesture *gesture = 0;
+ switch (type) {
+ case QWinGestureEvent::Pan: {
+ QPanGesture *pan = it.value().pan;
+ gesture = pan;
+ if (state == Qt::GestureStarted) {
+ gesture->setStartPos(ev->position);
+ gesture->setLastPos(ev->position);
+ } else {
+ gesture->setLastPos(gesture->pos());
+ }
+ gesture->setPos(ev->position);
+ break;
+ }
+ case QWinGestureEvent::Pinch:
+ break;
+ default:
+ break;
+ }
+ if (gesture) {
+ gesture->setState(state);
+ if (state == Qt::GestureStarted)
+ emit gesture->started();
+ emit gesture->triggered();
+ if (state == Qt::GestureFinished)
+ emit gesture->finished();
+ event->accept();
+ }
+ if (ev->gestureType == QWinGestureEvent::GestureEnd) {
+ qAppPriv->lastGestureId = 0;
+ } else {
+ qAppPriv->lastGestureId = type;
+ }
+ }
+ break;
+ }
+#endif
#ifndef QT_NO_PROPERTIES
case QEvent::DynamicPropertyChange: {
const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
@@ -9986,11 +10043,8 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
break;
case Qt::WA_InputMethodEnabled: {
QInputContext *ic = d->ic;
- if (!ic) {
- // implicitly create input context only if we have a focus
- if (hasFocus())
- ic = d->inputContext();
- }
+ if (!ic && (!on || hasFocus()))
+ ic = d->inputContext();
if (ic) {
if (on && hasFocus() && ic->focusWidget() != this && isEnabled()) {
ic->setFocusWidget(this);
@@ -10105,8 +10159,8 @@ bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const
By default the value of this property is 1.0.
- This feature is available on Embedded Linux, Mac OS X, X11 platforms that
- support the Composite extension, and Windows 2000 and later.
+ This feature is available on Embedded Linux, Mac OS X, Windows,
+ and X11 platforms that support the Composite extension.
This feature is not available on Windows CE.
@@ -11157,103 +11211,6 @@ QWindowSurface *QWidget::windowSurface() const
return bs ? bs->windowSurface : 0;
}
-/*!
- \since 4.6
-
- Subscribes the widget to the specified \a gesture type.
-
- Returns the id of the gesture.
-
- \sa releaseGesture(), setGestureEnabled()
-*/
-int QWidget::grabGesture(const QString &gesture)
-{
- Q_D(QWidget);
- int id = d->grabGesture(QGestureManager::instance()->makeGestureId(gesture));
- if (d->extra && d->extra->proxyWidget)
- d->extra->proxyWidget->QGraphicsItem::d_ptr->grabGesture(id);
- return id;
-}
-
-int QWidgetPrivate::grabGesture(int gestureId)
-{
- gestures << gestureId;
- ++qApp->d_func()->grabbedGestures[QGestureManager::instance()->gestureNameFromId(gestureId)];
- return gestureId;
-}
-
-bool QWidgetPrivate::releaseGesture(int gestureId)
-{
- QApplicationPrivate *qAppPriv = qApp->d_func();
- if (gestures.contains(gestureId)) {
- QString name = QGestureManager::instance()->gestureNameFromId(gestureId);
- Q_ASSERT(qAppPriv->grabbedGestures[name] > 0);
- --qAppPriv->grabbedGestures[name];
- gestures.remove(gestureId);
- return true;
- }
- return false;
-}
-
-bool QWidgetPrivate::hasGesture(const QString &name) const
-{
- QGestureManager *gm = QGestureManager::instance();
- QSet<int>::const_iterator it = gestures.begin(),
- e = gestures.end();
- for (; it != e; ++it) {
- if (gm->gestureNameFromId(*it) == name)
- return true;
- }
- return false;
-}
-
-/*!
- \since 4.6
-
- Subscribes the widget to the specified \a gesture type.
-
- Returns the id of the gesture.
-
- \sa releaseGesture(), setGestureEnabled()
-*/
-int QWidget::grabGesture(Qt::GestureType gesture)
-{
- return grabGesture(qt_getStandardGestureTypeName(gesture));
-}
-
-/*!
- \since 4.6
-
- Unsubscribes the widget from a gesture, which is specified by the
- \a gestureId.
-
- \sa grabGesture(), setGestureEnabled()
-*/
-void QWidget::releaseGesture(int gestureId)
-{
- Q_D(QWidget);
- if (d->releaseGesture(gestureId)) {
- if (d->extra && d->extra->proxyWidget)
- d->extra->proxyWidget->QGraphicsItem::d_ptr->releaseGesture(gestureId);
- QGestureManager::instance()->releaseGestureId(gestureId);
- }
-}
-
-/*!
- \since 4.6
-
- If \a enable is true, the gesture with the given \a gestureId is
- enabled; otherwise the gesture is disabled.
-
- The id of the gesture is returned by the grabGesture().
-
- \sa grabGesture(), releaseGesture()
-*/
-void QWidget::setGestureEnabled(int gestureId, bool enable)
-{
- //###
-}
-
void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const
{
if (left)
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 2008723..c73f633 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -90,7 +90,6 @@ class QDragLeaveEvent;
class QDropEvent;
class QShowEvent;
class QHideEvent;
-class QGestureEvent;
class QInputContext;
class QIcon;
class QWindowSurface;
@@ -616,11 +615,6 @@ public:
void setWindowSurface(QWindowSurface *surface);
QWindowSurface *windowSurface() const;
- int grabGesture(const QString &gesture);
- int grabGesture(Qt::GestureType gesture);
- void releaseGesture(int gestureId);
- void setGestureEnabled(int gestureId, bool enable = true);
-
Q_SIGNALS:
void customContextMenuRequested(const QPoint &pos);
@@ -765,7 +759,6 @@ private:
friend class QSymbianControl;
friend class QS60WindowSurface;
#endif
- friend class QGestureManager;
#ifdef Q_WS_X11
friend void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp);
friend void qt_net_remove_user_time(QWidget *tlw);
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 045bcb3..1717fbd 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -83,6 +83,7 @@
#include "qcursor.h"
#include "qdesktopwidget.h"
#include "qevent.h"
+#include "qfileinfo.h"
#include "qimage.h"
#include "qlayout.h"
#include "qmenubar.h"
@@ -843,8 +844,7 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event,
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
qt_button_down = 0;
} else if(ekind == kEventWindowToolbarSwitchMode) {
- QToolBarChangeEvent ev(!(GetCurrentKeyModifiers() & cmdKey));
- QApplication::sendSpontaneousEvent(widget, &ev);
+ macSendToolbarChangeEvent(widget);
HIToolbarRef toolbar;
if (GetWindowToolbar(wid, &toolbar) == noErr) {
if (toolbar) {
@@ -1198,22 +1198,13 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
p.setClipping(false);
if(was_unclipped)
widget->setAttribute(Qt::WA_PaintUnclipped);
-
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(widget->parent());
- QPoint scrollAreaOffset;
- if (scrollArea && scrollArea->viewport() == widget) {
- QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(static_cast<QWidget *>(scrollArea)->d_ptr.data());
- scrollAreaOffset = priv->contentsOffset();
- p.translate(-scrollAreaOffset);
- }
-
- widget->d_func()->paintBackground(&p, qrgn, scrollAreaOffset, widget->isWindow() ? DrawAsRoot : 0);
+ widget->d_func()->paintBackground(&p, qrgn, widget->isWindow() ? DrawAsRoot : 0);
if (widget->testAttribute(Qt::WA_TintedBackground)) {
QColor tint = widget->palette().window().color();
tint.setAlphaF(.6);
const QVector<QRect> &rects = qrgn.rects();
for (int i = 0; i < rects.size(); ++i)
- p.fillRect(rects.at(i).translated(scrollAreaOffset), tint);
+ p.fillRect(rects.at(i), tint);
}
p.end();
if (!redirectionOffset.isNull())
@@ -1369,6 +1360,14 @@ OSStatus QWidgetPrivate::qt_widget_event(EventHandlerCallRef er, EventRef event,
// Set dropWidget to zero, so qt_mac_dnd_event
// doesn't get called a second time below:
dropWidget = 0;
+ } else if (ekind == kEventControlDragLeave) {
+ dropWidget = QDragManager::self()->currentTarget();
+ if (dropWidget) {
+ dropWidget->d_func()->qt_mac_dnd_event(kEventControlDragLeave, drag);
+ }
+ // Set dropWidget to zero, so qt_mac_dnd_event
+ // doesn't get called a second time below:
+ dropWidget = 0;
}
}
}
@@ -2857,8 +2856,7 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
SetWindowTitleWithCFString(qt_mac_window_for(q), QCFString(caption));
#else
QMacCocoaAutoReleasePool pool;
- [qt_mac_window_for(q)
- setTitle:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(caption)))];
+ [qt_mac_window_for(q) setTitle:qt_mac_QStringToNSString(caption)];
#endif
}
}
@@ -2880,7 +2878,8 @@ void QWidgetPrivate::setWindowFilePath_sys(const QString &filePath)
Q_Q(QWidget);
#ifdef QT_MAC_USE_COCOA
QMacCocoaAutoReleasePool pool;
- [qt_mac_window_for(q) setRepresentedFilename:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(filePath)))];
+ QFileInfo fi(filePath);
+ [qt_mac_window_for(q) setRepresentedFilename:fi.exists() ? qt_mac_QStringToNSString(filePath) : @""];
#else
bool validRef = false;
FSRef ref;
@@ -2970,8 +2969,7 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
SetWindowAlternateTitle(qt_mac_window_for(q), QCFString(iconText));
#else
QMacCocoaAutoReleasePool pool;
- [qt_mac_window_for(q)
- setMiniwindowTitle:reinterpret_cast<const NSString *>(static_cast<CFStringRef>(QCFString(iconText)))];
+ [qt_mac_window_for(q) setMiniwindowTitle:qt_mac_QStringToNSString(iconText)];
#endif
}
}
@@ -3818,8 +3816,6 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
Qt coordinate system for parent
X coordinate system for parent (relative to parent's wrect).
*/
- QRect validRange(-XCOORD_MAX,-XCOORD_MAX, 2*XCOORD_MAX, 2*XCOORD_MAX);
- QRect wrectRange(-WRECT_MAX,-WRECT_MAX, 2*WRECT_MAX, 2*WRECT_MAX);
QRect wrect;
//xrect is the X geometry of my X widget. (starts out in parent's Qt coord sys, and ends up in parent's X coord sys)
QRect xrect = data.crect;
@@ -3841,6 +3837,7 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
parentWRect = QRect(tmpRect.origin.x, tmpRect.origin.y,
tmpRect.size.width, tmpRect.size.height);
} else {
+ const QRect wrectRange(-WRECT_MAX,-WRECT_MAX, 2*WRECT_MAX, 2*WRECT_MAX);
parentWRect = wrectRange;
}
} else {
@@ -3896,15 +3893,24 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
}
}
+ const QRect validRange(-XCOORD_MAX,-XCOORD_MAX, 2*XCOORD_MAX, 2*XCOORD_MAX);
if (!validRange.contains(xrect)) {
// we are too big, and must clip
- xrect &=wrectRange;
+ QPoint screenOffset(0, 0); // offset of the part being on screen
+ const QWidget *parentWidget = q->parentWidget();
+ while (parentWidget && !parentWidget->isWindow()) {
+ screenOffset -= parentWidget->data->crect.topLeft();
+ parentWidget = parentWidget->parentWidget();
+ }
+ QRect cropRect(screenOffset.x() - WRECT_MAX,
+ screenOffset.y() - WRECT_MAX,
+ 2*WRECT_MAX,
+ 2*WRECT_MAX);
+
+ xrect &=cropRect;
wrect = xrect;
- wrect.translate(-data.crect.topLeft());
- //parent's X coord system is equal to parent's Qt coord
- //sys, so we don't need to map xrect.
+ wrect.translate(-data.crect.topLeft()); // translate wrect in my Qt coordinates
}
-
}
// unmap if we are outside the valid window system coord system
@@ -3944,10 +3950,9 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
qt_mac_update_widget_posisiton(q, oldRect, xrect);
- if (jump) {
- updateSystemBackground();
+ if (jump)
q->update();
- }
+
if (mapWindow && !dontShow) {
q->setAttribute(Qt::WA_Mapped);
#ifndef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 84a15ed..1d9689e 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -311,7 +311,7 @@ public:
void setUpdatesEnabled_helper(bool );
- void paintBackground(QPainter *, const QRegion &, const QPoint & = QPoint(), int flags = DrawAsRoot) const;
+ void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
bool isAboutToShow() const;
QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
@@ -541,11 +541,6 @@ public:
QList<QAction*> actions;
#endif
- QSet<int> gestures;
- int grabGesture(int gestureId);
- bool releaseGesture(int gestureId);
- bool hasGesture(const QString &type) const;
-
// Bit fields.
uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
QPalette::ColorRole fg_role : 8;
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index e39ca77..46fa3be 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -140,14 +140,8 @@ static void init_wintab_functions()
if (!qt_is_gui_used)
return;
QLibrary library(QLatin1String("wintab32"));
- QT_WA({
- ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW");
- ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
- } , {
- ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenA");
- ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoA");
- });
-
+ ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW");
+ ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
ptrWTClose = (PtrWTClose)library.resolve("WTClose");
ptrWTQueueSizeGet = (PtrWTQueueSizeGet)library.resolve("WTQueueSizeGet");
ptrWTQueueSizeSet = (PtrWTQueueSizeSet)library.resolve("WTQueueSizeSet");
@@ -270,7 +264,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
HINSTANCE appinst = qWinAppInst();
HWND parentw, destroyw = 0;
- WId id;
+ WId id = 0;
QString windowClassName = qt_reg_winclass(q);
@@ -287,25 +281,18 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (desktop && !q->testAttribute(Qt::WA_DontShowOnScreen)) { // desktop widget
popup = false; // force this flags off
- if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95)
- data.crect.setRect(GetSystemMetrics(76 /* SM_XVIRTUALSCREEN */), GetSystemMetrics(77 /* SM_YVIRTUALSCREEN */),
+ data.crect.setRect(GetSystemMetrics(76 /* SM_XVIRTUALSCREEN */), GetSystemMetrics(77 /* SM_YVIRTUALSCREEN */),
GetSystemMetrics(78 /* SM_CXVIRTUALSCREEN */), GetSystemMetrics(79 /* SM_CYVIRTUALSCREEN */));
- else
- data.crect.setRect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
parentw = q->parentWidget() ? q->parentWidget()->effectiveWinId() : 0;
-#ifdef UNICODE
QString title;
- const TCHAR *ttitle = 0;
-#endif
- QByteArray title95;
int style = WS_CHILD;
int exsty = 0;
if (window) {
- style = GetWindowLongA(window, GWL_STYLE);
+ style = GetWindowLong(window, GWL_STYLE);
if (!style)
qErrnoWarning("QWidget::create: GetWindowLong failed");
topLevel = false; // #### needed for some IE plugins??
@@ -361,12 +348,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
if (flags & Qt::WindowTitleHint) {
- QT_WA({
- title = q->isWindow() ? qAppName() : q->objectName();
- ttitle = (TCHAR*)title.utf16();
- } , {
- title95 = q->isWindow() ? qAppName().toLocal8Bit() : q->objectName().toLatin1();
- });
+ title = q->isWindow() ? qAppName() : q->objectName();
}
// The Qt::WA_WState_Created flag is checked by translateConfigEvent() in
@@ -379,13 +361,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
destroyw = data.winid;
id = window;
setWinId(window);
- LONG res = SetWindowLongA(window, GWL_STYLE, style);
+ LONG res = SetWindowLong(window, GWL_STYLE, style);
if (!res)
qErrnoWarning("QWidget::create: Failed to set window style");
#ifdef _WIN64
- res = SetWindowLongPtrA( window, GWLP_WNDPROC, (LONG_PTR)QtWndProc );
+ res = SetWindowLongPtr( window, GWLP_WNDPROC, (LONG_PTR)QtWndProc );
#else
- res = SetWindowLongA( window, GWL_WNDPROC, (LONG)QtWndProc );
+ res = SetWindowLong( window, GWL_WNDPROC, (LONG)QtWndProc );
#endif
if (!res)
qErrnoWarning("QWidget::create: Failed to set window procedure");
@@ -436,16 +418,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
}
- QT_WA({
- const TCHAR *cname = (TCHAR*)windowClassName.utf16();
- id = CreateWindowEx(exsty, cname, ttitle, style,
- x, y, w, h,
- parentw, 0, appinst, 0);
- } , {
- id = CreateWindowExA(exsty, windowClassName.toLatin1(), title95, style,
- x, y, w, h,
- parentw, 0, appinst, 0);
- });
+ id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
+ reinterpret_cast<const wchar_t *>(title.utf16()), style,
+ x, y, w, h,
+ parentw, NULL, appinst, NULL);
if (!id)
qErrnoWarning("QWidget::create: Failed to create window");
setWinId(id);
@@ -457,16 +433,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
SetWindowPos(id, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
winUpdateIsOpaque();
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create child widget
- QT_WA({
- const TCHAR *cname = (TCHAR*)windowClassName.utf16();
- id = CreateWindowEx(exsty, cname, ttitle, style,
- data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
- parentw, NULL, appinst, NULL);
- } , {
- id = CreateWindowExA(exsty, windowClassName.toLatin1(), title95, style,
- data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
+ id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
+ reinterpret_cast<const wchar_t *>(title.utf16()), style,
+ data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
parentw, NULL, appinst, NULL);
- });
if (!id)
qErrnoWarning("QWidget::create: Failed to create window");
SetWindowPos(id, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
@@ -682,7 +652,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
// Show borderless toplevel windows in tasklist & NavBar
if (!parent) {
QString txt = q->windowTitle().isEmpty()?qAppName():q->windowTitle();
- SetWindowText(q->internalWinId(), (TCHAR*)txt.utf16());
+ SetWindowText(q->internalWinId(), (wchar_t*)txt.utf16());
}
#endif
invalidateBuffer(q->rect());
@@ -767,11 +737,7 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
return;
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
- QT_WA({
- SetWindowText(q->internalWinId(), (TCHAR*)caption.utf16());
- } , {
- SetWindowTextA(q->internalWinId(), caption.toLocal8Bit());
- });
+ SetWindowText(q->internalWinId(), (wchar_t*)caption.utf16());
}
/*
@@ -853,11 +819,11 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON),
&(x->iconPixmap));
if (x->winIconBig) {
- SendMessageA(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
- SendMessageA(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconBig);
+ SendMessage(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
+ SendMessage(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconBig);
} else {
- SendMessageA(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
- SendMessageA(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconSmall);
+ SendMessage(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
+ SendMessage(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconSmall);
}
}
@@ -884,7 +850,7 @@ LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam)
/* Works only as long as pointer is inside the application's window,
which is good enough for QDockWidget.
- Doesn't call SetWindowsHookExA() - this function causes a system-wide
+ Doesn't call SetWindowsHookEx() - this function causes a system-wide
freeze if any other app on the system installs a hook and fails to
process events. */
void QWidgetPrivate::grabMouseWhileInWindow()
@@ -908,7 +874,7 @@ void QWidget::grabMouse()
if (!qt_nograb()) {
if (mouseGrb)
mouseGrb->releaseMouse();
- journalRec = SetWindowsHookExA(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandleA(0), 0);
+ journalRec = SetWindowsHookEx(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandle(0), 0);
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
SetCapture(effectiveWinId());
mouseGrb = this;
@@ -921,7 +887,7 @@ void QWidget::grabMouse(const QCursor &cursor)
if (!qt_nograb()) {
if (mouseGrb)
mouseGrb->releaseMouse();
- journalRec = SetWindowsHookExA(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandleA(0), 0);
+ journalRec = SetWindowsHookEx(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandle(0), 0);
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
SetCapture(effectiveWinId());
mouseGrbCur = new QCursor(cursor);
@@ -1028,7 +994,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
if (newstate & Qt::WindowFullScreen) {
if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
d->topData()->normalGeometry = geometry();
- d->topData()->savedFlags = Qt::WindowFlags(GetWindowLongA(internalWinId(), GWL_STYLE));
+ d->topData()->savedFlags = Qt::WindowFlags(GetWindowLong(internalWinId(), GWL_STYLE));
#ifndef Q_FLATTEN_EXPOSE
UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
#else
@@ -1038,7 +1004,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
style |= WS_SYSMENU;
if (isVisible())
style |= WS_VISIBLE;
- SetWindowLongA(internalWinId(), GWL_STYLE, style);
+ SetWindowLong(internalWinId(), GWL_STYLE, style);
QRect r = QApplication::desktop()->screenGeometry(this);
UINT swpf = SWP_FRAMECHANGED;
if (newstate & Qt::WindowActive)
@@ -1050,7 +1016,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
UINT style = d->topData()->savedFlags;
if (isVisible())
style |= WS_VISIBLE;
- SetWindowLongA(internalWinId(), GWL_STYLE, style);
+ SetWindowLong(internalWinId(), GWL_STYLE, style);
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
if (newstate & Qt::WindowActive)
@@ -1395,7 +1361,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
UINT style = top->savedFlags;
if (q->isVisible())
style |= WS_VISIBLE;
- SetWindowLongA(q->internalWinId(), GWL_STYLE, style);
+ SetWindowLong(q->internalWinId(), GWL_STYLE, style);
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
if (data.window_state & Qt::WindowActive)
@@ -1410,7 +1376,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
const bool inTopLevelResize = tlwExtra ? tlwExtra->inTopLevelResize : false;
const bool isTranslucentWindow = !isOpaque && ptrUpdateLayeredWindowIndirect && (data.window_flags & Qt::FramelessWindowHint)
- && GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED;
+ && GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED;
if (q->testAttribute(Qt::WA_WState_ConfigPending)) { // processing config event
if (q->internalWinId())
@@ -1578,11 +1544,11 @@ void QWidgetPrivate::winUpdateIsOpaque()
return;
if (!isOpaque && ptrUpdateLayeredWindowIndirect) {
- SetWindowLongA(q->internalWinId(), GWL_EXSTYLE,
- GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) | Q_WS_EX_LAYERED);
+ SetWindowLong(q->internalWinId(), GWL_EXSTYLE,
+ GetWindowLong(q->internalWinId(), GWL_EXSTYLE) | Q_WS_EX_LAYERED);
} else {
- SetWindowLongA(q->internalWinId(), GWL_EXSTYLE,
- GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) & ~Q_WS_EX_LAYERED);
+ SetWindowLong(q->internalWinId(), GWL_EXSTYLE,
+ GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & ~Q_WS_EX_LAYERED);
}
#endif
}
@@ -1592,12 +1558,12 @@ void QWidgetPrivate::setConstraints_sys()
#ifndef Q_WS_WINCE_WM
Q_Q(QWidget);
if (q->isWindow() && q->testAttribute(Qt::WA_WState_Created)) {
- int style = GetWindowLongA(q->internalWinId(), GWL_STYLE);
+ int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
if (shouldShowMaximizeButton())
style |= WS_MAXIMIZEBOX;
else
style &= ~WS_MAXIMIZEBOX;
- SetWindowLongA(q->internalWinId(), GWL_STYLE, style);
+ SetWindowLong(q->internalWinId(), GWL_STYLE, style);
}
#endif
}
@@ -1867,10 +1833,8 @@ void QWidgetPrivate::updateFrameStrut()
RECT rect = {0,0,0,0};
QTLWExtra *top = topData();
- uint exstyle = QT_WA_INLINE(GetWindowLongW(q->internalWinId(), GWL_EXSTYLE),
- GetWindowLongA(q->internalWinId(), GWL_EXSTYLE));
- uint style = QT_WA_INLINE(GetWindowLongW(q->internalWinId(), GWL_STYLE),
- GetWindowLongA(q->internalWinId(), GWL_STYLE));
+ uint exstyle = GetWindowLong(q->internalWinId(), GWL_EXSTYLE);
+ uint style = GetWindowLong(q->internalWinId(), GWL_STYLE);
#ifndef Q_WS_WINCE
if (AdjustWindowRectEx(&rect, style & ~(WS_OVERLAPPED), FALSE, exstyle)) {
#else
@@ -1886,11 +1850,10 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
{
Q_Q(QWidget);
- if (!isOpaque && ptrUpdateLayeredWindowIndirect && (data.window_flags & Qt::FramelessWindowHint)) {
- if (GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED) {
- Q_BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * level), Q_AC_SRC_ALPHA};
- Q_UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, NULL, NULL, NULL, NULL, 0, &blend, Q_ULW_ALPHA, NULL};
- (*ptrUpdateLayeredWindowIndirect)(q->internalWinId(), &info);
+ if (!isOpaque && ptrUpdateLayeredWindow && (data.window_flags & Qt::FramelessWindowHint)) {
+ if (GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED) {
+ BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * level), AC_SRC_ALPHA};
+ ptrUpdateLayeredWindow(q->internalWinId(), NULL, NULL, NULL, NULL, NULL, 0, &blend, Q_ULW_ALPHA);
}
return;
}
@@ -1906,15 +1869,15 @@ void QWidgetPrivate::setWindowOpacity_sys(qreal level)
if (!ptrSetLayeredWindowAttributes)
return;
- int wl = GetWindowLongA(q->internalWinId(), GWL_EXSTYLE);
+ int wl = GetWindowLong(q->internalWinId(), GWL_EXSTYLE);
if (level != 1.0) {
if ((wl&Q_WS_EX_LAYERED) == 0)
- SetWindowLongA(q->internalWinId(), GWL_EXSTYLE, wl|Q_WS_EX_LAYERED);
+ SetWindowLong(q->internalWinId(), GWL_EXSTYLE, wl | Q_WS_EX_LAYERED);
} else if (wl&Q_WS_EX_LAYERED) {
- SetWindowLongA(q->internalWinId(), GWL_EXSTYLE, wl & ~Q_WS_EX_LAYERED);
+ SetWindowLong(q->internalWinId(), GWL_EXSTYLE, wl & ~Q_WS_EX_LAYERED);
}
- (*ptrSetLayeredWindowAttributes)(q->internalWinId(), 0, (int)(level * 255), Q_LWA_ALPHA);
+ ptrSetLayeredWindowAttributes(q->internalWinId(), 0, (int)(level * 255), Q_LWA_ALPHA);
}
#endif //Q_WS_WINCE
diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/gui/kernel/qwidget_wince.cpp
index 24d8156..b0eaa12 100644
--- a/src/gui/kernel/qwidget_wince.cpp
+++ b/src/gui/kernel/qwidget_wince.cpp
@@ -188,11 +188,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
parentw = q->parentWidget() ? q->parentWidget()->effectiveWinId() : 0;
-#ifdef UNICODE
QString title;
- const TCHAR *ttitle = 0;
-#endif
- QByteArray title95;
int style = WS_CHILD;
int exsty = WS_EX_NOPARENTNOTIFY;
@@ -236,12 +232,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
if (flags & Qt::WindowTitleHint) {
- QT_WA({
- title = q->isWindow() ? qAppName() : q->objectName();
- ttitle = (TCHAR*)title.utf16();
- } , {
- title95 = q->isWindow() ? qAppName().toLocal8Bit() : q->objectName().toLatin1();
- });
+ title = q->isWindow() ? qAppName() : q->objectName();
}
// The Qt::WA_WState_Created flag is checked by translateConfigEvent() in
@@ -254,11 +245,11 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
destroyw = data.winid;
id = window;
setWinId(window);
- LONG res = SetWindowLongA(window, GWL_STYLE, style);
+ LONG res = SetWindowLong(window, GWL_STYLE, style);
if (!res)
qErrnoWarning("QWidget::create: Failed to set window style");
- res = SetWindowLongA( window, GWL_WNDPROC, (LONG)QtWndProc );
+ res = SetWindowLong( window, GWL_WNDPROC, (LONG)QtWndProc );
if (!res)
qErrnoWarning("QWidget::create: Failed to set window procedure");
@@ -267,10 +258,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (!id) { //Create a dummy desktop
RECT r;
SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
- const TCHAR *cname = reinterpret_cast<const TCHAR *> (windowClassName.utf16());
- id = CreateWindow(cname, ttitle, style,
- r.left, r.top, r.right - r.left, r.bottom - r.top,
- 0, 0, appinst, 0);
+ id = CreateWindow(reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
+ reinterpret_cast<const wchar_t *>(title.utf16()), style,
+ r.left, r.top, r.right - r.left, r.bottom - r.top,
+ 0, 0, appinst, 0);
}
setWinId(id);
} else if (topLevel) { // create top-level widget
@@ -303,8 +294,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
}
- const TCHAR *cname = reinterpret_cast<const TCHAR *> (windowClassName.utf16());
- id = CreateWindowEx(exsty, cname, ttitle, style,
+ id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
+ reinterpret_cast<const wchar_t *>(title.utf16()), style,
x, y, w, h,
0, 0, appinst, 0);
@@ -314,16 +305,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if ((flags & Qt::WindowStaysOnTopHint) || (type == Qt::ToolTip))
SetWindowPos(id, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
} else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create child widget
- QT_WA({
- const TCHAR *cname = (TCHAR*)windowClassName.utf16();
- id = CreateWindowEx(exsty, cname, ttitle, style,
- data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
- parentw, NULL, appinst, NULL);
- } , {
- id = CreateWindowExA(exsty, windowClassName.toLatin1(), title95, style,
- data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
+ id = CreateWindowEx(exsty, (wchar_t*)windowClassName.utf16(), (wchar_t*)title.utf16(), style,
+ data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
parentw, NULL, appinst, NULL);
- });
if (!id)
qErrnoWarning("QWidget::create: Failed to create window");
SetWindowPos(id, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
@@ -510,7 +494,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
}
if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) {
if (!(newstate & Qt::WindowMaximized)) {
- int style = GetWindowLongW(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION;
+ int style = GetWindowLong(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION;
SetWindowLong(internalWinId(), GWL_STYLE, style);
SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG);
}
@@ -535,11 +519,11 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
if (newstate & Qt::WindowFullScreen) {
if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
d->topData()->normalGeometry = geometry();
- d->topData()->savedFlags = (Qt::WindowFlags) GetWindowLongA(internalWinId(), GWL_STYLE);
+ d->topData()->savedFlags = (Qt::WindowFlags)GetWindowLong(internalWinId(), GWL_STYLE);
UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
if (isVisible())
style |= WS_VISIBLE;
- SetWindowLongA(internalWinId(), GWL_STYLE, style);
+ SetWindowLong(internalWinId(), GWL_STYLE, style);
QRect r = qApp->desktop()->screenGeometry(this);
UINT swpf = SWP_FRAMECHANGED;
if (newstate & Qt::WindowActive)
@@ -550,7 +534,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
UINT style = d->topData()->savedFlags;
if (isVisible())
style |= WS_VISIBLE;
- SetWindowLongA(internalWinId(), GWL_STYLE, style);
+ SetWindowLong(internalWinId(), GWL_STYLE, style);
UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
if (newstate & Qt::WindowActive)
swpf |= SWP_NOACTIVATE;
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index 3ddde1b..659331f 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -826,7 +826,7 @@ bool QX11EmbedWidget::x11Event(XEvent *event)
&actual_format_return, &nitems_return,
&bytes_after_return, &prop_return) == Success) {
if (nitems_return > 1) {
- if (((int * )prop_return)[1] & XEMBED_MAPPED) {
+ if (((long * )prop_return)[1] & XEMBED_MAPPED) {
XMapWindow(x11Info().display(), internalWinId());
} else {
XUnmapWindow(x11Info().display(), internalWinId());
@@ -1670,9 +1670,9 @@ void QX11EmbedContainerPrivate::acceptClient(WId window)
// Clients with the _XEMBED_INFO property are XEMBED clients.
clientIsXEmbed = true;
- unsigned int *p = (unsigned int *)prop_return;
+ long *p = (long *)prop_return;
if (nitems_return >= 2)
- clientversion = p[0];
+ clientversion = (unsigned int)p[0];
}
XFree(prop_return);