summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-08-25 10:11:49 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-08-25 12:48:52 +0200
commit04d0a9626ce61b2e05a40f9562c2bcf12e234639 (patch)
treef1643f829aedc9ac51fcc260f7df2639dfe08360 /src/plugins/platforms
parent17f3451daa286b88a52f18c802d7b158dfb653b2 (diff)
parentbdc417b3828737334723eae23097c85f70c23a33 (diff)
Merge branch 'master' into refactor
Conflicts: src/gui/kernel/qapplication_qpa.cpp src/gui/kernel/qcursor_qpa.cpp src/gui/kernel/qwindowsysteminterface_qpa.cpp src/gui/kernel/qwindowsysteminterface_qpa.h src/gui/kernel/qwindowsysteminterface_qpa_p.h src/gui/text/qtextcontrol.cpp src/plugins/platforms/wayland/wayland.pro src/widgets/accessible/qaccessible2.h src/widgets/widgets/qwidgetlinecontrol_p.h Change-Id: I5e6f4eb184159dccc67e8f13673edb884d179c74
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/wayland/qwaylandclipboard.cpp20
-rw-r--r--src/plugins/platforms/wayland/qwaylandclipboard.h4
-rw-r--r--src/plugins/platforms/wayland/qwaylandmime.cpp83
-rw-r--r--src/plugins/platforms/wayland/qwaylandmime.h55
-rw-r--r--src/plugins/platforms/wayland/wayland.pro6
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp10
6 files changed, 165 insertions, 13 deletions
diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
index da5da4285a..f90d1a9802 100644
--- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp
+++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp
@@ -42,6 +42,7 @@
#include "qwaylandclipboard.h"
#include "qwaylanddisplay.h"
#include "qwaylandinputdevice.h"
+#include "qwaylandmime.h"
#include <QtGui/QPlatformNativeInterface>
#include <QtGui/QGuiApplication>
#include <QtCore/QMimeData>
@@ -49,10 +50,11 @@
#include <QtCore/QFile>
#include <QtCore/QtDebug>
#include <QtGui/private/qdnd_p.h>
+#include <QtCore/private/qcore_unix_p.h> // for QT_READ
static QWaylandClipboard *clipboard = 0;
-class QWaylandMimeData : public QInternalMimeData
+class QWaylandClipboardMimeData : public QInternalMimeData
{
public:
void clearAll();
@@ -64,28 +66,28 @@ private:
QStringList mFormatList;
};
-void QWaylandMimeData::clearAll()
+void QWaylandClipboardMimeData::clearAll()
{
clear();
mFormatList.clear();
}
-void QWaylandMimeData::setFormats(const QStringList &formatList)
+void QWaylandClipboardMimeData::setFormats(const QStringList &formatList)
{
mFormatList = formatList;
}
-bool QWaylandMimeData::hasFormat_sys(const QString &mimeType) const
+bool QWaylandClipboardMimeData::hasFormat_sys(const QString &mimeType) const
{
return formats().contains(mimeType);
}
-QStringList QWaylandMimeData::formats_sys() const
+QStringList QWaylandClipboardMimeData::formats_sys() const
{
return mFormatList;
}
-QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::Type type) const
+QVariant QWaylandClipboardMimeData::retrieveData_sys(const QString &mimeType, QVariant::Type type) const
{
return clipboard->retrieveData(mimeType, type);
}
@@ -147,7 +149,7 @@ void QWaylandSelection::send(void *data,
Q_UNUSED(selection);
QWaylandSelection *self = static_cast<QWaylandSelection *>(data);
QString mimeType = QString::fromLatin1(mime_type);
- QByteArray content = self->mMimeData->data(mimeType);
+ QByteArray content = QWaylandMimeHelper::getByteArray(self->mMimeData, mimeType);
if (!content.isEmpty()) {
QFile f;
if (f.open(fd, QIODevice::WriteOnly))
@@ -218,7 +220,7 @@ QVariant QWaylandClipboard::retrieveData(const QString &mimeType, QVariant::Type
char buf[256];
int n;
close(pipefd[1]);
- while ((n = read(pipefd[0], &buf, sizeof buf)) > 0)
+ while ((n = QT_READ(pipefd[0], &buf, sizeof buf)) > 0)
content.append(buf, n);
close(pipefd[0]);
return content;
@@ -230,7 +232,7 @@ QMimeData *QWaylandClipboard::mimeData(QClipboard::Mode mode)
if (!mSelections.isEmpty())
return mSelections.last()->mMimeData;
if (!mMimeDataIn)
- mMimeDataIn = new QWaylandMimeData;
+ mMimeDataIn = new QWaylandClipboardMimeData;
mMimeDataIn->clearAll();
if (!mOfferedMimeTypes.isEmpty() && mOffer)
mMimeDataIn->setFormats(mOfferedMimeTypes);
diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.h b/src/plugins/platforms/wayland/qwaylandclipboard.h
index 87294342d7..6b113ae5b0 100644
--- a/src/plugins/platforms/wayland/qwaylandclipboard.h
+++ b/src/plugins/platforms/wayland/qwaylandclipboard.h
@@ -48,7 +48,7 @@
class QWaylandDisplay;
class QWaylandSelection;
-class QWaylandMimeData;
+class QWaylandClipboardMimeData;
struct wl_selection_offer;
class QWaylandClipboardSignalEmitter : public QObject
@@ -90,7 +90,7 @@ private:
static void forceRoundtrip(struct wl_display *display);
QWaylandDisplay *mDisplay;
- QWaylandMimeData *mMimeDataIn;
+ QWaylandClipboardMimeData *mMimeDataIn;
QList<QWaylandSelection *> mSelections;
QStringList mOfferedMimeTypes;
struct wl_selection_offer *mOffer;
diff --git a/src/plugins/platforms/wayland/qwaylandmime.cpp b/src/plugins/platforms/wayland/qwaylandmime.cpp
new file mode 100644
index 0000000000..c218d7ddb8
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandmime.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandmime.h"
+#include <QImage>
+#include <QColor>
+#include <QUrl>
+#include <QBuffer>
+#include <QImageWriter>
+
+QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &mimeType)
+{
+ QByteArray content;
+ if (mimeType == QLatin1String("text/plain")) {
+ content = mimeData->text().toUtf8();
+ } else if (mimeData->hasImage()
+ && (mimeType == QLatin1String("application/x-qt-image")
+ || mimeType.startsWith("image/"))) {
+ QImage image = qvariant_cast<QImage>(mimeData->imageData());
+ if (!image.isNull()) {
+ QBuffer buf;
+ buf.open(QIODevice::ReadWrite);
+ QByteArray fmt = "BMP";
+ if (mimeType.startsWith("image/")) {
+ QByteArray imgFmt = mimeType.mid(6).toUpper().toAscii();
+ if (QImageWriter::supportedImageFormats().contains(imgFmt))
+ fmt = imgFmt;
+ }
+ QImageWriter wr(&buf, fmt);
+ wr.write(image);
+ content = buf.buffer();
+ }
+ } else if (mimeType == QLatin1String("application/x-color")) {
+ content = qvariant_cast<QColor>(mimeData->colorData()).name().toAscii();
+ } else if (mimeType == QLatin1String("text/uri-list")) {
+ QList<QUrl> urls = mimeData->urls();
+ for (int i = 0; i < urls.count(); ++i) {
+ content.append(urls.at(i).toEncoded());
+ content.append('\n');
+ }
+ } else {
+ content = mimeData->data(mimeType);
+ }
+ return content;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandmime.h b/src/plugins/platforms/wayland/qwaylandmime.h
new file mode 100644
index 0000000000..5f6ed954a1
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandmime.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDMIME_H
+#define QWAYLANDMIME_H
+
+#include <QString>
+#include <QByteArray>
+#include <QMimeData>
+
+class QWaylandMimeHelper
+{
+public:
+ static QByteArray getByteArray(QMimeData *mimeData, const QString &mimeType);
+};
+
+#endif
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
index a46f508417..fd6ffc06de 100644
--- a/src/plugins/platforms/wayland/wayland.pro
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -25,7 +25,8 @@ SOURCES = main.cpp \
qwaylandscreen.cpp \
qwaylandshmwindow.cpp \
qwaylandclipboard.cpp \
- qwaylanddnd.cpp
+ qwaylanddnd.cpp \
+ qwaylandmime.cpp
HEADERS = qwaylandintegration.h \
qwaylandnativeinterface.h \
@@ -37,7 +38,8 @@ HEADERS = qwaylandintegration.h \
qwaylandbuffer.h \
qwaylandshmwindow.h \
qwaylandclipboard.h \
- qwaylanddnd.h
+ qwaylanddnd.h \
+ qwaylandmime.h
INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
LIBS += $$QMAKE_LIBS_WAYLAND
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index f136b8167f..7b7b23ce0c 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -53,7 +53,17 @@
#include "qdri2context.h"
#endif
+#define class class_name // Yeah, in 2011 ...
#include <xcb/xcb_icccm.h>
+#undef class
+
+// xcb-icccm 3.8 support
+#ifdef XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS
+#define xcb_wm_hints_t xcb_icccm_wm_hints_t
+#define xcb_wm_hints_set_iconic xcb_icccm_wm_hints_set_iconic
+#define xcb_wm_hints_set_normal xcb_icccm_wm_hints_set_normal
+#define xcb_set_wm_hints xcb_icccm_set_wm_hints
+#endif
#include <private/qguiapplication_p.h>
#include <private/qwindow_p.h>