Source

Target

Showing with 829 additions and 546 deletions
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
#include <QtDBus/QDBusObjectPath> #include <QtDBus/QDBusObjectPath>
#include <QtDBus/QDBusContext> #include <QtDBus/QDBusContext>
#include <QMap> #include <QMap>
#include "qnmdbushelper.h"
#ifndef QT_NO_DBUS #ifndef QT_NO_DBUS
...@@ -89,7 +88,7 @@ typedef enum ...@@ -89,7 +88,7 @@ typedef enum
NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0, NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
NM_ACTIVE_CONNECTION_STATE_ACTIVATING, NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
NM_ACTIVE_CONNECTION_STATE_ACTIVATED, NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
NM_ACTIVE_CONNECTION_STATE_DEACTIVATED NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4
} NMActiveConnectionState; } NMActiveConnectionState;
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager" #define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
...@@ -135,12 +134,23 @@ class QNetworkManagerInterface : public QObject ...@@ -135,12 +134,23 @@ class QNetworkManagerInterface : public QObject
Q_OBJECT Q_OBJECT
public: public:
typedef enum
{
NM_STATE_UNKNOWN = 0,
NM_STATE_ASLEEP = 10,
NM_STATE_DISCONNECTED = 20,
NM_STATE_DISCONNECTING = 30,
NM_STATE_CONNECTING = 40,
NM_STATE_CONNECTED_LOCAL = 50,
NM_STATE_CONNECTED_SITE = 60,
NM_STATE_CONNECTED_GLOBAL = 70
} NMState;
QNetworkManagerInterface(QObject *parent = 0); QNetworkManagerInterface(QObject *parent = 0);
~QNetworkManagerInterface(); ~QNetworkManagerInterface();
QList <QDBusObjectPath> getDevices() const; QList <QDBusObjectPath> getDevices();
void activateConnection(const QString &serviceName, QDBusObjectPath connection, QDBusObjectPath device, QDBusObjectPath specificObject); void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject);
void deactivateConnection(QDBusObjectPath connectionPath) const; void deactivateConnection(QDBusObjectPath connectionPath) const;
QDBusObjectPath path() const; QDBusObjectPath path() const;
...@@ -149,21 +159,28 @@ public: ...@@ -149,21 +159,28 @@ public:
bool wirelessEnabled() const; bool wirelessEnabled() const;
bool wirelessHardwareEnabled() const; bool wirelessHardwareEnabled() const;
QList <QDBusObjectPath> activeConnections() const; QList <QDBusObjectPath> activeConnections() const;
quint32 state(); NMState state();
QString version() const;
bool setConnections(); bool setConnections();
bool isValid(); bool isValid();
Q_SIGNALS: Q_SIGNALS:
void deviceAdded(QDBusObjectPath); void deviceAdded(QDBusObjectPath);
void deviceRemoved(QDBusObjectPath); void deviceRemoved(QDBusObjectPath);
void propertiesChanged( const QString &, QMap<QString,QVariant>); void propertiesChanged(QMap<QString,QVariant>);
void stateChanged(const QString&, quint32); void stateChanged(quint32);
void activationFinished(QDBusPendingCallWatcher*); void activationFinished(QDBusPendingCallWatcher*);
void propertiesReady();
void devicesListReady();
private Q_SLOTS: private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private: private:
QNetworkManagerInterfacePrivate *d; QNetworkManagerInterfacePrivate *d;
QNmDBusHelper *nmDBusHelper; QVariantMap propertyMap;
QList<QDBusObjectPath> devicesPathList;
}; };
class QNetworkManagerInterfaceAccessPointPrivate; class QNetworkManagerInterfaceAccessPointPrivate;
...@@ -228,11 +245,14 @@ public: ...@@ -228,11 +245,14 @@ public:
Q_SIGNALS: Q_SIGNALS:
void propertiesChanged(QMap <QString,QVariant>); void propertiesChanged(QMap <QString,QVariant>);
void propertiesChanged( const QString &, QMap<QString,QVariant>); void propertiesReady();
private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private: private:
QNetworkManagerInterfaceAccessPointPrivate *d; QNetworkManagerInterfaceAccessPointPrivate *d;
QNmDBusHelper *nmDBusHelper; QVariantMap propertyMap;
}; };
class QNetworkManagerInterfaceDevicePrivate; class QNetworkManagerInterfaceDevicePrivate;
...@@ -258,11 +278,14 @@ public: ...@@ -258,11 +278,14 @@ public:
Q_SIGNALS: Q_SIGNALS:
void stateChanged(const QString &, quint32); void stateChanged(const QString &, quint32);
void propertiesChanged(const QString &, QMap<QString,QVariant>); void propertiesChanged(QMap<QString,QVariant>);
void connectionsChanged(QStringList); void connectionsChanged(QStringList);
void propertiesReady();
private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private: private:
QNetworkManagerInterfaceDevicePrivate *d; QNetworkManagerInterfaceDevicePrivate *d;
QNmDBusHelper *nmDBusHelper; QVariantMap propertyMap;
}; };
class QNetworkManagerInterfaceDeviceWiredPrivate; class QNetworkManagerInterfaceDeviceWiredPrivate;
...@@ -282,12 +305,19 @@ public: ...@@ -282,12 +305,19 @@ public:
bool carrier() const; bool carrier() const;
bool setConnections(); bool setConnections();
bool isValid(); bool isValid();
QStringList availableConnections();
Q_SIGNALS: Q_SIGNALS:
void propertiesChanged( const QString &, QMap<QString,QVariant>); void propertiesChanged(QMap<QString,QVariant>);
void propertiesReady();
void carrierChanged(bool);
private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private: private:
QNetworkManagerInterfaceDeviceWiredPrivate *d; QNetworkManagerInterfaceDeviceWiredPrivate *d;
QNmDBusHelper *nmDBusHelper; QVariantMap propertyMap;
}; };
class QNetworkManagerInterfaceDeviceWirelessPrivate; class QNetworkManagerInterfaceDeviceWirelessPrivate;
...@@ -325,15 +355,24 @@ public: ...@@ -325,15 +355,24 @@ public:
void requestScan(); void requestScan();
Q_SIGNALS: Q_SIGNALS:
void propertiesChanged( const QString &, QMap<QString,QVariant>); void propertiesChanged(QMap<QString,QVariant>);
void accessPointAdded(const QString &); void accessPointAdded(const QString &);
void accessPointRemoved(const QString &); void accessPointRemoved(const QString &);
void scanDone(); void scanDone();
void propertiesReady();
void accessPointsReady();
private Q_SLOTS: private Q_SLOTS:
void scanIsDone(); void scanIsDone();
void propertiesSwap(QMap<QString,QVariant>);
void slotAccessPointAdded(QDBusObjectPath);
void slotAccessPointRemoved(QDBusObjectPath);
private: private:
QNetworkManagerInterfaceDeviceWirelessPrivate *d; QNetworkManagerInterfaceDeviceWirelessPrivate *d;
QNmDBusHelper *nmDBusHelper; QVariantMap propertyMap;
QList <QDBusObjectPath> accessPointsList;
}; };
class QNetworkManagerInterfaceDeviceModemPrivate; class QNetworkManagerInterfaceDeviceModemPrivate;
...@@ -350,6 +389,7 @@ public: ...@@ -350,6 +389,7 @@ public:
Gsm_Umts = 0x4, Gsm_Umts = 0x4,
Lte = 0x08 Lte = 0x08
}; };
Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability)
explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath,
QObject *parent = 0); QObject *parent = 0);
...@@ -361,16 +401,22 @@ public: ...@@ -361,16 +401,22 @@ public:
bool setConnections(); bool setConnections();
bool isValid(); bool isValid();
quint32 modemCapabilities() const; ModemCapabilities modemCapabilities() const;
quint32 currentCapabilities() const; ModemCapabilities currentCapabilities() const;
Q_SIGNALS: Q_SIGNALS:
void propertiesChanged( const QString &, QMap<QString,QVariant>); void propertiesChanged(QMap<QString,QVariant>);
void propertiesReady();
private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private: private:
QNetworkManagerInterfaceDeviceModemPrivate *d; QNetworkManagerInterfaceDeviceModemPrivate *d;
QNmDBusHelper *nmDBusHelper; QVariantMap propertyMap;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities)
class QNetworkManagerSettingsPrivate; class QNetworkManagerSettingsPrivate;
class QNetworkManagerSettings : public QObject class QNetworkManagerSettings : public QObject
...@@ -390,8 +436,10 @@ public: ...@@ -390,8 +436,10 @@ public:
Q_SIGNALS: Q_SIGNALS:
void newConnection(QDBusObjectPath); void newConnection(QDBusObjectPath);
void connectionsListReady();
private: private:
QNetworkManagerSettingsPrivate *d; QNetworkManagerSettingsPrivate *d;
QList <QDBusObjectPath> connectionsList;
}; };
class QNetworkManagerSettingsConnectionPrivate; class QNetworkManagerSettingsConnectionPrivate;
...@@ -418,12 +466,14 @@ public: ...@@ -418,12 +466,14 @@ public:
bool isValid(); bool isValid();
Q_SIGNALS: Q_SIGNALS:
void updated(); void updated();
void removed(const QString &path); void removed(const QString &path);
void settingsReady();
private Q_SLOTS:
void slotSettingsRemoved();
private: private:
QNmDBusHelper *nmDBusHelper;
QNetworkManagerSettingsConnectionPrivate *d; QNetworkManagerSettingsConnectionPrivate *d;
}; };
...@@ -444,22 +494,26 @@ public: ...@@ -444,22 +494,26 @@ public:
~ QNetworkManagerConnectionActive(); ~ QNetworkManagerConnectionActive();
QDBusInterface *connectionInterface() const; QDBusInterface *connectionInterface() const;
QString serviceName() const;
QDBusObjectPath connection() const; QDBusObjectPath connection() const;
QDBusObjectPath specificObject() const; QDBusObjectPath specificObject() const;
QList<QDBusObjectPath> devices() const; QStringList devices() const;
quint32 state() const; quint32 state() const;
bool defaultRoute() const; bool defaultRoute() const;
bool default6Route() const;
bool setConnections(); bool setConnections();
bool isValid(); bool isValid();
Q_SIGNALS: Q_SIGNALS:
void propertiesChanged(QList<QDBusObjectPath>); void propertiesChanged(QMap<QString,QVariant>);
void propertiesChanged( const QString &, QMap<QString,QVariant>); void propertiesReady();
private Q_SLOTS:
void propertiesSwap(QMap<QString,QVariant>);
private: private:
QNetworkManagerConnectionActivePrivate *d; QNetworkManagerConnectionActivePrivate *d;
QNmDBusHelper *nmDBusHelper; QVariantMap propertyMap;
}; };
class QNetworkManagerIp4ConfigPrivate; class QNetworkManagerIp4ConfigPrivate;
......
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
// this class is for helping qdbus get stuff
#include "qnmdbushelper.h"
#include "qnetworkmanagerservice.h"
#include <QDBusError>
#include <QDBusInterface>
#include <QDBusMessage>
#include <QDBusReply>
#include <QDebug>
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
QNmDBusHelper::QNmDBusHelper(QObject * parent)
: QObject(parent)
{
}
QNmDBusHelper::~QNmDBusHelper()
{
}
void QNmDBusHelper::deviceStateChanged(quint32 state)
{
QDBusMessage msg = this->message();
if (state == NM_DEVICE_STATE_ACTIVATED
|| state == NM_DEVICE_STATE_DISCONNECTED
|| state == NM_DEVICE_STATE_UNAVAILABLE
|| state == NM_DEVICE_STATE_FAILED) {
emit pathForStateChanged(msg.path(), state);
}
}
void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path)
{
if (path.path().length() > 2)
emit pathForAccessPointAdded(path.path());
}
void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path)
{
if (path.path().length() > 2)
emit pathForAccessPointRemoved(path.path());
}
void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
{
QDBusMessage msg = this->message();
QMapIterator<QString, QVariant> i(map);
while (i.hasNext()) {
i.next();
if (i.key() == QStringLiteral("State")) {
quint32 state = i.value().toUInt();
if (state == NM_DEVICE_STATE_ACTIVATED
|| state == NM_DEVICE_STATE_DISCONNECTED
|| state == NM_DEVICE_STATE_UNAVAILABLE
|| state == NM_DEVICE_STATE_FAILED) {
emit pathForPropertiesChanged(msg.path(), map);
}
} else if (i.key() == QStringLiteral("ActiveAccessPoint")) {
emit pathForPropertiesChanged(msg.path(), map);
} else if (i.key() == QStringLiteral("ActiveConnections")) {
emit pathForPropertiesChanged(msg.path(), map);
} else if (i.key() == QStringLiteral("AvailableConnections")) {
const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>();
QDBusObjectPath path;
QStringList paths;
dbusArgs.beginArray();
while (!dbusArgs.atEnd()) {
dbusArgs >> path;
paths << path.path();
}
dbusArgs.endArray();
emit pathForConnectionsChanged(paths);
}
}
}
void QNmDBusHelper::slotSettingsRemoved()
{
QDBusMessage msg = this->message();
emit pathForSettingsRemoved(msg.path());
}
void QNmDBusHelper::activeConnectionPropertiesChanged(QMap<QString,QVariant> map)
{
QDBusMessage msg = this->message();
QMapIterator<QString, QVariant> i(map);
while (i.hasNext()) {
i.next();
if (i.key() == QStringLiteral("State")) {
quint32 state = i.value().toUInt();
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|| state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
emit pathForPropertiesChanged(msg.path(), map);
}
}
}
}
QT_END_NAMESPACE
#endif // QT_NO_DBUS
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QNMDBUSHELPERPRIVATE_H
#define QNMDBUSHELPERPRIVATE_H
#include <QDBusObjectPath>
#include <QDBusContext>
#include <QMap>
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
class QNmDBusHelper: public QObject, protected QDBusContext
{
Q_OBJECT
public:
QNmDBusHelper(QObject *parent = 0);
~QNmDBusHelper();
public slots:
void deviceStateChanged(quint32);
void slotAccessPointAdded(QDBusObjectPath);
void slotAccessPointRemoved(QDBusObjectPath);
void slotPropertiesChanged(QMap<QString,QVariant>);
void slotSettingsRemoved();
void activeConnectionPropertiesChanged(QMap<QString,QVariant>);
Q_SIGNALS:
void pathForStateChanged(const QString &, quint32);
void pathForAccessPointAdded(const QString &);
void pathForAccessPointRemoved(const QString &);
void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>);
void pathForSettingsRemoved(const QString &);
void pathForConnectionsChanged(const QStringList &pathsList);
};
QT_END_NAMESPACE
#endif // QT_NO_DBUS
#endif// QNMDBUSHELPERPRIVATE_H
...@@ -366,7 +366,8 @@ void QNetworkSessionPrivateImpl::networkConfigurationsChanged() ...@@ -366,7 +366,8 @@ void QNetworkSessionPrivateImpl::networkConfigurationsChanged()
else else
updateStateFromActiveConfig(); updateStateFromActiveConfig();
startTime = engine->startTime(activeConfig.identifier()); if (engine)
startTime = engine->startTime(activeConfig.identifier());
} }
void QNetworkSessionPrivateImpl::configurationChanged(QNetworkConfigurationPrivatePointer config) void QNetworkSessionPrivateImpl::configurationChanged(QNetworkConfigurationPrivatePointer config)
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
****************************************************************************/ ****************************************************************************/
#include "qibustypes.h" #include "qibustypes.h"
#include <qtextformat.h>
#include <QtDBus> #include <QtDBus>
#include <QHash> #include <QHash>
...@@ -134,7 +133,7 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &a ...@@ -134,7 +133,7 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, QIBusAttribute &a
return argument; return argument;
} }
QTextFormat QIBusAttribute::format() const QTextCharFormat QIBusAttribute::format() const
{ {
QTextCharFormat fmt; QTextCharFormat fmt;
switch (type) { switch (type) {
...@@ -225,11 +224,32 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &at ...@@ -225,11 +224,32 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, QIBusAttributeList &at
QList<QInputMethodEvent::Attribute> QIBusAttributeList::imAttributes() const QList<QInputMethodEvent::Attribute> QIBusAttributeList::imAttributes() const
{ {
QHash<QPair<int, int>, QTextCharFormat> rangeAttrs;
// Merge text fomats for identical ranges into a single QTextFormat.
for (int i = 0; i < attributes.size(); ++i) {
const QIBusAttribute &attr = attributes.at(i);
const QTextCharFormat &format = attr.format();
if (format.isValid()) {
const QPair<int, int> range(attr.start, attr.end);
rangeAttrs[range].merge(format);
}
}
// Assemble list in original attribute order.
QList<QInputMethodEvent::Attribute> imAttrs; QList<QInputMethodEvent::Attribute> imAttrs;
for (int i = 0; i < attributes.size(); ++i) { for (int i = 0; i < attributes.size(); ++i) {
const QIBusAttribute &attr = attributes.at(i); const QIBusAttribute &attr = attributes.at(i);
imAttrs += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, attr.start, attr.end - attr.start, attr.format()); const QTextFormat &format = attr.format();
imAttrs += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
attr.start,
attr.end - attr.start,
format.isValid() ? rangeAttrs[QPair<int, int>(attr.start, attr.end)] : format);
} }
return imAttrs; return imAttrs;
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <qvector.h> #include <qvector.h>
#include <qevent.h> #include <qevent.h>
#include <QDBusArgument> #include <QDBusArgument>
#include <QTextCharFormat>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
...@@ -70,7 +71,7 @@ public: ...@@ -70,7 +71,7 @@ public:
QIBusAttribute(); QIBusAttribute();
~QIBusAttribute(); ~QIBusAttribute();
QTextFormat format() const; QTextCharFormat format() const;
Type type; Type type;
quint32 value; quint32 value;
......
...@@ -268,6 +268,7 @@ public: // for QNSView ...@@ -268,6 +268,7 @@ public: // for QNSView
bool m_inConstructor; bool m_inConstructor;
bool m_inSetVisible; bool m_inSetVisible;
bool m_inSetGeometry;
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext; QCocoaGLContext *m_glContext;
#endif #endif
......
...@@ -381,6 +381,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) ...@@ -381,6 +381,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_windowUnderMouse(false) , m_windowUnderMouse(false)
, m_inConstructor(true) , m_inConstructor(true)
, m_inSetVisible(false) , m_inSetVisible(false)
, m_inSetGeometry(false)
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
, m_glContext(0) , m_glContext(0)
#endif #endif
...@@ -470,6 +471,8 @@ QSurfaceFormat QCocoaWindow::format() const ...@@ -470,6 +471,8 @@ QSurfaceFormat QCocoaWindow::format() const
void QCocoaWindow::setGeometry(const QRect &rectIn) void QCocoaWindow::setGeometry(const QRect &rectIn)
{ {
QBoolBlocker inSetGeometry(m_inSetGeometry, true);
QRect rect = rectIn; QRect rect = rectIn;
// This means it is a call from QWindow::setFramePosition() and // This means it is a call from QWindow::setFramePosition() and
// the coordinates include the frame (size is still the contents rectangle). // the coordinates include the frame (size is still the contents rectangle).
...@@ -1754,6 +1757,11 @@ void QCocoaWindow::updateExposedGeometry() ...@@ -1754,6 +1757,11 @@ void QCocoaWindow::updateExposedGeometry()
if (!m_geometryUpdateExposeAllowed) if (!m_geometryUpdateExposeAllowed)
return; return;
// Do not send incorrect exposes in case the window is not even visible yet.
// We might get here as a result of a resize() from QWidget's show(), for instance.
if (!window()->isVisible())
return;
if (!isWindowExposable()) if (!isWindowExposable())
return; return;
......
...@@ -361,12 +361,11 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; ...@@ -361,12 +361,11 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
// Send a geometry change event to Qt, if it's ready to handle events // Send a geometry change event to Qt, if it's ready to handle events
if (!m_platformWindow->m_inConstructor) { if (!m_platformWindow->m_inConstructor) {
QWindowSystemInterface::handleGeometryChange(m_window, geometry); QWindowSystemInterface::handleGeometryChange(m_window, geometry);
// Do not send incorrect exposes in case the window is not even visible yet. m_platformWindow->updateExposedGeometry();
// We might get here as a result of a resize() from QWidget's show(), for instance. // Guard against processing window system events during QWindow::setGeometry
if (m_platformWindow->window()->isVisible()) { // calles, which Qt and Qt applications do not excpect.
m_platformWindow->updateExposedGeometry(); if (!m_platformWindow->m_inSetGeometry)
QWindowSystemInterface::flushWindowSystemEvents(); QWindowSystemInterface::flushWindowSystemEvents();
}
} }
} }
...@@ -603,7 +602,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; ...@@ -603,7 +602,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
{ {
if (m_window->flags() & Qt::WindowTransparentForInput) if (m_window->flags() & Qt::WindowTransparentForInput)
return NO; return NO;
QWindowSystemInterface::handleWindowActivated([self topLevelWindow]); if (!m_platformWindow->windowIsPopupType())
QWindowSystemInterface::handleWindowActivated([self topLevelWindow]);
return YES; return YES;
} }
...@@ -662,6 +662,19 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; ...@@ -662,6 +662,19 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_frameStrutButtons = Qt::NoButton; m_frameStrutButtons = Qt::NoButton;
} }
- (NSPoint) screenMousePoint:(NSEvent *)theEvent
{
NSPoint screenPoint;
if (theEvent) {
NSPoint windowPoint = [theEvent locationInWindow];
NSRect screenRect = [[theEvent window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
screenPoint = screenRect.origin;
} else {
screenPoint = [NSEvent mouseLocation];
}
return screenPoint;
}
- (void)handleMouseEvent:(NSEvent *)theEvent - (void)handleMouseEvent:(NSEvent *)theEvent
{ {
[self handleTabletEvent: theEvent]; [self handleTabletEvent: theEvent];
...@@ -676,23 +689,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; ...@@ -676,23 +689,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_platformWindow->m_forwardWindow = 0; m_platformWindow->m_forwardWindow = 0;
} }
NSPoint globalPos = [NSEvent mouseLocation]; [targetView convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
if ([self.window parentWindow]
&& (theEvent.type == NSLeftMouseDragged || theEvent.type == NSLeftMouseUp)) {
// QToolBar can be implemented as a child window on top of its main window
// (with a borderless NSWindow). If an option "unified toolbar" set on the main window,
// it's possible to drag such a window using this toolbar.
// While handling mouse drag events, QToolBar moves the window (QWidget::move).
// In such a combination [NSEvent mouseLocation] is very different from the
// real event location and as a result a window will move chaotically.
NSPoint winPoint = [theEvent locationInWindow];
NSRect tmpRect = NSMakeRect(winPoint.x, winPoint.y, 1., 1.);
tmpRect = [[theEvent window] convertRectToScreen:tmpRect];
globalPos = tmpRect.origin;
}
[targetView convertFromScreen:globalPos toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
ulong timestamp = [theEvent timestamp] * 1000; ulong timestamp = [theEvent timestamp] * 1000;
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
...@@ -865,7 +862,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; ...@@ -865,7 +862,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
QPointF windowPoint; QPointF windowPoint;
QPointF screenPoint; QPointF screenPoint;
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; [self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
QWindow *childWindow = m_platformWindow->childWindowAt(windowPoint.toPoint()); QWindow *childWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
// Top-level windows generate enter-leave events for sub-windows. // Top-level windows generate enter-leave events for sub-windows.
......
...@@ -63,11 +63,13 @@ QByteArray QEglFSHooks::fbDeviceName() const ...@@ -63,11 +63,13 @@ QByteArray QEglFSHooks::fbDeviceName() const
int QEglFSHooks::framebufferIndex() const int QEglFSHooks::framebufferIndex() const
{ {
int fbIndex = 0; int fbIndex = 0;
#ifndef QT_NO_REGULAREXPRESSION
QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)")); QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName()); QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName());
if (match.hasMatch()) if (match.hasMatch())
fbIndex = match.captured(1).toInt(); fbIndex = match.captured(1).toInt();
#endif
return fbIndex; return fbIndex;
} }
......
...@@ -317,11 +317,16 @@ static bool rootLevelRunLoopIntegration() ...@@ -317,11 +317,16 @@ static bool rootLevelRunLoopIntegration()
} }
#if defined(Q_PROCESSOR_X86) #if defined(Q_PROCESSOR_X86)
# define SET_STACK_POINTER "mov %0, %%esp"
# define FUNCTION_CALL_ALIGNMENT 16 # define FUNCTION_CALL_ALIGNMENT 16
# if defined(Q_PROCESSOR_X86_32)
# define SET_STACK_POINTER "mov %0, %%esp"
# elif defined(Q_PROCESSOR_X86_64)
# define SET_STACK_POINTER "movq %0, %%rsp"
# endif
#elif defined(Q_PROCESSOR_ARM) #elif defined(Q_PROCESSOR_ARM)
# define SET_STACK_POINTER "mov sp, %0" # // Valid for both 32 and 64-bit ARM
# define FUNCTION_CALL_ALIGNMENT 4 # define FUNCTION_CALL_ALIGNMENT 4
# define SET_STACK_POINTER "mov sp, %0"
#else #else
# error "Unknown processor family" # error "Unknown processor family"
#endif #endif
......
...@@ -62,7 +62,7 @@ QPointF fromCGPoint(const CGPoint &point); ...@@ -62,7 +62,7 @@ QPointF fromCGPoint(const CGPoint &point);
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation); Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation);
UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation); UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation);
QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen);
int infoPlistValue(NSString* key, int defaultValue); int infoPlistValue(NSString* key, int defaultValue);
QT_END_NAMESPACE QT_END_NAMESPACE
......
...@@ -127,15 +127,6 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation) ...@@ -127,15 +127,6 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation)
return uiOrientation; return uiOrientation;
} }
QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen)
{
// UIScreen is always in portrait. Use this function to convert CGRects
// aligned with UIScreen into whatever is the current orientation of QScreen.
QRect geometry = screen->geometry();
return geometry.width() < geometry.height() ? rect
: QRect(rect.y(), geometry.height() - rect.width() - rect.x(), rect.height(), rect.width());
}
int infoPlistValue(NSString* key, int defaultValue) int infoPlistValue(NSString* key, int defaultValue)
{ {
static NSBundle *bundle = [NSBundle mainBundle]; static NSBundle *bundle = [NSBundle mainBundle];
...@@ -150,6 +141,11 @@ int infoPlistValue(NSString* key, int defaultValue) ...@@ -150,6 +141,11 @@ int infoPlistValue(NSString* key, int defaultValue)
@end @end
@implementation QtFirstResponderEvent @implementation QtFirstResponderEvent
- (void) dealloc
{
self.firstResponder = 0;
[super dealloc];
}
@end @end
......
...@@ -51,9 +51,10 @@ QT_BEGIN_NAMESPACE ...@@ -51,9 +51,10 @@ QT_BEGIN_NAMESPACE
struct ImeState struct ImeState
{ {
ImeState() : currentState(0) {} ImeState() : currentState(0), focusObject(0) {}
Qt::InputMethodQueries update(Qt::InputMethodQueries properties); Qt::InputMethodQueries update(Qt::InputMethodQueries properties);
QInputMethodQueryEvent currentState; QInputMethodQueryEvent currentState;
QObject *focusObject;
}; };
class QIOSInputContext : public QPlatformInputContext class QIOSInputContext : public QPlatformInputContext
...@@ -82,6 +83,7 @@ public: ...@@ -82,6 +83,7 @@ public:
void commit(); void commit();
const ImeState &imeState() { return m_imeState; }; const ImeState &imeState() { return m_imeState; };
bool inputMethodAccepted() const;
bool isReloadingInputViewsFromUpdate() const { return m_isReloadingInputViewsFromUpdate; } bool isReloadingInputViewsFromUpdate() const { return m_isReloadingInputViewsFromUpdate; }
......
...@@ -268,8 +268,11 @@ ...@@ -268,8 +268,11 @@
qImDebug() << "keyboard was closed, clearing focus object"; qImDebug() << "keyboard was closed, clearing focus object";
m_inputContext->clearCurrentFocusObject(); m_inputContext->clearCurrentFocusObject();
} else { } else {
// We've lost responder status because another window was made active // We've lost responder status because another Qt window was made active,
Q_ASSERT(FirstResponderCandidate::currentCandidate()); // another QIOSTextResponder was made first-responder, another UIView was
// made first-responder, or the first-responder was cleared globally. In
// either of these cases we don't have to do anything.
qImDebug() << "lost first responder, but not clearing focus object";
} }
return YES; return YES;
......
...@@ -1224,16 +1224,21 @@ void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters) ...@@ -1224,16 +1224,21 @@ void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters)
QScopedArrayPointer<WCHAR> buffer(new WCHAR[totalStringLength + 2 * size]); QScopedArrayPointer<WCHAR> buffer(new WCHAR[totalStringLength + 2 * size]);
QScopedArrayPointer<COMDLG_FILTERSPEC> comFilterSpec(new COMDLG_FILTERSPEC[size]); QScopedArrayPointer<COMDLG_FILTERSPEC> comFilterSpec(new COMDLG_FILTERSPEC[size]);
const QString matchesAll = QStringLiteral(" (*)");
WCHAR *ptr = buffer.data(); WCHAR *ptr = buffer.data();
// Split filter specification as 'Texts (*.txt[;] *.doc)' // Split filter specification as 'Texts (*.txt[;] *.doc)'
// into description and filters specification as '*.txt;*.doc' // into description and filters specification as '*.txt;*.doc'
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
// Display glitch (CLSID only): 'All files (*)' shows up as 'All files (*) (*)' // Display glitch (CLSID only): Any filter not filtering on suffix (such as
// '*', 'a.*') will be duplicated in combo: 'All files (*) (*)',
// 'AAA files (a.*) (a.*)'
QString description = specs[i].description; QString description = specs[i].description;
if (!m_hideFiltersDetails && description.endsWith(matchesAll)) const QString &filter = specs[i].filter;
description.truncate(description.size() - matchesAll.size()); if (!m_hideFiltersDetails && !filter.startsWith(QLatin1String("*."))) {
const int pos = description.lastIndexOf(QLatin1Char('('));
if (pos > 0)
description.truncate(pos);
}
// Add to buffer. // Add to buffer.
comFilterSpec[i].pszName = ptr; comFilterSpec[i].pszName = ptr;
ptr += description.toWCharArray(ptr); ptr += description.toWCharArray(ptr);
......
...@@ -470,9 +470,10 @@ void QPpdPrintDevice::loadPrinter() ...@@ -470,9 +470,10 @@ void QPpdPrintDevice::loadPrinter()
m_cupsDest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, m_cupsName, m_cupsInstance); m_cupsDest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, m_cupsName, m_cupsInstance);
if (m_cupsDest) { if (m_cupsDest) {
const char *ppdFile = cupsGetPPD(m_cupsName); const char *ppdFile = cupsGetPPD(m_cupsName);
if (ppdFile) if (ppdFile) {
m_ppd = ppdOpenFile(ppdFile); m_ppd = ppdOpenFile(ppdFile);
unlink(ppdFile); unlink(ppdFile);
}
if (m_ppd) { if (m_ppd) {
ppdMarkDefaults(m_ppd); ppdMarkDefaults(m_ppd);
} else { } else {
......
...@@ -493,7 +493,7 @@ void Generator::generateCode() ...@@ -493,7 +493,7 @@ void Generator::generateCode()
for (int i = 0; i < extraList.count(); ++i) { for (int i = 0; i < extraList.count(); ++i) {
fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData()); fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData());
} }
fprintf(out, " 0\n};\n\n"); fprintf(out, " Q_NULLPTR\n};\n\n");
} }
// //
...@@ -505,24 +505,24 @@ void Generator::generateCode() ...@@ -505,24 +505,24 @@ void Generator::generateCode()
fprintf(out, "const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData()); fprintf(out, "const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData());
if (isQObject) if (isQObject)
fprintf(out, " { 0, "); fprintf(out, " { Q_NULLPTR, ");
else if (cdef->superclassList.size()) else if (cdef->superclassList.size())
fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData()); fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData());
else else
fprintf(out, " { 0, "); fprintf(out, " { Q_NULLPTR, ");
fprintf(out, "qt_meta_stringdata_%s.data,\n" fprintf(out, "qt_meta_stringdata_%s.data,\n"
" qt_meta_data_%s, ", qualifiedClassNameIdentifier.constData(), " qt_meta_data_%s, ", qualifiedClassNameIdentifier.constData(),
qualifiedClassNameIdentifier.constData()); qualifiedClassNameIdentifier.constData());
if (cdef->hasQObject && !isQt) if (cdef->hasQObject && !isQt)
fprintf(out, " qt_static_metacall, "); fprintf(out, " qt_static_metacall, ");
else else
fprintf(out, " 0, "); fprintf(out, " Q_NULLPTR, ");
if (extraList.isEmpty()) if (extraList.isEmpty())
fprintf(out, "0, "); fprintf(out, "Q_NULLPTR, ");
else else
fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData()); fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData());
fprintf(out, "0}\n};\n\n"); fprintf(out, "Q_NULLPTR}\n};\n\n");
if(isQt) if(isQt)
return; return;
...@@ -537,7 +537,7 @@ void Generator::generateCode() ...@@ -537,7 +537,7 @@ void Generator::generateCode()
// Generate smart cast function // Generate smart cast function
// //
fprintf(out, "\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData()); fprintf(out, "\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData());
fprintf(out, " if (!_clname) return 0;\n"); fprintf(out, " if (!_clname) return Q_NULLPTR;\n");
fprintf(out, " if (!strcmp(_clname, qt_meta_stringdata_%s.stringdata))\n" fprintf(out, " if (!strcmp(_clname, qt_meta_stringdata_%s.stringdata))\n"
" return static_cast<void*>(const_cast< %s*>(this));\n", " return static_cast<void*>(const_cast< %s*>(this));\n",
qualifiedClassNameIdentifier.constData(), cdef->classname.constData()); qualifiedClassNameIdentifier.constData(), cdef->classname.constData());
...@@ -562,7 +562,7 @@ void Generator::generateCode() ...@@ -562,7 +562,7 @@ void Generator::generateCode()
QByteArray superClass = purestSuperClass; QByteArray superClass = purestSuperClass;
fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData()); fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData());
} else { } else {
fprintf(out, " return 0;\n"); fprintf(out, " return Q_NULLPTR;\n");
} }
fprintf(out, "}\n"); fprintf(out, "}\n");
...@@ -1416,7 +1416,7 @@ void Generator::generateSignal(FunctionDef *def,int index) ...@@ -1416,7 +1416,7 @@ void Generator::generateSignal(FunctionDef *def,int index)
fprintf(out, "QPrivateSignal"); fprintf(out, "QPrivateSignal");
fprintf(out, ")%s\n{\n" fprintf(out, ")%s\n{\n"
" QMetaObject::activate(%s, &staticMetaObject, %d, 0);\n" " QMetaObject::activate(%s, &staticMetaObject, %d, Q_NULLPTR);\n"
"}\n", constQualifier, thisPtr.constData(), index); "}\n", constQualifier, thisPtr.constData(), index);
return; return;
} }
...@@ -1446,7 +1446,7 @@ void Generator::generateSignal(FunctionDef *def,int index) ...@@ -1446,7 +1446,7 @@ void Generator::generateSignal(FunctionDef *def,int index)
fprintf(out, " void *_a[] = { "); fprintf(out, " void *_a[] = { ");
if (def->normalizedType == "void") { if (def->normalizedType == "void") {
fprintf(out, "0"); fprintf(out, "Q_NULLPTR");
} else { } else {
if (def->returnTypeIsVolatile) if (def->returnTypeIsVolatile)
fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(&_t0))"); fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(&_t0))");
......