summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.tests/qpa/wayland/wayland.cpp46
-rw-r--r--config.tests/qpa/wayland/wayland.pro6
-rwxr-xr-xconfigure7
-rw-r--r--mkspecs/common/mac/qplatformdefs.h2
-rw-r--r--mkspecs/features/qttest_p4.prf2
-rw-r--r--src/gui/embedded/qkbd_defaultmap_qws_p.h1
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication_p.h2
-rw-r--r--src/gui/kernel/qapplication_qpa.cpp33
-rw-r--r--src/gui/kernel/qclipboard_qpa.cpp82
-rw-r--r--src/gui/kernel/qdesktopwidget_qpa_p.h8
-rw-r--r--src/gui/kernel/qdnd_p.h2
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.cpp101
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.h70
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.cpp2
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.h2
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp18
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h4
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa.cpp27
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa_p.h4
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp15
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.h4
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp19
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h1
-rw-r--r--src/gui/kernel/qwidget.cpp5
-rw-r--r--src/gui/kernel/qwidget_p.h5
-rw-r--r--src/gui/kernel/qwidget_qpa.cpp64
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp6
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h1
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h9
-rw-r--r--src/gui/text/qfont_qpa.cpp2
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp12
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.cpp3
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.h2
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp21
-rw-r--r--src/opengl/opengl.pro.user.2.1pre183
-rw-r--r--src/opengl/qgl.cpp34
-rw-r--r--src/opengl/qgl_p.h1
-rw-r--r--src/opengl/qgl_qpa.cpp35
-rw-r--r--src/opengl/qglpaintdevice.cpp6
-rw-r--r--src/opengl/qglpaintdevice_p.h1
-rw-r--r--src/opengl/qwindowsurface_gl.cpp12
-rw-r--r--src/plugins/phonon/gstreamer/gstreamer.pro2
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.cpp8
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.h1
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp3
-rw-r--r--src/plugins/platforms/externalplugin.pri29
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp27
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h2
-rw-r--r--src/plugins/platforms/platforms.pro4
-rw-r--r--src/plugins/platforms/testlite/qglxintegration.cpp78
-rw-r--r--src/plugins/platforms/testlite/qglxintegration.h21
-rw-r--r--src/plugins/platforms/testlite/qtestliteclipboard.cpp676
-rw-r--r--src/plugins/platforms/testlite/qtestliteclipboard.h94
-rw-r--r--src/plugins/platforms/testlite/qtestlitecursor.cpp199
-rw-r--r--src/plugins/platforms/testlite/qtestlitecursor.h68
-rw-r--r--src/plugins/platforms/testlite/qtestliteeglintegration.cpp186
-rw-r--r--src/plugins/platforms/testlite/qtestliteeglintegration.h54
-rw-r--r--src/plugins/platforms/testlite/qtestliteintegration.cpp101
-rw-r--r--src/plugins/platforms/testlite/qtestliteintegration.h31
-rw-r--r--src/plugins/platforms/testlite/qtestlitekeyboard.cpp1000
-rw-r--r--src/plugins/platforms/testlite/qtestlitekeyboard.h76
-rw-r--r--src/plugins/platforms/testlite/qtestlitemime.cpp322
-rw-r--r--src/plugins/platforms/testlite/qtestlitemime.h67
-rw-r--r--src/plugins/platforms/testlite/qtestlitescreen.cpp468
-rw-r--r--src/plugins/platforms/testlite/qtestlitescreen.h104
-rw-r--r--src/plugins/platforms/testlite/qtestlitestaticinfo.cpp511
-rw-r--r--src/plugins/platforms/testlite/qtestlitestaticinfo.h413
-rw-r--r--src/plugins/platforms/testlite/qtestlitewindow.cpp1299
-rw-r--r--src/plugins/platforms/testlite/qtestlitewindow.h103
-rw-r--r--src/plugins/platforms/testlite/qtestlitewindowsurface.cpp34
-rw-r--r--src/plugins/platforms/testlite/qtestlitewindowsurface.h2
-rw-r--r--src/plugins/platforms/testlite/testlite.pro38
-rw-r--r--src/plugins/platforms/wayland/main.cpp75
-rw-r--r--src/plugins/platforms/wayland/qwaylandbuffer.h60
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.cpp188
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.h60
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp313
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h131
-rw-r--r--src/plugins/platforms/wayland/qwaylanddrmsurface.cpp271
-rw-r--r--src/plugins/platforms/wayland/qwaylanddrmsurface.h134
-rw-r--r--src/plugins/platforms/wayland/qwaylandglcontext.cpp147
-rw-r--r--src/plugins/platforms/wayland/qwaylandglcontext.h80
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp311
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.h100
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp99
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h73
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.cpp87
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.h74
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.cpp143
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.h82
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp123
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h80
-rw-r--r--src/plugins/platforms/wayland/wayland.pro39
94 files changed, 7908 insertions, 1549 deletions
diff --git a/config.tests/qpa/wayland/wayland.cpp b/config.tests/qpa/wayland/wayland.cpp
new file mode 100644
index 0000000..09f72c6
--- /dev/null
+++ b/config.tests/qpa/wayland/wayland.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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 config.tests 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <wayland-client.h>
+
+int main(int, char **)
+{
+ return 0;
+}
diff --git a/config.tests/qpa/wayland/wayland.pro b/config.tests/qpa/wayland/wayland.pro
new file mode 100644
index 0000000..266e4d6
--- /dev/null
+++ b/config.tests/qpa/wayland/wayland.pro
@@ -0,0 +1,6 @@
+SOURCES = wayland.cpp
+CONFIG -= qt
+
+QMAKE_CXXFLAGS += $$QT_CFLAGS_WAYLAND
+LIBS += $$QT_LIBS_WAYLAND -lfreetype -lfontconfig -lwayland-client
+
diff --git a/configure b/configure
index 1f28146..b11d82d 100755
--- a/configure
+++ b/configure
@@ -1483,7 +1483,7 @@ while [ "$#" -gt 0 ]; do
;;
framework)
- if [ "$PLATFORM_MAC" = "yes" ]; then
+ if [ "$PLATFORM_MAC" = "yes" ] || [ "$PLATFORM_QPA" = "yes" ]; then
CFG_FRAMEWORK="$VAL"
else
UNKNOWN_OPT=yes
@@ -6143,6 +6143,11 @@ if [ "$PLATFORM_QPA" = "yes" ]; then
QMakeVar set QMAKE_LIBS_FONTCONFIG "$QT_LIBS_FONTCONFIG"
CFG_LIBFREETYPE=system
fi
+
+ if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qpa/wayland "Wayland" $L_FLAGS $I_FLAGS $l_FLAGS; then
+ QT_CONFIG="$QT_CONFIG wayland"
+ fi
+
fi
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/mac/coreservices "CoreServices" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
diff --git a/mkspecs/common/mac/qplatformdefs.h b/mkspecs/common/mac/qplatformdefs.h
index 99d64ef..5d1f99a 100644
--- a/mkspecs/common/mac/qplatformdefs.h
+++ b/mkspecs/common/mac/qplatformdefs.h
@@ -75,7 +75,7 @@
#include <net/if.h>
#endif
-#include "../common/posix/qplatformdefs.h"
+#include "../posix/qplatformdefs.h"
#undef QT_OPEN_LARGEFILE
#undef QT_SOCKLEN_T
diff --git a/mkspecs/features/qttest_p4.prf b/mkspecs/features/qttest_p4.prf
index 5e1e8fd..ede9657 100644
--- a/mkspecs/features/qttest_p4.prf
+++ b/mkspecs/features/qttest_p4.prf
@@ -2,7 +2,7 @@ isEmpty(TEMPLATE):TEMPLATE=app
CONFIG += qt warn_on console depend_includepath testcase
# x11 is not defined by configure (the following line is copied from gui.pro)
-!win32:!embedded:!mac:!symbian:CONFIG += x11
+!win32:!embedded:!qpa:!mac:!symbian:CONFIG += x11
qtAddLibrary(QtTest)
diff --git a/src/gui/embedded/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h
index 0444093..017f56d 100644
--- a/src/gui/embedded/qkbd_defaultmap_qws_p.h
+++ b/src/gui/embedded/qkbd_defaultmap_qws_p.h
@@ -649,6 +649,7 @@ const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = {
{ 119, 0xffff, 0x01000008, 0x00, 0x00, 0x0000 },
{ 138, 0xffff, 0x01000058, 0x00, 0x00, 0x0000 },
{ 139, 0xffff, 0x01000055, 0x00, 0x00, 0x0000 },
+ { 152, 0xffff, 0x010000ba, 0x00, 0x00, 0x0000 },
};
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 4261e93..0ff3d88 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -222,7 +222,8 @@ qpa {
kernel/qplatformglcontext_qpa.h \
kernel/qdesktopwidget_qpa_p.h \
kernel/qplatformeventloopintegration_qpa.h \
- kernel/qplatformcursor_qpa.h
+ kernel/qplatformcursor_qpa.h \
+ kernel/qplatformclipboard_qpa.h
SOURCES += \
kernel/qapplication_qpa.cpp \
@@ -244,7 +245,8 @@ qpa {
kernel/qplatformwindowformat_qpa.cpp \
kernel/qplatformeventloopintegration_qpa.cpp \
kernel/qplatformglcontext_qpa.cpp \
- kernel/qplatformcursor_qpa.cpp
+ kernel/qplatformcursor_qpa.cpp \
+ kernel/qplatformclipboard_qpa.cpp
contains(QT_CONFIG, glib) {
SOURCES += \
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index f9508a7..1a511a8 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -508,6 +508,8 @@ public:
static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
+ static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
+
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
// static void reportScreenCount(int count);
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp
index ece035c..cd76adf 100644
--- a/src/gui/kernel/qapplication_qpa.cpp
+++ b/src/gui/kernel/qapplication_qpa.cpp
@@ -79,7 +79,6 @@ int qt_last_x = 0;
int qt_last_y = 0;
QPointer<QWidget> qt_last_mouse_receiver = 0;
-static Qt::KeyboardModifiers modifiers = Qt::NoModifier;
static Qt::MouseButtons buttons = Qt::NoButton;
static ulong mousePressTime;
static Qt::MouseButton mousePressButton = Qt::NoButton;
@@ -111,6 +110,9 @@ void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate
case QWindowSystemInterfacePrivate::Leave:
QApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
break;
+ case QWindowSystemInterfacePrivate::ActivatedWindow:
+ QApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
+ break;
case QWindowSystemInterfacePrivate::Close:
QApplicationPrivate::processCloseEvent(
static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
@@ -441,11 +443,11 @@ void QApplication::alert(QWidget *, int)
{
}
-static void init_platform(const QString &name)
+static void init_platform(const QString &name, const QString &platformPluginPath)
{
- QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name);
+ QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
if (!QApplicationPrivate::platform_integration) {
- QStringList keys = QPlatformIntegrationFactory::keys();
+ QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
QString fatalMessage =
QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
foreach(QString key, keys) {
@@ -510,6 +512,7 @@ void qt_init(QApplicationPrivate *priv, int type)
}
QList<QByteArray> pluginList;
+ QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
QString platformName = QLatin1String(qgetenv("QT_QPA_PLATFORM"));
// Get command line params
@@ -524,6 +527,9 @@ void qt_init(QApplicationPrivate *priv, int type)
if (arg == "-fn" || arg == "-font") {
if (++i < argc)
appFont = QString::fromLocal8Bit(argv[i]);
+ } else if (arg == "-platformpluginpath") {
+ if (++i < argc)
+ platformPluginPath = QLatin1String(argv[i]);
} else if (arg == "-platform") {
if (++i < argc)
platformName = QLatin1String(argv[i]);
@@ -547,7 +553,7 @@ void qt_init(QApplicationPrivate *priv, int type)
}
#endif
- init_platform(platformName);
+ init_platform(platformName, platformPluginPath);
init_plugins(pluginList);
QColormap::initialize();
@@ -724,7 +730,7 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
// qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber;
- QMouseEvent ev(type, localPoint, globalPoint, button, buttons, modifiers);
+ QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QApplication::keyboardModifiers());
QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances();
foreach (QWeakPointer<QPlatformCursor> cursor, cursors) {
@@ -732,7 +738,15 @@ void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mouse
cursor.data()->pointerEvent(ev);
}
+ int oldOpenPopupCount = openPopupCount;
QApplication::sendSpontaneousEvent(mouseWidget, &ev);
+
+#ifndef QT_NO_CONTEXTMENU
+ if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
+ QContextMenuEvent e(QContextMenuEvent::Mouse, localPoint, globalPoint, QApplication::keyboardModifiers());
+ QApplication::sendSpontaneousEvent(mouseWidget, &e);
+ }
+#endif // QT_NO_CONTEXTMENU
}
@@ -771,7 +785,7 @@ void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wheel
p = mouseWidget->mapFromGlobal(globalPoint);
}
- QWheelEvent ev(p, globalPoint, e->delta, buttons, modifiers,
+ QWheelEvent ev(p, globalPoint, e->delta, buttons, QApplication::keyboardModifiers(),
e->orient);
QApplication::sendSpontaneousEvent(mouseWidget, &ev);
}
@@ -802,7 +816,6 @@ void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEven
if (app_do_modal && !qt_try_modal(focusW, e->keyType))
return;
- modifiers = e->modifiers;
QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
QApplication::sendSpontaneousEvent(focusW, &ev);
}
@@ -823,6 +836,10 @@ void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Leave
}
+void QApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
+{
+ QApplication::setActiveWindow(e->activated.data());
+}
void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
{
diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp
index 92b9e83..b8ce60e 100644
--- a/src/gui/kernel/qclipboard_qpa.cpp
+++ b/src/gui/kernel/qclipboard_qpa.cpp
@@ -44,73 +44,16 @@
#ifndef QT_NO_CLIPBOARD
#include "qmimedata.h"
-#include "qapplication.h"
+#include "private/qapplication_p.h"
+#include "qplatformclipboard_qpa.h"
QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
-
-class QClipboardData
-{
-public:
- QClipboardData();
- ~QClipboardData();
-
- void setSource(QMimeData* s)
- {
- if (s == src)
- return;
- delete src;
- src = s;
- }
- QMimeData* source()
- { return src; }
-
- void clear();
-
-private:
- QMimeData* src;
-};
-
-QClipboardData::QClipboardData()
-{
- src = 0;
-}
-
-QClipboardData::~QClipboardData()
-{
- delete src;
-}
-
-void QClipboardData::clear()
-{
- delete src;
- src = 0;
-}
-
-
-static QClipboardData *internalCbData = 0;
-
-static void cleanupClipboardData()
-{
- delete internalCbData;
- internalCbData = 0;
-}
-
-static QClipboardData *clipboardData()
-{
- if (internalCbData == 0) {
- internalCbData = new QClipboardData;
- qAddPostRoutine(cleanupClipboardData);
- }
- return internalCbData;
-}
-
-
void QClipboard::clear(Mode mode)
{
- setText(QString(), mode);
+ setMimeData(0,mode);
}
@@ -121,26 +64,25 @@ bool QClipboard::event(QEvent *e)
const QMimeData* QClipboard::mimeData(Mode mode) const
{
- if (mode != Clipboard) return 0;
-
- QClipboardData *d = clipboardData();
- return d->source();
+ QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return 0;
+ return clipboard->mimeData(mode);
}
void QClipboard::setMimeData(QMimeData* src, Mode mode)
{
- if (mode != Clipboard) return;
-
- QClipboardData *d = clipboardData();
+ QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return;
- d->setSource(src);
+ clipboard->setMimeData(src,mode);
- emitChanged(QClipboard::Clipboard);
+ emitChanged(mode);
}
bool QClipboard::supportsMode(Mode mode) const
{
- return (mode == Clipboard);
+ QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
+ return clipboard->supportsMode(mode);
}
bool QClipboard::ownsMode(Mode mode) const
diff --git a/src/gui/kernel/qdesktopwidget_qpa_p.h b/src/gui/kernel/qdesktopwidget_qpa_p.h
index 8bed09d..47ccca2 100644
--- a/src/gui/kernel/qdesktopwidget_qpa_p.h
+++ b/src/gui/kernel/qdesktopwidget_qpa_p.h
@@ -59,7 +59,13 @@
class QDesktopScreenWidget : public QWidget {
Q_OBJECT
public:
- QDesktopScreenWidget(int screenNumber = -1) { setWindowFlags(Qt::Desktop); setVisible(false); d_func()->screenNumber = screenNumber; }
+ QDesktopScreenWidget(int screenNumber = -1)
+ {
+ setWindowFlags(Qt::Desktop);
+ setVisible(false);
+ QTLWExtra *topData = d_func()->topData();
+ topData->screenIndex = screenNumber;
+ }
};
class QDesktopWidgetPrivate : public QWidgetPrivate {
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index 9a55b18..7543666 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -76,7 +76,7 @@ class QEventLoop;
#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
-class QInternalMimeData : public QMimeData
+class Q_GUI_EXPORT QInternalMimeData : public QMimeData
{
Q_OBJECT
public:
diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/kernel/qplatformclipboard_qpa.cpp
new file mode 100644
index 0000000..fff4e19
--- /dev/null
+++ b/src/gui/kernel/qplatformclipboard_qpa.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qplatformclipboard_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+class QClipboardData
+{
+public:
+ QClipboardData();
+ ~QClipboardData();
+
+ void setSource(QMimeData* s)
+ {
+ if (s == src)
+ return;
+ delete src;
+ src = s;
+ }
+ QMimeData* source()
+ { return src; }
+
+private:
+ QMimeData* src;
+};
+
+QClipboardData::QClipboardData()
+{
+ src = 0;
+}
+
+QClipboardData::~QClipboardData()
+{
+ delete src;
+}
+
+Q_GLOBAL_STATIC(QClipboardData,q_clipboardData);
+
+QPlatformClipboard::~QPlatformClipboard()
+{
+
+}
+
+const QMimeData *QPlatformClipboard::mimeData(QClipboard::Mode mode) const
+{
+ //we know its clipboard
+ Q_UNUSED(mode);
+ return q_clipboardData()->source();
+}
+
+void QPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ //we know its clipboard
+ Q_UNUSED(mode);
+ q_clipboardData()->setSource(data);
+}
+
+bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ return mode == QClipboard::Clipboard;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformclipboard_qpa.h b/src/gui/kernel/qplatformclipboard_qpa.h
new file mode 100644
index 0000000..3f7bfbb
--- /dev/null
+++ b/src/gui/kernel/qplatformclipboard_qpa.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMCLIPBOARD_QPA_H
+#define QPLATFORMCLIPBOARD_QPA_H
+
+#include <qplatformdefs.h>
+
+#include <QtGui/QClipboard>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformClipboard
+{
+public:
+ virtual ~QPlatformClipboard();
+
+ virtual const QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard ) const;
+ virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
+ virtual bool supportsMode(QClipboard::Mode mode) const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif //QPLATFORMCLIPBOARD_QPA_H
diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp
index 14bd718..1673aed 100644
--- a/src/gui/kernel/qplatformglcontext_qpa.cpp
+++ b/src/gui/kernel/qplatformglcontext_qpa.cpp
@@ -138,7 +138,7 @@ void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedConte
Default shared context is intended to be a globally awailable pointer to a context which can
be used for sharing resources when creating new contexts. Its default value is 0;
*/
-const QPlatformGLContext *QPlatformGLContext::defaultSharedContext()
+QPlatformGLContext *QPlatformGLContext::defaultSharedContext()
{
return QPlatformGLContextPrivate::staticSharedContext;
}
diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h
index a70e046..807ed3d 100644
--- a/src/gui/kernel/qplatformglcontext_qpa.h
+++ b/src/gui/kernel/qplatformglcontext_qpa.h
@@ -69,7 +69,7 @@ public:
virtual QPlatformWindowFormat platformWindowFormat() const = 0;
const static QPlatformGLContext *currentContext();
- const static QPlatformGLContext *defaultSharedContext();
+ static QPlatformGLContext *defaultSharedContext();
protected:
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index 9b6e590..0cac57d 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -42,6 +42,7 @@
#include "qplatformintegration_qpa.h"
#include <QtGui/QPlatformFontDatabase>
+#include <QtGui/QPlatformClipboard>
QT_BEGIN_NAMESPACE
@@ -94,6 +95,23 @@ QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
}
/*!
+ Accessor for the platform integrations clipboard.
+
+ Default implementation returns a default QPlatformClipboard.
+
+ \sa QPlatformClipboard
+
+*/
+QPlatformClipboard *QPlatformIntegration::clipboard() const
+{
+ static QPlatformClipboard *clipboard = 0;
+ if (!clipboard) {
+ clipboard = new QPlatformClipboard;
+ }
+ return clipboard;
+}
+
+/*!
\class QPlatformIntegration
\since 4.8
\internal
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index f01b4f4..7050245 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -59,6 +59,7 @@ class QBlittable;
class QWidget;
class QPlatformEventLoopIntegration;
class QPlatformFontDatabase;
+class QPlatformClipboard;
class Q_GUI_EXPORT QPlatformIntegration
{
@@ -76,8 +77,9 @@ public:
virtual bool isVirtualDesktop() { return false; }
virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
-//Fontdatabase integration.
+//Deeper window system integrations
virtual QPlatformFontDatabase *fontDatabase() const;
+ virtual QPlatformClipboard *clipboard() const;
// Experimental in mainthread eventloop integration
// This should only be used if it is only possible to do window system event processing in
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
index 9122e1a..17a130d 100644
--- a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
@@ -52,15 +52,27 @@ QT_BEGIN_NAMESPACE
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif
-QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key)
+QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
{
QPlatformIntegration *ret = 0;
QStringList paramList = key.split(QLatin1Char(':'));
QString platform = paramList.takeFirst().toLower();
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ // Try loading the plugin from platformPluginPath first:
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ if (QPlatformIntegrationFactoryInterface *factory =
+ qobject_cast<QPlatformIntegrationFactoryInterface*>(directLoader()->instance(platform)))
+ ret = factory->create(key, paramList);
+
+ if (ret)
+ return ret;
+ }
if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform)))
ret = factory->create(platform, paramList);
#endif
@@ -74,10 +86,19 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key)
\sa create()
*/
-QStringList QPlatformIntegrationFactory::keys()
+QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
{
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- QStringList list = loader()->keys();
+ QStringList list;
+
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ foreach (const QString &key, directLoader()->keys()) {
+ list += key + QString(QLatin1String(" (from %1)")).arg(platformPluginPath);
+ }
+ }
+
+ list += loader()->keys();
#else
QStringList list;
#endif
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa_p.h b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
index ba02d2c..77e1da1 100644
--- a/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
+++ b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
@@ -66,8 +66,8 @@ class QPlatformIntegration;
class QPlatformIntegrationFactory
{
public:
- static QStringList keys();
- static QPlatformIntegration *create(const QString&);
+ static QStringList keys(const QString &platformPluginPath = QString());
+ static QPlatformIntegration *create(const QString &key, const QString &platformPluginPath = QString());
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
index 5e80ba8..118835f 100644
--- a/src/gui/kernel/qplatformscreen_qpa.cpp
+++ b/src/gui/kernel/qplatformscreen_qpa.cpp
@@ -41,7 +41,11 @@
#include "qplatformscreen_qpa.h"
#include <QtGui/qapplication.h>
+#include <QtGui/private/qapplication_p.h>
#include <QtGui/qdesktopwidget.h>
+#include <QtGui/qplatformintegration_qpa.h>
+#include <QtGui/qwidget.h>
+#include <QtGui/private/qwidget_p.h>
/*!
Return the given top level widget for a given position.
@@ -77,6 +81,17 @@ QSize QPlatformScreen::physicalSize() const
return QSize(width,height);
}
+Q_GUI_EXPORT extern QWidgetPrivate *qt_widget_private(QWidget *widget);
+QPlatformScreen * QPlatformScreen::platformScreenForWidget(const QWidget *widget)
+{
+ QWidget *window = widget->window();
+ QWidgetPrivate *windowPrivate = qt_widget_private(window);
+ QTLWExtra * topData = windowPrivate->topData();
+ QPlatformIntegration *integration =
+ QApplicationPrivate::platformIntegration();
+ return integration->screens()[topData->screenIndex];
+}
+
/*!
\class QPlatformScreen
\since 4.8
diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h
index 9080489..1f52764 100644
--- a/src/gui/kernel/qplatformscreen_qpa.h
+++ b/src/gui/kernel/qplatformscreen_qpa.h
@@ -73,6 +73,10 @@ public:
//jl: should setDirty be removed.
virtual void setDirty(const QRect &) {}
virtual QWidget *topLevelAt(const QPoint &point) const;
+
+ //jl: should this function be in QPlatformIntegration
+ //jl: maybe screenForWidget is a better name?
+ static QPlatformScreen *platformScreenForWidget(const QWidget *widget);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
index 29eaa82..b6b6693 100644
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -41,6 +41,7 @@
#include "qplatformwindow_qpa.h"
+#include <QtGui/qwindowsysteminterface_qpa.h>
#include <QtGui/qwidget.h>
class QPlatformWindowPrivate
@@ -171,6 +172,24 @@ void QPlatformWindow::setOpacity(qreal level)
}
/*!
+ Reimplement to let Qt be able to request activation/focus for a window
+
+ Some window systems will probably not have callbacks for this functionality,
+ and then calling QWindowSystemInterface::handleWindowActivated(QWidget *w)
+ would be sufficient.
+
+ If the window system has some event handling/callbacks then call
+ QWindowSystemInterface::handleWindowActivated(QWidget *w) when the window system
+ gives the notification.
+
+ Default implementation calls QWindowSystem::handleWindowActivated(QWidget *w)
+*/
+void QPlatformWindow::requestActivateWindow()
+{
+ QWindowSystemInterface::handleWindowActivated(widget());
+}
+
+/*!
Reimplement to return the glContext associated with the window.
*/
QPlatformGLContext *QPlatformWindow::glContext() const
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
index 4f6fedc..abc35d1 100644
--- a/src/gui/kernel/qplatformwindow_qpa.h
+++ b/src/gui/kernel/qplatformwindow_qpa.h
@@ -80,6 +80,7 @@ public:
virtual void lower();
virtual void setOpacity(qreal level);
+ virtual void requestActivateWindow();
virtual QPlatformGLContext *glContext() const;
protected:
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index f35afb0..4ba0ef8 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -303,8 +303,6 @@ QWidgetPrivate::QWidgetPrivate(int version)
, hasAlienChildren(0)
, window_event(0)
, qd_hd(0)
-#elif defined (Q_WS_QPA)
- , screenNumber(0)
#endif
{
if (!qApp) {
@@ -1277,7 +1275,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
}
#elif defined(Q_WS_QPA)
if (desktopWidget) {
- int screen = desktopWidget->d_func()->screenNumber;
+ int screen = desktopWidget->d_func()->topData()->screenIndex;
QPlatformIntegration *platform = QApplicationPrivate::platformIntegration();
platform->moveToScreen(q, screen);
}
@@ -1729,6 +1727,7 @@ void QWidgetPrivate::createTLExtra()
#if defined(Q_WS_QPA)
x->platformWindow = 0;
x->platformWindowFormat = QPlatformWindowFormat::defaultFormat();
+ x->screenIndex = 0;
#endif
}
}
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index b5bc5d0..32f827e 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -233,6 +233,7 @@ struct QTLWExtra {
#elif defined(Q_WS_QPA)
QPlatformWindow *platformWindow;
QPlatformWindowFormat platformWindowFormat;
+ quint32 screenIndex; // index in qplatformscreenlist
#endif
};
@@ -887,11 +888,9 @@ public:
void updateCursor() const;
#endif
QScreen* getScreen() const;
-#elif defined(Q_WS_QPA)
+#elif defined(Q_WS_QPA) // <--------------------------------------------------------- QPA
void setMaxWindowState_helper();
void setFullScreenSize_helper();
-
- int screenNumber; // screen the widget should be displayed on
#ifndef QT_NO_CURSOR
void updateCursor() const;
#endif
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp
index 617d984..001810e 100644
--- a/src/gui/kernel/qwidget_qpa.cpp
+++ b/src/gui/kernel/qwidget_qpa.cpp
@@ -53,7 +53,6 @@
#include <QtGui/QPlatformCursor>
QT_BEGIN_NAMESPACE
-static QPlatformScreen *qt_screenForWidget(const QWidget *w);
void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWidget *parentWidget)
{
@@ -122,7 +121,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
}
- QApplicationPrivate::platformIntegration()->moveToScreen(q, screenNumber);
+ QApplicationPrivate::platformIntegration()->moveToScreen(q, topData()->screenIndex);
// qDebug() << "create_sys" << q << q->internalWinId();
}
@@ -163,7 +162,6 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
{
Q_Q(QWidget);
- // QWidget *oldParent = q->parentWidget();
Qt::WindowFlags oldFlags = data.window_flags;
int targetScreen = -1;
@@ -173,7 +171,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
// programmer specified desktop widget
// get the desktop's screen number
- targetScreen = newparent->d_func()->screenNumber;
+ targetScreen = newparent->window()->d_func()->topData()->screenIndex;
newparent = 0;
}
@@ -192,7 +190,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
f |= Qt::Window;
if (targetScreen == -1) {
if (parent)
- targetScreen = qobject_cast<QWidget *>(parent)->d_func()->screenNumber;
+ targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex;
}
}
@@ -215,20 +213,14 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
data.window_flags = window->setWindowFlags(data.window_flags);
}
- // Reparenting child to toplevel
- if ((f&Qt::Window) && !(oldFlags&Qt::Window)) {
- //qDebug() << "setParent_sys() change to toplevel";
- q->create(); //### too early: this ought to happen at show() time
- }
-
-
if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
q->setAttribute(Qt::WA_WState_Hidden);
q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
// move the window to the selected screen
if (!newparent && targetScreen != -1) {
- screenNumber = targetScreen;
+ if (maybeTopData())
+ maybeTopData()->screenIndex = targetScreen;
// only if it is already created
if (q->testAttribute(Qt::WA_WState_Created)) {
QPlatformIntegration *platform = QApplicationPrivate::platformIntegration();
@@ -379,9 +371,8 @@ QWidget *QWidget::keyboardGrabber()
void QWidget::activateWindow()
{
- // XXX
-// qDebug() << "QWidget::activateWindow" << this;
- QApplication::setActiveWindow(this); //#####
+ if (platformWindow())
+ platformWindow()->requestActivateWindow();
}
void QWidgetPrivate::show_sys()
@@ -397,7 +388,11 @@ void QWidgetPrivate::show_sys()
QPlatformWindow *window = q->platformWindow();
if (window) {
- const QRect geomRect = q->geometry();
+ QRect geomRect = q->geometry();
+ if (!q->isWindow()) {
+ QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
+ geomRect.moveTopLeft(topLeftOfWindow);
+ }
const QRect windowRect = window->geometry();
if (windowRect != geomRect) {
window->setGeometry(geomRect);
@@ -409,9 +404,6 @@ void QWidgetPrivate::show_sys()
}
if (window)
window->setVisible(true);
-
- if (q->isWindow() && q->windowType() != Qt::Popup && q->windowType() != Qt::ToolTip && !(q->windowFlags() & Qt::X11BypassWindowManagerHint))
- q->activateWindow(); //### QWindowSystemInterface should have callback function for when WS actually activates window.
}
}
@@ -595,7 +587,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
if (q->isVisible()) {
if (q->platformWindow()) {
if (q->isWindow()) {
- q->platformWindow()->setGeometry(q->frameGeometry());
+ q->platformWindow()->setGeometry(q->geometry());
} else {
QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size()));
@@ -647,37 +639,11 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
scrollRect(r, dx, dy);
}
-static QPlatformScreen *qt_screenForWidget(const QWidget *w)
-{
- if (!w)
- return 0;
- QRect frame = w->frameGeometry();
- if (!w->isWindow())
- frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
- const QPoint p = (frame.topLeft() + frame.bottomRight()) / 2;
-
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
- QList<QPlatformScreen *> screens = pi->screens();
-
- for (int i = 0; i < screens.size(); ++i) {
- if (screens[i]->geometry().contains(p))
- return screens[i];
- }
-
- // Assume screen zero if we have it.
- if (!screens.isEmpty())
- return screens[0];
- else
- qWarning("qt_screenForWidget: no screens");
-
- return 0;
-}
-
int QWidget::metric(PaintDeviceMetric m) const
{
Q_D(const QWidget);
- QPlatformScreen *screen = qt_screenForWidget(this);
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWidget(this);
if (!screen) {
if (m == PdmDpiX || m == PdmDpiY)
return 72;
@@ -798,9 +764,9 @@ void QWidgetPrivate::deleteTLSysExtra()
context->deleteQGLContext();
}
}
+ setWinId(0);
delete extra->topextra->platformWindow;
extra->topextra->platformWindow = 0;
- extra->topextra->backingStore.destroy();
}
}
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
index bb29cbf..b6177b0 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
@@ -82,6 +82,12 @@ void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw)
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
+void QWindowSystemInterface::handleWindowActivated(QWidget *tlw)
+{
+ QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect)
{
if (tlw) {
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h
index 1c79f2a..39c2f79 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.h
@@ -83,6 +83,7 @@ public:
static void handleCloseEvent(QWidget *w);
static void handleEnterEvent(QWidget *w);
static void handleLeaveEvent(QWidget *w);
+ static void handleWindowActivated(QWidget *w);
// Changes to the screen
static void handleScreenGeometryChange(int screenIndex);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
index 78e1f33..3491a1a 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
@@ -54,6 +54,7 @@ public:
GeometryChange,
Enter,
Leave,
+ ActivatedWindow,
Mouse,
Wheel,
Key,
@@ -102,6 +103,14 @@ public:
QWeakPointer<QWidget> leave;
};
+ class ActivatedWindowEvent : public WindowSystemEvent {
+ public:
+ ActivatedWindowEvent(QWidget *activatedWindow)
+ : WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
+ { }
+ QWeakPointer<QWidget> activated;
+ };
+
class UserEvent : public WindowSystemEvent {
public:
UserEvent(QWidget * w, ulong time, EventType t)
diff --git a/src/gui/text/qfont_qpa.cpp b/src/gui/text/qfont_qpa.cpp
index 5fed18b..7b09b59 100644
--- a/src/gui/text/qfont_qpa.cpp
+++ b/src/gui/text/qfont_qpa.cpp
@@ -90,7 +90,7 @@ QString QFont::defaultFamily() const
familyName = QString::fromLatin1("helvetica");
}
- QStringList list = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(familyName,QFont::StyleNormal,QUnicodeTables::Common);
+ QStringList list = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(familyName,QFont::StyleNormal,QFont::StyleHint(d->request.styleHint),QUnicodeTables::Common);
if (list.size()) {
familyName = list.at(0);
}
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index e54093c..e6d99c6 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -80,9 +80,9 @@ Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &fou
size->handle = handle;
}
-static QStringList fallbackFamilies(const QString &family, const QFont::Style &style, const QUnicodeTables::Script &script)
+static QStringList fallbackFamilies(const QString &family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script)
{
- QStringList retList = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,script);
+ QStringList retList = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
QFontDatabasePrivate *db = privateDb();
QStringList::iterator i;
@@ -177,7 +177,11 @@ QFontEngine *loadEngine(int script, const QFontDef &request,
&& !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol ) {
if (family && !family->askedForFallback) {
- family->fallbackFamilies = fallbackFamilies(family->name,QFont::Style(style->key.style),QUnicodeTables::Script(script));
+ QFont::Style fontStyle = QFont::Style(style->key.style);
+ QFont::StyleHint styleHint = QFont::StyleHint(request.styleHint);
+ if (styleHint == QFont::AnyStyle && request.fixedPitch)
+ styleHint = QFont::TypeWriter;
+ family->fallbackFamilies = fallbackFamilies(family->name,fontStyle,styleHint,QUnicodeTables::Script(script));
family->askedForFallback = true;
}
@@ -287,7 +291,7 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp,
if (!engine) {
if (!request.family.isEmpty()) {
- QStringList fallbacks = fallbackFamilies(request.family,QFont::Style(request.style),QUnicodeTables::Script(script));
+ QStringList fallbacks = fallbackFamilies(request.family,QFont::Style(request.style),QFont::StyleHint(request.styleHint),QUnicodeTables::Script(script));
for (int i = 0; i < fallbacks.size(); i++) {
QFontDef def = request;
def.family = fallbacks.at(i);
diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp
index d6dff41..afe762a 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.cpp
+++ b/src/gui/text/qplatformfontdatabase_qpa.cpp
@@ -221,10 +221,11 @@ QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicode
/*!
*/
-QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const
+QStringList QPlatformFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
{
Q_UNUSED(family);
Q_UNUSED(style);
+ Q_UNUSED(styleHint);
Q_UNUSED(script);
return QStringList();
}
diff --git a/src/gui/text/qplatformfontdatabase_qpa.h b/src/gui/text/qplatformfontdatabase_qpa.h
index aa465ab..a1faea9 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.h
+++ b/src/gui/text/qplatformfontdatabase_qpa.h
@@ -88,7 +88,7 @@ class Q_GUI_EXPORT QPlatformFontDatabase
public:
virtual void populateFontDatabase();
virtual QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
- virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const;
+ virtual QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
virtual QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName);
virtual void releaseHandle(void *handle);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index fe8554f..2e21fbd 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -337,7 +337,13 @@ void QGL2PaintEngineExPrivate::updateBrushUniforms()
matrix.translate(brushOrigin.x(), brushOrigin.y());
QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y());
- QTransform gl_to_qt(1, 0, 0, -1, 0, height);
+ qreal m22 = -1;
+ qreal dy = height;
+ if (device->isFlipped()) {
+ m22 = 1;
+ dy = 0;
+ }
+ QTransform gl_to_qt(1, 0, 0, m22, 0, dy);
QTransform inv_matrix;
if (style == Qt::TexturePattern && textureInvertedY == -1)
inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate;
@@ -376,10 +382,16 @@ void QGL2PaintEngineExPrivate::updateMatrix()
// NOTE: The resultant matrix is also transposed, as GL expects column-major matracies
const GLfloat wfactor = 2.0f / width;
- const GLfloat hfactor = -2.0f / height;
+ GLfloat hfactor = -2.0f / height;
+
GLfloat dx = transform.dx();
GLfloat dy = transform.dy();
+ if (device->isFlipped()) {
+ hfactor *= -1;
+ dy -= height;
+ }
+
// Non-integer translates can have strange effects for some rendering operations such as
// anti-aliased text rendering. In such cases, we snap the translate to the pixel grid.
if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
@@ -2063,7 +2075,10 @@ void QGL2PaintEngineExPrivate::setScissor(const QRect &rect)
{
const int left = rect.left();
const int width = rect.width();
- const int bottom = height - (rect.top() + rect.height());
+ int bottom = height - (rect.top() + rect.height());
+ if (device->isFlipped()) {
+ bottom = rect.top();
+ }
const int height = rect.height();
glScissor(left, bottom, width, height);
diff --git a/src/opengl/opengl.pro.user.2.1pre1 b/src/opengl/opengl.pro.user.2.1pre1
new file mode 100644
index 0000000..0c38724
--- /dev/null
+++ b/src/opengl/opengl.pro.user.2.1pre1
@@ -0,0 +1,83 @@
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value key="EditorConfiguration.Codec" type="QByteArray">UTF-8</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
+ <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList">
+ <value type="QString">QMAKE_ABSOLUTE_SOURCE_PATH=/home/jlind/dev/qt/lighthouse-master/src/opengl</value>
+ </valuelist>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">-j9</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/jlind/builds/master-lighthouse/src/opengl</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">23</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">1</value>
+ <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">headers</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">../../../../../builds/master-lighthouse/include/QtOpenGL/headers.pri</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">4</value>
+ </data>
+</qtcreator>
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index be2da4a..0ec3a15 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -3772,24 +3772,7 @@ QGLWidget::QGLWidget(QWidget *parent, const QGLWidget* shareWidget, Qt::WindowFl
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
setAutoFillBackground(true); // for compatibility
-#ifdef Q_WS_QPA
- QPlatformWindowFormat platformFormat = QGLFormat::toPlatformWindowFormat(QGLFormat::defaultFormat());
- platformFormat.setUseDefaultSharedContext(false);
- if (shareWidget && shareWidget->d_func()->glcx) {
- QPlatformGLContext *sharedPlatformContext = shareWidget->d_func()->glcx->d_func()->platformContext;
- platformFormat.setSharedContext(sharedPlatformContext);
- }
- setPlatformWindowFormat(platformFormat);
- winId(); // create window;
- QGLContext *glContext = 0;
- if (platformWindow())
- glContext = QGLContext::fromPlatformGLContext(platformWindow()->glContext());
- if (glContext){
- d->init(glContext,shareWidget);
- }
-#else
d->init(new QGLContext(QGLFormat::defaultFormat(), this), shareWidget);
-#endif
}
@@ -3829,24 +3812,7 @@ QGLWidget::QGLWidget(const QGLFormat &format, QWidget *parent, const QGLWidget*
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
setAutoFillBackground(true); // for compatibility
-#ifdef Q_WS_QPA
- QPlatformWindowFormat platformFormat = QGLFormat::toPlatformWindowFormat(format);
- platformFormat.setUseDefaultSharedContext(false);
- if (shareWidget && shareWidget->d_func()->glcx) {
- QPlatformGLContext *sharedPlatformContext = shareWidget->d_func()->glcx->d_func()->platformContext;
- platformFormat.setSharedContext(sharedPlatformContext);
- }
- setPlatformWindowFormat(platformFormat);
- winId(); // create window;
- QGLContext *glContext = 0;
- if (platformWindow())
- glContext = QGLContext::fromPlatformGLContext(platformWindow()->glContext());
- if (glContext){
- d->init(glContext,shareWidget);
- }
-#else
d->init(new QGLContext(format, this), shareWidget);
-#endif
}
/*!
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 204abe8..5508598 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -373,6 +373,7 @@ public:
#if defined(Q_WS_QPA)
QPlatformGLContext *platformContext;
+ void setupSharing();
#elif defined(Q_WS_X11) || defined(Q_WS_MAC)
void* cx;
#endif
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 415e915..0f4b305 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -115,6 +115,16 @@ QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
return retFormat;
}
+void QGLContextPrivate::setupSharing() {
+ Q_Q(QGLContext);
+ QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext();
+ if (sharedPlatformGLContext) {
+ QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
+ sharing = true;
+ QGLContextGroup::addShare(q,actualSharedContext);
+ }
+}
+
bool QGLFormat::hasOpenGL()
{
return QApplicationPrivate::platformIntegration()->hasOpenGL();
@@ -151,19 +161,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
if (d->valid) {
d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
}
+ d->setupSharing();
}
- if (d->valid) {
- QPlatformGLContext *sharedPlatformGLContext = d->platformContext->platformWindowFormat().sharedGLContext();
- if (sharedPlatformGLContext) {
- QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
- if (actualSharedContext == shareContext) {
- d->sharing = true;//Will add combination in QGLContext::create
- }else {
- QGLContextGroup::addShare(this,actualSharedContext);
- }
- }
- }
return d->valid;
}
@@ -325,11 +325,6 @@ void QGLWidget::setMouseTracking(bool enable)
bool QGLWidget::event(QEvent *e)
{
Q_D(QGLWidget);
- if (e->type() == QEvent::WinIdChange) {
- if (platformWindow()) {
- d->glcx = QGLContext::fromPlatformGLContext(platformWindow()->glContext());
- }
- }
return QWidget::event(e);
}
@@ -377,6 +372,9 @@ QGLContext::QGLContext(QPlatformGLContext *platformContext)
Q_D(QGLContext);
d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()));
d->platformContext = platformContext;
+ d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->valid = true;
+ d->setupSharing();
}
QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext)
@@ -389,11 +387,6 @@ QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContex
QGLContext *glContext = new QGLContext(platformContext);
//Dont call create on context. This can cause the platformFormat to be set on the widget, which
//will cause the platformWindow to be recreated.
- glContext->d_func()->platformContext->setQGLContextHandle(glContext,qDeleteQGLContext);
- QGLFormat format = QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat());
- glContext->d_func()->glFormat = format;
- glContext->d_func()->valid = true;
-
return glContext;
}
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index ae61ca1..7d0eb5b 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -145,8 +145,10 @@ bool QGLPaintDevice::alphaRequested() const
return context()->d_func()->reqFormat.alpha();
}
-
-
+bool QGLPaintDevice::isFlipped() const
+{
+ return false;
+}
////////////////// QGLWidgetGLPaintDevice //////////////////
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index f90edf4..f4176fb 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -76,6 +76,7 @@ public:
virtual QGLFormat format() const;
virtual QSize size() const = 0;
virtual bool alphaRequested() const;
+ virtual bool isFlipped() const;
// returns the QGLPaintDevice for the given QPaintDevice
static QGLPaintDevice* getDevice(QPaintDevice*);
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 8b54368..5a783ca 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -402,11 +402,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
if (widgetPrivate->extraData()->glContext)
return;
-#ifdef Q_WS_QPA
- QGLContext *ctx = QGLContext::fromPlatformGLContext(widget->platformWindow()->glContext());
- if (!d_ptr->fbo && d_ptr->tried_fbo)
- d_ptr->ctx = ctx;
-#else
QGLContext *ctx = NULL;
// For translucent top-level widgets we need alpha in the format.
@@ -419,8 +414,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
} else
ctx = new QGLContext(surfaceFormat, widget);
- ctx->create(qt_gl_share_widget()->context());
-#endif
+ ctx->create(qt_gl_share_context());
#ifndef QT_NO_EGL
static bool checkedForNOKSwapRegion = false;
@@ -480,6 +474,8 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize,
void QGLWindowSurface::beginPaint(const QRegion &)
{
+ d_ptr->did_paint = true;
+
if (!context())
return;
@@ -494,8 +490,6 @@ void QGLWindowSurface::beginPaint(const QRegion &)
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(clearFlags);
}
-
- d_ptr->did_paint = true;
}
void QGLWindowSurface::endPaint(const QRegion &rgn)
diff --git a/src/plugins/phonon/gstreamer/gstreamer.pro b/src/plugins/phonon/gstreamer/gstreamer.pro
index 02e0848..c0d2604 100644
--- a/src/plugins/phonon/gstreamer/gstreamer.pro
+++ b/src/plugins/phonon/gstreamer/gstreamer.pro
@@ -58,7 +58,7 @@ SOURCES += $$PHONON_GSTREAMER_DIR/abstractrenderer.cpp \
$$PHONON_GSTREAMER_DIR/volumefadereffect.cpp \
$$PHONON_GSTREAMER_DIR/widgetrenderer.cpp
-x11 {
+!qpa:!embedded{
HEADERS += $$PHONON_GSTREAMER_DIR/x11renderer.h
SOURCES += $$PHONON_GSTREAMER_DIR/x11renderer.cpp
}
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
index b203fe8..1612f79 100644
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
@@ -313,4 +313,12 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con
return format;
}
+bool q_hasEglExtension(EGLDisplay display, const char* extensionName)
+{
+ QList<QByteArray> extensions =
+ QByteArray(reinterpret_cast<const char *>
+ (eglQueryString(display, EGL_EXTENSIONS))).split(' ');
+ return extensions.contains(extensionName);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h
index 604262b..98c30b8 100644
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.h
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h
@@ -53,6 +53,7 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &
bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes);
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format);
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config);
+bool q_hasEglExtension(EGLDisplay display,const char* extensionName);
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
index d0e15d3..b5b7e05 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -62,6 +62,9 @@ void QEglFSWindow::setGeometry(const QRect &)
QRect rect(m_screen->availableGeometry());
QWindowSystemInterface::handleGeometryChange(this->widget(), rect);
+ // Since toplevels are fullscreen, propegate the screen size back to the widget
+ widget()->setGeometry(rect);
+
QPlatformWindow::setGeometry(rect);
}
diff --git a/src/plugins/platforms/externalplugin.pri b/src/plugins/platforms/externalplugin.pri
new file mode 100644
index 0000000..54da4d9
--- /dev/null
+++ b/src/plugins/platforms/externalplugin.pri
@@ -0,0 +1,29 @@
+#
+# Lighthouse now has preliminarily support for building and
+# loading platform plugins from outside the Qt source/build
+# tree.
+#
+# 1) Building external plugins:
+# Set QTDIR to the Qt build directory, copy this file to
+# the plugin source repository and include it at the top
+# of the plugin's pro file. Use QT_SOURCE_TREE if you
+# want to pull in source code from Qt:
+#
+# include($$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri)
+#
+# 2) Loading external plugins:
+# Specify the path to the directory containing the
+# plugin on the command line, in addition to the
+# platform name.
+#
+# ./wiggly -platformPluginPath /path/to/myPlugin -platform gullfaksA
+#
+
+!exists($$(QTDIR)/.qmake.cache) {
+ error("Please set QTDIR to the Qt build directory")
+}
+
+QT_SOURCE_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_SOURCE_TREE)
+QT_BUILD_TREE = $$fromfile($$(QTDIR)/.qmake.cache,QT_BUILD_TREE)
+
+include($$QT_SOURCE_TREE/src/plugins/qpluginbase.pri)
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 92f30fc..9b9be07 100644
--- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -274,6 +274,25 @@ static const char *openType[] = {
"nko " // N'Ko
};
+static const char *getFcFamilyForStyleHint(const QFont::StyleHint style)
+{
+ const char *stylehint = 0;
+ switch (style) {
+ case QFont::SansSerif:
+ stylehint = "sans-serif";
+ break;
+ case QFont::Serif:
+ stylehint = "serif";
+ break;
+ case QFont::TypeWriter:
+ stylehint = "monospace";
+ break;
+ default:
+ break;
+ }
+ return stylehint;
+}
+
void QFontconfigDatabase::populateFontDatabase()
{
FcFontSet *fonts;
@@ -522,7 +541,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::
return engine;
}
-QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const
+QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const
{
QStringList fallbackFamilies;
FcPattern *pattern = FcPatternCreate();
@@ -550,6 +569,12 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const
FcLangSetDestroy(ls);
}
+ const char *stylehint = getFcFamilyForStyleHint(styleHint);
+ if (stylehint) {
+ value.u.s = (const FcChar8 *)stylehint;
+ FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue);
+ }
+
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcConfigSubstitute(0, pattern, FcMatchFont);
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
index 33382dc..cf62b88 100644
--- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
+++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.h
@@ -50,7 +50,7 @@ class QFontconfigDatabase : public QBasicUnixFontDatabase
public:
void populateFontDatabase();
QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle);
- QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QUnicodeTables::Script &script) const;
+ QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const;
};
#endif // QFONTCONFIGDATABASE_H
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
index 26ccd44..57015e7 100644
--- a/src/plugins/platforms/platforms.pro
+++ b/src/plugins/platforms/platforms.pro
@@ -2,3 +2,7 @@ TEMPLATE = subdirs
SUBDIRS += minimal
+contains(QT_CONFIG, wayland) {
+ SUBDIRS += wayland
+}
+
diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp
index a4b7b69..8023014 100644
--- a/src/plugins/platforms/testlite/qglxintegration.cpp
+++ b/src/plugins/platforms/testlite/qglxintegration.cpp
@@ -44,7 +44,9 @@
#include <QGLFormat>
#include "qtestlitewindow.h"
+#include "qtestlitescreen.h"
+#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/glx.h>
@@ -57,9 +59,9 @@
QT_BEGIN_NAMESPACE
-QMutex QGLXGLContext::m_defaultSharedContextMutex(QMutex::Recursive);
+QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive);
-QVector<int> QGLXGLContext::buildSpec(const QPlatformWindowFormat &format)
+QVector<int> QGLXContext::buildSpec(const QPlatformWindowFormat &format)
{
QVector<int> spec(48);
int i = 0;
@@ -111,7 +113,7 @@ QVector<int> QGLXGLContext::buildSpec(const QPlatformWindowFormat &format)
return spec;
}
-GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindowFormat &format)
+GLXFBConfig QGLXContext::findConfig(const QTestLiteScreen *screen, const QPlatformWindowFormat &format)
{
bool reduced = true;
GLXFBConfig chosenConfig = 0;
@@ -120,7 +122,7 @@ GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindow
QVector<int> spec = buildSpec(reducedFormat);
int confcount = 0;
GLXFBConfig *configs;
- configs = glXChooseFBConfig(xd->display,xd->screen,spec.constData(),&confcount);
+ configs = glXChooseFBConfig(screen->display(),screen->xScreenNumber(),spec.constData(),&confcount);
if (confcount)
{
for (int i = 0; i < confcount; i++) {
@@ -128,7 +130,7 @@ GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindow
// Make sure we try to get an ARGB visual if the format asked for an alpha:
if (reducedFormat.alpha()) {
int alphaSize;
- glXGetFBConfigAttrib(xd->display,configs[i],GLX_ALPHA_SIZE,&alphaSize);
+ glXGetFBConfigAttrib(screen->display(),configs[i],GLX_ALPHA_SIZE,&alphaSize);
if (alphaSize > 0)
break;
} else {
@@ -147,14 +149,14 @@ GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindow
return chosenConfig;
}
-XVisualInfo *QGLXGLContext::findVisualInfo(const MyDisplay *xd, const QPlatformWindowFormat &format)
+XVisualInfo *QGLXContext::findVisualInfo(const QTestLiteScreen *screen, const QPlatformWindowFormat &format)
{
- GLXFBConfig config = QGLXGLContext::findConfig(xd,format);
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(xd->display,config);
+ GLXFBConfig config = QGLXContext::findConfig(screen,format);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display(),config);
return visualInfo;
}
-QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
+QPlatformWindowFormat QGLXContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
{
QPlatformWindowFormat format;
int redSize = 0;
@@ -210,7 +212,7 @@ QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *disp
return format;
}
-QPlatformWindowFormat QGLXGLContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
+QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
{
QPlatformWindowFormat retFormat = format;
*reduced = true;
@@ -235,9 +237,9 @@ QPlatformWindowFormat QGLXGLContext::reducePlatformWindowFormat(const QPlatformW
return retFormat;
}
-QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format)
+QGLXContext::QGLXContext(Window window, QTestLiteScreen *screen, const QPlatformWindowFormat &format)
: QPlatformGLContext()
- , m_xd(xd)
+ , m_screen(screen)
, m_drawable((Drawable)window)
, m_context(0)
{
@@ -246,7 +248,7 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow
if (format.useDefaultSharedContext()) {
if (!QPlatformGLContext::defaultSharedContext()) {
if (m_defaultSharedContextMutex.tryLock()){
- createDefaultSharedContex(xd);
+ createDefaultSharedContex(screen);
m_defaultSharedContextMutex.unlock();
} else {
m_defaultSharedContextMutex.lock(); //wait to the the shared context is created
@@ -259,32 +261,32 @@ QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindow
}
GLXContext shareGlxContext = 0;
if (sharePlatformContext)
- shareGlxContext = static_cast<const QGLXGLContext*>(sharePlatformContext)->glxContext();
+ shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
- GLXFBConfig config = findConfig(xd,format);
- m_context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,shareGlxContext,TRUE);
- m_windowFormat = QGLXGLContext::platformWindowFromGLXFBConfig(xd->display,config,m_context);
+ GLXFBConfig config = findConfig(screen,format);
+ m_context = glXCreateNewContext(screen->display(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE);
+ m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(screen->display(),config,m_context);
#ifdef MYX11_DEBUG
qDebug() << "QGLXGLContext::create context" << m_context;
#endif
}
-QGLXGLContext::QGLXGLContext(MyDisplay *display, Drawable drawable, GLXContext context)
- : QPlatformGLContext(), m_xd(display), m_drawable(drawable), m_context(context)
+QGLXContext::QGLXContext(QTestLiteScreen *screen, Drawable drawable, GLXContext context)
+ : QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
{
}
-QGLXGLContext::~QGLXGLContext()
+QGLXContext::~QGLXContext()
{
if (m_context) {
qDebug("Destroying GLX context 0x%p", m_context);
- glXDestroyContext(m_xd->display, m_context);
+ glXDestroyContext(m_screen->display(), m_context);
}
}
-void QGLXGLContext::createDefaultSharedContex(MyDisplay *xd)
+void QGLXContext::createDefaultSharedContex(QTestLiteScreen *screen)
{
int x = 0;
int y = 0;
@@ -293,45 +295,45 @@ void QGLXGLContext::createDefaultSharedContex(MyDisplay *xd)
QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat();
GLXContext context;
- GLXFBConfig config = findConfig(xd,format);
+ GLXFBConfig config = findConfig(screen,format);
if (config) {
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(xd->display,config);
- Colormap cmap = XCreateColormap(xd->display,xd->rootWindow(),visualInfo->visual,AllocNone);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display(),config);
+ Colormap cmap = XCreateColormap(screen->display(),screen->rootWindow(),visualInfo->visual,AllocNone);
XSetWindowAttributes a;
a.colormap = cmap;
- Window sharedWindow = XCreateWindow(xd->display, xd->rootWindow(),x, y, w, h,
+ Window sharedWindow = XCreateWindow(screen->display(), screen->rootWindow(),x, y, w, h,
0, visualInfo->depth, InputOutput, visualInfo->visual,
CWColormap, &a);
- context = glXCreateNewContext(xd->display,config,GLX_RGBA_TYPE,0,TRUE);
- QPlatformGLContext *sharedContext = new QGLXGLContext(xd,sharedWindow,context);
+ context = glXCreateNewContext(screen->display(),config,GLX_RGBA_TYPE,0,TRUE);
+ QPlatformGLContext *sharedContext = new QGLXContext(screen,sharedWindow,context);
QPlatformGLContext::setDefaultSharedContext(sharedContext);
} else {
qWarning("Warning no shared context created");
}
}
-void QGLXGLContext::makeCurrent()
+void QGLXContext::makeCurrent()
{
QPlatformGLContext::makeCurrent();
#ifdef MYX11_DEBUG
qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", m_drawable, m_context);
#endif
- glXMakeCurrent(m_xd->display, m_drawable, m_context);
+ glXMakeCurrent(m_screen->display(), m_drawable, m_context);
}
-void QGLXGLContext::doneCurrent()
+void QGLXContext::doneCurrent()
{
QPlatformGLContext::doneCurrent();
- glXMakeCurrent(m_xd->display, 0, 0);
+ glXMakeCurrent(m_screen->display(), 0, 0);
}
-void QGLXGLContext::swapBuffers()
+void QGLXContext::swapBuffers()
{
- glXSwapBuffers(m_xd->display, m_drawable);
+ glXSwapBuffers(m_screen->display(), m_drawable);
}
-void* QGLXGLContext::getProcAddress(const QString& procName)
+void* QGLXContext::getProcAddress(const QString& procName)
{
typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *);
static qt_glXGetProcAddressARB glXGetProcAddressARB = 0;
@@ -340,7 +342,7 @@ void* QGLXGLContext::getProcAddress(const QString& procName)
if (resolved && !glXGetProcAddressARB)
return 0;
if (!glXGetProcAddressARB) {
- QList<QByteArray> glxExt = QByteArray(glXGetClientString(m_xd->display, GLX_EXTENSIONS)).split(' ');
+ QList<QByteArray> glxExt = QByteArray(glXGetClientString(m_screen->display(), GLX_EXTENSIONS)).split(' ');
if (glxExt.contains("GLX_ARB_get_proc_address")) {
#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
void *handle = dlopen(NULL, RTLD_LAZY);
@@ -364,9 +366,11 @@ void* QGLXGLContext::getProcAddress(const QString& procName)
return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
}
-QPlatformWindowFormat QGLXGLContext::platformWindowFormat() const
+QPlatformWindowFormat QGLXContext::platformWindowFormat() const
{
return m_windowFormat;
}
QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h
index e17790e..abece45 100644
--- a/src/plugins/platforms/testlite/qglxintegration.h
+++ b/src/plugins/platforms/testlite/qglxintegration.h
@@ -49,17 +49,16 @@
#include <QtCore/QMutex>
+#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
#include <GL/glx.h>
QT_BEGIN_NAMESPACE
-class MyDisplay;
-
-class QGLXGLContext : public QPlatformGLContext
+class QGLXContext : public QPlatformGLContext
{
public:
- QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format);
- ~QGLXGLContext();
+ QGLXContext(Window window, QTestLiteScreen *xd, const QPlatformWindowFormat &format);
+ ~QGLXContext();
virtual void makeCurrent();
virtual void doneCurrent();
@@ -70,24 +69,26 @@ public:
QPlatformWindowFormat platformWindowFormat() const;
- static XVisualInfo *findVisualInfo(const MyDisplay *xd, const QPlatformWindowFormat &format);
+ static XVisualInfo *findVisualInfo(const QTestLiteScreen *xd, const QPlatformWindowFormat &format);
private:
- static GLXFBConfig findConfig(const MyDisplay *xd,const QPlatformWindowFormat &format);
+ static GLXFBConfig findConfig(const QTestLiteScreen *xd,const QPlatformWindowFormat &format);
static QVector<int> buildSpec(const QPlatformWindowFormat &format);
static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced);
- MyDisplay *m_xd;
+ QTestLiteScreen *m_screen;
Drawable m_drawable;
GLXContext m_context;
QPlatformWindowFormat m_windowFormat;
- QGLXGLContext (MyDisplay *display, Drawable drawable, GLXContext context);
+ QGLXContext (QTestLiteScreen *screen, Drawable drawable, GLXContext context);
static QMutex m_defaultSharedContextMutex;
- static void createDefaultSharedContex(MyDisplay *xd);
+ static void createDefaultSharedContex(QTestLiteScreen *xd);
};
QT_END_NAMESPACE
+#endif //!defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
+
#endif
diff --git a/src/plugins/platforms/testlite/qtestliteclipboard.cpp b/src/plugins/platforms/testlite/qtestliteclipboard.cpp
new file mode 100644
index 0000000..9bab7f9
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestliteclipboard.cpp
@@ -0,0 +1,676 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtestliteclipboard.h"
+
+#include "qtestlitescreen.h"
+#include "qtestlitemime.h"
+
+#include <private/qapplication_p.h>
+
+#include <QtCore/QDebug>
+
+class QTestLiteClipboardMime : public QTestLiteMime
+{
+ Q_OBJECT
+public:
+ QTestLiteClipboardMime(QClipboard::Mode mode, QTestLiteClipboard *clipboard)
+ : QTestLiteMime()
+ , m_clipboard(clipboard)
+ {
+ switch (mode) {
+ case QClipboard::Selection:
+ modeAtom = XA_PRIMARY;
+ break;
+
+ case QClipboard::Clipboard:
+ modeAtom = QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD);
+ break;
+
+ default:
+ qWarning("QTestLiteMime: Internal error: Unsupported clipboard mode");
+ break;
+ }
+ }
+
+protected:
+ QStringList formats_sys() const
+ {
+ if (empty())
+ return QStringList();
+
+ if (!formatList.count()) {
+ QTestLiteClipboardMime *that = const_cast<QTestLiteClipboardMime *>(this);
+ // get the list of targets from the current clipboard owner - we do this
+ // once so that multiple calls to this function don't require multiple
+ // server round trips...
+ that->format_atoms = m_clipboard->getDataInFormat(modeAtom,QTestLiteStatic::atom(QTestLiteStatic::TARGETS));
+
+ if (format_atoms.size() > 0) {
+ Atom *targets = (Atom *) format_atoms.data();
+ int size = format_atoms.size() / sizeof(Atom);
+
+ for (int i = 0; i < size; ++i) {
+ if (targets[i] == 0)
+ continue;
+
+ QStringList formatsForAtom = mimeFormatsForAtom(m_clipboard->screen()->display(),targets[i]);
+ for (int j = 0; j < formatsForAtom.size(); ++j) {
+ if (!formatList.contains(formatsForAtom.at(j)))
+ that->formatList.append(formatsForAtom.at(j));
+ }
+ }
+ }
+ }
+
+ return formatList;
+ }
+
+ bool hasFormat_sys(const QString &format) const
+ {
+ QStringList list = formats();
+ return list.contains(format);
+ }
+
+ QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const
+ {
+ if (fmt.isEmpty() || empty())
+ return QByteArray();
+
+ (void)formats(); // trigger update of format list
+
+ QList<Atom> atoms;
+ Atom *targets = (Atom *) format_atoms.data();
+ int size = format_atoms.size() / sizeof(Atom);
+ for (int i = 0; i < size; ++i)
+ atoms.append(targets[i]);
+
+ QByteArray encoding;
+ Atom fmtatom = mimeAtomForFormat(m_clipboard->screen()->display(),fmt, requestedType, atoms, &encoding);
+
+ if (fmtatom == 0)
+ return QVariant();
+
+ return mimeConvertToFormat(m_clipboard->screen()->display(),fmtatom, m_clipboard->getDataInFormat(modeAtom,fmtatom), fmt, requestedType, encoding);
+ }
+private:
+ bool empty() const
+ {
+ Window win = XGetSelectionOwner(m_clipboard->screen()->display(), modeAtom);
+
+ return win == XNone;
+ }
+
+
+ Atom modeAtom;
+ QTestLiteClipboard *m_clipboard;
+ QStringList formatList;
+ QByteArray format_atoms;
+};
+
+const int QTestLiteClipboard::clipboard_timeout = 5000;
+
+QTestLiteClipboard::QTestLiteClipboard(QTestLiteScreen *screen)
+ : QPlatformClipboard()
+ , m_screen(screen)
+ , m_xClipboard(0)
+ , m_clientClipboard(0)
+ , m_xSelection(0)
+ , m_clientSelection(0)
+ , m_requestor(XNone)
+ , m_owner(XNone)
+{
+}
+
+const QMimeData * QTestLiteClipboard::mimeData(QClipboard::Mode mode) const
+{
+ if (mode == QClipboard::Clipboard) {
+ if (!m_xClipboard) {
+ QTestLiteClipboard *that = const_cast<QTestLiteClipboard *>(this);
+ that->m_xClipboard = new QTestLiteClipboardMime(mode,that);
+ }
+ Window clipboardOwner = XGetSelectionOwner(screen()->display(),QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD));
+ if (clipboardOwner == owner()) {
+ return m_clientClipboard;
+ } else {
+ return m_xClipboard;
+ }
+ } else if (mode == QClipboard::Selection) {
+ if (!m_xSelection) {
+ QTestLiteClipboard *that = const_cast<QTestLiteClipboard *>(this);
+ that->m_xSelection = new QTestLiteClipboardMime(mode,that);
+ }
+ Window clipboardOwner = XGetSelectionOwner(screen()->display(),XA_PRIMARY);
+ if (clipboardOwner == owner()) {
+ return m_clientSelection;
+ } else {
+ return m_xSelection;
+ }
+ }
+ return 0;
+}
+
+void QTestLiteClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ Atom modeAtom;
+ QMimeData **d;
+ switch (mode) {
+ case QClipboard::Selection:
+ modeAtom = XA_PRIMARY;
+ d = &m_clientSelection;
+ break;
+
+ case QClipboard::Clipboard:
+ modeAtom = QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD);
+ d = &m_clientClipboard;
+ break;
+
+ default:
+ qWarning("QClipboard::setMimeData: unsupported mode '%d'", mode);
+ return;
+ }
+
+ Window newOwner;
+
+ if (! data) { // no data, clear clipboard contents
+ newOwner = XNone;
+ } else {
+ newOwner = owner();
+
+ *d = data;
+ }
+
+ XSetSelectionOwner(m_screen->display(), modeAtom, newOwner, CurrentTime);
+
+ if (XGetSelectionOwner(m_screen->display(), modeAtom) != newOwner) {
+ qWarning("QClipboard::setData: Cannot set X11 selection owner");
+ }
+
+}
+
+bool QTestLiteClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ if (mode == QClipboard::Clipboard || mode == QClipboard::Selection)
+ return true;
+ return false;
+}
+
+
+QTestLiteScreen * QTestLiteClipboard::screen() const
+{
+ return m_screen;
+}
+
+Window QTestLiteClipboard::requestor() const
+{
+ if (!m_requestor) {
+ int x = 0, y = 0, w = 3, h = 3;
+ QTestLiteClipboard *that = const_cast<QTestLiteClipboard *>(this);
+ Window window = XCreateSimpleWindow(m_screen->display(), m_screen->rootWindow(),
+ x, y, w, h, 0 /*border_width*/,
+ m_screen->blackPixel(), m_screen->whitePixel());
+ that->setRequestor(window);
+ }
+ return m_requestor;
+}
+
+void QTestLiteClipboard::setRequestor(Window window)
+{
+ if (m_requestor != XNone) {
+ XDestroyWindow(m_screen->display(),m_requestor);
+ }
+ m_requestor = window;
+}
+
+Window QTestLiteClipboard::owner() const
+{
+ if (!m_owner) {
+ int x = 0, y = 0, w = 3, h = 3;
+ QTestLiteClipboard *that = const_cast<QTestLiteClipboard *>(this);
+ Window window = XCreateSimpleWindow(m_screen->display(), m_screen->rootWindow(),
+ x, y, w, h, 0 /*border_width*/,
+ m_screen->blackPixel(), m_screen->whitePixel());
+ that->setOwner(window);
+ }
+ return m_owner;
+}
+
+void QTestLiteClipboard::setOwner(Window window)
+{
+ if (m_owner != XNone){
+ XDestroyWindow(m_screen->display(),m_owner);
+ }
+ m_owner = window;
+}
+
+Atom QTestLiteClipboard::sendTargetsSelection(QMimeData *d, Window window, Atom property)
+{
+ QVector<Atom> types;
+ QStringList formats = QInternalMimeData::formatsHelper(d);
+ for (int i = 0; i < formats.size(); ++i) {
+ QList<Atom> atoms = QTestLiteMime::mimeAtomsForFormat(screen()->display(),formats.at(i));
+ for (int j = 0; j < atoms.size(); ++j) {
+ if (!types.contains(atoms.at(j)))
+ types.append(atoms.at(j));
+ }
+ }
+ types.append(QTestLiteStatic::atom(QTestLiteStatic::TARGETS));
+ types.append(QTestLiteStatic::atom(QTestLiteStatic::MULTIPLE));
+ types.append(QTestLiteStatic::atom(QTestLiteStatic::TIMESTAMP));
+ types.append(QTestLiteStatic::atom(QTestLiteStatic::SAVE_TARGETS));
+
+ XChangeProperty(screen()->display(), window, property, XA_ATOM, 32,
+ PropModeReplace, (uchar *) types.data(), types.size());
+ return property;
+}
+
+Atom QTestLiteClipboard::sendSelection(QMimeData *d, Atom target, Window window, Atom property)
+{
+ Atom atomFormat = target;
+ int dataFormat = 0;
+ QByteArray data;
+
+ QString fmt = QTestLiteMime::mimeAtomToString(screen()->display(), target);
+ if (fmt.isEmpty()) { // Not a MIME type we have
+ qDebug() << "QClipboard: send_selection(): converting to type '%s' is not supported" << fmt.data();
+ return XNone;
+ }
+ qDebug() << "QClipboard: send_selection(): converting to type '%s'" << fmt.data();
+
+ if (QTestLiteMime::mimeDataForAtom(screen()->display(),target, d, &data, &atomFormat, &dataFormat)) {
+
+ // don't allow INCR transfers when using MULTIPLE or to
+ // Motif clients (since Motif doesn't support INCR)
+ static Atom motif_clip_temporary = QTestLiteStatic::atom(QTestLiteStatic::CLIP_TEMPORARY);
+ bool allow_incr = property != motif_clip_temporary;
+
+ // X_ChangeProperty protocol request is 24 bytes
+ const int increment = (XMaxRequestSize(screen()->display()) * 4) - 24;
+ if (data.size() > increment && allow_incr) {
+ long bytes = data.size();
+ XChangeProperty(screen()->display(), window, property,
+ QTestLiteStatic::atom(QTestLiteStatic::INCR), 32, PropModeReplace, (uchar *) &bytes, 1);
+
+// (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
+ qDebug() << "not implemented INCRT just YET!";
+ return property;
+ }
+
+ // make sure we can perform the XChangeProperty in a single request
+ if (data.size() > increment)
+ return XNone; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
+ int dataSize = data.size() / (dataFormat / 8);
+ // use a single request to transfer data
+ XChangeProperty(screen()->display(), window, property, atomFormat,
+ dataFormat, PropModeReplace, (uchar *) data.data(),
+ dataSize);
+ }
+ return property;
+}
+
+void QTestLiteClipboard::handleSelectionRequest(XEvent *xevent)
+{
+ XSelectionRequestEvent *req = &xevent->xselectionrequest;
+
+ if (requestor() && req->requestor == requestor()) {
+ qDebug() << "This should be caught before";
+ return;
+ }
+
+ XEvent event;
+ event.xselection.type = SelectionNotify;
+ event.xselection.display = req->display;
+ event.xselection.requestor = req->requestor;
+ event.xselection.selection = req->selection;
+ event.xselection.target = req->target;
+ event.xselection.property = XNone;
+ event.xselection.time = req->time;
+
+ QMimeData *d;
+ if (req->selection == XA_PRIMARY) {
+ d = m_clientSelection;
+ } else if (req->selection == QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD)) {
+ d = m_clientClipboard;
+ } else {
+ qWarning("QClipboard: Unknown selection '%lx'", req->selection);
+ XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ return;
+ }
+
+ if (!d) {
+ qWarning("QClipboard: Cannot transfer data, no data available");
+ XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ return;
+ }
+
+ Atom xa_targets = QTestLiteStatic::atom(QTestLiteStatic::TARGETS);
+ Atom xa_multiple = QTestLiteStatic::atom(QTestLiteStatic::MULTIPLE);
+ Atom xa_timestamp = QTestLiteStatic::atom(QTestLiteStatic::TIMESTAMP);
+
+ struct AtomPair { Atom target; Atom property; } *multi = 0;
+ Atom multi_type = XNone;
+ int multi_format = 0;
+ int nmulti = 0;
+ int imulti = -1;
+ bool multi_writeback = false;
+
+ if (req->target == xa_multiple) {
+ QByteArray multi_data;
+ if (req->property == XNone
+ || !clipboardReadProperty(req->requestor, req->property, false, &multi_data,
+ 0, &multi_type, &multi_format)
+ || multi_format != 32) {
+ // MULTIPLE property not formatted correctly
+ XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ return;
+ }
+ nmulti = multi_data.size()/sizeof(*multi);
+ multi = new AtomPair[nmulti];
+ memcpy(multi,multi_data.data(),multi_data.size());
+ imulti = 0;
+ }
+
+ for (; imulti < nmulti; ++imulti) {
+ Atom target;
+ Atom property;
+
+ if (multi) {
+ target = multi[imulti].target;
+ property = multi[imulti].property;
+ } else {
+ target = req->target;
+ property = req->property;
+ if (property == XNone) // obsolete client
+ property = target;
+ }
+
+ Atom ret = XNone;
+ if (target == XNone || property == XNone) {
+ ;
+ } else if (target == xa_timestamp) {
+// if (d->timestamp != CurrentTime) {
+// XChangeProperty(screen()->display(), req->requestor, property, XA_INTEGER, 32,
+// PropModeReplace, CurrentTime, 1);
+// ret = property;
+// } else {
+// qWarning("QClipboard: Invalid data timestamp");
+// }
+ } else if (target == xa_targets) {
+ ret = sendTargetsSelection(d, req->requestor, property);
+ } else {
+ ret = sendSelection(d, target, req->requestor, property);
+ }
+
+ if (nmulti > 0) {
+ if (ret == XNone) {
+ multi[imulti].property = XNone;
+ multi_writeback = true;
+ }
+ } else {
+ event.xselection.property = ret;
+ break;
+ }
+ }
+
+ if (nmulti > 0) {
+ if (multi_writeback) {
+ // according to ICCCM 2.6.2 says to put None back
+ // into the original property on the requestor window
+ XChangeProperty(screen()->display(), req->requestor, req->property, multi_type, 32,
+ PropModeReplace, (uchar *) multi, nmulti * 2);
+ }
+
+ delete [] multi;
+ event.xselection.property = req->property;
+ }
+
+ // send selection notify to requestor
+ XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+}
+
+static inline int maxSelectionIncr(Display *dpy)
+{ return XMaxRequestSize(dpy) > 65536 ? 65536*4 : XMaxRequestSize(dpy)*4 - 100; }
+
+bool QTestLiteClipboard::clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const
+{
+ int maxsize = maxSelectionIncr(screen()->display());
+ ulong bytes_left; // bytes_after
+ ulong length; // nitems
+ uchar *data;
+ Atom dummy_type;
+ int dummy_format;
+ int r;
+
+ if (!type) // allow null args
+ type = &dummy_type;
+ if (!format)
+ format = &dummy_format;
+
+ // Don't read anything, just get the size of the property data
+ r = XGetWindowProperty(screen()->display(), win, property, 0, 0, False,
+ AnyPropertyType, type, format,
+ &length, &bytes_left, &data);
+ if (r != Success || (type && *type == XNone)) {
+ buffer->resize(0);
+ return false;
+ }
+ XFree((char*)data);
+
+ int offset = 0, buffer_offset = 0, format_inc = 1, proplen = bytes_left;
+
+ switch (*format) {
+ case 8:
+ default:
+ format_inc = sizeof(char) / 1;
+ break;
+
+ case 16:
+ format_inc = sizeof(short) / 2;
+ proplen *= sizeof(short) / 2;
+ break;
+
+ case 32:
+ format_inc = sizeof(long) / 4;
+ proplen *= sizeof(long) / 4;
+ break;
+ }
+
+ int newSize = proplen;
+ buffer->resize(newSize);
+
+ bool ok = (buffer->size() == newSize);
+
+ if (ok && newSize) {
+ // could allocate buffer
+
+ while (bytes_left) {
+ // more to read...
+
+ r = XGetWindowProperty(screen()->display(), win, property, offset, maxsize/4,
+ False, AnyPropertyType, type, format,
+ &length, &bytes_left, &data);
+ if (r != Success || (type && *type == XNone))
+ break;
+
+ offset += length / (32 / *format);
+ length *= format_inc * (*format) / 8;
+
+ // Here we check if we get a buffer overflow and tries to
+ // recover -- this shouldn't normally happen, but it doesn't
+ // hurt to be defensive
+ if ((int)(buffer_offset + length) > buffer->size()) {
+ length = buffer->size() - buffer_offset;
+
+ // escape loop
+ bytes_left = 0;
+ }
+
+ memcpy(buffer->data() + buffer_offset, data, length);
+ buffer_offset += length;
+
+ XFree((char*)data);
+ }
+
+ if (*format == 8 && *type == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT)) {
+ // convert COMPOUND_TEXT to a multibyte string
+ XTextProperty textprop;
+ textprop.encoding = *type;
+ textprop.format = *format;
+ textprop.nitems = buffer_offset;
+ textprop.value = (unsigned char *) buffer->data();
+
+ char **list_ret = 0;
+ int count;
+ if (XmbTextPropertyToTextList(screen()->display(), &textprop, &list_ret,
+ &count) == Success && count && list_ret) {
+ offset = buffer_offset = strlen(list_ret[0]);
+ buffer->resize(offset);
+ memcpy(buffer->data(), list_ret[0], offset);
+ }
+ if (list_ret) XFreeStringList(list_ret);
+ }
+ }
+
+ // correct size, not 0-term.
+ if (size)
+ *size = buffer_offset;
+
+ if (deleteProperty)
+ XDeleteProperty(screen()->display(), win, property);
+
+ XFlush(screen()->display());
+
+ return ok;
+}
+
+QByteArray QTestLiteClipboard::clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm)
+{
+ XEvent event;
+
+ QByteArray buf;
+ QByteArray tmp_buf;
+ bool alloc_error = false;
+ int length;
+ int offset = 0;
+
+ if (nbytes > 0) {
+ // Reserve buffer + zero-terminator (for text data)
+ // We want to complete the INCR transfer even if we cannot
+ // allocate more memory
+ buf.resize(nbytes+1);
+ alloc_error = buf.size() != nbytes+1;
+ }
+
+ for (;;) {
+ XFlush(screen()->display());
+ if (!screen()->waitForClipboardEvent(win,PropertyNotify,&event,clipboard_timeout))
+ break;
+ if (event.xproperty.atom != property ||
+ event.xproperty.state != PropertyNewValue)
+ continue;
+ if (clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) {
+ if (length == 0) { // no more data, we're done
+ if (nullterm) {
+ buf.resize(offset+1);
+ buf[offset] = '\0';
+ } else {
+ buf.resize(offset);
+ }
+ return buf;
+ } else if (!alloc_error) {
+ if (offset+length > (int)buf.size()) {
+ buf.resize(offset+length+65535);
+ if (buf.size() != offset+length+65535) {
+ alloc_error = true;
+ length = buf.size() - offset;
+ }
+ }
+ memcpy(buf.data()+offset, tmp_buf.constData(), length);
+ tmp_buf.resize(0);
+ offset += length;
+ }
+ } else {
+ break;
+ }
+ }
+
+ // timed out ... create a new requestor window, otherwise the requestor
+ // could consider next request to be still part of this timed out request
+ setRequestor(0);
+
+ return QByteArray();
+}
+
+QByteArray QTestLiteClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
+{
+ QByteArray buf;
+
+ Window win = requestor();
+
+ XSelectInput(screen()->display(), win, NoEventMask); // don't listen for any events
+
+ XDeleteProperty(screen()->display(), win, QTestLiteStatic::atom(QTestLiteStatic::_QT_SELECTION));
+ XConvertSelection(screen()->display(), modeAtom, fmtatom, QTestLiteStatic::atom(QTestLiteStatic::_QT_SELECTION), win, CurrentTime);
+ XSync(screen()->display(), false);
+
+ XEvent xevent;
+ if (!screen()->waitForClipboardEvent(win,SelectionNotify,&xevent,clipboard_timeout) ||
+ xevent.xselection.property == XNone) {
+ return buf;
+ }
+
+ Atom type;
+ XSelectInput(screen()->display(), win, PropertyChangeMask);
+
+ if (clipboardReadProperty(win, QTestLiteStatic::atom(QTestLiteStatic::_QT_SELECTION), true, &buf, 0, &type, 0)) {
+ if (type == QTestLiteStatic::atom(QTestLiteStatic::INCR)) {
+ int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
+ buf = clipboardReadIncrementalProperty(win, QTestLiteStatic::atom(QTestLiteStatic::_QT_SELECTION), nbytes, false);
+ }
+ }
+
+ XSelectInput(screen()->display(), win, NoEventMask);
+
+
+ return buf;
+}
+
+#include "qtestliteclipboard.moc"
diff --git a/src/plugins/platforms/testlite/qtestliteclipboard.h b/src/plugins/platforms/testlite/qtestliteclipboard.h
new file mode 100644
index 0000000..76065a2
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestliteclipboard.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITECLIPBOARD_H
+#define QTESTLITECLIPBOARD_H
+
+#include <QPlatformClipboard>
+#include "qtestlitestaticinfo.h"
+
+class QTestLiteScreen;
+class QTestLiteClipboard : public QPlatformClipboard
+{
+public:
+ QTestLiteClipboard(QTestLiteScreen *screen);
+
+ const QMimeData *mimeData(QClipboard::Mode mode) const;
+ void setMimeData(QMimeData *data, QClipboard::Mode mode);
+
+ bool supportsMode(QClipboard::Mode mode) const;
+
+ QTestLiteScreen *screen() const;
+
+ Window requestor() const;
+ void setRequestor(Window window);
+
+ Window owner() const;
+
+ void handleSelectionRequest(XEvent *event);
+
+ bool clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const;
+ QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm);
+
+ QByteArray getDataInFormat(Atom modeAtom, Atom fmtatom);
+
+private:
+ void setOwner(Window window);
+
+ Atom sendTargetsSelection(QMimeData *d, Window window, Atom property);
+ Atom sendSelection(QMimeData *d, Atom target, Window window, Atom property);
+
+ QTestLiteScreen *m_screen;
+
+ QMimeData *m_xClipboard;
+ QMimeData *m_clientClipboard;
+
+ QMimeData *m_xSelection;
+ QMimeData *m_clientSelection;
+
+ Window m_requestor;
+ Window m_owner;
+
+ static const int clipboard_timeout;
+
+};
+
+#endif // QTESTLITECLIPBOARD_H
diff --git a/src/plugins/platforms/testlite/qtestlitecursor.cpp b/src/plugins/platforms/testlite/qtestlitecursor.cpp
new file mode 100644
index 0000000..e7ef673
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitecursor.cpp
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtestlitecursor.h"
+
+#include "qtestliteintegration.h"
+#include "qtestlitescreen.h"
+#include "qtestlitewindow.h"
+
+#include <QtGui/QBitmap>
+
+#include <X11/cursorfont.h>
+
+QT_BEGIN_NAMESPACE
+
+QTestLiteCursor::QTestLiteCursor(QTestLiteScreen *screen)
+ : QPlatformCursor(screen)
+{
+}
+
+void QTestLiteCursor::changeCursor(QCursor *cursor, QWidget *widget)
+{
+ QTestLiteWindow *w = 0;
+ if (widget) {
+ QWidget *window = widget->window();
+ w = static_cast<QTestLiteWindow*>(window->platformWindow());
+ } else {
+ // No X11 cursor control when there is no widget under the cursor
+ return;
+ }
+
+ if (!w)
+ return;
+
+ int id = cursor->handle();
+
+ Cursor c;
+ if (!cursorMap.contains(id)) {
+ if (cursor->shape() == Qt::BitmapCursor)
+ c = createCursorBitmap(cursor);
+ else
+ c = createCursorShape(cursor->shape());
+ if (!c) {
+ return;
+ }
+ cursorMap.insert(id, c);
+ } else {
+ c = cursorMap.value(id);
+ }
+
+ w->setCursor(c);
+}
+
+Cursor QTestLiteCursor::createCursorBitmap(QCursor * cursor)
+{
+ XColor bg, fg;
+ bg.red = 255 << 8;
+ bg.green = 255 << 8;
+ bg.blue = 255 << 8;
+ fg.red = 0;
+ fg.green = 0;
+ fg.blue = 0;
+ QPoint spot = cursor->hotSpot();
+ Window rootwin = testLiteScreen()->rootWindow();
+
+ QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB);
+ QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB);
+
+ int width = cursor->bitmap()->width();
+ int height = cursor->bitmap()->height();
+ int bytesPerLine = mapImage.bytesPerLine();
+ int destLineSize = width / 8;
+ if (width % 8)
+ destLineSize++;
+
+ const uchar * map = mapImage.bits();
+ const uchar * mask = maskImage.bits();
+
+ char * mapBits = new char[height * destLineSize];
+ char * maskBits = new char[height * destLineSize];
+ for (int i = 0; i < height; i++) {
+ memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize);
+ memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize);
+ }
+
+ Pixmap cp = XCreateBitmapFromData(testLiteScreen()->display(), rootwin, mapBits, width, height);
+ Pixmap mp = XCreateBitmapFromData(testLiteScreen()->display(), rootwin, maskBits, width, height);
+ Cursor c = XCreatePixmapCursor(testLiteScreen()->display(), cp, mp, &fg, &bg, spot.x(), spot.y());
+ XFreePixmap(testLiteScreen()->display(), cp);
+ XFreePixmap(testLiteScreen()->display(), mp);
+ delete[] mapBits;
+ delete[] maskBits;
+
+ return c;
+}
+
+Cursor QTestLiteCursor::createCursorShape(int cshape)
+{
+ Cursor cursor = 0;
+
+ if (cshape < 0 || cshape > Qt::LastCursor)
+ return 0;
+
+ switch (cshape) {
+ case Qt::ArrowCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_left_ptr);
+ break;
+ case Qt::UpArrowCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_center_ptr);
+ break;
+ case Qt::CrossCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_crosshair);
+ break;
+ case Qt::WaitCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_watch);
+ break;
+ case Qt::IBeamCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_xterm);
+ break;
+ case Qt::SizeAllCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_fleur);
+ break;
+ case Qt::PointingHandCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_hand2);
+ break;
+ case Qt::SizeBDiagCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_top_right_corner);
+ break;
+ case Qt::SizeFDiagCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_bottom_right_corner);
+ break;
+ case Qt::SizeVerCursor:
+ case Qt::SplitVCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_sb_v_double_arrow);
+ break;
+ case Qt::SizeHorCursor:
+ case Qt::SplitHCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_sb_h_double_arrow);
+ break;
+ case Qt::WhatsThisCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_question_arrow);
+ break;
+ case Qt::ForbiddenCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_circle);
+ break;
+ case Qt::BusyCursor:
+ cursor = XCreateFontCursor(testLiteScreen()->display(), XC_watch);
+ break;
+
+ default: //default cursor for all the rest
+ break;
+ }
+ return cursor;
+}
+
+QTestLiteScreen * QTestLiteCursor::testLiteScreen() const
+{
+ return static_cast<QTestLiteScreen *>(screen);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/testlite/qtestlitecursor.h b/src/plugins/platforms/testlite/qtestlitecursor.h
new file mode 100644
index 0000000..bb3549e
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitecursor.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITECURSOR_H
+#define QTESTLITECURSOR_H
+
+#include <QtGui/QPlatformCursor>
+
+#include "qtestliteintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTestLiteCursor : QPlatformCursor
+{
+public:
+ QTestLiteCursor(QTestLiteScreen *screen);
+
+ void changeCursor(QCursor * cursor, QWidget * widget);
+private:
+
+ Cursor createCursorBitmap(QCursor * cursor);
+ Cursor createCursorShape(int cshape);
+
+ QTestLiteScreen *testLiteScreen() const;
+ QMap<int, Cursor> cursorMap;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTESTLITECURSOR_H
diff --git a/src/plugins/platforms/testlite/qtestliteeglintegration.cpp b/src/plugins/platforms/testlite/qtestliteeglintegration.cpp
new file mode 100644
index 0000000..532c63d
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestliteeglintegration.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtestliteeglintegration.h"
+
+static int countBits(unsigned long mask)
+{
+ int count = 0;
+ while (mask != 0) {
+ if (mask & 1)
+ ++count;
+ mask >>= 1;
+ }
+ return count;
+}
+
+VisualID QTestLiteEglIntegration::getCompatibleVisualId(Display *display, EGLConfig config)
+{
+ VisualID visualId = 0;
+ EGLint eglValue = 0;
+
+ EGLDisplay eglDisplay = eglGetDisplay(display);
+
+ EGLint configRedSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize);
+
+ EGLint configGreenSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &configGreenSize);
+
+ EGLint configBlueSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &configBlueSize);
+
+ EGLint configAlphaSize = 0;
+ eglGetConfigAttrib(eglDisplay, config, EGL_ALPHA_SIZE, &configAlphaSize);
+
+ eglGetConfigAttrib(eglDisplay, config, EGL_CONFIG_ID, &eglValue);
+ int configId = eglValue;
+
+ // See if EGL provided a valid VisualID:
+ eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);
+ visualId = (VisualID)eglValue;
+ if (visualId) {
+ // EGL has suggested a visual id, so get the rest of the visual info for that id:
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = visualId;
+
+ XVisualInfo *chosenVisualInfo;
+ int matchingCount = 0;
+ chosenVisualInfo = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &matchingCount);
+ if (chosenVisualInfo) {
+ // Skip size checks if implementation supports non-matching visual
+ // and config (http://bugreports.qt.nokia.com/browse/QTBUG-9444).
+ if (q_hasEglExtension(eglDisplay,"EGL_NV_post_convert_rounding")) {
+ XFree(chosenVisualInfo);
+ return visualId;
+ }
+
+ int visualRedSize = countBits(chosenVisualInfo->red_mask);
+ int visualGreenSize = countBits(chosenVisualInfo->green_mask);
+ int visualBlueSize = countBits(chosenVisualInfo->blue_mask);
+ int visualAlphaSize = -1; // Need XRender to tell us the alpha channel size
+
+ bool visualMatchesConfig = false;
+ if ( visualRedSize == configRedSize &&
+ visualGreenSize == configGreenSize &&
+ visualBlueSize == configBlueSize )
+ {
+ // We need XRender to check the alpha channel size of the visual. If we don't have
+ // the alpha size, we don't check it against the EGL config's alpha size.
+ if (visualAlphaSize >= 0)
+ visualMatchesConfig = visualAlphaSize == configAlphaSize;
+ else
+ visualMatchesConfig = true;
+ }
+
+ if (!visualMatchesConfig) {
+ if (visualAlphaSize >= 0) {
+ qWarning("Warning: EGL suggested using X Visual ID %d (ARGB%d%d%d%d) for EGL config %d (ARGB%d%d%d%d), but this is incompatable",
+ (int)visualId, visualAlphaSize, visualRedSize, visualGreenSize, visualBlueSize,
+ configId, configAlphaSize, configRedSize, configGreenSize, configBlueSize);
+ } else {
+ qWarning("Warning: EGL suggested using X Visual ID %d (RGB%d%d%d) for EGL config %d (RGB%d%d%d), but this is incompatable",
+ (int)visualId, visualRedSize, visualGreenSize, visualBlueSize,
+ configId, configRedSize, configGreenSize, configBlueSize);
+ }
+ visualId = 0;
+ }
+ } else {
+ qWarning("Warning: EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID",
+ (int)visualId, configId);
+ visualId = 0;
+ }
+ XFree(chosenVisualInfo);
+ }
+#ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ else
+ qDebug("EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId);
+#endif
+
+ if (visualId) {
+#ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ if (configAlphaSize > 0)
+ qDebug("Using ARGB Visual ID %d provided by EGL for config %d", (int)visualId, configId);
+ else
+ qDebug("Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId);
+#endif
+ return visualId;
+ }
+
+ // Finally, try to
+ // use XGetVisualInfo and only use the bit depths to match on:
+ if (!visualId) {
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ XVisualInfo *matchingVisuals;
+ int matchingCount = 0;
+
+ visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize;
+ matchingVisuals = XGetVisualInfo(display,
+ VisualDepthMask,
+ &visualInfoTemplate,
+ &matchingCount);
+ if (!matchingVisuals) {
+ // Try again without taking the alpha channel into account:
+ visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize;
+ matchingVisuals = XGetVisualInfo(display,
+ VisualDepthMask,
+ &visualInfoTemplate,
+ &matchingCount);
+ }
+
+ if (matchingVisuals) {
+ visualId = matchingVisuals[0].visualid;
+ XFree(matchingVisuals);
+ }
+ }
+
+ if (visualId) {
+#ifdef QT_DEBUG_X11_VISUAL_SELECTION
+ qDebug("Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId);
+#endif
+ return visualId;
+ }
+
+ qWarning("Unable to find an X11 visual which matches EGL config %d", configId);
+ return (VisualID)0;
+}
diff --git a/src/plugins/platforms/testlite/qtestliteeglintegration.h b/src/plugins/platforms/testlite/qtestliteeglintegration.h
new file mode 100644
index 0000000..99e9018
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestliteeglintegration.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITEEGLINTEGRATION_H
+#define QTESTLITEEGLINTEGRATION_H
+
+#include "qtestlitestaticinfo.h"
+#include "../eglconvenience/qeglconvenience.h"
+
+class QTestLiteEglIntegration
+{
+public:
+ static VisualID getCompatibleVisualId(Display *display, EGLConfig config);
+};
+
+#endif // QTESTLITEEGLINTEGRATION_H
diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/testlite/qtestliteintegration.cpp
index 68e9051..9b641d1 100644
--- a/src/plugins/platforms/testlite/qtestliteintegration.cpp
+++ b/src/plugins/platforms/testlite/qtestliteintegration.cpp
@@ -39,70 +39,35 @@
**
****************************************************************************/
-
-
#include "qtestliteintegration.h"
#include "qtestlitewindowsurface.h"
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtCore/qdebug.h>
-#include <QPlatformCursor>
-
#include "qtestlitewindow.h"
#include "qgenericunixfontdatabase.h"
+#include "qtestlitescreen.h"
+#include "qtestliteclipboard.h"
-#ifndef QT_NO_OPENGL
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
#include <GL/glx.h>
+#else
+#include <EGL/egl.h>
+#endif //!defined(QT_OPENGL_ES_2)
#include <private/qwindowsurface_gl_p.h>
#include <private/qpixmapdata_gl_p.h>
#endif //QT_NO_OPENGL
QT_BEGIN_NAMESPACE
-class MyCursor : QPlatformCursor
-{
-public:
- MyCursor(QPlatformScreen *screen) : QPlatformCursor(screen) {}
-
- void changeCursor(QCursor * cursor, QWidget * widget) {
- QTestLiteWindow *w = 0;
- if (widget) {
- QWidget *window = widget->window();
- w = static_cast<QTestLiteWindow*>(window->platformWindow());
- } else {
- // No X11 cursor control when there is no widget under the cursor
- return;
- }
-
- //qDebug() << "changeCursor" << widget << ws;
- if (!w)
- return;
-
- w->setCursor(cursor);
- }
-};
-
-
QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL)
: mUseOpenGL(useOpenGL)
, mFontDb(new QGenericUnixFontDatabase())
+ , mClipboard(0)
{
- xd = new MyDisplay;
-
mPrimaryScreen = new QTestLiteScreen();
-
- mPrimaryScreen->mGeometry = QRect
- (0, 0, xd->width, xd->height);
- mPrimaryScreen->mDepth = 32;
- mPrimaryScreen->mFormat = QImage::Format_RGB32;
- mPrimaryScreen->mPhysicalSize =
- QSize(xd->physicalWidth, xd->physicalHeight);
-
mScreens.append(mPrimaryScreen);
-
-
- (void)new MyCursor(mPrimaryScreen);
-
}
QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const
@@ -120,21 +85,33 @@ QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId)
if (mUseOpenGL)
return new QGLWindowSurface(widget);
#endif
- return new QTestLiteWindowSurface(mPrimaryScreen, widget);
+ return new QTestLiteWindowSurface(widget);
}
QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
{
- return new QTestLiteWindow(this, mPrimaryScreen, widget);
+ return new QTestLiteWindow(widget);
}
QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, int height) const
{
- QImage img = xd->grabWindow(window, x, y, width, height);
- return QPixmap::fromImage(img);
+ QImage image;
+ QWidget *widget = QWidget::find(window);
+ if (widget) {
+ QTestLiteScreen *screen = QTestLiteScreen::testLiteScreenForWidget(widget);
+ image = screen->grabWindow(window,x,y,width,height);
+ } else {
+ for (int i = 0; i < mScreens.size(); i++) {
+ QTestLiteScreen *screen = static_cast<QTestLiteScreen *>(mScreens[i]);
+ if (screen->rootWindow() == window) {
+ image = screen->grabWindow(window,x,y,width,height);
+ }
+ }
+ }
+ return QPixmap::fromImage(image);
}
QPlatformFontDatabase *QTestLiteIntegration::fontDatabase() const
@@ -142,12 +119,38 @@ QPlatformFontDatabase *QTestLiteIntegration::fontDatabase() const
return mFontDb;
}
+QPlatformClipboard * QTestLiteIntegration::clipboard() const
+{
+ //Use lazy init since clipboard needs QTestliteScreen
+ if (!mClipboard) {
+ QTestLiteIntegration *that = const_cast<QTestLiteIntegration *>(this);
+ that->mClipboard = new QTestLiteClipboard(mPrimaryScreen);
+ }
+ return mClipboard;
+}
+
bool QTestLiteIntegration::hasOpenGL() const
{
-#ifndef QT_NO_OPENGL
- return glXQueryExtension(xd->display, 0, 0) != 0;
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+ QTestLiteScreen *screen = static_cast<const QTestLiteScreen *>(mScreens.at(0));
+ return glXQueryExtension(screen->display(), 0, 0) != 0;
+#else
+ static bool eglHasbeenInitialized = false;
+ static bool wasEglInitialized = false;
+ if (!eglHasbeenInitialized) {
+ eglHasbeenInitialized = true;
+ QTestLiteScreen *screen = static_cast<const QTestLiteScreen *>(mScreens.at(0));
+ EGLint major, minor;
+ eglBindAPI(EGL_OPENGL_ES_API);
+ EGLDisplay disp = eglGetDisplay(screen->display());
+ wasEglInitialized = eglInitialize(disp,&major,&minor);
+ }
+ return wasEglInitialized;
+#endif
#endif
return false;
}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/testlite/qtestliteintegration.h
index 8286ef0..320cf00 100644
--- a/src/plugins/platforms/testlite/qtestliteintegration.h
+++ b/src/plugins/platforms/testlite/qtestliteintegration.h
@@ -42,34 +42,17 @@
#ifndef QGRAPHICSSYSTEM_TESTLITE_H
#define QGRAPHICSSYSTEM_TESTLITE_H
-#include <QtGui/QPlatformIntegration>
-#include <QtGui/QPlatformScreen>
-
//make sure textstream is included before any X11 headers
#include <QtCore/QTextStream>
-QT_BEGIN_NAMESPACE
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
-class MyDisplay;
+#include "qtestlitestaticinfo.h"
-class QTestLiteScreen : public QPlatformScreen
-{
-public:
- QTestLiteScreen()
- : mDepth(16), mFormat(QImage::Format_RGB16) {}
- ~QTestLiteScreen() {}
-
- QRect geometry() const { return mGeometry; }
- int depth() const { return mDepth; }
- QImage::Format format() const { return mFormat; }
- QSize physicalSize() const { return mPhysicalSize; }
+QT_BEGIN_NAMESPACE
-public:
- QRect mGeometry;
- int mDepth;
- QImage::Format mFormat;
- QSize mPhysicalSize;
-};
+class QTestLiteScreen;
class QTestLiteIntegration : public QPlatformIntegration
{
@@ -85,16 +68,16 @@ public:
QList<QPlatformScreen *> screens() const { return mScreens; }
QPlatformFontDatabase *fontDatabase() const;
+ QPlatformClipboard *clipboard() const;
bool hasOpenGL() const;
- MyDisplay *xd;
-
private:
bool mUseOpenGL;
QTestLiteScreen *mPrimaryScreen;
QList<QPlatformScreen *> mScreens;
QPlatformFontDatabase *mFontDb;
+ QPlatformClipboard *mClipboard;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/testlite/qtestlitekeyboard.cpp b/src/plugins/platforms/testlite/qtestlitekeyboard.cpp
new file mode 100644
index 0000000..5b4ebd7
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitekeyboard.cpp
@@ -0,0 +1,1000 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtestlitekeyboard.h"
+
+#include "qtestlitescreen.h"
+
+#include <QtGui/QWindowSystemInterface>
+
+#include <QtCore/QTextCodec>
+
+#ifndef XK_ISO_Left_Tab
+#define XK_ISO_Left_Tab 0xFE20
+#endif
+
+#ifndef XK_dead_hook
+#define XK_dead_hook 0xFE61
+#endif
+
+#ifndef XK_dead_horn
+#define XK_dead_horn 0xFE62
+#endif
+
+#ifndef XK_Codeinput
+#define XK_Codeinput 0xFF37
+#endif
+
+#ifndef XK_Kanji_Bangou
+#define XK_Kanji_Bangou 0xFF37 /* same as codeinput */
+#endif
+
+// Fix old X libraries
+#ifndef XK_KP_Home
+#define XK_KP_Home 0xFF95
+#endif
+#ifndef XK_KP_Left
+#define XK_KP_Left 0xFF96
+#endif
+#ifndef XK_KP_Up
+#define XK_KP_Up 0xFF97
+#endif
+#ifndef XK_KP_Right
+#define XK_KP_Right 0xFF98
+#endif
+#ifndef XK_KP_Down
+#define XK_KP_Down 0xFF99
+#endif
+#ifndef XK_KP_Prior
+#define XK_KP_Prior 0xFF9A
+#endif
+#ifndef XK_KP_Next
+#define XK_KP_Next 0xFF9B
+#endif
+#ifndef XK_KP_End
+#define XK_KP_End 0xFF9C
+#endif
+#ifndef XK_KP_Insert
+#define XK_KP_Insert 0xFF9E
+#endif
+#ifndef XK_KP_Delete
+#define XK_KP_Delete 0xFF9F
+#endif
+
+// the next lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special
+// multimedia keys. They are included here as not every system has them.
+#define XF86XK_MonBrightnessUp 0x1008FF02
+#define XF86XK_MonBrightnessDown 0x1008FF03
+#define XF86XK_KbdLightOnOff 0x1008FF04
+#define XF86XK_KbdBrightnessUp 0x1008FF05
+#define XF86XK_KbdBrightnessDown 0x1008FF06
+#define XF86XK_Standby 0x1008FF10
+#define XF86XK_AudioLowerVolume 0x1008FF11
+#define XF86XK_AudioMute 0x1008FF12
+#define XF86XK_AudioRaiseVolume 0x1008FF13
+#define XF86XK_AudioPlay 0x1008FF14
+#define XF86XK_AudioStop 0x1008FF15
+#define XF86XK_AudioPrev 0x1008FF16
+#define XF86XK_AudioNext 0x1008FF17
+#define XF86XK_HomePage 0x1008FF18
+#define XF86XK_Mail 0x1008FF19
+#define XF86XK_Start 0x1008FF1A
+#define XF86XK_Search 0x1008FF1B
+#define XF86XK_AudioRecord 0x1008FF1C
+#define XF86XK_Calculator 0x1008FF1D
+#define XF86XK_Memo 0x1008FF1E
+#define XF86XK_ToDoList 0x1008FF1F
+#define XF86XK_Calendar 0x1008FF20
+#define XF86XK_PowerDown 0x1008FF21
+#define XF86XK_ContrastAdjust 0x1008FF22
+#define XF86XK_Back 0x1008FF26
+#define XF86XK_Forward 0x1008FF27
+#define XF86XK_Stop 0x1008FF28
+#define XF86XK_Refresh 0x1008FF29
+#define XF86XK_PowerOff 0x1008FF2A
+#define XF86XK_WakeUp 0x1008FF2B
+#define XF86XK_Eject 0x1008FF2C
+#define XF86XK_ScreenSaver 0x1008FF2D
+#define XF86XK_WWW 0x1008FF2E
+#define XF86XK_Sleep 0x1008FF2F
+#define XF86XK_Favorites 0x1008FF30
+#define XF86XK_AudioPause 0x1008FF31
+#define XF86XK_AudioMedia 0x1008FF32
+#define XF86XK_MyComputer 0x1008FF33
+#define XF86XK_LightBulb 0x1008FF35
+#define XF86XK_Shop 0x1008FF36
+#define XF86XK_History 0x1008FF37
+#define XF86XK_OpenURL 0x1008FF38
+#define XF86XK_AddFavorite 0x1008FF39
+#define XF86XK_HotLinks 0x1008FF3A
+#define XF86XK_BrightnessAdjust 0x1008FF3B
+#define XF86XK_Finance 0x1008FF3C
+#define XF86XK_Community 0x1008FF3D
+#define XF86XK_AudioRewind 0x1008FF3E
+#define XF86XK_BackForward 0x1008FF3F
+#define XF86XK_Launch0 0x1008FF40
+#define XF86XK_Launch1 0x1008FF41
+#define XF86XK_Launch2 0x1008FF42
+#define XF86XK_Launch3 0x1008FF43
+#define XF86XK_Launch4 0x1008FF44
+#define XF86XK_Launch5 0x1008FF45
+#define XF86XK_Launch6 0x1008FF46
+#define XF86XK_Launch7 0x1008FF47
+#define XF86XK_Launch8 0x1008FF48
+#define XF86XK_Launch9 0x1008FF49
+#define XF86XK_LaunchA 0x1008FF4A
+#define XF86XK_LaunchB 0x1008FF4B
+#define XF86XK_LaunchC 0x1008FF4C
+#define XF86XK_LaunchD 0x1008FF4D
+#define XF86XK_LaunchE 0x1008FF4E
+#define XF86XK_LaunchF 0x1008FF4F
+#define XF86XK_ApplicationLeft 0x1008FF50
+#define XF86XK_ApplicationRight 0x1008FF51
+#define XF86XK_Book 0x1008FF52
+#define XF86XK_CD 0x1008FF53
+#define XF86XK_Calculater 0x1008FF54
+#define XF86XK_Clear 0x1008FF55
+#define XF86XK_ClearGrab 0x1008FE21
+#define XF86XK_Close 0x1008FF56
+#define XF86XK_Copy 0x1008FF57
+#define XF86XK_Cut 0x1008FF58
+#define XF86XK_Display 0x1008FF59
+#define XF86XK_DOS 0x1008FF5A
+#define XF86XK_Documents 0x1008FF5B
+#define XF86XK_Excel 0x1008FF5C
+#define XF86XK_Explorer 0x1008FF5D
+#define XF86XK_Game 0x1008FF5E
+#define XF86XK_Go 0x1008FF5F
+#define XF86XK_iTouch 0x1008FF60
+#define XF86XK_LogOff 0x1008FF61
+#define XF86XK_Market 0x1008FF62
+#define XF86XK_Meeting 0x1008FF63
+#define XF86XK_MenuKB 0x1008FF65
+#define XF86XK_MenuPB 0x1008FF66
+#define XF86XK_MySites 0x1008FF67
+#define XF86XK_News 0x1008FF69
+#define XF86XK_OfficeHome 0x1008FF6A
+#define XF86XK_Option 0x1008FF6C
+#define XF86XK_Paste 0x1008FF6D
+#define XF86XK_Phone 0x1008FF6E
+#define XF86XK_Reply 0x1008FF72
+#define XF86XK_Reload 0x1008FF73
+#define XF86XK_RotateWindows 0x1008FF74
+#define XF86XK_RotationPB 0x1008FF75
+#define XF86XK_RotationKB 0x1008FF76
+#define XF86XK_Save 0x1008FF77
+#define XF86XK_Send 0x1008FF7B
+#define XF86XK_Spell 0x1008FF7C
+#define XF86XK_SplitScreen 0x1008FF7D
+#define XF86XK_Support 0x1008FF7E
+#define XF86XK_TaskPane 0x1008FF7F
+#define XF86XK_Terminal 0x1008FF80
+#define XF86XK_Tools 0x1008FF81
+#define XF86XK_Travel 0x1008FF82
+#define XF86XK_Video 0x1008FF87
+#define XF86XK_Word 0x1008FF89
+#define XF86XK_Xfer 0x1008FF8A
+#define XF86XK_ZoomIn 0x1008FF8B
+#define XF86XK_ZoomOut 0x1008FF8C
+#define XF86XK_Away 0x1008FF8D
+#define XF86XK_Messenger 0x1008FF8E
+#define XF86XK_WebCam 0x1008FF8F
+#define XF86XK_MailForward 0x1008FF90
+#define XF86XK_Pictures 0x1008FF91
+#define XF86XK_Music 0x1008FF92
+#define XF86XK_Battery 0x1008FF93
+#define XF86XK_Bluetooth 0x1008FF94
+#define XF86XK_WLAN 0x1008FF95
+#define XF86XK_UWB 0x1008FF96
+#define XF86XK_AudioForward 0x1008FF97
+#define XF86XK_AudioRepeat 0x1008FF98
+#define XF86XK_AudioRandomPlay 0x1008FF99
+#define XF86XK_Subtitle 0x1008FF9A
+#define XF86XK_AudioCycleTrack 0x1008FF9B
+#define XF86XK_Time 0x1008FF9F
+#define XF86XK_Select 0x1008FFA0
+#define XF86XK_View 0x1008FFA1
+#define XF86XK_TopMenu 0x1008FFA2
+#define XF86XK_Suspend 0x1008FFA7
+#define XF86XK_Hibernate 0x1008FFA8
+
+
+// end of XF86keysyms.h
+
+// Special keys used by Qtopia, mapped into the X11 private keypad range.
+#define QTOPIAXK_Select 0x11000601
+#define QTOPIAXK_Yes 0x11000602
+#define QTOPIAXK_No 0x11000603
+#define QTOPIAXK_Cancel 0x11000604
+#define QTOPIAXK_Printer 0x11000605
+#define QTOPIAXK_Execute 0x11000606
+#define QTOPIAXK_Sleep 0x11000607
+#define QTOPIAXK_Play 0x11000608
+#define QTOPIAXK_Zoom 0x11000609
+#define QTOPIAXK_Context1 0x1100060A
+#define QTOPIAXK_Context2 0x1100060B
+#define QTOPIAXK_Context3 0x1100060C
+#define QTOPIAXK_Context4 0x1100060D
+#define QTOPIAXK_Call 0x1100060E
+#define QTOPIAXK_Hangup 0x1100060F
+#define QTOPIAXK_Flip 0x11000610
+
+// keyboard mapping table
+static const unsigned int KeyTbl[] = {
+
+ // misc keys
+
+ XK_Escape, Qt::Key_Escape,
+ XK_Tab, Qt::Key_Tab,
+ XK_ISO_Left_Tab, Qt::Key_Backtab,
+ XK_BackSpace, Qt::Key_Backspace,
+ XK_Return, Qt::Key_Return,
+ XK_Insert, Qt::Key_Insert,
+ XK_Delete, Qt::Key_Delete,
+ XK_Clear, Qt::Key_Delete,
+ XK_Pause, Qt::Key_Pause,
+ XK_Print, Qt::Key_Print,
+ 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq
+ 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq
+
+ // cursor movement
+
+ XK_Home, Qt::Key_Home,
+ XK_End, Qt::Key_End,
+ XK_Left, Qt::Key_Left,
+ XK_Up, Qt::Key_Up,
+ XK_Right, Qt::Key_Right,
+ XK_Down, Qt::Key_Down,
+ XK_Prior, Qt::Key_PageUp,
+ XK_Next, Qt::Key_PageDown,
+
+ // modifiers
+
+ XK_Shift_L, Qt::Key_Shift,
+ XK_Shift_R, Qt::Key_Shift,
+ XK_Shift_Lock, Qt::Key_Shift,
+ XK_Control_L, Qt::Key_Control,
+ XK_Control_R, Qt::Key_Control,
+ XK_Meta_L, Qt::Key_Meta,
+ XK_Meta_R, Qt::Key_Meta,
+ XK_Alt_L, Qt::Key_Alt,
+ XK_Alt_R, Qt::Key_Alt,
+ XK_Caps_Lock, Qt::Key_CapsLock,
+ XK_Num_Lock, Qt::Key_NumLock,
+ XK_Scroll_Lock, Qt::Key_ScrollLock,
+ XK_Super_L, Qt::Key_Super_L,
+ XK_Super_R, Qt::Key_Super_R,
+ XK_Menu, Qt::Key_Menu,
+ XK_Hyper_L, Qt::Key_Hyper_L,
+ XK_Hyper_R, Qt::Key_Hyper_R,
+ XK_Help, Qt::Key_Help,
+ 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab
+ 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11)
+ 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12)
+
+ // numeric and function keypad keys
+
+ XK_KP_Space, Qt::Key_Space,
+ XK_KP_Tab, Qt::Key_Tab,
+ XK_KP_Enter, Qt::Key_Enter,
+ //XK_KP_F1, Qt::Key_F1,
+ //XK_KP_F2, Qt::Key_F2,
+ //XK_KP_F3, Qt::Key_F3,
+ //XK_KP_F4, Qt::Key_F4,
+ XK_KP_Home, Qt::Key_Home,
+ XK_KP_Left, Qt::Key_Left,
+ XK_KP_Up, Qt::Key_Up,
+ XK_KP_Right, Qt::Key_Right,
+ XK_KP_Down, Qt::Key_Down,
+ XK_KP_Prior, Qt::Key_PageUp,
+ XK_KP_Next, Qt::Key_PageDown,
+ XK_KP_End, Qt::Key_End,
+ XK_KP_Begin, Qt::Key_Clear,
+ XK_KP_Insert, Qt::Key_Insert,
+ XK_KP_Delete, Qt::Key_Delete,
+ XK_KP_Equal, Qt::Key_Equal,
+ XK_KP_Multiply, Qt::Key_Asterisk,
+ XK_KP_Add, Qt::Key_Plus,
+ XK_KP_Separator, Qt::Key_Comma,
+ XK_KP_Subtract, Qt::Key_Minus,
+ XK_KP_Decimal, Qt::Key_Period,
+ XK_KP_Divide, Qt::Key_Slash,
+
+ // International input method support keys
+
+ // International & multi-key character composition
+ XK_ISO_Level3_Shift, Qt::Key_AltGr,
+ XK_Multi_key, Qt::Key_Multi_key,
+ XK_Codeinput, Qt::Key_Codeinput,
+ XK_SingleCandidate, Qt::Key_SingleCandidate,
+ XK_MultipleCandidate, Qt::Key_MultipleCandidate,
+ XK_PreviousCandidate, Qt::Key_PreviousCandidate,
+
+ // Misc Functions
+ XK_Mode_switch, Qt::Key_Mode_switch,
+ XK_script_switch, Qt::Key_Mode_switch,
+
+ // Japanese keyboard support
+ XK_Kanji, Qt::Key_Kanji,
+ XK_Muhenkan, Qt::Key_Muhenkan,
+ //XK_Henkan_Mode, Qt::Key_Henkan_Mode,
+ XK_Henkan_Mode, Qt::Key_Henkan,
+ XK_Henkan, Qt::Key_Henkan,
+ XK_Romaji, Qt::Key_Romaji,
+ XK_Hiragana, Qt::Key_Hiragana,
+ XK_Katakana, Qt::Key_Katakana,
+ XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana,
+ XK_Zenkaku, Qt::Key_Zenkaku,
+ XK_Hankaku, Qt::Key_Hankaku,
+ XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku,
+ XK_Touroku, Qt::Key_Touroku,
+ XK_Massyo, Qt::Key_Massyo,
+ XK_Kana_Lock, Qt::Key_Kana_Lock,
+ XK_Kana_Shift, Qt::Key_Kana_Shift,
+ XK_Eisu_Shift, Qt::Key_Eisu_Shift,
+ XK_Eisu_toggle, Qt::Key_Eisu_toggle,
+ //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou,
+ //XK_Zen_Koho, Qt::Key_Zen_Koho,
+ //XK_Mae_Koho, Qt::Key_Mae_Koho,
+ XK_Kanji_Bangou, Qt::Key_Codeinput,
+ XK_Zen_Koho, Qt::Key_MultipleCandidate,
+ XK_Mae_Koho, Qt::Key_PreviousCandidate,
+
+#ifdef XK_KOREAN
+ // Korean keyboard support
+ XK_Hangul, Qt::Key_Hangul,
+ XK_Hangul_Start, Qt::Key_Hangul_Start,
+ XK_Hangul_End, Qt::Key_Hangul_End,
+ XK_Hangul_Hanja, Qt::Key_Hangul_Hanja,
+ XK_Hangul_Jamo, Qt::Key_Hangul_Jamo,
+ XK_Hangul_Romaja, Qt::Key_Hangul_Romaja,
+ //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput,
+ XK_Hangul_Codeinput, Qt::Key_Codeinput,
+ XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja,
+ XK_Hangul_Banja, Qt::Key_Hangul_Banja,
+ XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja,
+ XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja,
+ //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate,
+ //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate,
+ //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate,
+ XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate,
+ XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate,
+ XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate,
+ XK_Hangul_Special, Qt::Key_Hangul_Special,
+ //XK_Hangul_switch, Qt::Key_Hangul_switch,
+ XK_Hangul_switch, Qt::Key_Mode_switch,
+#endif // XK_KOREAN
+
+ // dead keys
+ XK_dead_grave, Qt::Key_Dead_Grave,
+ XK_dead_acute, Qt::Key_Dead_Acute,
+ XK_dead_circumflex, Qt::Key_Dead_Circumflex,
+ XK_dead_tilde, Qt::Key_Dead_Tilde,
+ XK_dead_macron, Qt::Key_Dead_Macron,
+ XK_dead_breve, Qt::Key_Dead_Breve,
+ XK_dead_abovedot, Qt::Key_Dead_Abovedot,
+ XK_dead_diaeresis, Qt::Key_Dead_Diaeresis,
+ XK_dead_abovering, Qt::Key_Dead_Abovering,
+ XK_dead_doubleacute, Qt::Key_Dead_Doubleacute,
+ XK_dead_caron, Qt::Key_Dead_Caron,
+ XK_dead_cedilla, Qt::Key_Dead_Cedilla,
+ XK_dead_ogonek, Qt::Key_Dead_Ogonek,
+ XK_dead_iota, Qt::Key_Dead_Iota,
+ XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound,
+ XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound,
+ XK_dead_belowdot, Qt::Key_Dead_Belowdot,
+ XK_dead_hook, Qt::Key_Dead_Hook,
+ XK_dead_horn, Qt::Key_Dead_Horn,
+
+ // Special keys from X.org - This include multimedia keys,
+ // wireless/bluetooth/uwb keys, special launcher keys, etc.
+ XF86XK_Back, Qt::Key_Back,
+ XF86XK_Forward, Qt::Key_Forward,
+ XF86XK_Stop, Qt::Key_Stop,
+ XF86XK_Refresh, Qt::Key_Refresh,
+ XF86XK_Favorites, Qt::Key_Favorites,
+ XF86XK_AudioMedia, Qt::Key_LaunchMedia,
+ XF86XK_OpenURL, Qt::Key_OpenUrl,
+ XF86XK_HomePage, Qt::Key_HomePage,
+ XF86XK_Search, Qt::Key_Search,
+ XF86XK_AudioLowerVolume, Qt::Key_VolumeDown,
+ XF86XK_AudioMute, Qt::Key_VolumeMute,
+ XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp,
+ XF86XK_AudioPlay, Qt::Key_MediaPlay,
+ XF86XK_AudioStop, Qt::Key_MediaStop,
+ XF86XK_AudioPrev, Qt::Key_MediaPrevious,
+ XF86XK_AudioNext, Qt::Key_MediaNext,
+ XF86XK_AudioRecord, Qt::Key_MediaRecord,
+ XF86XK_Mail, Qt::Key_LaunchMail,
+ XF86XK_MyComputer, Qt::Key_Launch0, // ### Qt 5: remap properly
+ XF86XK_Calculator, Qt::Key_Launch1,
+ XF86XK_Memo, Qt::Key_Memo,
+ XF86XK_ToDoList, Qt::Key_ToDoList,
+ XF86XK_Calendar, Qt::Key_Calendar,
+ XF86XK_PowerDown, Qt::Key_PowerDown,
+ XF86XK_ContrastAdjust, Qt::Key_ContrastAdjust,
+ XF86XK_Standby, Qt::Key_Standby,
+ XF86XK_MonBrightnessUp, Qt::Key_MonBrightnessUp,
+ XF86XK_MonBrightnessDown, Qt::Key_MonBrightnessDown,
+ XF86XK_KbdLightOnOff, Qt::Key_KeyboardLightOnOff,
+ XF86XK_KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp,
+ XF86XK_KbdBrightnessDown, Qt::Key_KeyboardBrightnessDown,
+ XF86XK_PowerOff, Qt::Key_PowerOff,
+ XF86XK_WakeUp, Qt::Key_WakeUp,
+ XF86XK_Eject, Qt::Key_Eject,
+ XF86XK_ScreenSaver, Qt::Key_ScreenSaver,
+ XF86XK_WWW, Qt::Key_WWW,
+ XF86XK_Sleep, Qt::Key_Sleep,
+ XF86XK_LightBulb, Qt::Key_LightBulb,
+ XF86XK_Shop, Qt::Key_Shop,
+ XF86XK_History, Qt::Key_History,
+ XF86XK_AddFavorite, Qt::Key_AddFavorite,
+ XF86XK_HotLinks, Qt::Key_HotLinks,
+ XF86XK_BrightnessAdjust, Qt::Key_BrightnessAdjust,
+ XF86XK_Finance, Qt::Key_Finance,
+ XF86XK_Community, Qt::Key_Community,
+ XF86XK_AudioRewind, Qt::Key_AudioRewind,
+ XF86XK_BackForward, Qt::Key_BackForward,
+ XF86XK_ApplicationLeft, Qt::Key_ApplicationLeft,
+ XF86XK_ApplicationRight, Qt::Key_ApplicationRight,
+ XF86XK_Book, Qt::Key_Book,
+ XF86XK_CD, Qt::Key_CD,
+ XF86XK_Calculater, Qt::Key_Calculator,
+ XF86XK_Clear, Qt::Key_Clear,
+ XF86XK_ClearGrab, Qt::Key_ClearGrab,
+ XF86XK_Close, Qt::Key_Close,
+ XF86XK_Copy, Qt::Key_Copy,
+ XF86XK_Cut, Qt::Key_Cut,
+ XF86XK_Display, Qt::Key_Display,
+ XF86XK_DOS, Qt::Key_DOS,
+ XF86XK_Documents, Qt::Key_Documents,
+ XF86XK_Excel, Qt::Key_Excel,
+ XF86XK_Explorer, Qt::Key_Explorer,
+ XF86XK_Game, Qt::Key_Game,
+ XF86XK_Go, Qt::Key_Go,
+ XF86XK_iTouch, Qt::Key_iTouch,
+ XF86XK_LogOff, Qt::Key_LogOff,
+ XF86XK_Market, Qt::Key_Market,
+ XF86XK_Meeting, Qt::Key_Meeting,
+ XF86XK_MenuKB, Qt::Key_MenuKB,
+ XF86XK_MenuPB, Qt::Key_MenuPB,
+ XF86XK_MySites, Qt::Key_MySites,
+ XF86XK_News, Qt::Key_News,
+ XF86XK_OfficeHome, Qt::Key_OfficeHome,
+ XF86XK_Option, Qt::Key_Option,
+ XF86XK_Paste, Qt::Key_Paste,
+ XF86XK_Phone, Qt::Key_Phone,
+ XF86XK_Reply, Qt::Key_Reply,
+ XF86XK_Reload, Qt::Key_Reload,
+ XF86XK_RotateWindows, Qt::Key_RotateWindows,
+ XF86XK_RotationPB, Qt::Key_RotationPB,
+ XF86XK_RotationKB, Qt::Key_RotationKB,
+ XF86XK_Save, Qt::Key_Save,
+ XF86XK_Send, Qt::Key_Send,
+ XF86XK_Spell, Qt::Key_Spell,
+ XF86XK_SplitScreen, Qt::Key_SplitScreen,
+ XF86XK_Support, Qt::Key_Support,
+ XF86XK_TaskPane, Qt::Key_TaskPane,
+ XF86XK_Terminal, Qt::Key_Terminal,
+ XF86XK_Tools, Qt::Key_Tools,
+ XF86XK_Travel, Qt::Key_Travel,
+ XF86XK_Video, Qt::Key_Video,
+ XF86XK_Word, Qt::Key_Word,
+ XF86XK_Xfer, Qt::Key_Xfer,
+ XF86XK_ZoomIn, Qt::Key_ZoomIn,
+ XF86XK_ZoomOut, Qt::Key_ZoomOut,
+ XF86XK_Away, Qt::Key_Away,
+ XF86XK_Messenger, Qt::Key_Messenger,
+ XF86XK_WebCam, Qt::Key_WebCam,
+ XF86XK_MailForward, Qt::Key_MailForward,
+ XF86XK_Pictures, Qt::Key_Pictures,
+ XF86XK_Music, Qt::Key_Music,
+ XF86XK_Battery, Qt::Key_Battery,
+ XF86XK_Bluetooth, Qt::Key_Bluetooth,
+ XF86XK_WLAN, Qt::Key_WLAN,
+ XF86XK_UWB, Qt::Key_UWB,
+ XF86XK_AudioForward, Qt::Key_AudioForward,
+ XF86XK_AudioRepeat, Qt::Key_AudioRepeat,
+ XF86XK_AudioRandomPlay, Qt::Key_AudioRandomPlay,
+ XF86XK_Subtitle, Qt::Key_Subtitle,
+ XF86XK_AudioCycleTrack, Qt::Key_AudioCycleTrack,
+ XF86XK_Time, Qt::Key_Time,
+ XF86XK_Select, Qt::Key_Select,
+ XF86XK_View, Qt::Key_View,
+ XF86XK_TopMenu, Qt::Key_TopMenu,
+ XF86XK_Bluetooth, Qt::Key_Bluetooth,
+ XF86XK_Suspend, Qt::Key_Suspend,
+ XF86XK_Hibernate, Qt::Key_Hibernate,
+ XF86XK_Launch0, Qt::Key_Launch2, // ### Qt 5: remap properly
+ XF86XK_Launch1, Qt::Key_Launch3,
+ XF86XK_Launch2, Qt::Key_Launch4,
+ XF86XK_Launch3, Qt::Key_Launch5,
+ XF86XK_Launch4, Qt::Key_Launch6,
+ XF86XK_Launch5, Qt::Key_Launch7,
+ XF86XK_Launch6, Qt::Key_Launch8,
+ XF86XK_Launch7, Qt::Key_Launch9,
+ XF86XK_Launch8, Qt::Key_LaunchA,
+ XF86XK_Launch9, Qt::Key_LaunchB,
+ XF86XK_LaunchA, Qt::Key_LaunchC,
+ XF86XK_LaunchB, Qt::Key_LaunchD,
+ XF86XK_LaunchC, Qt::Key_LaunchE,
+ XF86XK_LaunchD, Qt::Key_LaunchF,
+ XF86XK_LaunchE, Qt::Key_LaunchG,
+ XF86XK_LaunchF, Qt::Key_LaunchH,
+
+ // Qtopia keys
+ QTOPIAXK_Select, Qt::Key_Select,
+ QTOPIAXK_Yes, Qt::Key_Yes,
+ QTOPIAXK_No, Qt::Key_No,
+ QTOPIAXK_Cancel, Qt::Key_Cancel,
+ QTOPIAXK_Printer, Qt::Key_Printer,
+ QTOPIAXK_Execute, Qt::Key_Execute,
+ QTOPIAXK_Sleep, Qt::Key_Sleep,
+ QTOPIAXK_Play, Qt::Key_Play,
+ QTOPIAXK_Zoom, Qt::Key_Zoom,
+ QTOPIAXK_Context1, Qt::Key_Context1,
+ QTOPIAXK_Context2, Qt::Key_Context2,
+ QTOPIAXK_Context3, Qt::Key_Context3,
+ QTOPIAXK_Context4, Qt::Key_Context4,
+ QTOPIAXK_Call, Qt::Key_Call,
+ QTOPIAXK_Hangup, Qt::Key_Hangup,
+ QTOPIAXK_Flip, Qt::Key_Flip,
+
+ 0, 0
+};
+
+static const unsigned short katakanaKeysymsToUnicode[] = {
+ 0x0000, 0x3002, 0x300C, 0x300D, 0x3001, 0x30FB, 0x30F2, 0x30A1,
+ 0x30A3, 0x30A5, 0x30A7, 0x30A9, 0x30E3, 0x30E5, 0x30E7, 0x30C3,
+ 0x30FC, 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD,
+ 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD,
+ 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC,
+ 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE,
+ 0x30DF, 0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9,
+ 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F3, 0x309B, 0x309C
+};
+
+static const unsigned short cyrillicKeysymsToUnicode[] = {
+ 0x0000, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0000, 0x045e, 0x045f,
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0000, 0x040e, 0x040f,
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e,
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a,
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a
+};
+
+static const unsigned short greekKeysymsToUnicode[] = {
+ 0x0000, 0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c,
+ 0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015,
+ 0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc,
+ 0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
+ 0x03a0, 0x03a1, 0x03a3, 0x0000, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
+ 0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
+ 0x03c0, 0x03c1, 0x03c3, 0x03c2, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
+ 0x03c8, 0x03c9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short technicalKeysymsToUnicode[] = {
+ 0x0000, 0x23B7, 0x250C, 0x2500, 0x2320, 0x2321, 0x2502, 0x23A1,
+ 0x23A3, 0x23A4, 0x23A6, 0x239B, 0x239D, 0x239E, 0x23A0, 0x23A8,
+ 0x23AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222B,
+ 0x2234, 0x221D, 0x221E, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000,
+ 0x223C, 0x2243, 0x0000, 0x0000, 0x0000, 0x21D4, 0x21D2, 0x2261,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221A, 0x0000,
+ 0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222A, 0x2227, 0x2228,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2202,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193, 0x0000
+};
+
+static const unsigned short specialKeysymsToUnicode[] = {
+ 0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x0000, 0x0000,
+ 0x2424, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0x23BA,
+ 0x23BB, 0x2500, 0x23BC, 0x23BD, 0x251C, 0x2524, 0x2534, 0x252C,
+ 0x2502, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short publishingKeysymsToUnicode[] = {
+ 0x0000, 0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009,
+ 0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025,
+ 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a,
+ 0x2105, 0x0000, 0x0000, 0x2012, 0x2329, 0x0000, 0x232a, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000,
+ 0x0000, 0x2122, 0x2613, 0x0000, 0x25c1, 0x25b7, 0x25cb, 0x25af,
+ 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033,
+ 0x0000, 0x271d, 0x0000, 0x25ac, 0x25c0, 0x25b6, 0x25cf, 0x25ae,
+ 0x25e6, 0x25ab, 0x25ad, 0x25b3, 0x25bd, 0x2606, 0x2022, 0x25aa,
+ 0x25b2, 0x25bc, 0x261c, 0x261e, 0x2663, 0x2666, 0x2665, 0x0000,
+ 0x2720, 0x2020, 0x2021, 0x2713, 0x2717, 0x266f, 0x266d, 0x2642,
+ 0x2640, 0x260e, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e, 0x0000
+};
+
+static const unsigned short aplKeysymsToUnicode[] = {
+ 0x0000, 0x0000, 0x0000, 0x003c, 0x0000, 0x0000, 0x003e, 0x0000,
+ 0x2228, 0x2227, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x00af, 0x0000, 0x22a5, 0x2229, 0x230a, 0x0000, 0x005f, 0x0000,
+ 0x0000, 0x0000, 0x2218, 0x0000, 0x2395, 0x0000, 0x22a4, 0x25cb,
+ 0x0000, 0x0000, 0x0000, 0x2308, 0x0000, 0x0000, 0x222a, 0x0000,
+ 0x2283, 0x0000, 0x2282, 0x0000, 0x22a2, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x22a3, 0x0000, 0x0000, 0x0000
+};
+
+static const unsigned short koreanKeysymsToUnicode[] = {
+ 0x0000, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137,
+ 0x3138, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f,
+ 0x3140, 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147,
+ 0x3148, 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f,
+ 0x3150, 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157,
+ 0x3158, 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f,
+ 0x3160, 0x3161, 0x3162, 0x3163, 0x11a8, 0x11a9, 0x11aa, 0x11ab,
+ 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3,
+ 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb,
+ 0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x316d,
+ 0x3171, 0x3178, 0x317f, 0x3181, 0x3184, 0x3186, 0x318d, 0x318e,
+ 0x11eb, 0x11f0, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9
+};
+
+static QChar keysymToUnicode(unsigned char byte3, unsigned char byte4)
+{
+ switch (byte3) {
+ case 0x04:
+ // katakana
+ if (byte4 > 0xa0 && byte4 < 0xe0)
+ return QChar(katakanaKeysymsToUnicode[byte4 - 0xa0]);
+ else if (byte4 == 0x7e)
+ return QChar(0x203e); // Overline
+ break;
+ case 0x06:
+ // russian, use lookup table
+ if (byte4 > 0xa0)
+ return QChar(cyrillicKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x07:
+ // greek
+ if (byte4 > 0xa0)
+ return QChar(greekKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x08:
+ // technical
+ if (byte4 > 0xa0)
+ return QChar(technicalKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x09:
+ // special
+ if (byte4 >= 0xe0)
+ return QChar(specialKeysymsToUnicode[byte4 - 0xe0]);
+ break;
+ case 0x0a:
+ // publishing
+ if (byte4 > 0xa0)
+ return QChar(publishingKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x0b:
+ // APL
+ if (byte4 > 0xa0)
+ return QChar(aplKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ case 0x0e:
+ // Korean
+ if (byte4 > 0xa0)
+ return QChar(koreanKeysymsToUnicode[byte4 - 0xa0]);
+ break;
+ default:
+ break;
+ }
+ return QChar(0x0);
+}
+
+Qt::KeyboardModifiers QTestLiteKeyboard::translateModifiers(int s)
+{
+ Qt::KeyboardModifiers ret = 0;
+ if (s & ShiftMask)
+ ret |= Qt::ShiftModifier;
+ if (s & ControlMask)
+ ret |= Qt::ControlModifier;
+ if (s & m_alt_mask)
+ ret |= Qt::AltModifier;
+ if (s & m_meta_mask)
+ ret |= Qt::MetaModifier;
+// if (s & m_mode_switch_mask) //doesn't seem to work correctly
+// ret |= Qt::GroupSwitchModifier;
+ return ret;
+}
+
+void QTestLiteKeyboard::setMask(KeySym sym, uint mask)
+{
+ if (m_alt_mask == 0
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Alt_L || sym == XK_Alt_R)) {
+ m_alt_mask = mask;
+ }
+ if (m_meta_mask == 0
+ && m_alt_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Meta_L || sym == XK_Meta_R)) {
+ m_meta_mask = mask;
+ }
+ if (m_super_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_hyper_mask != mask
+ && (sym == XK_Super_L || sym == XK_Super_R)) {
+ m_super_mask = mask;
+ }
+ if (m_hyper_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && (sym == XK_Hyper_L || sym == XK_Hyper_R)) {
+ m_hyper_mask = mask;
+ }
+ if (m_mode_switch_mask == 0
+ && m_alt_mask != mask
+ && m_meta_mask != mask
+ && m_super_mask != mask
+ && m_hyper_mask != mask
+ && sym == XK_Mode_switch) {
+ m_mode_switch_mask = mask;
+ }
+ if (m_num_lock_mask == 0
+ && sym == XK_Num_Lock) {
+ m_num_lock_mask = mask;
+ }
+}
+
+int QTestLiteKeyboard::translateKeySym(uint key) const
+{
+ int code = -1;
+ int i = 0; // any other keys
+ while (KeyTbl[i]) {
+ if (key == KeyTbl[i]) {
+ code = (int)KeyTbl[i+1];
+ break;
+ }
+ i += 2;
+ }
+ if (m_meta_mask) {
+ // translate Super/Hyper keys to Meta if we're using them as the MetaModifier
+ if (m_meta_mask == m_super_mask && (code == Qt::Key_Super_L || code == Qt::Key_Super_R)) {
+ code = Qt::Key_Meta;
+ } else if (m_meta_mask == m_hyper_mask && (code == Qt::Key_Hyper_L || code == Qt::Key_Hyper_R)) {
+ code = Qt::Key_Meta;
+ }
+ }
+ return code;
+}
+
+QString QTestLiteKeyboard::translateKeySym(KeySym keysym, uint xmodifiers,
+ int &code, Qt::KeyboardModifiers &modifiers,
+ QByteArray &chars, int &count)
+{
+ // all keysyms smaller than 0xff00 are actally keys that can be mapped to unicode chars
+
+ QTextCodec *mapper = QTextCodec::codecForLocale();
+ QChar converted;
+
+ if (/*count == 0 &&*/ keysym < 0xff00) {
+ unsigned char byte3 = (unsigned char)(keysym >> 8);
+ int mib = -1;
+ switch(byte3) {
+ case 0: // Latin 1
+ case 1: // Latin 2
+ case 2: //latin 3
+ case 3: // latin4
+ mib = byte3 + 4; break;
+ case 5: // arabic
+ mib = 82; break;
+ case 12: // Hebrew
+ mib = 85; break;
+ case 13: // Thai
+ mib = 2259; break;
+ case 4: // kana
+ case 6: // cyrillic
+ case 7: // greek
+ case 8: // technical, no mapping here at the moment
+ case 9: // Special
+ case 10: // Publishing
+ case 11: // APL
+ case 14: // Korean, no mapping
+ mib = -1; // manual conversion
+ mapper= 0;
+#if !defined(QT_NO_XIM)
+ converted = keysymToUnicode(byte3, keysym & 0xff);
+#endif
+ case 0x20:
+ // currency symbols
+ if (keysym >= 0x20a0 && keysym <= 0x20ac) {
+ mib = -1; // manual conversion
+ mapper = 0;
+ converted = (uint)keysym;
+ }
+ break;
+ default:
+ break;
+ }
+ if (mib != -1) {
+ mapper = QTextCodec::codecForMib(mib);
+ if (chars.isEmpty())
+ chars.resize(1);
+ chars[0] = (unsigned char) (keysym & 0xff); // get only the fourth bit for conversion later
+ count = 1;
+ }
+ } else if (keysym >= 0x1000000 && keysym <= 0x100ffff) {
+ converted = (ushort) (keysym - 0x1000000);
+ mapper = 0;
+ }
+ if (count < (int)chars.size()-1)
+ chars[count] = '\0';
+
+ QString text;
+ if (!mapper && converted.unicode() != 0x0) {
+ text = converted;
+ } else if (!chars.isEmpty()) {
+ // convert chars (8bit) to text (unicode).
+ if (mapper)
+ text = mapper->toUnicode(chars.data(), count, 0);
+ if (text.isEmpty()) {
+ // no mapper, or codec couldn't convert to unicode (this
+ // can happen when running in the C locale or with no LANG
+ // set). try converting from latin-1
+ text = QString::fromLatin1(chars);
+ }
+ }
+
+ modifiers = translateModifiers(xmodifiers);
+
+ // Commentary in X11/keysymdef says that X codes match ASCII, so it
+ // is safe to use the locale functions to process X codes in ISO8859-1.
+ //
+ // This is mainly for compatibility - applications should not use the
+ // Qt keycodes between 128 and 255, but should rather use the
+ // QKeyEvent::text().
+ //
+ if (keysym < 128 || (keysym < 256 && (!mapper || mapper->mibEnum()==4))) {
+ // upper-case key, if known
+ code = isprint((int)keysym) ? toupper((int)keysym) : 0;
+ } else if (keysym >= XK_F1 && keysym <= XK_F35) {
+ // function keys
+ code = Qt::Key_F1 + ((int)keysym - XK_F1);
+ } else if (keysym >= XK_KP_Space && keysym <= XK_KP_9) {
+ if (keysym >= XK_KP_0) {
+ // numeric keypad keys
+ code = Qt::Key_0 + ((int)keysym - XK_KP_0);
+ } else {
+ code = translateKeySym(keysym);
+ }
+ modifiers |= Qt::KeypadModifier;
+ } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f && text.unicode()->unicode() != 0x7f && !(keysym >= XK_dead_grave && keysym <= XK_dead_horn)) {
+ code = text.unicode()->toUpper().unicode();
+ } else {
+ // any other keys
+ code = translateKeySym(keysym);
+
+ if (code == Qt::Key_Tab && (modifiers & Qt::ShiftModifier)) {
+ // map shift+tab to shift+backtab, QShortcutMap knows about it
+ // and will handle it.
+ code = Qt::Key_Backtab;
+ text = QString();
+ }
+ }
+
+ return text;
+}
+
+QTestLiteKeyboard::QTestLiteKeyboard(QTestLiteScreen *screen)
+ : m_screen(screen)
+ , m_alt_mask(0)
+ , m_super_mask(0)
+ , m_hyper_mask(0)
+ , m_meta_mask(0)
+{
+ changeLayout();
+}
+
+void QTestLiteKeyboard::changeLayout()
+{
+ XkbDescPtr xkbDesc = XkbGetMap(m_screen->display(), XkbAllClientInfoMask, XkbUseCoreKbd);
+ for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) {
+ const uint mask = xkbDesc->map->modmap ? xkbDesc->map->modmap[i] : 0;
+ if (mask == 0) {
+ // key is not bound to a modifier
+ continue;
+ }
+
+ for (int j = 0; j < XkbKeyGroupsWidth(xkbDesc, i); ++j) {
+ KeySym keySym = XkbKeySym(xkbDesc, i, j);
+ if (keySym == NoSymbol)
+ continue;
+ setMask(keySym, mask);
+ }
+ }
+ XkbFreeKeyboard(xkbDesc, XkbAllComponentsMask, true);
+
+}
+
+static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode)
+{
+ switch (qtcode) {
+ case Qt::Key_Control:
+ return Qt::ControlModifier;
+ case Qt::Key_Alt:
+ return Qt::AltModifier;
+ case Qt::Key_Shift:
+ return Qt::ShiftModifier;
+ case Qt::Key_Meta:
+ return Qt::MetaModifier;
+ default:
+ return Qt::NoModifier;
+ }
+}
+
+void QTestLiteKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev)
+{
+ int qtcode = 0;
+ Qt::KeyboardModifiers modifiers = translateModifiers(ev->state);
+ QByteArray chars;
+ chars.resize(513);
+ int count = 0;
+ KeySym keySym;
+ count = XLookupString(ev,chars.data(),chars.size(),&keySym,0);
+ QString text = translateKeySym(keySym,ev->state,qtcode,modifiers,chars,count);
+ QWindowSystemInterface::handleKeyEvent(widget,ev->time,type,qtcode,modifiers,text.left(count));
+}
diff --git a/src/plugins/platforms/testlite/qtestlitekeyboard.h b/src/plugins/platforms/testlite/qtestlitekeyboard.h
new file mode 100644
index 0000000..6873a09
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitekeyboard.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITEKEYBOARD_H
+#define QTESTLITEKEYBOARD_H
+
+#include "qtestliteintegration.h"
+
+class QTestLiteKeyboard
+{
+public:
+ QTestLiteKeyboard(QTestLiteScreen *screen);
+
+ void changeLayout();
+
+ void handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev);
+
+ Qt::KeyboardModifiers translateModifiers(int s);
+
+private:
+
+ void setMask(KeySym sym, uint mask);
+ int translateKeySym(uint key) const;
+ QString translateKeySym(KeySym keysym, uint xmodifiers,
+ int &code, Qt::KeyboardModifiers &modifiers,
+ QByteArray &chars, int &count);
+
+ QTestLiteScreen *m_screen;
+
+ uint m_alt_mask;
+ uint m_super_mask;
+ uint m_hyper_mask;
+ uint m_meta_mask;
+ uint m_mode_switch_mask;
+ uint m_num_lock_mask;
+};
+
+#endif // QTESTLITEKEYBOARD_H
diff --git a/src/plugins/platforms/testlite/qtestlitemime.cpp b/src/plugins/platforms/testlite/qtestlitemime.cpp
new file mode 100644
index 0000000..c509991
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitemime.cpp
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtestlitemime.h"
+
+#include "qtestlitestaticinfo.h"
+#include "qtestlitescreen.h"
+
+#include <QtCore/QTextCodec>
+#include <QtGui/QImageWriter>
+#include <QtCore/QBuffer>
+
+QTestLiteMime::QTestLiteMime()
+ : QInternalMimeData()
+{ }
+
+QTestLiteMime::~QTestLiteMime()
+{}
+
+
+
+
+
+QString QTestLiteMime::mimeAtomToString(Display *display, Atom a)
+{
+ if (!a) return 0;
+
+ if (a == XA_STRING || a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)) {
+ return "text/plain"; // some Xdnd clients are dumb
+ }
+ char *atom = XGetAtomName(display, a);
+ QString result = QString::fromLatin1(atom);
+ XFree(atom);
+ return result;
+}
+
+Atom QTestLiteMime::mimeStringToAtom(Display *display, const QString &mimeType)
+{
+ if (mimeType.isEmpty())
+ return 0;
+ return XInternAtom(display, mimeType.toLatin1().constData(), False);
+}
+
+QStringList QTestLiteMime::mimeFormatsForAtom(Display *display, Atom a)
+{
+ QStringList formats;
+ if (a) {
+ QString atomName = mimeAtomToString(display, a);
+ formats.append(atomName);
+
+ // special cases for string type
+ if (a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)
+ || a == XA_STRING
+ || a == QTestLiteStatic::atom(QTestLiteStatic::TEXT)
+ || a == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT))
+ formats.append(QLatin1String("text/plain"));
+
+ // special cases for uris
+ if (atomName == QLatin1String("text/x-moz-url"))
+ formats.append(QLatin1String("text/uri-list"));
+
+ // special case for images
+ if (a == XA_PIXMAP)
+ formats.append(QLatin1String("image/ppm"));
+ }
+ return formats;
+}
+
+bool QTestLiteMime::mimeDataForAtom(Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
+{
+ bool ret = false;
+ *atomFormat = a;
+ *dataFormat = 8;
+ QString atomName = mimeAtomToString(display, a);
+ if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) {
+ *data = QInternalMimeData::renderDataHelper(atomName, mimeData);
+ if (atomName == QLatin1String("application/x-color"))
+ *dataFormat = 16;
+ ret = true;
+ } else {
+ if ((a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)
+ || a == XA_STRING
+ || a == QTestLiteStatic::atom(QTestLiteStatic::TEXT)
+ || a == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT))
+ && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
+ if (a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)){
+ *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
+ ret = true;
+ } else if (a == XA_STRING) {
+ *data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
+ QLatin1String("text/plain"), mimeData)).toLocal8Bit();
+ ret = true;
+ } else if (a == QTestLiteStatic::atom(QTestLiteStatic::TEXT)
+ || a == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT)) {
+ // the ICCCM states that TEXT and COMPOUND_TEXT are in the
+ // encoding of choice, so we choose the encoding of the locale
+ QByteArray strData = QString::fromUtf8(QInternalMimeData::renderDataHelper(
+ QLatin1String("text/plain"), mimeData)).toLocal8Bit();
+ char *list[] = { strData.data(), NULL };
+
+ XICCEncodingStyle style = (a == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT))
+ ? XCompoundTextStyle : XStdICCTextStyle;
+ XTextProperty textprop;
+ if (list[0] != NULL
+ && XmbTextListToTextProperty(display, list, 1, style,
+ &textprop) == Success) {
+ *atomFormat = textprop.encoding;
+ *dataFormat = textprop.format;
+ *data = QByteArray((const char *) textprop.value, textprop.nitems * textprop.format / 8);
+ ret = true;
+
+ XFree(textprop.value);
+ }
+ }
+ } else if (atomName == QLatin1String("text/x-moz-url") &&
+ QInternalMimeData::hasFormatHelper(QLatin1String("text/uri-list"), mimeData)) {
+ QByteArray uri = QInternalMimeData::renderDataHelper(
+ QLatin1String("text/uri-list"), mimeData).split('\n').first();
+ QString mozUri = QString::fromLatin1(uri, uri.size());
+ mozUri += QLatin1Char('\n');
+ *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2);
+ ret = true;
+ } else if ((a == XA_PIXMAP || a == XA_BITMAP) && mimeData->hasImage()) {
+ ret = true;
+ }
+ }
+ return ret && data != 0;
+}
+
+QList<Atom> QTestLiteMime::mimeAtomsForFormat(Display *display, const QString &format)
+{
+ QList<Atom> atoms;
+ atoms.append(mimeStringToAtom(display, format));
+
+ // special cases for strings
+ if (format == QLatin1String("text/plain")) {
+ atoms.append(QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING));
+ atoms.append(XA_STRING);
+ atoms.append(QTestLiteStatic::atom(QTestLiteStatic::TEXT));
+ atoms.append(QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT));
+ }
+
+ // special cases for uris
+ if (format == QLatin1String("text/uri-list")) {
+ atoms.append(mimeStringToAtom(display,QLatin1String("text/x-moz-url")));
+ }
+
+ //special cases for images
+ if (format == QLatin1String("image/ppm"))
+ atoms.append(XA_PIXMAP);
+ if (format == QLatin1String("image/pbm"))
+ atoms.append(XA_BITMAP);
+
+ return atoms;
+}
+
+QVariant QTestLiteMime::mimeConvertToFormat(Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
+{
+ QString atomName = mimeAtomToString(display,a);
+ if (atomName == format)
+ return data;
+
+ if (!encoding.isEmpty()
+ && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
+
+ if (requestedType == QVariant::String) {
+ QTextCodec *codec = QTextCodec::codecForName(encoding);
+ if (codec)
+ return codec->toUnicode(data);
+ }
+
+ return data;
+ }
+
+ // special cases for string types
+ if (format == QLatin1String("text/plain")) {
+ if (a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING))
+ return QString::fromUtf8(data);
+ if (a == XA_STRING)
+ return QString::fromLatin1(data);
+ if (a == QTestLiteStatic::atom(QTestLiteStatic::TEXT)
+ || a == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT))
+ // #### might be wrong for COMPUND_TEXT
+ return QString::fromLocal8Bit(data, data.size());
+ }
+
+ // special case for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ if (atomName == QLatin1String("text/x-moz-url")) {
+ // we expect this as utf16 <url><space><title>
+ // the first part is a url that should only contain ascci char
+ // so it should be safe to check that the second char is 0
+ // to verify that it is utf16
+ if (data.size() > 1 && data.at(1) == 0)
+ return QString::fromRawData((const QChar *)data.constData(),
+ data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
+ }
+ }
+
+ // special cas for images
+ if (format == QLatin1String("image/ppm")) {
+ if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) {
+ Pixmap xpm = *((Pixmap*)data.data());
+ if (!xpm)
+ return QByteArray();
+ Window root;
+ int x;
+ int y;
+ uint width;
+ uint height;
+ uint border_width;
+ uint depth;
+
+ XGetGeometry(display, xpm, &root, &x, &y, &width, &height, &border_width, &depth);
+ XImage *ximg = XGetImage(display,xpm,x,y,width,height,AllPlanes,depth==1 ? XYPixmap : ZPixmap);
+ QImage qimg = QTestLiteStatic::qimageFromXImage(ximg);
+ XDestroyImage(ximg);
+
+ QImageWriter imageWriter;
+ imageWriter.setFormat("PPMRAW");
+ QBuffer buf;
+ buf.open(QIODevice::WriteOnly);
+ imageWriter.setDevice(&buf);
+ imageWriter.write(qimg);
+ return buf.buffer();
+ }
+ }
+ return QVariant();
+}
+
+Atom QTestLiteMime::mimeAtomForFormat(Display *display, const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *requestedEncoding)
+{
+ requestedEncoding->clear();
+
+ // find matches for string types
+ if (format == QLatin1String("text/plain")) {
+ if (atoms.contains(QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)))
+ return QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING);
+ if (atoms.contains(QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT)))
+ return QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT);
+ if (atoms.contains(QTestLiteStatic::atom(QTestLiteStatic::TEXT)))
+ return QTestLiteStatic::atom(QTestLiteStatic::TEXT);
+ if (atoms.contains(XA_STRING))
+ return XA_STRING;
+ }
+
+ // find matches for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ Atom a = mimeStringToAtom(display,format);
+ if (a && atoms.contains(a))
+ return a;
+ a = mimeStringToAtom(display,QLatin1String("text/x-moz-url"));
+ if (a && atoms.contains(a))
+ return a;
+ }
+
+ // find match for image
+ if (format == QLatin1String("image/ppm")) {
+ if (atoms.contains(XA_PIXMAP))
+ return XA_PIXMAP;
+ }
+
+ // for string/text requests try to use a format with a well-defined charset
+ // first to avoid encoding problems
+ if (requestedType == QVariant::String
+ && format.startsWith(QLatin1String("text/"))
+ && !format.contains(QLatin1String("charset="))) {
+
+ QString formatWithCharset = format;
+ formatWithCharset.append(QLatin1String(";charset=utf-8"));
+
+ Atom a = mimeStringToAtom(display,formatWithCharset);
+ if (a && atoms.contains(a)) {
+ *requestedEncoding = "utf-8";
+ return a;
+ }
+ }
+
+ Atom a = mimeStringToAtom(display,format);
+ if (a && atoms.contains(a))
+ return a;
+
+ return 0;
+}
diff --git a/src/plugins/platforms/testlite/qtestlitemime.h b/src/plugins/platforms/testlite/qtestlitemime.h
new file mode 100644
index 0000000..f11070f
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitemime.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITEMIME_H
+#define QTESTLITEMIME_H
+
+#include <private/qdnd_p.h>
+
+#include <QtGui/QClipboard>
+
+#include "qtestliteintegration.h"
+#include "qtestliteclipboard.h"
+
+class QTestLiteMime : public QInternalMimeData {
+ Q_OBJECT
+public:
+ QTestLiteMime();
+ ~QTestLiteMime();
+
+ static QList<Atom> mimeAtomsForFormat(Display *display, const QString &format);
+ static QString mimeAtomToString(Display *display, Atom a);
+ static bool mimeDataForAtom(Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat);
+ static QStringList mimeFormatsForAtom(Display *display, Atom a);
+ static Atom mimeStringToAtom(Display *display, const QString &mimeType);
+ static QVariant mimeConvertToFormat(Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding);
+ static Atom mimeAtomForFormat(Display *display, const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *requestedEncoding);
+};
+
+#endif // QTESTLITEMIME_H
diff --git a/src/plugins/platforms/testlite/qtestlitescreen.cpp b/src/plugins/platforms/testlite/qtestlitescreen.cpp
new file mode 100644
index 0000000..c211ee6
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitescreen.cpp
@@ -0,0 +1,468 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtestlitescreen.h"
+
+#include "qtestlitecursor.h"
+#include "qtestlitewindow.h"
+#include "qtestlitekeyboard.h"
+#include "qtestlitestaticinfo.h"
+#include "qtestliteclipboard.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QSocketNotifier>
+#include <QtCore/QElapsedTimer>
+
+#include <private/qapplication_p.h>
+
+#include <X11/extensions/Xfixes.h>
+
+QT_BEGIN_NAMESPACE
+
+static int (*original_x_errhandler)(Display *dpy, XErrorEvent *);
+static bool seen_badwindow;
+
+static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
+{
+
+qDebug() << "qt_x_errhandler" << err->error_code;
+
+ switch (err->error_code) {
+ case BadAtom:
+#if 0
+ if (err->request_code == 20 /* X_GetProperty */
+ && (err->resourceid == XA_RESOURCE_MANAGER
+ || err->resourceid == XA_RGB_DEFAULT_MAP
+ || err->resourceid == ATOM(_NET_SUPPORTED)
+ || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
+ || err->resourceid == ATOM(KDE_FULL_SESSION)
+ || err->resourceid == ATOM(KWIN_RUNNING)
+ || err->resourceid == ATOM(XdndProxy)
+ || err->resourceid == ATOM(XdndAware))
+
+
+ ) {
+ // Perhaps we're running under SECURITY reduction? :/
+ return 0;
+ }
+#endif
+ qDebug() << "BadAtom";
+ break;
+
+ case BadWindow:
+ if (err->request_code == 2 /* X_ChangeWindowAttributes */
+ || err->request_code == 38 /* X_QueryPointer */) {
+ for (int i = 0; i < ScreenCount(dpy); ++i) {
+ if (err->resourceid == RootWindow(dpy, i)) {
+ // Perhaps we're running under SECURITY reduction? :/
+ return 0;
+ }
+ }
+ }
+ seen_badwindow = true;
+ if (err->request_code == 25 /* X_SendEvent */) {
+ for (int i = 0; i < ScreenCount(dpy); ++i) {
+ if (err->resourceid == RootWindow(dpy, i)) {
+ // Perhaps we're running under SECURITY reduction? :/
+ return 0;
+ }
+ }
+#if 0
+ if (X11->xdndHandleBadwindow()) {
+ qDebug("xdndHandleBadwindow returned true");
+ return 0;
+ }
+#endif
+ }
+#if 0
+ if (X11->ignore_badwindow)
+ return 0;
+#endif
+ break;
+
+ case BadMatch:
+ if (err->request_code == 42 /* X_SetInputFocus */)
+ return 0;
+ break;
+
+ default:
+#if 0 //!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;
+ }
+
+ char errstr[256];
+ XGetErrorText( dpy, err->error_code, errstr, 256 );
+ char buffer[256];
+ char request_str[256];
+ qsnprintf(buffer, 256, "%d", err->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256);
+ if (err->request_code < 128) {
+ // X error for a normal protocol request
+ qWarning( "X Error: %s %d\n"
+ " Major opcode: %d (%s)\n"
+ " Resource id: 0x%lx",
+ errstr, err->error_code,
+ err->request_code,
+ request_str,
+ err->resourceid );
+ } else {
+ // X error for an extension request
+ const char *extensionName = 0;
+#if 0
+ if (err->request_code == X11->xrender_major)
+ extensionName = "RENDER";
+ else if (err->request_code == X11->xrandr_major)
+ extensionName = "RANDR";
+ else if (err->request_code == X11->xinput_major)
+ extensionName = "XInputExtension";
+ else if (err->request_code == X11->mitshm_major)
+ extensionName = "MIT-SHM";
+#endif
+ char minor_str[256];
+ if (extensionName) {
+ qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256);
+ } else {
+ extensionName = "Uknown extension";
+ qsnprintf(minor_str, 256, "Unknown request");
+ }
+ qWarning( "X Error: %s %d\n"
+ " Extension: %d (%s)\n"
+ " Minor opcode: %d (%s)\n"
+ " Resource id: 0x%lx",
+ errstr, err->error_code,
+ err->request_code,
+ extensionName,
+ err->minor_code,
+ minor_str,
+ err->resourceid );
+ }
+
+ // ### we really should distinguish between severe, non-severe and
+ // ### application specific errors
+
+ return 0;
+}
+
+QTestLiteScreen::QTestLiteScreen()
+ : mFormat(QImage::Format_RGB32)
+{
+ char *display_name = getenv("DISPLAY");
+ mDisplay = XOpenDisplay(display_name);
+ mDisplayName = QString::fromLocal8Bit(display_name);
+ if (!mDisplay) {
+ fprintf(stderr, "Cannot connect to X server: %s\n",
+ display_name);
+ exit(1);
+ }
+
+#ifndef DONT_USE_MIT_SHM
+ Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay);
+ Q_ASSERT(MIT_SHM_extension_supported == True);
+#endif
+ original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
+
+ if (qgetenv("DO_X_SYNCHRONIZE").toInt())
+ XSynchronize(mDisplay, true);
+
+ mScreen = DefaultScreen(mDisplay);
+ XSelectInput(mDisplay,rootWindow(), KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
+ int width = DisplayWidth(mDisplay, mScreen);
+ int height = DisplayHeight(mDisplay, mScreen);
+ mGeometry = QRect(0,0,width,height);
+
+ int physicalWidth = DisplayWidthMM(mDisplay, mScreen);
+ int physicalHeight = DisplayHeightMM(mDisplay, mScreen);
+ mPhysicalSize = QSize(physicalWidth,physicalHeight);
+
+ int xSocketNumber = XConnectionNumber(mDisplay);
+
+ mDepth = DefaultDepth(mDisplay,mScreen);
+#ifdef MYX11_DEBUG
+ qDebug() << "X socket:"<< xSocketNumber;
+#endif
+ QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this);
+ connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher()));
+
+ mCursor = new QTestLiteCursor(this);
+ mKeyboard = new QTestLiteKeyboard(this);
+}
+
+QTestLiteScreen::~QTestLiteScreen()
+{
+ delete mCursor;
+ XCloseDisplay(mDisplay);
+}
+
+#ifdef KeyPress
+#undef KeyPress
+#endif
+#ifdef KeyRelease
+#undef KeyRelease
+#endif
+
+bool QTestLiteScreen::handleEvent(XEvent *xe)
+{
+ int quit = false;
+ QTestLiteWindow *platformWindow = 0;
+ QWidget *widget = QWidget::find(xe->xany.window);
+ if (widget) {
+ platformWindow = static_cast<QTestLiteWindow *>(widget->platformWindow());
+ }
+
+ Atom wmProtocolsAtom = QTestLiteStatic::atom(QTestLiteStatic::WM_PROTOCOLS);
+ Atom wmDeleteWindowAtom = QTestLiteStatic::atom(QTestLiteStatic::WM_DELETE_WINDOW);
+ switch (xe->type) {
+
+ case ClientMessage:
+ if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) {
+ Atom a = xe->xclient.data.l[0];
+ if (a == wmDeleteWindowAtom)
+ platformWindow->handleCloseEvent();
+ }
+ break;
+
+ case Expose:
+ if (platformWindow)
+ if (xe->xexpose.count == 0)
+ platformWindow->paintEvent();
+ break;
+ case ConfigureNotify:
+ if (platformWindow)
+ platformWindow->resizeEvent(&xe->xconfigure);
+ break;
+
+ case ButtonPress:
+ if (platformWindow)
+ platformWindow->mousePressEvent(&xe->xbutton);
+ break;
+
+ case ButtonRelease:
+ if (platformWindow)
+ platformWindow->handleMouseEvent(QEvent::MouseButtonRelease, &xe->xbutton);
+ break;
+
+ case MotionNotify:
+ if (platformWindow)
+ platformWindow->handleMouseEvent(QEvent::MouseMove, &xe->xbutton);
+ break;
+
+ case XKeyPress:
+ mKeyboard->handleKeyEvent(widget,QEvent::KeyPress, &xe->xkey);
+ break;
+
+ case XKeyRelease:
+ mKeyboard->handleKeyEvent(widget,QEvent::KeyRelease, &xe->xkey);
+ break;
+
+ case EnterNotify:
+ if (platformWindow)
+ platformWindow->handleEnterEvent();
+ break;
+
+ case LeaveNotify:
+ if (platformWindow)
+ platformWindow->handleLeaveEvent();
+ break;
+
+ case XFocusIn:
+ if (platformWindow)
+ platformWindow->handleFocusInEvent();
+ break;
+
+ case XFocusOut:
+ if (platformWindow)
+ platformWindow->handleFocusOutEvent();
+ break;
+
+ case PropertyNotify:
+ break;
+
+ case SelectionClear:
+ qDebug() << "Selection Clear!!!";
+ break;
+ case SelectionRequest:
+ handleSelectionRequest(xe);
+ break;
+ case SelectionNotify:
+ qDebug() << "Selection Notify!!!!";
+
+ break;
+
+
+ default:
+#ifdef MYX11_DEBUG
+ qDebug() << hex << xe->xany.window << "Other X event" << xe->type;
+#endif
+ break;
+ }
+
+ return quit;
+}
+
+static Bool checkForClipboardEvents(Display *, XEvent *e, XPointer)
+{
+ Atom clipboard = QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD);
+ return ((e->type == SelectionRequest && (e->xselectionrequest.selection == XA_PRIMARY
+ || e->xselectionrequest.selection == clipboard))
+ || (e->type == SelectionClear && (e->xselectionclear.selection == XA_PRIMARY
+ || e->xselectionclear.selection == clipboard)));
+}
+
+bool QTestLiteScreen::waitForClipboardEvent(Window win, int type, XEvent *event, int timeout)
+{
+ QElapsedTimer timer;
+ timer.start();
+ do {
+ if (XCheckTypedWindowEvent(mDisplay,win,type,event))
+ return true;
+
+ // process other clipboard events, since someone is probably requesting data from us
+ XEvent e;
+ if (XCheckIfEvent(mDisplay, &e, checkForClipboardEvents, 0))
+ handleEvent(&e);
+
+ XFlush(mDisplay);
+
+ // sleep 50 ms, so we don't use up CPU cycles all the time.
+ struct timeval usleep_tv;
+ usleep_tv.tv_sec = 0;
+ usleep_tv.tv_usec = 50000;
+ select(0, 0, 0, 0, &usleep_tv);
+ } while (timer.elapsed() < timeout);
+ return false;
+}
+
+void QTestLiteScreen::eventDispatcher()
+{
+ ulong marker = XNextRequest(mDisplay);
+ // int i = 0;
+ while (XPending(mDisplay)) {
+ XEvent event;
+ XNextEvent(mDisplay, &event);
+ /* done = */
+ handleEvent(&event);
+
+ if (event.xany.serial >= marker) {
+ #ifdef MYX11_DEBUG
+ qDebug() << "potential livelock averted";
+ #endif
+ #if 0
+ if (XEventsQueued(mDisplay, QueuedAfterFlush)) {
+ qDebug() << " with events queued";
+ QTimer::singleShot(0, this, SLOT(eventDispatcher()));
+ }
+ #endif
+ break;
+ }
+ }
+}
+
+QImage QTestLiteScreen::grabWindow(Window window, int x, int y, int w, int h)
+{
+ if (w == 0 || h ==0)
+ return QImage();
+
+ //WinId 0 means the desktop widget
+ if (!window)
+ window = rootWindow();
+
+ XWindowAttributes window_attr;
+ if (!XGetWindowAttributes(mDisplay, window, &window_attr))
+ return QImage();
+
+ if (w < 0)
+ w = window_attr.width - x;
+ if (h < 0)
+ h = window_attr.height - y;
+
+ // Ideally, we should also limit ourselves to the screen area, but the Qt docs say
+ // that it's "unsafe" to go outside the screen, so we can ignore that problem.
+
+ //We're definitely not optimizing for speed...
+ XImage *xi = XGetImage(mDisplay, window, x, y, w, h, AllPlanes, ZPixmap);
+
+ if (!xi)
+ return QImage();
+
+ //taking a copy to make sure we have ownership -- not fast
+ QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy();
+
+ XDestroyImage(xi);
+
+ return result;
+}
+
+QTestLiteScreen * QTestLiteScreen::testLiteScreenForWidget(QWidget *widget)
+{
+ QPlatformScreen *platformScreen = platformScreenForWidget(widget);
+ return static_cast<QTestLiteScreen *>(platformScreen);
+}
+
+Display * QTestLiteScreen::display() const
+{
+ return mDisplay;
+}
+
+int QTestLiteScreen::xScreenNumber() const
+{
+ return mScreen;
+}
+
+QTestLiteKeyboard * QTestLiteScreen::keyboard() const
+{
+ return mKeyboard;
+}
+
+void QTestLiteScreen::handleSelectionRequest(XEvent *event)
+{
+ QPlatformIntegration *integration = QApplicationPrivate::platformIntegration();
+ QTestLiteClipboard *clipboard = static_cast<QTestLiteClipboard *>(integration->clipboard());
+ clipboard->handleSelectionRequest(event);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/testlite/qtestlitescreen.h b/src/plugins/platforms/testlite/qtestlitescreen.h
new file mode 100644
index 0000000..860a67c
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitescreen.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITESCREEN_H
+#define QTESTLITESCREEN_H
+
+#include <QtGui/QPlatformScreen>
+#include "qtestliteintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTestLiteCursor;
+class QTestLiteKeyboard;
+
+class QTestLiteScreen : public QPlatformScreen
+{
+ Q_OBJECT
+public:
+ QTestLiteScreen();
+
+ ~QTestLiteScreen();
+
+ QString displayName() const { return mDisplayName; }
+
+ QRect geometry() const { return mGeometry; }
+ int depth() const { return mDepth; }
+ QImage::Format format() const { return mFormat; }
+ QSize physicalSize() const { return mPhysicalSize; }
+
+ Window rootWindow() { return RootWindow(mDisplay, mScreen); }
+ unsigned long blackPixel() { return BlackPixel(mDisplay, mScreen); }
+ unsigned long whitePixel() { return WhitePixel(mDisplay, mScreen); }
+
+ bool handleEvent(XEvent *xe);
+ bool waitForClipboardEvent(Window win, int type, XEvent *event, int timeout);
+
+ QImage grabWindow(Window window, int x, int y, int w, int h);
+
+ static QTestLiteScreen *testLiteScreenForWidget(QWidget *widget);
+
+ Display *display() const;
+ int xScreenNumber() const;
+
+ QTestLiteKeyboard *keyboard() const;
+
+public slots:
+ void eventDispatcher();
+
+private:
+
+ void handleSelectionRequest(XEvent *event);
+ QString mDisplayName;
+ QRect mGeometry;
+ QSize mPhysicalSize;
+ int mDepth;
+ QImage::Format mFormat;
+ QTestLiteCursor *mCursor;
+ QTestLiteKeyboard *mKeyboard;
+
+ Display * mDisplay;
+ int mScreen;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTESTLITESCREEN_H
diff --git a/src/plugins/platforms/testlite/qtestlitestaticinfo.cpp b/src/plugins/platforms/testlite/qtestlitestaticinfo.cpp
new file mode 100644
index 0000000..2c6404d
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitestaticinfo.cpp
@@ -0,0 +1,511 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtestlitestaticinfo.h"
+#include "qtestlitescreen.h"
+
+#include <qplatformdefs.h>
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtCore/QBuffer>
+#include <QtCore/QLibrary>
+
+#include <QDebug>
+
+#ifndef QT_NO_XFIXES
+#include <X11/extensions/Xfixes.h>
+#endif // QT_NO_XFIXES
+
+static const char * x11_atomnames = {
+ // window-manager <-> client protocols
+ "WM_PROTOCOLS\0"
+ "WM_DELETE_WINDOW\0"
+ "WM_TAKE_FOCUS\0"
+ "_NET_WM_PING\0"
+ "_NET_WM_CONTEXT_HELP\0"
+ "_NET_WM_SYNC_REQUEST\0"
+ "_NET_WM_SYNC_REQUEST_COUNTER\0"
+
+ // ICCCM window state
+ "WM_STATE\0"
+ "WM_CHANGE_STATE\0"
+
+ // Session management
+ "WM_CLIENT_LEADER\0"
+ "WM_WINDOW_ROLE\0"
+ "SM_CLIENT_ID\0"
+
+ // Clipboard
+ "CLIPBOARD\0"
+ "INCR\0"
+ "TARGETS\0"
+ "MULTIPLE\0"
+ "TIMESTAMP\0"
+ "SAVE_TARGETS\0"
+ "CLIP_TEMPORARY\0"
+ "_QT_SELECTION\0"
+ "_QT_CLIPBOARD_SENTINEL\0"
+ "_QT_SELECTION_SENTINEL\0"
+ "CLIPBOARD_MANAGER\0"
+
+ "RESOURCE_MANAGER\0"
+
+ "_XSETROOT_ID\0"
+
+ "_QT_SCROLL_DONE\0"
+ "_QT_INPUT_ENCODING\0"
+
+ "_MOTIF_WM_HINTS\0"
+
+ "DTWM_IS_RUNNING\0"
+ "ENLIGHTENMENT_DESKTOP\0"
+ "_DT_SAVE_MODE\0"
+ "_SGI_DESKS_MANAGER\0"
+
+ // EWMH (aka NETWM)
+ "_NET_SUPPORTED\0"
+ "_NET_VIRTUAL_ROOTS\0"
+ "_NET_WORKAREA\0"
+
+ "_NET_MOVERESIZE_WINDOW\0"
+ "_NET_WM_MOVERESIZE\0"
+
+ "_NET_WM_NAME\0"
+ "_NET_WM_ICON_NAME\0"
+ "_NET_WM_ICON\0"
+
+ "_NET_WM_PID\0"
+
+ "_NET_WM_WINDOW_OPACITY\0"
+
+ "_NET_WM_STATE\0"
+ "_NET_WM_STATE_ABOVE\0"
+ "_NET_WM_STATE_BELOW\0"
+ "_NET_WM_STATE_FULLSCREEN\0"
+ "_NET_WM_STATE_MAXIMIZED_HORZ\0"
+ "_NET_WM_STATE_MAXIMIZED_VERT\0"
+ "_NET_WM_STATE_MODAL\0"
+ "_NET_WM_STATE_STAYS_ON_TOP\0"
+ "_NET_WM_STATE_DEMANDS_ATTENTION\0"
+
+ "_NET_WM_USER_TIME\0"
+ "_NET_WM_USER_TIME_WINDOW\0"
+ "_NET_WM_FULL_PLACEMENT\0"
+
+ "_NET_WM_WINDOW_TYPE\0"
+ "_NET_WM_WINDOW_TYPE_DESKTOP\0"
+ "_NET_WM_WINDOW_TYPE_DOCK\0"
+ "_NET_WM_WINDOW_TYPE_TOOLBAR\0"
+ "_NET_WM_WINDOW_TYPE_MENU\0"
+ "_NET_WM_WINDOW_TYPE_UTILITY\0"
+ "_NET_WM_WINDOW_TYPE_SPLASH\0"
+ "_NET_WM_WINDOW_TYPE_DIALOG\0"
+ "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU\0"
+ "_NET_WM_WINDOW_TYPE_POPUP_MENU\0"
+ "_NET_WM_WINDOW_TYPE_TOOLTIP\0"
+ "_NET_WM_WINDOW_TYPE_NOTIFICATION\0"
+ "_NET_WM_WINDOW_TYPE_COMBO\0"
+ "_NET_WM_WINDOW_TYPE_DND\0"
+ "_NET_WM_WINDOW_TYPE_NORMAL\0"
+ "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE\0"
+
+ "_KDE_NET_WM_FRAME_STRUT\0"
+
+ "_NET_STARTUP_INFO\0"
+ "_NET_STARTUP_INFO_BEGIN\0"
+
+ "_NET_SUPPORTING_WM_CHECK\0"
+
+ "_NET_WM_CM_S0\0"
+
+ "_NET_SYSTEM_TRAY_VISUAL\0"
+
+ "_NET_ACTIVE_WINDOW\0"
+
+ // Property formats
+ "COMPOUND_TEXT\0"
+ "TEXT\0"
+ "UTF8_STRING\0"
+
+ // xdnd
+ "XdndEnter\0"
+ "XdndPosition\0"
+ "XdndStatus\0"
+ "XdndLeave\0"
+ "XdndDrop\0"
+ "XdndFinished\0"
+ "XdndTypeList\0"
+ "XdndActionList\0"
+
+ "XdndSelection\0"
+
+ "XdndAware\0"
+ "XdndProxy\0"
+
+ "XdndActionCopy\0"
+ "XdndActionLink\0"
+ "XdndActionMove\0"
+ "XdndActionPrivate\0"
+
+ // Motif DND
+ "_MOTIF_DRAG_AND_DROP_MESSAGE\0"
+ "_MOTIF_DRAG_INITIATOR_INFO\0"
+ "_MOTIF_DRAG_RECEIVER_INFO\0"
+ "_MOTIF_DRAG_WINDOW\0"
+ "_MOTIF_DRAG_TARGETS\0"
+
+ "XmTRANSFER_SUCCESS\0"
+ "XmTRANSFER_FAILURE\0"
+
+ // Xkb
+ "_XKB_RULES_NAMES\0"
+
+ // XEMBED
+ "_XEMBED\0"
+ "_XEMBED_INFO\0"
+
+ // Wacom old. (before version 0.10)
+ "Wacom Stylus\0"
+ "Wacom Cursor\0"
+ "Wacom Eraser\0"
+
+ // Tablet
+ "STYLUS\0"
+ "ERASER\0"
+};
+
+/*!
+ \internal
+ Try to resolve a \a symbol from \a library with the version specified
+ by \a vernum.
+
+ Note that, in the case of the Xfixes library, \a vernum is not the same as
+ \c XFIXES_MAJOR - it is a part of soname and may differ from the Xfixes
+ version.
+*/
+static void* qt_load_library_runtime(const char *library, int vernum,
+ int highestVernum, const char *symbol)
+{
+ QList<int> versions;
+ // we try to load in the following order:
+ // explicit version -> the default one -> (from the highest (highestVernum) to the lowest (vernum) )
+ if (vernum != -1)
+ versions << vernum;
+ versions << -1;
+ if (vernum != -1) {
+ for(int i = highestVernum; i > vernum; --i)
+ versions << i;
+ }
+ Q_FOREACH(int version, versions) {
+ QLatin1String libName(library);
+ QLibrary xfixesLib(libName, version);
+ void *ptr = xfixesLib.resolve(symbol);
+ if (ptr)
+ return ptr;
+ }
+ return 0;
+}
+
+# define XFIXES_LOAD_RUNTIME(vernum, symbol, symbol_type) \
+ (symbol_type)qt_load_library_runtime("libXfixes", vernum, 4, #symbol);
+# define XFIXES_LOAD_V1(symbol) \
+ XFIXES_LOAD_RUNTIME(1, symbol, Ptr##symbol)
+# define XFIXES_LOAD_V2(symbol) \
+ XFIXES_LOAD_RUNTIME(2, symbol, Ptr##symbol)
+
+
+class QTestLiteStaticInfoPrivate
+{
+public:
+ QTestLiteStaticInfoPrivate()
+ : use_xfixes(false)
+ , xfixes_major(0)
+ , xfixes_eventbase(0)
+ , xfixes_errorbase(0)
+ {
+ QTestLiteScreen *screen = qobject_cast<QTestLiteScreen *> (QApplicationPrivate::platformIntegration()->screens().at(0));
+ Q_ASSERT(screen);
+
+ initializeAllAtoms(screen);
+ initializeSupportedAtoms(screen);
+
+ resolveXFixes(screen);
+ }
+
+ bool isSupportedByWM(Atom atom)
+ {
+ if (!m_supportedAtoms)
+ return false;
+
+ bool supported = false;
+ int i = 0;
+ while (m_supportedAtoms[i] != 0) {
+ if (m_supportedAtoms[i++] == atom) {
+ supported = true;
+ break;
+ }
+ }
+
+ return supported;
+ }
+
+ Atom atom(QTestLiteStatic::X11Atom atom)
+ {
+ return m_allAtoms[atom];
+ }
+
+ bool useXFixes() const { return use_xfixes; }
+
+ int xFixesEventBase() const {return xfixes_eventbase; }
+
+ PtrXFixesSelectSelectionInput xFixesSelectSelectionInput() const
+ {
+ return ptrXFixesSelectSelectionInput;
+ }
+
+ QImage qimageFromXImage(XImage *xi)
+ {
+ QImage::Format format = QImage::Format_ARGB32_Premultiplied;
+ if (xi->depth == 24)
+ format = QImage::Format_RGB32;
+ else if (xi->depth == 16)
+ format = QImage::Format_RGB16;
+
+ QImage image = QImage((uchar *)xi->data, xi->width, xi->height, xi->bytes_per_line, format).copy();
+
+ // we may have to swap the byte order
+ if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst)
+ || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst))
+ {
+ for (int i=0; i < image.height(); i++) {
+ if (xi->depth == 16) {
+ ushort *p = (ushort*)image.scanLine(i);
+ ushort *end = p + image.width();
+ while (p < end) {
+ *p = ((*p << 8) & 0xff00) | ((*p >> 8) & 0x00ff);
+ p++;
+ }
+ } else {
+ uint *p = (uint*)image.scanLine(i);
+ uint *end = p + image.width();
+ while (p < end) {
+ *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
+ | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
+ p++;
+ }
+ }
+ }
+ }
+
+ // fix-up alpha channel
+ if (format == QImage::Format_RGB32) {
+ QRgb *p = (QRgb *)image.bits();
+ for (int y = 0; y < xi->height; ++y) {
+ for (int x = 0; x < xi->width; ++x)
+ p[x] |= 0xff000000;
+ p += xi->bytes_per_line / 4;
+ }
+ }
+
+ return image;
+ }
+
+
+private:
+
+ void initializeAllAtoms(QTestLiteScreen *screen) {
+ const char *names[QTestLiteStatic::NAtoms];
+ const char *ptr = x11_atomnames;
+
+ int i = 0;
+ while (*ptr) {
+ names[i++] = ptr;
+ while (*ptr)
+ ++ptr;
+ ++ptr;
+ }
+
+ Q_ASSERT(i == QTestLiteStatic::NPredefinedAtoms);
+
+ QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
+ settings_atom_name += XDisplayName(qPrintable(screen->displayName()));
+ names[i++] = settings_atom_name;
+
+ Q_ASSERT(i == QTestLiteStatic::NAtoms);
+ #if 0//defined(XlibSpecificationRelease) && (XlibSpecificationRelease >= 6)
+ XInternAtoms(screen->display(), (char **)names, i, False, m_allAtoms);
+ #else
+ for (i = 0; i < QTestLiteStatic::NAtoms; ++i)
+ m_allAtoms[i] = XInternAtom(screen->display(), (char *)names[i], False);
+ #endif
+ }
+
+ void initializeSupportedAtoms(QTestLiteScreen *screen)
+ {
+ Atom type;
+ int format;
+ long offset = 0;
+ unsigned long nitems, after;
+ unsigned char *data = 0;
+
+ int e = XGetWindowProperty(screen->display(), screen->rootWindow(),
+ this->atom(QTestLiteStatic::_NET_SUPPORTED), 0, 0,
+ False, XA_ATOM, &type, &format, &nitems, &after, &data);
+ if (data)
+ XFree(data);
+
+ if (e == Success && type == XA_ATOM && format == 32) {
+ QBuffer ts;
+ ts.open(QIODevice::WriteOnly);
+
+ while (after > 0) {
+ XGetWindowProperty(screen->display(), screen->rootWindow(),
+ this->atom(QTestLiteStatic::_NET_SUPPORTED), offset, 1024,
+ False, XA_ATOM, &type, &format, &nitems, &after, &data);
+
+ if (type == XA_ATOM && format == 32) {
+ ts.write(reinterpret_cast<char *>(data), nitems * sizeof(long));
+ offset += nitems;
+ } else
+ after = 0;
+ if (data)
+ XFree(data);
+ }
+
+ // compute nitems
+ QByteArray buffer(ts.buffer());
+ nitems = buffer.size() / sizeof(Atom);
+ m_supportedAtoms = new Atom[nitems + 1];
+ Atom *a = (Atom *) buffer.data();
+ uint i;
+ for (i = 0; i < nitems; i++)
+ m_supportedAtoms[i] = a[i];
+ m_supportedAtoms[nitems] = 0;
+
+ }
+ }
+
+ void resolveXFixes(QTestLiteScreen *screen)
+ {
+#ifndef QT_NO_XFIXES
+ // See if Xfixes is supported on the connected display
+ if (XQueryExtension(screen->display(), "XFIXES", &xfixes_major,
+ &xfixes_eventbase, &xfixes_errorbase)) {
+ ptrXFixesQueryExtension = XFIXES_LOAD_V1(XFixesQueryExtension);
+ ptrXFixesQueryVersion = XFIXES_LOAD_V1(XFixesQueryVersion);
+ ptrXFixesSetCursorName = XFIXES_LOAD_V2(XFixesSetCursorName);
+ ptrXFixesSelectSelectionInput = XFIXES_LOAD_V2(XFixesSelectSelectionInput);
+
+ if(ptrXFixesQueryExtension && ptrXFixesQueryVersion
+ && ptrXFixesQueryExtension(screen->display(), &xfixes_eventbase,
+ &xfixes_errorbase)) {
+ // Xfixes is supported.
+ // Note: the XFixes protocol version is negotiated using QueryVersion.
+ // We supply the highest version we support, the X server replies with
+ // the highest version it supports, but no higher than the version we
+ // asked for. The version sent back is the protocol version the X server
+ // will use to talk us. If this call is removed, the behavior of the
+ // X server when it receives an XFixes request is undefined.
+ int major = 3;
+ int minor = 0;
+ ptrXFixesQueryVersion(screen->display(), &major, &minor);
+ use_xfixes = (major >= 1);
+ xfixes_major = major;
+ }
+ }
+#endif // QT_NO_XFIXES
+
+ }
+
+ Atom *m_supportedAtoms;
+ Atom m_allAtoms[QTestLiteStatic::NAtoms];
+
+#ifndef QT_NO_XFIXES
+ PtrXFixesQueryExtension ptrXFixesQueryExtension;
+ PtrXFixesQueryVersion ptrXFixesQueryVersion;
+ PtrXFixesSetCursorName ptrXFixesSetCursorName;
+ PtrXFixesSelectSelectionInput ptrXFixesSelectSelectionInput;
+#endif
+
+ bool use_xfixes;
+ int xfixes_major;
+ int xfixes_eventbase;
+ int xfixes_errorbase;
+
+};
+Q_GLOBAL_STATIC(QTestLiteStaticInfoPrivate, qTestLiteStaticInfoPrivate);
+
+
+Atom QTestLiteStatic::atom(QTestLiteStatic::X11Atom atom)
+{
+ return qTestLiteStaticInfoPrivate()->atom(atom);
+}
+
+bool QTestLiteStatic::isSupportedByWM(Atom atom)
+{
+ return qTestLiteStaticInfoPrivate()->isSupportedByWM(atom);
+}
+
+bool QTestLiteStatic::useXFixes()
+{
+ return qTestLiteStaticInfoPrivate()->useXFixes();
+}
+
+int QTestLiteStatic::xFixesEventBase()
+{
+ return qTestLiteStaticInfoPrivate()->xFixesEventBase();
+}
+
+#ifndef QT_NO_XFIXES
+PtrXFixesSelectSelectionInput QTestLiteStatic::xFixesSelectSelectionInput()
+{
+ qDebug() << qTestLiteStaticInfoPrivate()->useXFixes();
+ if (!qTestLiteStaticInfoPrivate()->useXFixes())
+ return 0;
+
+ return qTestLiteStaticInfoPrivate()->xFixesSelectSelectionInput();
+}
+
+QImage QTestLiteStatic::qimageFromXImage(XImage *xi)
+{
+ return qTestLiteStaticInfoPrivate()->qimageFromXImage(xi);
+}
+#endif //QT_NO_XFIXES
diff --git a/src/plugins/platforms/testlite/qtestlitestaticinfo.h b/src/plugins/platforms/testlite/qtestlitestaticinfo.h
new file mode 100644
index 0000000..0876768
--- /dev/null
+++ b/src/plugins/platforms/testlite/qtestlitestaticinfo.h
@@ -0,0 +1,413 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTESTLITESTATICINFO_H
+#define QTESTLITESTATICINFO_H
+
+#include <QtCore/QTextStream>
+#include <QtCore/QDataStream>
+#include <QtCore/QMetaType>
+#include <QtCore/QVariant>
+
+#if defined(_XLIB_H_) // crude hack, but...
+#error "cannot include <X11/Xlib.h> before this file"
+#endif
+#define XRegisterIMInstantiateCallback qt_XRegisterIMInstantiateCallback
+#define XUnregisterIMInstantiateCallback qt_XUnregisterIMInstantiateCallback
+#define XSetIMValues qt_XSetIMValues
+#include <X11/Xlib.h>
+#undef XRegisterIMInstantiateCallback
+#undef XUnregisterIMInstantiateCallback
+#undef XSetIMValues
+
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#ifdef index
+# undef index
+#endif
+#ifdef rindex
+# undef rindex
+#endif
+#ifdef Q_OS_VXWORS
+# ifdef open
+# undef open
+# endif
+# ifdef getpid
+# undef getpid
+# endif
+#endif // Q_OS_VXWORKS
+#include <X11/Xatom.h>
+
+//#define QT_NO_SHAPE
+#ifdef QT_NO_SHAPE
+# define XShapeCombineRegion(a,b,c,d,e,f,g)
+# define XShapeCombineMask(a,b,c,d,e,f,g)
+#else
+# include <X11/extensions/shape.h>
+#endif // QT_NO_SHAPE
+
+
+#if !defined (QT_NO_TABLET)
+# include <X11/extensions/XInput.h>
+#if defined (Q_OS_IRIX)
+# include <X11/extensions/SGIMisc.h>
+# include <wacom.h>
+#endif
+#endif // QT_NO_TABLET
+
+
+// #define QT_NO_XINERAMA
+#ifndef QT_NO_XINERAMA
+// XFree86 does not C++ify Xinerama (at least up to XFree86 4.0.3).
+extern "C" {
+# include <X11/extensions/Xinerama.h>
+}
+#endif // QT_NO_XINERAMA
+
+// #define QT_NO_XRANDR
+#ifndef QT_NO_XRANDR
+# include <X11/extensions/Xrandr.h>
+#endif // QT_NO_XRANDR
+
+// #define QT_NO_XRENDER
+#ifndef QT_NO_XRENDER
+# include <X11/extensions/Xrender.h>
+#endif // QT_NO_XRENDER
+
+#ifndef QT_NO_XSYNC
+extern "C" {
+# include "X11/extensions/sync.h"
+}
+#endif
+
+// #define QT_NO_XKB
+#ifndef QT_NO_XKB
+# include <X11/XKBlib.h>
+#endif // QT_NO_XKB
+
+
+#if !defined(XlibSpecificationRelease)
+# define X11R4
+typedef char *XPointer;
+#else
+# undef X11R4
+#endif
+
+#ifndef QT_NO_XFIXES
+typedef Bool (*PtrXFixesQueryExtension)(Display *, int *, int *);
+typedef Status (*PtrXFixesQueryVersion)(Display *, int *, int *);
+typedef void (*PtrXFixesSetCursorName)(Display *dpy, Cursor cursor, const char *name);
+typedef void (*PtrXFixesSelectSelectionInput)(Display *dpy, Window win, Atom selection, unsigned long eventMask);
+#endif // QT_NO_XFIXES
+
+#ifndef QT_NO_XCURSOR
+#include <X11/Xcursor/Xcursor.h>
+typedef Cursor (*PtrXcursorLibraryLoadCursor)(Display *, const char *);
+#endif // QT_NO_XCURSOR
+
+#ifndef QT_NO_XINERAMA
+typedef Bool (*PtrXineramaQueryExtension)(Display *dpy, int *event_base, int *error_base);
+typedef Bool (*PtrXineramaIsActive)(Display *dpy);
+typedef XineramaScreenInfo *(*PtrXineramaQueryScreens)(Display *dpy, int *number);
+#endif // QT_NO_XINERAMA
+
+#ifndef QT_NO_XRANDR
+typedef void (*PtrXRRSelectInput)(Display *, Window, int);
+typedef int (*PtrXRRUpdateConfiguration)(XEvent *);
+typedef int (*PtrXRRRootToScreen)(Display *, Window);
+typedef Bool (*PtrXRRQueryExtension)(Display *, int *, int *);
+#endif // QT_NO_XRANDR
+
+#ifndef QT_NO_XINPUT
+typedef int (*PtrXCloseDevice)(Display *, XDevice *);
+typedef XDeviceInfo* (*PtrXListInputDevices)(Display *, int *);
+typedef XDevice* (*PtrXOpenDevice)(Display *, XID);
+typedef void (*PtrXFreeDeviceList)(XDeviceInfo *);
+typedef int (*PtrXSelectExtensionEvent)(Display *, Window, XEventClass *, int);
+#endif // QT_NO_XINPUT
+
+/*
+ * Solaris patch 108652-47 and higher fixes crases in
+ * XRegisterIMInstantiateCallback, but the function doesn't seem to
+ * work.
+ *
+ * Instead, we disabled R6 input, and open the input method
+ * immediately at application start.
+ */
+
+//######### XFree86 has wrong declarations for XRegisterIMInstantiateCallback
+//######### and XUnregisterIMInstantiateCallback in at least version 3.3.2.
+//######### Many old X11R6 header files lack XSetIMValues.
+//######### Therefore, we have to declare these functions ourselves.
+
+extern "C" Bool XRegisterIMInstantiateCallback(
+ Display*,
+ struct _XrmHashBucketRec*,
+ char*,
+ char*,
+ XIMProc, //XFree86 has XIDProc, which has to be wrong
+ XPointer
+);
+
+extern "C" Bool XUnregisterIMInstantiateCallback(
+ Display*,
+ struct _XrmHashBucketRec*,
+ char*,
+ char*,
+ XIMProc, //XFree86 has XIDProc, which has to be wrong
+ XPointer
+);
+
+#ifndef X11R4
+# include <X11/Xlocale.h>
+#endif // X11R4
+
+
+#ifndef QT_NO_MITSHM
+# include <X11/extensions/XShm.h>
+#endif // QT_NO_MITSHM
+
+// rename a couple of X defines to get rid of name clashes
+// resolve the conflict between X11's FocusIn and QEvent::FocusIn
+enum {
+ XFocusOut = FocusOut,
+ XFocusIn = FocusIn,
+ XKeyPress = KeyPress,
+ XKeyRelease = KeyRelease,
+ XNone = None,
+ XRevertToParent = RevertToParent,
+ XGrayScale = GrayScale,
+ XCursorShape = CursorShape
+};
+#undef FocusOut
+#undef FocusIn
+#undef KeyPress
+#undef KeyRelease
+#undef None
+#undef RevertToParent
+#undef GrayScale
+#undef CursorShape
+
+#ifdef FontChange
+#undef FontChange
+#endif
+
+
+class QTestLiteStatic
+{
+public:
+ enum X11Atom {
+ // window-manager <-> client protocols
+ WM_PROTOCOLS,
+ WM_DELETE_WINDOW,
+ WM_TAKE_FOCUS,
+ _NET_WM_PING,
+ _NET_WM_CONTEXT_HELP,
+ _NET_WM_SYNC_REQUEST,
+ _NET_WM_SYNC_REQUEST_COUNTER,
+
+ // ICCCM window state
+ WM_STATE,
+ WM_CHANGE_STATE,
+
+ // Session management
+ WM_CLIENT_LEADER,
+ WM_WINDOW_ROLE,
+ SM_CLIENT_ID,
+
+ // Clipboard
+ CLIPBOARD,
+ INCR,
+ TARGETS,
+ MULTIPLE,
+ TIMESTAMP,
+ SAVE_TARGETS,
+ CLIP_TEMPORARY,
+ _QT_SELECTION,
+ _QT_CLIPBOARD_SENTINEL,
+ _QT_SELECTION_SENTINEL,
+ CLIPBOARD_MANAGER,
+
+ RESOURCE_MANAGER,
+
+ _XSETROOT_ID,
+
+ _QT_SCROLL_DONE,
+ _QT_INPUT_ENCODING,
+
+ _MOTIF_WM_HINTS,
+
+ DTWM_IS_RUNNING,
+ ENLIGHTENMENT_DESKTOP,
+ _DT_SAVE_MODE,
+ _SGI_DESKS_MANAGER,
+
+ // EWMH (aka NETWM)
+ _NET_SUPPORTED,
+ _NET_VIRTUAL_ROOTS,
+ _NET_WORKAREA,
+
+ _NET_MOVERESIZE_WINDOW,
+ _NET_WM_MOVERESIZE,
+
+ _NET_WM_NAME,
+ _NET_WM_ICON_NAME,
+ _NET_WM_ICON,
+
+ _NET_WM_PID,
+
+ _NET_WM_WINDOW_OPACITY,
+
+ _NET_WM_STATE,
+ _NET_WM_STATE_ABOVE,
+ _NET_WM_STATE_BELOW,
+ _NET_WM_STATE_FULLSCREEN,
+ _NET_WM_STATE_MAXIMIZED_HORZ,
+ _NET_WM_STATE_MAXIMIZED_VERT,
+ _NET_WM_STATE_MODAL,
+ _NET_WM_STATE_STAYS_ON_TOP,
+ _NET_WM_STATE_DEMANDS_ATTENTION,
+
+ _NET_WM_USER_TIME,
+ _NET_WM_USER_TIME_WINDOW,
+ _NET_WM_FULL_PLACEMENT,
+
+ _NET_WM_WINDOW_TYPE,
+ _NET_WM_WINDOW_TYPE_DESKTOP,
+ _NET_WM_WINDOW_TYPE_DOCK,
+ _NET_WM_WINDOW_TYPE_TOOLBAR,
+ _NET_WM_WINDOW_TYPE_MENU,
+ _NET_WM_WINDOW_TYPE_UTILITY,
+ _NET_WM_WINDOW_TYPE_SPLASH,
+ _NET_WM_WINDOW_TYPE_DIALOG,
+ _NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
+ _NET_WM_WINDOW_TYPE_POPUP_MENU,
+ _NET_WM_WINDOW_TYPE_TOOLTIP,
+ _NET_WM_WINDOW_TYPE_NOTIFICATION,
+ _NET_WM_WINDOW_TYPE_COMBO,
+ _NET_WM_WINDOW_TYPE_DND,
+ _NET_WM_WINDOW_TYPE_NORMAL,
+ _KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
+
+ _KDE_NET_WM_FRAME_STRUT,
+
+ _NET_STARTUP_INFO,
+ _NET_STARTUP_INFO_BEGIN,
+
+ _NET_SUPPORTING_WM_CHECK,
+
+ _NET_WM_CM_S0,
+
+ _NET_SYSTEM_TRAY_VISUAL,
+
+ _NET_ACTIVE_WINDOW,
+
+ // Property formats
+ COMPOUND_TEXT,
+ TEXT,
+ UTF8_STRING,
+
+ // Xdnd
+ XdndEnter,
+ XdndPosition,
+ XdndStatus,
+ XdndLeave,
+ XdndDrop,
+ XdndFinished,
+ XdndTypelist,
+ XdndActionList,
+
+ XdndSelection,
+
+ XdndAware,
+ XdndProxy,
+
+ XdndActionCopy,
+ XdndActionLink,
+ XdndActionMove,
+ XdndActionPrivate,
+
+ // Motif DND
+ _MOTIF_DRAG_AND_DROP_MESSAGE,
+ _MOTIF_DRAG_INITIATOR_INFO,
+ _MOTIF_DRAG_RECEIVER_INFO,
+ _MOTIF_DRAG_WINDOW,
+ _MOTIF_DRAG_TARGETS,
+
+ XmTRANSFER_SUCCESS,
+ XmTRANSFER_FAILURE,
+
+ // Xkb
+ _XKB_RULES_NAMES,
+
+ // XEMBED
+ _XEMBED,
+ _XEMBED_INFO,
+
+ XWacomStylus,
+ XWacomCursor,
+ XWacomEraser,
+
+ XTabletStylus,
+ XTabletEraser,
+
+ NPredefinedAtoms,
+
+ _QT_SETTINGS_TIMESTAMP = NPredefinedAtoms,
+ NAtoms
+ };
+
+ static Atom atom(X11Atom atom);
+ static bool isSupportedByWM(Atom atom);
+
+ static bool useXFixes();
+ static int xFixesEventBase();
+
+ #ifndef QT_NO_XFIXES
+ static PtrXFixesSelectSelectionInput xFixesSelectSelectionInput();
+ #endif //QT_NO_XFIXES
+
+ static QImage qimageFromXImage(XImage *xi);
+
+
+};
+
+#endif // QTESTLITESTATICINFO_H
diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/testlite/qtestlitewindow.cpp
index b52aae9..d9c69e3 100644
--- a/src/plugins/platforms/testlite/qtestlitewindow.cpp
+++ b/src/plugins/platforms/testlite/qtestlitewindow.cpp
@@ -39,191 +39,125 @@
**
****************************************************************************/
-#include "qtestliteintegration.h"
-#include <QWindowSystemInterface>
-#include <private/qwindowsurface_p.h>
-#include <QtGui/private/qapplication_p.h>
-
#include "qtestlitewindow.h"
-#include <QBitmap>
-#include <QCursor>
-#include <QDateTime>
-#include <QPixmap>
-#include <QImage>
-#include <QSocketNotifier>
+#include "qtestliteintegration.h"
+#include "qtestlitescreen.h"
+#include "qtestlitekeyboard.h"
+#include "qtestlitestaticinfo.h"
-#include <qdebug.h>
-#include <QTimer>
+#include <QtGui/QWindowSystemInterface>
+#include <QSocketNotifier>
#include <QApplication>
+#include <QDebug>
-#ifndef QT_NO_OPENGL
-#include "qglxintegration.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-
-
-#include <X11/Xatom.h>
-
-#include <X11/cursorfont.h>
-
-
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QtGui/private/qapplication_p.h>
-//### remove stuff we don't want from qt_x11_p.h
-#undef ATOM
-#undef X11
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+#include "qglxintegration.h"
+#else
+#include "../eglconvenience/qeglconvenience.h"
+#include "../eglconvenience/qeglplatformcontext.h"
+#include "qtestliteeglintegration.h"
+#endif //QT_OPENGL_ES_2
+#endif //QT_NO_OPENGL
//#define MYX11_DEBUG
QT_BEGIN_NAMESPACE
-static int (*original_x_errhandler)(Display *dpy, XErrorEvent *);
-static bool seen_badwindow;
-
-
-static Atom wmProtocolsAtom;
-static Atom wmDeleteWindowAtom;
-
-class MyX11CursorNode
-{
-public:
- MyX11CursorNode(int id, Cursor c) { idValue = id; cursorValue = c; refCount = 1; }
- QDateTime expiration() { return t; }
- void setExpiration(QDateTime val) { t = val; }
- MyX11CursorNode * ante() { return before; }
- void setAnte(MyX11CursorNode *node) { before = node; }
- MyX11CursorNode * post() { return after; }
- void setPost(MyX11CursorNode *node) { after = node; }
- Cursor cursor() { return cursorValue; }
- int id() { return idValue; }
- unsigned int refCount;
-
-private:
- MyX11CursorNode *before;
- MyX11CursorNode *after;
- QDateTime t;
- Cursor cursorValue;
- int idValue;
-
- Display * display;
-};
-
-
-
-
-
-class MyX11Cursors : public QObject
+QTestLiteWindow::QTestLiteWindow(QWidget *window)
+ : QPlatformWindow(window)
+ , mGLContext(0)
+ , mScreen(QTestLiteScreen::testLiteScreenForWidget(window))
{
- Q_OBJECT
-public:
- MyX11Cursors(Display * d);
- ~MyX11Cursors() { timer.stop(); }
- void incrementUseCount(int id);
- void decrementUseCount(int id);
- void createNode(int id, Cursor c);
- bool exists(int id) { return lookupMap.contains(id); }
- Cursor cursor(int id);
-public slots:
- void timeout();
-
-private:
- void removeNode(MyX11CursorNode *node);
- void insertNode(MyX11CursorNode *node);
-
- // linked list of cursors currently not assigned to any window
- MyX11CursorNode *firstExpired;
- MyX11CursorNode *lastExpired;
-
- QHash<int, MyX11CursorNode *> lookupMap;
- QTimer timer;
-
- Display *display;
-
- int removalDelay;
-};
-
-
-
-
-
-QTestLiteWindow::QTestLiteWindow(const QTestLiteIntegration *platformIntegration,
- QTestLiteScreen */*screen*/, QWidget *window)
- :QPlatformWindow(window), mGLContext(0)
-{
- xd = platformIntegration->xd;
- xd->windowList.append(this);
- {
- int x = window->x();
- int y = window->y();
- int w = window->width();
- int h = window->height();
+ int x = window->x();
+ int y = window->y();
+ int w = window->width();
+ int h = window->height();
if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
&& QApplicationPrivate::platformIntegration()->hasOpenGL() ) {
-#ifndef QT_NO_OPENGL
- XVisualInfo *visualInfo = QGLXGLContext::findVisualInfo(xd,window->platformWindowFormat());
- Colormap cmap = XCreateColormap(xd->display,xd->rootWindow(),visualInfo->visual,AllocNone);
-
- XSetWindowAttributes a;
- a.colormap = cmap;
- x_window = XCreateWindow(xd->display, xd->rootWindow(),x, y, w, h,
- 0, visualInfo->depth, InputOutput, visualInfo->visual,
- CWColormap, &a);
-#endif //QT_NO_OPENGL
+ #if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+ XVisualInfo *visualInfo = QGLXContext::findVisualInfo(mScreen,window->platformWindowFormat());
+#else
+ QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());
+
+ EGLDisplay eglDisplay = eglGetDisplay(mScreen->display());
+ EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat);
+ VisualID id = QTestLiteEglIntegration::getCompatibleVisualId(mScreen->display(),eglConfig);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
+
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(mScreen->display(), VisualIDMask, &visualInfoTemplate, &matchingCount);
+#endif //!defined(QT_OPENGL_ES_2)
+ if (visualInfo) {
+ Colormap cmap = XCreateColormap(mScreen->display(),mScreen->rootWindow(),visualInfo->visual,AllocNone);
+
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ x_window = XCreateWindow(mScreen->display(), mScreen->rootWindow(),x, y, w, h,
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+ } else {
+ qFatal("no window!");
+ }
+#endif //!defined(QT_NO_OPENGL)
} else {
- x_window = XCreateSimpleWindow(xd->display, xd->rootWindow(),
+ x_window = XCreateSimpleWindow(mScreen->display(), mScreen->rootWindow(),
x, y, w, h, 0 /*border_width*/,
- xd->blackPixel(), xd->whitePixel());
+ mScreen->blackPixel(), mScreen->whitePixel());
}
#ifdef MYX11_DEBUG
qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;
#endif
- }
-
- width = -1;
- height = -1;
- xpos = -1;
- ypos = -1;
- XSetWindowBackgroundPixmap(xd->display, x_window, XNone);
+ XSetWindowBackgroundPixmap(mScreen->display(), x_window, XNone);
- XSelectInput(xd->display, x_window, ExposureMask | KeyPressMask | KeyReleaseMask |
+ XSelectInput(mScreen->display(), x_window,
+ ExposureMask | KeyPressMask | KeyReleaseMask |
EnterWindowMask | LeaveWindowMask | FocusChangeMask |
- PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
+ PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
+ ButtonMotionMask | PropertyChangeMask |
StructureNotifyMask);
gc = createGC();
- XChangeProperty (xd->display, x_window,
- wmProtocolsAtom,
- XA_ATOM, 32, PropModeAppend,
- (unsigned char *) &wmDeleteWindowAtom, 1);
- currentCursor = -1;
+ Atom protocols[5];
+ int n = 0;
+ protocols[n++] = QTestLiteStatic::atom(QTestLiteStatic::WM_DELETE_WINDOW); // support del window protocol
+ protocols[n++] = QTestLiteStatic::atom(QTestLiteStatic::WM_TAKE_FOCUS); // support take focus window protocol
+ protocols[n++] = QTestLiteStatic::atom(QTestLiteStatic::_NET_WM_PING); // support _NET_WM_PING protocol
+#ifndef QT_NO_XSYNC
+ protocols[n++] = QTestLiteStatic::atom(QTestLiteStatic::_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol
+#endif // QT_NO_XSYNC
+ if (window->windowFlags() & Qt::WindowContextHelpButtonHint)
+ protocols[n++] = QTestLiteStatic::atom(QTestLiteStatic::_NET_WM_CONTEXT_HELP);
+ XSetWMProtocols(mScreen->display(), x_window, protocols, n);
}
+
QTestLiteWindow::~QTestLiteWindow()
{
#ifdef MYX11_DEBUG
qDebug() << "~QTestLiteWindow" << hex << x_window;
#endif
delete mGLContext;
- XFreeGC(xd->display, gc);
- XDestroyWindow(xd->display, x_window);
-
- xd->windowList.removeAll(this);
+ XFreeGC(mScreen->display(), gc);
+ XDestroyWindow(mScreen->display(), x_window);
}
-
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Mouse event stuff
-
-
-
-
static Qt::MouseButtons translateMouseButtons(int s)
{
Qt::MouseButtons ret = 0;
@@ -237,27 +171,6 @@ static Qt::MouseButtons translateMouseButtons(int s)
}
-static Qt::KeyboardModifiers translateModifiers(int s)
-{
- const uchar qt_alt_mask = Mod1Mask;
- const uchar qt_meta_mask = Mod4Mask;
-
-
- Qt::KeyboardModifiers ret = 0;
- if (s & ShiftMask)
- ret |= Qt::ShiftModifier;
- if (s & ControlMask)
- ret |= Qt::ControlModifier;
- if (s & qt_alt_mask)
- ret |= Qt::AltModifier;
- if (s & qt_meta_mask)
- ret |= Qt::MetaModifier;
-#if 0
- if (s & qt_mode_switch_mask)
- ret |= Qt::GroupSwitchModifier;
-#endif
- return ret;
-}
void QTestLiteWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
{
@@ -265,7 +178,7 @@ void QTestLiteWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
Qt::MouseButton button = Qt::NoButton;
Qt::MouseButtons buttons = translateMouseButtons(e->state);
- Qt::KeyboardModifiers modifiers = translateModifiers(e->state);
+ Qt::KeyboardModifiers modifiers = mScreen->keyboard()->translateModifiers(e->state);
if (type != QEvent::MouseMove) {
switch (e->button) {
case Button1: button = Qt::LeftButton; break;
@@ -318,319 +231,21 @@ void QTestLiteWindow::handleLeaveEvent()
QWindowSystemInterface::handleLeaveEvent(widget());
}
-
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// Key event stuff -- not pretty either
-//
-// What we want to do is to port Robert's keytable code properly
-
-// keyboard mapping table
-static const unsigned int keyTbl[] = {
-
- // misc keys
-
- XK_Escape, Qt::Key_Escape,
- XK_Tab, Qt::Key_Tab,
- XK_ISO_Left_Tab, Qt::Key_Backtab,
- XK_BackSpace, Qt::Key_Backspace,
- XK_Return, Qt::Key_Return,
- XK_Insert, Qt::Key_Insert,
- XK_Delete, Qt::Key_Delete,
- XK_Clear, Qt::Key_Delete,
- XK_Pause, Qt::Key_Pause,
- XK_Print, Qt::Key_Print,
- 0x1005FF60, Qt::Key_SysReq, // hardcoded Sun SysReq
- 0x1007ff00, Qt::Key_SysReq, // hardcoded X386 SysReq
-
- // cursor movement
-
- XK_Home, Qt::Key_Home,
- XK_End, Qt::Key_End,
- XK_Left, Qt::Key_Left,
- XK_Up, Qt::Key_Up,
- XK_Right, Qt::Key_Right,
- XK_Down, Qt::Key_Down,
- XK_Prior, Qt::Key_PageUp,
- XK_Next, Qt::Key_PageDown,
-
- // modifiers
-
- XK_Shift_L, Qt::Key_Shift,
- XK_Shift_R, Qt::Key_Shift,
- XK_Shift_Lock, Qt::Key_Shift,
- XK_Control_L, Qt::Key_Control,
- XK_Control_R, Qt::Key_Control,
- XK_Meta_L, Qt::Key_Meta,
- XK_Meta_R, Qt::Key_Meta,
- XK_Alt_L, Qt::Key_Alt,
- XK_Alt_R, Qt::Key_Alt,
- XK_Caps_Lock, Qt::Key_CapsLock,
- XK_Num_Lock, Qt::Key_NumLock,
- XK_Scroll_Lock, Qt::Key_ScrollLock,
- XK_Super_L, Qt::Key_Super_L,
- XK_Super_R, Qt::Key_Super_R,
- XK_Menu, Qt::Key_Menu,
- XK_Hyper_L, Qt::Key_Hyper_L,
- XK_Hyper_R, Qt::Key_Hyper_R,
- XK_Help, Qt::Key_Help,
- 0x1000FF74, Qt::Key_Backtab, // hardcoded HP backtab
- 0x1005FF10, Qt::Key_F11, // hardcoded Sun F36 (labeled F11)
- 0x1005FF11, Qt::Key_F12, // hardcoded Sun F37 (labeled F12)
-
- // numeric and function keypad keys
-
- XK_KP_Space, Qt::Key_Space,
- XK_KP_Tab, Qt::Key_Tab,
- XK_KP_Enter, Qt::Key_Enter,
- //XK_KP_F1, Qt::Key_F1,
- //XK_KP_F2, Qt::Key_F2,
- //XK_KP_F3, Qt::Key_F3,
- //XK_KP_F4, Qt::Key_F4,
- XK_KP_Home, Qt::Key_Home,
- XK_KP_Left, Qt::Key_Left,
- XK_KP_Up, Qt::Key_Up,
- XK_KP_Right, Qt::Key_Right,
- XK_KP_Down, Qt::Key_Down,
- XK_KP_Prior, Qt::Key_PageUp,
- XK_KP_Next, Qt::Key_PageDown,
- XK_KP_End, Qt::Key_End,
- XK_KP_Begin, Qt::Key_Clear,
- XK_KP_Insert, Qt::Key_Insert,
- XK_KP_Delete, Qt::Key_Delete,
- XK_KP_Equal, Qt::Key_Equal,
- XK_KP_Multiply, Qt::Key_Asterisk,
- XK_KP_Add, Qt::Key_Plus,
- XK_KP_Separator, Qt::Key_Comma,
- XK_KP_Subtract, Qt::Key_Minus,
- XK_KP_Decimal, Qt::Key_Period,
- XK_KP_Divide, Qt::Key_Slash,
-
- // International input method support keys
-
- // International & multi-key character composition
- XK_ISO_Level3_Shift, Qt::Key_AltGr,
- XK_Multi_key, Qt::Key_Multi_key,
- XK_Codeinput, Qt::Key_Codeinput,
- XK_SingleCandidate, Qt::Key_SingleCandidate,
- XK_MultipleCandidate, Qt::Key_MultipleCandidate,
- XK_PreviousCandidate, Qt::Key_PreviousCandidate,
-
- // Misc Functions
- XK_Mode_switch, Qt::Key_Mode_switch,
- XK_script_switch, Qt::Key_Mode_switch,
-
- // Japanese keyboard support
- XK_Kanji, Qt::Key_Kanji,
- XK_Muhenkan, Qt::Key_Muhenkan,
- //XK_Henkan_Mode, Qt::Key_Henkan_Mode,
- XK_Henkan_Mode, Qt::Key_Henkan,
- XK_Henkan, Qt::Key_Henkan,
- XK_Romaji, Qt::Key_Romaji,
- XK_Hiragana, Qt::Key_Hiragana,
- XK_Katakana, Qt::Key_Katakana,
- XK_Hiragana_Katakana, Qt::Key_Hiragana_Katakana,
- XK_Zenkaku, Qt::Key_Zenkaku,
- XK_Hankaku, Qt::Key_Hankaku,
- XK_Zenkaku_Hankaku, Qt::Key_Zenkaku_Hankaku,
- XK_Touroku, Qt::Key_Touroku,
- XK_Massyo, Qt::Key_Massyo,
- XK_Kana_Lock, Qt::Key_Kana_Lock,
- XK_Kana_Shift, Qt::Key_Kana_Shift,
- XK_Eisu_Shift, Qt::Key_Eisu_Shift,
- XK_Eisu_toggle, Qt::Key_Eisu_toggle,
- //XK_Kanji_Bangou, Qt::Key_Kanji_Bangou,
- //XK_Zen_Koho, Qt::Key_Zen_Koho,
- //XK_Mae_Koho, Qt::Key_Mae_Koho,
- XK_Kanji_Bangou, Qt::Key_Codeinput,
- XK_Zen_Koho, Qt::Key_MultipleCandidate,
- XK_Mae_Koho, Qt::Key_PreviousCandidate,
-
-#ifdef XK_KOREAN
- // Korean keyboard support
- XK_Hangul, Qt::Key_Hangul,
- XK_Hangul_Start, Qt::Key_Hangul_Start,
- XK_Hangul_End, Qt::Key_Hangul_End,
- XK_Hangul_Hanja, Qt::Key_Hangul_Hanja,
- XK_Hangul_Jamo, Qt::Key_Hangul_Jamo,
- XK_Hangul_Romaja, Qt::Key_Hangul_Romaja,
- //XK_Hangul_Codeinput, Qt::Key_Hangul_Codeinput,
- XK_Hangul_Codeinput, Qt::Key_Codeinput,
- XK_Hangul_Jeonja, Qt::Key_Hangul_Jeonja,
- XK_Hangul_Banja, Qt::Key_Hangul_Banja,
- XK_Hangul_PreHanja, Qt::Key_Hangul_PreHanja,
- XK_Hangul_PostHanja, Qt::Key_Hangul_PostHanja,
- //XK_Hangul_SingleCandidate,Qt::Key_Hangul_SingleCandidate,
- //XK_Hangul_MultipleCandidate,Qt::Key_Hangul_MultipleCandidate,
- //XK_Hangul_PreviousCandidate,Qt::Key_Hangul_PreviousCandidate,
- XK_Hangul_SingleCandidate, Qt::Key_SingleCandidate,
- XK_Hangul_MultipleCandidate,Qt::Key_MultipleCandidate,
- XK_Hangul_PreviousCandidate,Qt::Key_PreviousCandidate,
- XK_Hangul_Special, Qt::Key_Hangul_Special,
- //XK_Hangul_switch, Qt::Key_Hangul_switch,
- XK_Hangul_switch, Qt::Key_Mode_switch,
-#endif // XK_KOREAN
-
- // dead keys
- XK_dead_grave, Qt::Key_Dead_Grave,
- XK_dead_acute, Qt::Key_Dead_Acute,
- XK_dead_circumflex, Qt::Key_Dead_Circumflex,
- XK_dead_tilde, Qt::Key_Dead_Tilde,
- XK_dead_macron, Qt::Key_Dead_Macron,
- XK_dead_breve, Qt::Key_Dead_Breve,
- XK_dead_abovedot, Qt::Key_Dead_Abovedot,
- XK_dead_diaeresis, Qt::Key_Dead_Diaeresis,
- XK_dead_abovering, Qt::Key_Dead_Abovering,
- XK_dead_doubleacute, Qt::Key_Dead_Doubleacute,
- XK_dead_caron, Qt::Key_Dead_Caron,
- XK_dead_cedilla, Qt::Key_Dead_Cedilla,
- XK_dead_ogonek, Qt::Key_Dead_Ogonek,
- XK_dead_iota, Qt::Key_Dead_Iota,
- XK_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound,
- XK_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound,
- XK_dead_belowdot, Qt::Key_Dead_Belowdot,
- XK_dead_hook, Qt::Key_Dead_Hook,
- XK_dead_horn, Qt::Key_Dead_Horn,
-
-#if 0
- // Special multimedia keys
- // currently only tested with MS internet keyboard
-
- // browsing keys
- XF86XK_Back, Qt::Key_Back,
- XF86XK_Forward, Qt::Key_Forward,
- XF86XK_Stop, Qt::Key_Stop,
- XF86XK_Refresh, Qt::Key_Refresh,
- XF86XK_Favorites, Qt::Key_Favorites,
- XF86XK_AudioMedia, Qt::Key_LaunchMedia,
- XF86XK_OpenURL, Qt::Key_OpenUrl,
- XF86XK_HomePage, Qt::Key_HomePage,
- XF86XK_Search, Qt::Key_Search,
-
- // media keys
- XF86XK_AudioLowerVolume, Qt::Key_VolumeDown,
- XF86XK_AudioMute, Qt::Key_VolumeMute,
- XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp,
- XF86XK_AudioPlay, Qt::Key_MediaPlay,
- XF86XK_AudioStop, Qt::Key_MediaStop,
- XF86XK_AudioPrev, Qt::Key_MediaPrevious,
- XF86XK_AudioNext, Qt::Key_MediaNext,
- XF86XK_AudioRecord, Qt::Key_MediaRecord,
-
- // launch keys
- XF86XK_Mail, Qt::Key_LaunchMail,
- XF86XK_MyComputer, Qt::Key_Launch0,
- XF86XK_Calculator, Qt::Key_Launch1,
- XF86XK_Standby, Qt::Key_Standby,
-
- XF86XK_Launch0, Qt::Key_Launch2,
- XF86XK_Launch1, Qt::Key_Launch3,
- XF86XK_Launch2, Qt::Key_Launch4,
- XF86XK_Launch3, Qt::Key_Launch5,
- XF86XK_Launch4, Qt::Key_Launch6,
- XF86XK_Launch5, Qt::Key_Launch7,
- XF86XK_Launch6, Qt::Key_Launch8,
- XF86XK_Launch7, Qt::Key_Launch9,
- XF86XK_Launch8, Qt::Key_LaunchA,
- XF86XK_Launch9, Qt::Key_LaunchB,
- XF86XK_LaunchA, Qt::Key_LaunchC,
- XF86XK_LaunchB, Qt::Key_LaunchD,
- XF86XK_LaunchC, Qt::Key_LaunchE,
- XF86XK_LaunchD, Qt::Key_LaunchF,
-#endif
-
-#if 0
- // Qtopia keys
- QTOPIAXK_Select, Qt::Key_Select,
- QTOPIAXK_Yes, Qt::Key_Yes,
- QTOPIAXK_No, Qt::Key_No,
- QTOPIAXK_Cancel, Qt::Key_Cancel,
- QTOPIAXK_Printer, Qt::Key_Printer,
- QTOPIAXK_Execute, Qt::Key_Execute,
- QTOPIAXK_Sleep, Qt::Key_Sleep,
- QTOPIAXK_Play, Qt::Key_Play,
- QTOPIAXK_Zoom, Qt::Key_Zoom,
- QTOPIAXK_Context1, Qt::Key_Context1,
- QTOPIAXK_Context2, Qt::Key_Context2,
- QTOPIAXK_Context3, Qt::Key_Context3,
- QTOPIAXK_Context4, Qt::Key_Context4,
- QTOPIAXK_Call, Qt::Key_Call,
- QTOPIAXK_Hangup, Qt::Key_Hangup,
- QTOPIAXK_Flip, Qt::Key_Flip,
-#endif
- 0, 0
-};
-
-
-static int lookupCode(unsigned int xkeycode)
+void QTestLiteWindow::handleFocusInEvent()
{
- if (xkeycode >= XK_F1 && xkeycode <= XK_F35)
- return Qt::Key_F1 + (int(xkeycode) - XK_F1);
-
- const unsigned int *p = keyTbl;
- while (*p) {
- if (*p == xkeycode)
- return *++p;
- p += 2;
- }
-
- return 0;
+ QWindowSystemInterface::handleWindowActivated(widget());
}
-
-static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode)
+void QTestLiteWindow::handleFocusOutEvent()
{
- switch (qtcode) {
- case Qt::Key_Control:
- return Qt::ControlModifier;
- case Qt::Key_Alt:
- return Qt::AltModifier;
- case Qt::Key_Shift:
- return Qt::ShiftModifier;
- case Qt::Key_Meta:
- return Qt::MetaModifier;
- default:
- return Qt::NoModifier;
- }
+ QWindowSystemInterface::handleWindowActivated(0);
}
-void QTestLiteWindow::handleKeyEvent(QEvent::Type type, void *ev)
-{
- XKeyEvent *e = static_cast<XKeyEvent*>(ev);
-
- KeySym keySym;
- QByteArray chars;
- chars.resize(513);
-
- int count = XLookupString(e, chars.data(), chars.size(), &keySym, 0);
- Q_UNUSED(count);
-// qDebug() << "QTLWS::handleKeyEvent" << count << hex << "XKeysym:" << keySym;
-// if (count)
-// qDebug() << hex << int(chars[0]) << "String:" << chars;
-
- Qt::KeyboardModifiers modifiers = translateModifiers(e->state);
-
- int qtcode = lookupCode(keySym);
-// qDebug() << "lookup: " << hex << keySym << qtcode << "mod" << modifiers;
- //X11 specifies state *before*, Qt expects state *after* the event
-
- modifiers ^= modifierFromKeyCode(qtcode);
-
- if (qtcode) {
- QWindowSystemInterface::handleKeyEvent(widget(), e->time, type, qtcode, modifiers);
- } else if (chars[0]) {
- int qtcode = chars.toUpper()[0]; //Not exactly right...
- if (modifiers & Qt::ControlModifier && qtcode < ' ')
- qtcode = chars[0] + '@';
- QWindowSystemInterface::handleKeyEvent(0, e->time, type, qtcode, modifiers, QString::fromLatin1(chars));
- } else {
- qWarning() << "unknown X keycode" << hex << e->keycode << keySym;
- }
-}
void QTestLiteWindow::setGeometry(const QRect &rect)
{
- XMoveResizeWindow(xd->display, x_window, rect.x(), rect.y(), rect.width(), rect.height());
+ XMoveResizeWindow(mScreen->display(), x_window, rect.x(), rect.y(), rect.width(), rect.height());
QPlatformWindow::setGeometry(rect);
}
@@ -647,18 +262,18 @@ WId QTestLiteWindow::winId() const
void QTestLiteWindow::setParent(const QPlatformWindow *window)
{
- QPoint point = widget()->mapTo(widget()->nativeParentWidget(),QPoint());
- XReparentWindow(xd->display,x_window,window->winId(),point.x(),point.y());
+ QPoint topLeft = geometry().topLeft();
+ XReparentWindow(mScreen->display(),x_window,window->winId(),topLeft.x(),topLeft.y());
}
void QTestLiteWindow::raise()
{
- XRaiseWindow(xd->display, x_window);
+ XRaiseWindow(mScreen->display(), x_window);
}
void QTestLiteWindow::lower()
{
- XLowerWindow(xd->display, x_window);
+ XLowerWindow(mScreen->display(), x_window);
}
void QTestLiteWindow::setWindowTitle(const QString &title)
@@ -670,14 +285,14 @@ void QTestLiteWindow::setWindowTitle(const QString &title)
windowName.format = 8;
windowName.nitems = ba.length();
- XSetWMName(xd->display, x_window, &windowName);
+ XSetWMName(mScreen->display(), x_window, &windowName);
}
GC QTestLiteWindow::createGC()
{
GC gc;
- gc = XCreateGC(xd->display, x_window, 0, 0);
+ gc = XCreateGC(mScreen->display(), x_window, 0, 0);
if (gc < 0) {
qWarning("QTestLiteWindow::createGC() could not create GC");
}
@@ -691,30 +306,33 @@ void QTestLiteWindow::paintEvent()
#endif
if (QWindowSurface *surface = widget()->windowSurface())
- surface->flush(widget(), QRect(xpos,ypos,width, height), QPoint());
+ surface->flush(widget(), widget()->geometry(), QPoint());
}
+void QTestLiteWindow::requestActivateWindow()
+{
+ XSetInputFocus(mScreen->display(), x_window, XRevertToParent, CurrentTime);
+}
void QTestLiteWindow::resizeEvent(XConfigureEvent *e)
{
- if ((e->width != width || e->height != height) && e->x == 0 && e->y == 0) {
+ int xpos = geometry().x();
+ int ypos = geometry().y();
+ if ((e->width != geometry().width() || e->height != geometry().height()) && e->x == 0 && e->y == 0) {
//qDebug() << "resize with bogus pos" << e->x << e->y << e->width << e->height << "window"<< hex << window;
} else {
//qDebug() << "geometry change" << e->x << e->y << e->width << e->height << "window"<< hex << window;
xpos = e->x;
ypos = e->y;
}
- width = e->width;
- height = e->height;
-
#ifdef MYX11_DEBUG
qDebug() << hex << x_window << dec << "ConfigureNotify" << e->x << e->y << e->width << e->height << "geometry" << xpos << ypos << width << height;
#endif
- QWindowSystemInterface::handleGeometryChange(widget(), QRect(xpos, ypos, width, height));
+ QRect newRect(xpos, ypos, e->width, e->height);
+ QWindowSystemInterface::handleGeometryChange(widget(), newRect);
}
-
void QTestLiteWindow::mousePressEvent(XButtonEvent *e)
{
static long prevTime = 0;
@@ -738,51 +356,7 @@ void QTestLiteWindow::mousePressEvent(XButtonEvent *e)
handleMouseEvent(type, e);
}
-
-
-// WindowFlag stuff, lots of copied code from qwidget_x11.cpp...
-
-//We're hacking here...
-
-
-// MWM support
-struct QtMWMHints {
- ulong flags, functions, decorations;
- long input_mode;
- ulong status;
-};
-
-enum {
- MWM_HINTS_FUNCTIONS = (1L << 0),
-
- MWM_FUNC_ALL = (1L << 0),
- MWM_FUNC_RESIZE = (1L << 1),
- MWM_FUNC_MOVE = (1L << 2),
- MWM_FUNC_MINIMIZE = (1L << 3),
- MWM_FUNC_MAXIMIZE = (1L << 4),
- MWM_FUNC_CLOSE = (1L << 5),
-
- MWM_HINTS_DECORATIONS = (1L << 1),
-
- MWM_DECOR_ALL = (1L << 0),
- MWM_DECOR_BORDER = (1L << 1),
- MWM_DECOR_RESIZEH = (1L << 2),
- MWM_DECOR_TITLE = (1L << 3),
- MWM_DECOR_MENU = (1L << 4),
- MWM_DECOR_MINIMIZE = (1L << 5),
- MWM_DECOR_MAXIMIZE = (1L << 6),
-
- MWM_HINTS_INPUT_MODE = (1L << 2),
-
- MWM_INPUT_MODELESS = 0L,
- MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L,
- MWM_INPUT_FULL_APPLICATION_MODAL = 3L
-};
-
-static Atom mwm_hint_atom = XNone;
-
-#if 0
-static QtMWMHints GetMWMHints(Display *display, Window window)
+QtMWMHints QTestLiteWindow::getMWMHints() const
{
QtMWMHints mwmhints;
@@ -790,10 +364,11 @@ static QtMWMHints GetMWMHints(Display *display, Window window)
int format;
ulong nitems, bytesLeft;
uchar *data = 0;
- if ((XGetWindowProperty(display, window, mwm_hint_atom, 0, 5, false,
- mwm_hint_atom, &type, &format, &nitems, &bytesLeft,
+ Atom atomForMotifWmHints = QTestLiteStatic::atom(QTestLiteStatic::_MOTIF_WM_HINTS);
+ if ((XGetWindowProperty(mScreen->display(), x_window, atomForMotifWmHints, 0, 5, false,
+ atomForMotifWmHints, &type, &format, &nitems, &bytesLeft,
&data) == Success)
- && (type == mwm_hint_atom
+ && (type == atomForMotifWmHints
&& format == 32
&& nitems >= 5)) {
mwmhints = *(reinterpret_cast<QtMWMHints *>(data));
@@ -810,15 +385,16 @@ static QtMWMHints GetMWMHints(Display *display, Window window)
return mwmhints;
}
-#endif
-static void SetMWMHints(Display *display, Window window, const QtMWMHints &mwmhints)
+void QTestLiteWindow::setMWMHints(const QtMWMHints &mwmhints)
{
+ Atom atomForMotifWmHints = QTestLiteStatic::atom(QTestLiteStatic::_MOTIF_WM_HINTS);
if (mwmhints.flags != 0l) {
- XChangeProperty(display, window, mwm_hint_atom, mwm_hint_atom, 32,
+ XChangeProperty(mScreen->display(), x_window,
+ atomForMotifWmHints, atomForMotifWmHints, 32,
PropModeReplace, (unsigned char *) &mwmhints, 5);
} else {
- XDeleteProperty(display, window, mwm_hint_atom);
+ XDeleteProperty(mScreen->display(), x_window, atomForMotifWmHints);
}
}
@@ -835,17 +411,11 @@ static inline bool isTransient(const QWidget *w)
&& !w->testAttribute(Qt::WA_X11BypassTransientForHint));
}
-
-
Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
{
// Q_ASSERT(flags & Qt::Window);
window_flags = flags;
- if (mwm_hint_atom == XNone) {
- mwm_hint_atom = XInternAtom(xd->display, "_MOTIF_WM_HINTS\0", False);
- }
-
#ifdef MYX11_DEBUG
qDebug() << "QTestLiteWindow::setWindowFlags" << hex << x_window << "flags" << flags;
#endif
@@ -864,12 +434,10 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
bool tool = (type == Qt::Tool || type == Qt::SplashScreen
|| type == Qt::ToolTip || type == Qt::Drawer);
-
Q_UNUSED(topLevel);
Q_UNUSED(dialog);
Q_UNUSED(desktop);
-
bool tooltip = (type == Qt::ToolTip);
XSetWindowAttributes wsa;
@@ -950,7 +518,7 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
mwmhints.decorations = 0;
}
- SetMWMHints(xd->display, x_window, mwmhints);
+ setMWMHints(mwmhints);
//##### only if initializeWindow???
@@ -963,7 +531,7 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
wsa.override_redirect = True;
wsa.save_under = True;
- XChangeWindowAttributes(xd->display, x_window, CWOverrideRedirect | CWSaveUnder,
+ XChangeWindowAttributes(mScreen->display(), x_window, CWOverrideRedirect | CWSaveUnder,
&wsa);
} else {
#ifdef MYX11_DEBUG
@@ -979,39 +547,19 @@ void QTestLiteWindow::setVisible(bool visible)
#ifdef MYX11_DEBUG
qDebug() << "QTestLiteWindow::setVisible" << visible << hex << x_window;
#endif
- if (visible)
- XMapWindow(xd->display, x_window);
- else
- XUnmapWindow(xd->display, x_window);
-}
-
-
-void QTestLiteWindow::setCursor(QCursor * cursor)
-{
- int id = cursor->handle();
- if (id == currentCursor)
- return;
- Cursor c;
- if (!xd->cursors->exists(id)) {
- if (cursor->shape() == Qt::BitmapCursor)
- c = createCursorBitmap(cursor);
- else
- c = createCursorShape(cursor->shape());
- if (!c) {
- return;
- }
- xd->cursors->createNode(id, c);
+ if (visible) {
+ //ensure that the window is viewed in correct position.
+ doSizeHints();
+ XMapWindow(mScreen->display(), x_window);
} else {
- xd->cursors->incrementUseCount(id);
- c = xd->cursors->cursor(id);
+ XUnmapWindow(mScreen->display(), x_window);
}
+}
- if (currentCursor != -1)
- xd->cursors->decrementUseCount(currentCursor);
- currentCursor = id;
-
- XDefineCursor(xd->display, x_window, c);
- XFlush(xd->display);
+void QTestLiteWindow::setCursor(const Cursor &cursor)
+{
+ XDefineCursor(mScreen->display(), x_window, cursor);
+ XFlush(mScreen->display());
}
QPlatformGLContext *QTestLiteWindow::glContext() const
@@ -1020,567 +568,78 @@ QPlatformGLContext *QTestLiteWindow::glContext() const
return 0;
if (!mGLContext) {
QTestLiteWindow *that = const_cast<QTestLiteWindow *>(this);
-#ifndef QT_NO_OPENGL
- that->mGLContext = new QGLXGLContext(x_window, xd,widget()->platformWindowFormat());
+#if !defined(QT_NO_OPENGL)
+#if !defined(QT_OPENGL_ES_2)
+ that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat());
+#else
+ EGLDisplay display = eglGetDisplay(mScreen->display());
+
+ QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat());
+
+ EGLConfig config = q_configFromQPlatformWindowFormat(display,windowFormat);
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
+ EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)x_window,0);
+ that->mGLContext = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API);
+#endif
#endif
}
return mGLContext;
}
-Cursor QTestLiteWindow::createCursorBitmap(QCursor * cursor)
-{
- XColor bg, fg;
- bg.red = 255 << 8;
- bg.green = 255 << 8;
- bg.blue = 255 << 8;
- fg.red = 0;
- fg.green = 0;
- fg.blue = 0;
- QPoint spot = cursor->hotSpot();
- Window rootwin = x_window;
-
- QImage mapImage = cursor->bitmap()->toImage().convertToFormat(QImage::Format_MonoLSB);
- QImage maskImage = cursor->mask()->toImage().convertToFormat(QImage::Format_MonoLSB);
-
- int width = cursor->bitmap()->width();
- int height = cursor->bitmap()->height();
- int bytesPerLine = mapImage.bytesPerLine();
- int destLineSize = width / 8;
- if (width % 8)
- destLineSize++;
-
- const uchar * map = mapImage.bits();
- const uchar * mask = maskImage.bits();
-
- char * mapBits = new char[height * destLineSize];
- char * maskBits = new char[height * destLineSize];
- for (int i = 0; i < height; i++) {
- memcpy(mapBits + (destLineSize * i),map + (bytesPerLine * i), destLineSize);
- memcpy(maskBits + (destLineSize * i),mask + (bytesPerLine * i), destLineSize);
- }
-
- Pixmap cp = XCreateBitmapFromData(xd->display, rootwin, mapBits, width, height);
- Pixmap mp = XCreateBitmapFromData(xd->display, rootwin, maskBits, width, height);
- Cursor c = XCreatePixmapCursor(xd->display, cp, mp, &fg, &bg, spot.x(), spot.y());
- XFreePixmap(xd->display, cp);
- XFreePixmap(xd->display, mp);
- delete[] mapBits;
- delete[] maskBits;
-
- return c;
-}
-
-Cursor QTestLiteWindow::createCursorShape(int cshape)
-{
- Cursor cursor = 0;
-
- if (cshape < 0 || cshape > Qt::LastCursor)
- return 0;
-
- switch (cshape) {
- case Qt::ArrowCursor:
- cursor = XCreateFontCursor(xd->display, XC_left_ptr);
- break;
- case Qt::UpArrowCursor:
- cursor = XCreateFontCursor(xd->display, XC_center_ptr);
- break;
- case Qt::CrossCursor:
- cursor = XCreateFontCursor(xd->display, XC_crosshair);
- break;
- case Qt::WaitCursor:
- cursor = XCreateFontCursor(xd->display, XC_watch);
- break;
- case Qt::IBeamCursor:
- cursor = XCreateFontCursor(xd->display, XC_xterm);
- break;
- case Qt::SizeAllCursor:
- cursor = XCreateFontCursor(xd->display, XC_fleur);
- break;
- case Qt::PointingHandCursor:
- cursor = XCreateFontCursor(xd->display, XC_hand2);
- break;
- case Qt::SizeBDiagCursor:
- cursor = XCreateFontCursor(xd->display, XC_top_right_corner);
- break;
- case Qt::SizeFDiagCursor:
- cursor = XCreateFontCursor(xd->display, XC_bottom_right_corner);
- break;
- case Qt::SizeVerCursor:
- case Qt::SplitVCursor:
- cursor = XCreateFontCursor(xd->display, XC_sb_v_double_arrow);
- break;
- case Qt::SizeHorCursor:
- case Qt::SplitHCursor:
- cursor = XCreateFontCursor(xd->display, XC_sb_h_double_arrow);
- break;
- case Qt::WhatsThisCursor:
- cursor = XCreateFontCursor(xd->display, XC_question_arrow);
- break;
- case Qt::ForbiddenCursor:
- cursor = XCreateFontCursor(xd->display, XC_circle);
- break;
- case Qt::BusyCursor:
- cursor = XCreateFontCursor(xd->display, XC_watch);
- break;
-
- default: //default cursor for all the rest
- break;
- }
- return cursor;
-}
-
-
-MyX11Cursors::MyX11Cursors(Display * d) : firstExpired(0), lastExpired(0), display(d), removalDelay(3)
-{
- connect(&timer, SIGNAL(timeout()), this, SLOT(timeout()));
-}
-
-void MyX11Cursors::insertNode(MyX11CursorNode * node)
+Window QTestLiteWindow::xWindow() const
{
- QDateTime now = QDateTime::currentDateTime();
- QDateTime timeout = now.addSecs(removalDelay);
- node->setExpiration(timeout);
- node->setPost(0);
- if (lastExpired) {
- lastExpired->setPost(node);
- node->setAnte(lastExpired);
- }
- lastExpired = node;
- if (!firstExpired) {
- firstExpired = node;
- node->setAnte(0);
- int interval = removalDelay * 1000;
- timer.setInterval(interval);
- timer.start();
- }
-}
-
-void MyX11Cursors::removeNode(MyX11CursorNode * node)
-{
- MyX11CursorNode *pre = node->ante();
- MyX11CursorNode *post = node->post();
- if (pre)
- pre->setPost(post);
- if (post)
- post->setAnte(pre);
- if (node == lastExpired)
- lastExpired = pre;
- if (node == firstExpired) {
- firstExpired = post;
- if (!firstExpired) {
- timer.stop();
- return;
- }
- int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000;
- timer.stop();
- timer.setInterval(interval);
- timer.start();
- }
-}
-
-void MyX11Cursors::incrementUseCount(int id)
-{
- MyX11CursorNode * node = lookupMap.value(id);
- Q_ASSERT(node);
- if (!node->refCount)
- removeNode(node);
- node->refCount++;
-}
-
-void MyX11Cursors::decrementUseCount(int id)
-{
- MyX11CursorNode * node = lookupMap.value(id);
- Q_ASSERT(node);
- node->refCount--;
- if (!node->refCount)
- insertNode(node);
-}
-
-void MyX11Cursors::createNode(int id, Cursor c)
-{
- MyX11CursorNode * node = new MyX11CursorNode(id, c);
- lookupMap.insert(id, node);
-}
-
-void MyX11Cursors::timeout()
-{
- MyX11CursorNode * node;
- node = firstExpired;
- QDateTime now = QDateTime::currentDateTime();
- while (node && now.secsTo(node->expiration()) < 1) {
- Cursor c = node->cursor();
- int id = node->id();
- lookupMap.take(id);
- MyX11CursorNode * tmp = node;
- node = node->post();
- if (node)
- node->setAnte(0);
- delete tmp;
- XFreeCursor(display, c);
- }
- firstExpired = node;
- if (node == 0) {
- timer.stop();
- lastExpired = 0;
- }
- else {
- int interval = QDateTime::currentDateTime().secsTo(firstExpired->expiration()) * 1000;
- timer.setInterval(interval);
- timer.start();
- }
+ return x_window;
}
-Cursor MyX11Cursors::cursor(int id)
+GC QTestLiteWindow::graphicsContext() const
{
- MyX11CursorNode * node = lookupMap.value(id);
- Q_ASSERT(node);
- return node->cursor();
+ return gc;
}
-
-
-/********************************************************************
-
-MyDisplay class - perhaps better placed in qplatformintegration_testlite?
-
-*********************************************************************/
-
-//### copied from qapplication_x11.cpp
-
-static int qt_x_errhandler(Display *dpy, XErrorEvent *err)
-{
-
-qDebug() << "qt_x_errhandler" << err->error_code;
-
- switch (err->error_code) {
- case BadAtom:
-#if 0
- if (err->request_code == 20 /* X_GetProperty */
- && (err->resourceid == XA_RESOURCE_MANAGER
- || err->resourceid == XA_RGB_DEFAULT_MAP
- || err->resourceid == ATOM(_NET_SUPPORTED)
- || err->resourceid == ATOM(_NET_SUPPORTING_WM_CHECK)
- || err->resourceid == ATOM(KDE_FULL_SESSION)
- || err->resourceid == ATOM(KWIN_RUNNING)
- || err->resourceid == ATOM(XdndProxy)
- || err->resourceid == ATOM(XdndAware))
-
-
- ) {
- // Perhaps we're running under SECURITY reduction? :/
- return 0;
- }
-#endif
- qDebug() << "BadAtom";
- break;
-
- case BadWindow:
- if (err->request_code == 2 /* X_ChangeWindowAttributes */
- || err->request_code == 38 /* X_QueryPointer */) {
- for (int i = 0; i < ScreenCount(dpy); ++i) {
- if (err->resourceid == RootWindow(dpy, i)) {
- // Perhaps we're running under SECURITY reduction? :/
- return 0;
- }
- }
- }
- seen_badwindow = true;
- if (err->request_code == 25 /* X_SendEvent */) {
- for (int i = 0; i < ScreenCount(dpy); ++i) {
- if (err->resourceid == RootWindow(dpy, i)) {
- // Perhaps we're running under SECURITY reduction? :/
- return 0;
- }
- }
-#if 0
- if (X11->xdndHandleBadwindow()) {
- qDebug("xdndHandleBadwindow returned true");
- return 0;
- }
-#endif
- }
-#if 0
- if (X11->ignore_badwindow)
- return 0;
-#endif
- break;
-
- case BadMatch:
- if (err->request_code == 42 /* X_SetInputFocus */)
- return 0;
- break;
-
- default:
-#if 0 //!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;
- }
-
- char errstr[256];
- XGetErrorText( dpy, err->error_code, errstr, 256 );
- char buffer[256];
- char request_str[256];
- qsnprintf(buffer, 256, "%d", err->request_code);
- XGetErrorDatabaseText(dpy, "XRequest", buffer, "", request_str, 256);
- if (err->request_code < 128) {
- // X error for a normal protocol request
- qWarning( "X Error: %s %d\n"
- " Major opcode: %d (%s)\n"
- " Resource id: 0x%lx",
- errstr, err->error_code,
- err->request_code,
- request_str,
- err->resourceid );
+void QTestLiteWindow::doSizeHints()
+{
+ Q_ASSERT(widget()->testAttribute(Qt::WA_WState_Created));
+ XSizeHints s;
+ s.flags = 0;
+ QRect g = geometry();
+ s.x = g.x();
+ s.y = g.y();
+ s.width = g.width();
+ s.height = g.height();
+ s.flags |= USPosition;
+ s.flags |= PPosition;
+ s.flags |= USSize;
+ s.flags |= PSize;
+ s.flags |= PWinGravity;
+ s.win_gravity = QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
+ XSetWMNormalHints(mScreen->display(), x_window, &s);
+}
+
+QPlatformWindowFormat QTestLiteWindow::correctColorBuffers(const QPlatformWindowFormat &platformWindowFormat) const
+{
+ // I have only tested this setup on a dodgy intel setup, where I didn't use standard libs,
+ // so this might be not what we want to do :)
+ if ( !(platformWindowFormat.redBufferSize() == -1 &&
+ platformWindowFormat.greenBufferSize() == -1 &&
+ platformWindowFormat.blueBufferSize() == -1))
+ return platformWindowFormat;
+
+ QPlatformWindowFormat windowFormat = platformWindowFormat;
+ if (mScreen->depth() == 16) {
+ windowFormat.setRedBufferSize(5);
+ windowFormat.setGreenBufferSize(6);
+ windowFormat.setBlueBufferSize(5);
} else {
- // X error for an extension request
- const char *extensionName = 0;
-#if 0
- if (err->request_code == X11->xrender_major)
- extensionName = "RENDER";
- else if (err->request_code == X11->xrandr_major)
- extensionName = "RANDR";
- else if (err->request_code == X11->xinput_major)
- extensionName = "XInputExtension";
- else if (err->request_code == X11->mitshm_major)
- extensionName = "MIT-SHM";
-#endif
- char minor_str[256];
- if (extensionName) {
- qsnprintf(buffer, 256, "%s.%d", extensionName, err->minor_code);
- XGetErrorDatabaseText(dpy, "XRequest", buffer, "", minor_str, 256);
- } else {
- extensionName = "Uknown extension";
- qsnprintf(minor_str, 256, "Unknown request");
- }
- qWarning( "X Error: %s %d\n"
- " Extension: %d (%s)\n"
- " Minor opcode: %d (%s)\n"
- " Resource id: 0x%lx",
- errstr, err->error_code,
- err->request_code,
- extensionName,
- err->minor_code,
- minor_str,
- err->resourceid );
+ windowFormat.setRedBufferSize(8);
+ windowFormat.setGreenBufferSize(8);
+ windowFormat.setBlueBufferSize(8);
}
- // ### we really should distinguish between severe, non-severe and
- // ### application specific errors
-
- return 0;
+ return windowFormat;
}
-
-#ifdef KeyPress
-#undef KeyPress
-#endif
-#ifdef KeyRelease
-#undef KeyRelease
-#endif
-
-bool MyDisplay::handleEvent(XEvent *xe)
-{
- //qDebug() << "handleEvent" << xe->xany.type << xe->xany.window;
- int quit = false;
- QTestLiteWindow *xw = 0;
- foreach (QTestLiteWindow *w, windowList) {
- if (w->winId() == xe->xany.window) {
- xw = w;
- break;
- }
- }
- if (!xw) {
-#ifdef MYX11_DEBUG
- qWarning() << "Unknown window" << hex << xe->xany.window << "received event" << xe->type;
-#endif
- return quit;
- }
-
- switch (xe->type) {
-
- case ClientMessage:
- if (xe->xclient.format == 32 && xe->xclient.message_type == wmProtocolsAtom) {
- Atom a = xe->xclient.data.l[0];
- if (a == wmDeleteWindowAtom)
- xw->handleCloseEvent();
-#ifdef MYX11_DEBUG
- qDebug() << "ClientMessage WM_PROTOCOLS" << a;
-#endif
- }
-#ifdef MYX11_DEBUG
- else
- qDebug() << "ClientMessage" << xe->xclient.format << xe->xclient.message_type;
-#endif
- break;
-
- case Expose:
- if (xw)
- if (xe->xexpose.count == 0)
- xw->paintEvent();
- break;
- case ConfigureNotify:
- if (xw)
- xw->resizeEvent(&xe->xconfigure);
- break;
-
- case ButtonPress:
- xw->mousePressEvent(&xe->xbutton);
- break;
-
- case ButtonRelease:
- xw->handleMouseEvent(QEvent::MouseButtonRelease, &xe->xbutton);
- break;
-
- case MotionNotify:
- xw->handleMouseEvent(QEvent::MouseMove, &xe->xbutton);
- break;
-
- case XKeyPress:
- xw->handleKeyEvent(QEvent::KeyPress, &xe->xkey);
- break;
-
- case XKeyRelease:
- xw->handleKeyEvent(QEvent::KeyRelease, &xe->xkey);
- break;
-
- case EnterNotify:
- xw->handleEnterEvent();
- break;
-
- case LeaveNotify:
- xw->handleLeaveEvent();
- break;
-
- default:
-#ifdef MYX11_DEBUG
- qDebug() << hex << xe->xany.window << "Other X event" << xe->type;
-#endif
- break;
- }
- return quit;
-};
-
-
-
-MyDisplay::MyDisplay()
-{
- char *display_name = getenv("DISPLAY");
- display = XOpenDisplay(display_name);
- if (!display) {
- fprintf(stderr, "Cannot connect to X server: %s\n",
- display_name);
- exit(1);
- }
-
-#ifndef DONT_USE_MIT_SHM
- Status MIT_SHM_extension_supported = XShmQueryExtension (display);
- Q_ASSERT(MIT_SHM_extension_supported == True);
-#endif
- original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
-
- if (qgetenv("DO_X_SYNCHRONIZE").toInt())
- XSynchronize(display, true);
-
- screen = DefaultScreen(display);
- width = DisplayWidth(display, screen);
- height = DisplayHeight(display, screen);
- physicalWidth = DisplayWidthMM(display, screen);
- physicalHeight = DisplayHeightMM(display, screen);
-
- int xSocketNumber = XConnectionNumber(display);
-#ifdef MYX11_DEBUG
- qDebug() << "X socket:"<< xSocketNumber;
-#endif
- QSocketNotifier *sock = new QSocketNotifier(xSocketNumber, QSocketNotifier::Read, this);
- connect(sock, SIGNAL(activated(int)), this, SLOT(eventDispatcher()));
-
- wmProtocolsAtom = XInternAtom (display, "WM_PROTOCOLS", False);
- wmDeleteWindowAtom = XInternAtom (display, "WM_DELETE_WINDOW", False);
-
- cursors = new MyX11Cursors(display);
-}
-
-
-MyDisplay::~MyDisplay()
-{
- XCloseDisplay(display);
-}
-
-
-void MyDisplay::eventDispatcher()
-{
-// qDebug() << "eventDispatcher";
-
-
- ulong marker = XNextRequest(display);
-// int i = 0;
- while (XPending(display)) {
- XEvent event;
- XNextEvent(display, &event);
- /* done = */
- handleEvent(&event);
-
- if (event.xany.serial >= marker) {
-#ifdef MYX11_DEBUG
- qDebug() << "potential livelock averted";
-#endif
-#if 0
- if (XEventsQueued(display, QueuedAfterFlush)) {
- qDebug() << " with events queued";
- QTimer::singleShot(0, this, SLOT(eventDispatcher()));
- }
-#endif
- break;
- }
- }
-}
-
-
-QImage MyDisplay::grabWindow(Window window, int x, int y, int w, int h)
-{
- if (w == 0 || h ==0)
- return QImage();
-
- //WinId 0 means the desktop widget
- if (!window)
- window = rootWindow();
-
- XWindowAttributes window_attr;
- if (!XGetWindowAttributes(display, window, &window_attr))
- return QImage();
-
- if (w < 0)
- w = window_attr.width - x;
- if (h < 0)
- h = window_attr.height - y;
-
- // Ideally, we should also limit ourselves to the screen area, but the Qt docs say
- // that it's "unsafe" to go outside the screen, so we can ignore that problem.
-
- //We're definitely not optimizing for speed...
- XImage *xi = XGetImage(display, window, x, y, w, h, AllPlanes, ZPixmap);
-
- if (!xi)
- return QImage();
-
- //taking a copy to make sure we have ownership -- not fast
- QImage result = QImage( (uchar*) xi->data, xi->width, xi->height, xi->bytes_per_line, QImage::Format_RGB32 ).copy();
-
- XDestroyImage(xi);
-
- return result;
-}
-
-
-
-
-
-
-
QT_END_NAMESPACE
-#include "qtestlitewindow.moc"
diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/testlite/qtestlitewindow.h
index dc628f1..e45c3fd 100644
--- a/src/plugins/platforms/testlite/qtestlitewindow.h
+++ b/src/plugins/platforms/testlite/qtestlitewindow.h
@@ -42,77 +42,67 @@
#ifndef QTESTLITEWINDOW_H
#define QTESTLITEWINDOW_H
+#include "qtestliteintegration.h"
+
#include <QPlatformWindow>
-#include <qevent.h>
+#include <QEvent>
#include <QObject>
#include <QImage>
-#include <qtimer.h>
-#include <QDateTime>
-
-#include <private/qt_x11_p.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-
-
-class QTestLiteIntegration;
-class QTestLiteScreen;
-class QTestLiteWindowSurface;
-class MyX11Cursors;
-class QTestLiteWindow;
-class MyDisplay : public QObject
-{
- Q_OBJECT;
-public:
- MyDisplay();
- ~MyDisplay();
+struct QtMWMHints {
+ ulong flags, functions, decorations;
+ long input_mode;
+ ulong status;
+};
- Window rootWindow() { return RootWindow(display, screen); }
- unsigned long blackPixel() { return BlackPixel(display, screen); }
- unsigned long whitePixel() { return WhitePixel(display, screen); }
+enum {
+ MWM_HINTS_FUNCTIONS = (1L << 0),
- bool handleEvent(XEvent *xe);
- QImage grabWindow(Window window, int x, int y, int w, int h);
+ MWM_FUNC_ALL = (1L << 0),
+ MWM_FUNC_RESIZE = (1L << 1),
+ MWM_FUNC_MOVE = (1L << 2),
+ MWM_FUNC_MINIMIZE = (1L << 3),
+ MWM_FUNC_MAXIMIZE = (1L << 4),
+ MWM_FUNC_CLOSE = (1L << 5),
-public slots:
- void eventDispatcher();
+ MWM_HINTS_DECORATIONS = (1L << 1),
-public: //###
- Display * display;
- int screen;
- int width, height;
- int physicalWidth;
- int physicalHeight;
+ MWM_DECOR_ALL = (1L << 0),
+ MWM_DECOR_BORDER = (1L << 1),
+ MWM_DECOR_RESIZEH = (1L << 2),
+ MWM_DECOR_TITLE = (1L << 3),
+ MWM_DECOR_MENU = (1L << 4),
+ MWM_DECOR_MINIMIZE = (1L << 5),
+ MWM_DECOR_MAXIMIZE = (1L << 6),
- QList<QTestLiteWindow*> windowList;
+ MWM_HINTS_INPUT_MODE = (1L << 2),
- MyX11Cursors * cursors;
+ MWM_INPUT_MODELESS = 0L,
+ MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L,
+ MWM_INPUT_FULL_APPLICATION_MODAL = 3L
};
-struct MyShmImageInfo;
-
class QTestLiteWindow : public QPlatformWindow
{
public:
- QTestLiteWindow(const QTestLiteIntegration *platformIntegration,
- QTestLiteScreen *screen, QWidget *window);
+ QTestLiteWindow(QWidget *window);
~QTestLiteWindow();
void mousePressEvent(XButtonEvent*);
void handleMouseEvent(QEvent::Type, XButtonEvent *ev);
- void handleKeyEvent(QEvent::Type, void *);
void handleCloseEvent();
void handleEnterEvent();
void handleLeaveEvent();
+ void handleFocusInEvent();
+ void handleFocusOutEvent();
void resizeEvent(XConfigureEvent *configure_event);
void paintEvent();
+ void requestActivateWindow();
void setGeometry(const QRect &rect);
@@ -125,33 +115,30 @@ public:
void lower();
void setWindowTitle(const QString &title);
- void setCursor(QCursor * cursor);
+ void setCursor(const Cursor &cursor);
QPlatformGLContext *glContext() const;
+ Window xWindow() const;
+ GC graphicsContext() const;
+
+protected:
+ void setMWMHints(const QtMWMHints &mwmhints);
+ QtMWMHints getMWMHints() const;
+
+ void doSizeHints();
+
private:
- int xpos, ypos;
- int width, height;
+ QPlatformWindowFormat correctColorBuffers(const QPlatformWindowFormat &windowFormat)const;
+
Window x_window;
GC gc;
GC createGC();
- Cursor createCursorShape(int cshape);
- Cursor createCursorBitmap(QCursor * cursor);
-
- int currentCursor;
-
- MyDisplay *xd;
+ QPlatformGLContext *mGLContext;
QTestLiteScreen *mScreen;
Qt::WindowFlags window_flags;
- QPlatformGLContext *mGLContext;
-
- friend class QTestLiteWindowSurface; // x_window, gc and windowSurface
};
-
-
-
-
#endif
diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp
index b3232c8..ced964a 100644
--- a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp
+++ b/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp
@@ -46,6 +46,7 @@
#include <QWindowSystemInterface>
#include "qtestlitewindow.h"
+#include "qtestlitescreen.h"
# include <sys/ipc.h>
# include <sys/shm.h>
@@ -65,8 +66,6 @@ struct MyShmImageInfo {
Display *display;
};
-//void QTestLiteWindowSurface::flush()
-
#ifndef DONT_USE_MIT_SHM
void MyShmImageInfo::destroy()
@@ -80,20 +79,21 @@ void MyShmImageInfo::destroy()
void QTestLiteWindowSurface::resizeShmImage(int width, int height)
{
- MyDisplay *xd = xw->xd;
#ifdef DONT_USE_MIT_SHM
shm_img = QImage(width, height, QImage::Format_RGB32);
#else
+
+ QTestLiteScreen *screen = QTestLiteScreen::testLiteScreenForWidget(window());
if (image_info)
image_info->destroy();
else
- image_info = new MyShmImageInfo(xd->display);
+ image_info = new MyShmImageInfo(screen->display());
- Visual *visual = DefaultVisual(xd->display, xd->screen);
+ Visual *visual = DefaultVisual(screen->display(), screen->xScreenNumber());
- XImage *image = XShmCreateImage (xd->display, visual, 24, ZPixmap, 0,
+ XImage *image = XShmCreateImage (screen->display(), visual, 24, ZPixmap, 0,
&image_info->shminfo, width, height);
@@ -105,7 +105,7 @@ void QTestLiteWindowSurface::resizeShmImage(int width, int height)
image_info->image = image;
- Status shm_attach_status = XShmAttach(xd->display, &image_info->shminfo);
+ Status shm_attach_status = XShmAttach(screen->display(), &image_info->shminfo);
Q_ASSERT(shm_attach_status == True);
@@ -126,7 +126,7 @@ QSize QTestLiteWindowSurface::bufferSize() const
return shm_img.size();
}
-QTestLiteWindowSurface::QTestLiteWindowSurface (QTestLiteScreen */*screen*/, QWidget *window)
+QTestLiteWindowSurface::QTestLiteWindowSurface (QWidget *window)
: QWindowSurface(window),
painted(false), image_info(0)
{
@@ -151,29 +151,27 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion &region, const
Q_UNUSED(region);
Q_UNUSED(offset);
- // qDebug() << "QTestLiteWindowSurface::flush:" << (long)this;
-
if (!painted)
return;
- MyDisplay *xd = xw->xd;
- GC gc = xw->gc;
- Window window = xw->x_window;
+ QTestLiteScreen *screen = QTestLiteScreen::testLiteScreenForWidget(widget);
+ GC gc = xw->graphicsContext();
+ Window window = xw->xWindow();
#ifdef DONT_USE_MIT_SHM
// just convert the image every time...
if (!shm_img.isNull()) {
- Visual *visual = DefaultVisual(xd->display, xd->screen);
+ Visual *visual = DefaultVisual(screen->display(), screen->xScreenNumber());
QImage image = shm_img;
//img.convertToFormat(
- XImage *xi = XCreateImage(xd->display, visual, 24, ZPixmap,
+ XImage *xi = XCreateImage(screen->display(), visual, 24, ZPixmap,
0, (char *) image.scanLine(0), image.width(), image.height(),
32, image.bytesPerLine());
int x = 0;
int y = 0;
- /*int r =*/ XPutImage(xd->display, window, gc, xi, 0, 0, x, y, image.width(), image.height());
+ /*int r =*/ XPutImage(screen->display(), window, gc, xi, 0, 0, x, y, image.width(), image.height());
xi->data = 0; // QImage owns these bits
XDestroyImage(xi);
@@ -187,11 +185,11 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion &region, const
// We could set send_event to true, and then use the ShmCompletion to synchronize,
// but let's do like Qt/11 and just use XSync
- XShmPutImage (xd->display, window, gc, image_info->image, 0, 0,
+ XShmPutImage (screen->display(), window, gc, image_info->image, 0, 0,
x, y, image_info->image->width, image_info->image->height,
/*send_event*/ False);
- XSync(xd->display, False);
+ XSync(screen->display(), False);
}
#endif
}
diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.h b/src/plugins/platforms/testlite/qtestlitewindowsurface.h
index 915e7fe..ca900e5 100644
--- a/src/plugins/platforms/testlite/qtestlitewindowsurface.h
+++ b/src/plugins/platforms/testlite/qtestlitewindowsurface.h
@@ -55,7 +55,7 @@ class MyShmImageInfo;
class QTestLiteWindowSurface : public QWindowSurface
{
public:
- QTestLiteWindowSurface (QTestLiteScreen *screen, QWidget *window);
+ QTestLiteWindowSurface (QWidget *window);
~QTestLiteWindowSurface();
QPaintDevice *paintDevice();
diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/testlite/testlite.pro
index 05bd384..7fb3304 100644
--- a/src/plugins/platforms/testlite/testlite.pro
+++ b/src/plugins/platforms/testlite/testlite.pro
@@ -7,22 +7,50 @@ SOURCES = \
main.cpp \
qtestliteintegration.cpp \
qtestlitewindowsurface.cpp \
- qtestlitewindow.cpp
+ qtestlitewindow.cpp \
+ qtestlitecursor.cpp \
+ qtestlitescreen.cpp \
+ qtestlitekeyboard.cpp \
+ qtestliteclipboard.cpp \
+ qtestlitemime.cpp \
+ qtestlitestaticinfo.cpp
HEADERS = \
qtestliteintegration.h \
qtestlitewindowsurface.h \
- qtestlitewindow.h
-
+ qtestlitewindow.h \
+ qtestlitecursor.h \
+ qtestlitescreen.h \
+ qtestlitekeyboard.h \
+ qtestliteclipboard.h \
+ qtestlitemime.h \
+ qtestlitestaticinfo.h
LIBS += -lX11 -lXext
+mac {
+ LIBS += -L/usr/X11/lib -lz -framework Carbon
+}
+
include (../fontdatabases/genericunix/genericunix.pri)
contains(QT_CONFIG, opengl) {
QT += opengl
- HEADERS += qglxintegration.h
- SOURCES += qglxintegration.cpp
+ !contains(QT_CONFIG, opengles2) {
+ HEADERS += qglxintegration.h
+ SOURCES += qglxintegration.cpp
+ } else { # There is no easy way to detect if we'r suppose to use glx or not
+ HEADERS += \
+ ../eglconvenience/qeglplatformcontext.h \
+ ../eglconvenience/qeglconvenience.h \
+ qtestliteeglintegration.h
+
+ SOURCES += \
+ ../eglconvenience/qeglplatformcontext.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ qtestliteeglintegration.cpp
+ LIBS += -lEGL
+ }
}
target.path += $$[QT_INSTALL_PLUGINS]/platforms
diff --git a/src/plugins/platforms/wayland/main.cpp b/src/plugins/platforms/wayland/main.cpp
new file mode 100644
index 0000000..1bca661
--- /dev/null
+++ b/src/plugins/platforms/wayland/main.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "qwaylandintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QWaylandIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "Wayland";
+ list << "WaylandGL";
+ return list;
+}
+
+QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "wayland")
+ return new QWaylandIntegration;
+ if (system.toLower() == "waylandgl")
+ return new QWaylandIntegration(true);
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(wayland, QWaylandIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandbuffer.h b/src/plugins/platforms/wayland/qwaylandbuffer.h
new file mode 100644
index 0000000..643e89c
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandbuffer.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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 config.tests 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDBUFFER_H
+#define QWAYLANDBUFFER_H
+
+#include <QtCore/QSize>
+
+#include <wayland-client-protocol.h>
+
+class QWaylandBuffer {
+public:
+ QWaylandBuffer() { }
+ virtual ~QWaylandBuffer() { }
+ wl_buffer *buffer() {return mBuffer;}
+ virtual QSize size() const = 0;
+
+protected:
+ struct wl_buffer *mBuffer;
+};
+
+#endif // QWAYLANDBUFFER_H
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp
new file mode 100644
index 0000000..29c6abd
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandcursor.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandinputdevice.h"
+#include "qwaylandshmsurface.h"
+#include "qwaylandscreen.h"
+
+#include <QtGui/QImageReader>
+
+#define DATADIR "/home/jlind/install/share"
+
+static const struct pointer_image {
+ const char *filename;
+ int hotspot_x, hotspot_y;
+} pointer_images[] = {
+ /* FIXME: Half of these are wrong... */
+ /* Qt::ArrowCursor */
+ { DATADIR "/wayland/left_ptr.png", 10, 5 },
+ /* Qt::UpArrowCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::CrossCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::WaitCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::IBeamCursor */
+ { DATADIR "/wayland/xterm.png", 15, 15 },
+ /* Qt::SizeVerCursor */
+ { DATADIR "/wayland/top_side.png", 18, 8 },
+ /* Qt::SizeHorCursor */
+ { DATADIR "/wayland/bottom_left_corner.png", 6, 30 },
+ /* Qt::SizeBDiagCursor */
+ { DATADIR "/wayland/bottom_right_corner.png", 28, 28 },
+ /* Qt::SizeFDiagCursor */
+ { DATADIR "/wayland/bottom_side.png", 16, 20 },
+ /* Qt::SizeAllCursor */
+ { DATADIR "/wayland/left_side.png", 10, 20 },
+ /* Qt::BlankCursor */
+ { DATADIR "/wayland/right_side.png", 30, 19 },
+ /* Qt::SplitVCursor */
+ { DATADIR "/wayland/sb_v_double_arrow.png", 15, 15 },
+ /* Qt::SplitHCursor */
+ { DATADIR "/wayland/sb_h_double_arrow.png", 15, 15 },
+ /* Qt::PointingHandCursor */
+ { DATADIR "/wayland/hand2.png", 14, 8 },
+ /* Qt::ForbiddenCursor */
+ { DATADIR "/wayland/top_right_corner.png", 26, 8 },
+ /* Qt::WhatsThisCursor */
+ { DATADIR "/wayland/top_right_corner.png", 26, 8 },
+ /* Qt::BusyCursor */
+ { DATADIR "/wayland/top_right_corner.png", 26, 8 },
+ /* Qt::OpenHandCursor */
+ { DATADIR "/wayland/hand1.png", 18, 11 },
+ /* Qt::ClosedHandCursor */
+ { DATADIR "/wayland/grabbing.png", 20, 17 },
+ /* Qt::DragCopyCursor */
+ { DATADIR "/wayland/dnd-copy.png", 13, 13 },
+ /* Qt::DragMoveCursor */
+ { DATADIR "/wayland/dnd-move.png", 13, 13 },
+ /* Qt::DragLinkCursor */
+ { DATADIR "/wayland/dnd-link.png", 13, 13 },
+};
+
+QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
+ : QPlatformCursor(screen)
+ , mBuffer(0)
+ , mDisplay(screen->display())
+{
+}
+
+void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget)
+{
+ const struct pointer_image *p;
+
+ if (widget == NULL)
+ return;
+
+ p = NULL;
+
+ switch (cursor->shape()) {
+ case Qt::ArrowCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+ case Qt::UpArrowCursor:
+ case Qt::CrossCursor:
+ case Qt::WaitCursor:
+ break;
+ case Qt::IBeamCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+ case Qt::SizeVerCursor: /* 5 */
+ case Qt::SizeHorCursor:
+ case Qt::SizeBDiagCursor:
+ case Qt::SizeFDiagCursor:
+ case Qt::SizeAllCursor:
+ case Qt::BlankCursor: /* 10 */
+ break;
+ case Qt::SplitVCursor:
+ case Qt::SplitHCursor:
+ case Qt::PointingHandCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+ case Qt::ForbiddenCursor:
+ case Qt::WhatsThisCursor: /* 15 */
+ case Qt::BusyCursor:
+ break;
+ case Qt::OpenHandCursor:
+ case Qt::ClosedHandCursor:
+ case Qt::DragCopyCursor:
+ case Qt::DragMoveCursor: /* 20 */
+ case Qt::DragLinkCursor:
+ p = &pointer_images[cursor->shape()];
+ break;
+
+ default:
+ case Qt::BitmapCursor:
+ break;
+ }
+
+ if (!p) {
+ p = &pointer_images[0];
+ qWarning("unhandled cursor %d", cursor->shape());
+ }
+
+ QImageReader reader(p->filename);
+
+ if (mBuffer == NULL || mBuffer->size() != reader.size()) {
+ if (mBuffer)
+ delete mBuffer;
+
+ mBuffer = new QWaylandShmBuffer(mDisplay, reader.size(),
+ QImage::Format_ARGB32);
+ }
+
+ reader.read(mBuffer->image());
+
+ mDisplay->setCursor(mBuffer, p->hotspot_x, p->hotspot_y);
+}
+
+void QWaylandDisplay::setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y)
+{
+ /* Qt doesn't tell us which input device we should set the cursor
+ * for, so set it for all devices. */
+ for (int i = 0; i < mInputDevices.count(); i++) {
+ QWaylandInputDevice *inputDevice = mInputDevices.at(i);
+ inputDevice->attach(buffer, x, y);
+ }
+}
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h
new file mode 100644
index 0000000..19e6047
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandcursor.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDCURSOR_H
+#define QWAYLANDCURSOR_H
+
+#include <QtGui/QPlatformCursor>
+
+class QWaylandShmBuffer;
+class QWaylandDisplay;
+class QWaylandScreen;
+
+class QWaylandCursor : QPlatformCursor {
+public:
+ QWaylandCursor(QWaylandScreen *screen);
+
+ void changeCursor(QCursor *cursor, QWidget *widget);
+ QWaylandShmBuffer *mBuffer;
+ QWaylandDisplay *mDisplay;
+};
+
+#endif // QWAYLANDCURSOR_H
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
new file mode 100644
index 0000000..70713ec
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -0,0 +1,313 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylanddisplay.h"
+
+#include "qwaylandwindow.h"
+#include "qwaylandscreen.h"
+#include "qwaylandcursor.h"
+#include "qwaylandinputdevice.h"
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+extern "C" {
+#include <xf86drm.h>
+}
+
+struct wl_surface *QWaylandDisplay::createSurface()
+{
+ return wl_compositor_create_surface(mCompositor);
+}
+
+struct wl_buffer *QWaylandDisplay::createShmBuffer(int fd,
+ int width, int height,
+ uint32_t stride,
+ struct wl_visual *visual)
+{
+ return wl_shm_create_buffer(mShm, fd, width, height, stride, visual);
+}
+
+struct wl_buffer *QWaylandDisplay::createDrmBuffer(int name,
+ int width, int height,
+ uint32_t stride,
+ struct wl_visual *visual)
+{
+ return wl_drm_create_buffer(mDrm, name, width, height, stride, visual);
+}
+
+struct wl_visual *QWaylandDisplay::rgbVisual()
+{
+ return wl_display_get_rgb_visual(mDisplay);
+}
+
+struct wl_visual *QWaylandDisplay::argbVisual()
+{
+ return wl_display_get_argb_visual(mDisplay);
+}
+
+struct wl_visual *QWaylandDisplay::argbPremultipliedVisual()
+{
+ return wl_display_get_premultiplied_argb_visual(mDisplay);
+}
+
+void QWaylandDisplay::drmHandleDevice(void *data,
+ struct wl_drm *drm, const char *device)
+{
+ Q_UNUSED(drm);
+ QWaylandDisplay *qwd = (QWaylandDisplay *) data;
+ drm_magic_t magic;
+
+ qwd->mDeviceName = strdup(device);
+
+ qwd->mFd = open(qwd->mDeviceName, O_RDWR);
+ if (qwd->mFd < 0) {
+ qWarning("drm open failed: %m");
+ return;
+ }
+
+ if (drmGetMagic(qwd->mFd, &magic)) {
+ qWarning("DRI2: failed to get drm magic");
+ return;
+ }
+
+ wl_drm_authenticate(qwd->mDrm, magic);
+}
+
+void QWaylandDisplay::drmHandleAuthenticated(void *data, struct wl_drm *drm)
+{
+ Q_UNUSED(drm);
+ QWaylandDisplay *qwd = (QWaylandDisplay *) data;
+ EGLint major, minor;
+ const char *extensions;
+
+ qwd->mEglDisplay = eglGetDRMDisplayMESA(qwd->mFd);
+ if (qwd->mEglDisplay == NULL) {
+ qWarning("failed to create display");
+ return;
+ }
+
+ if (!eglInitialize(qwd->mEglDisplay, &major, &minor)) {
+ qWarning("failed to initialize display");
+ qwd->mEglDisplay = NULL;
+ return;
+ }
+
+ extensions = eglQueryString(qwd->mEglDisplay, EGL_EXTENSIONS);
+ if (!strstr(extensions, "EGL_KHR_surfaceless_gles2")) {
+ qWarning("EGL_KHR_surfaceless_opengles2 not available");
+ eglTerminate(qwd->mEglDisplay);
+ qwd->mEglDisplay = NULL;
+ return;
+ }
+}
+
+const struct wl_drm_listener QWaylandDisplay::drmListener = {
+ QWaylandDisplay::drmHandleDevice,
+ QWaylandDisplay::drmHandleAuthenticated
+};
+
+void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell,
+ uint32_t time, uint32_t edges,
+ struct wl_surface *surface,
+ int32_t width, int32_t height)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(shell);
+ Q_UNUSED(time);
+ Q_UNUSED(edges);
+ QWaylandWindow *ww = (QWaylandWindow *) wl_surface_get_user_data(surface);
+
+ ww->configure(time, edges, 0, 0, width, height);
+}
+
+const struct wl_shell_listener QWaylandDisplay::shellListener = {
+ QWaylandDisplay::shellHandleConfigure,
+};
+
+void QWaylandDisplay::outputHandleGeometry(void *data,
+ struct wl_output *output,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ QWaylandDisplay *waylandDisplay = (QWaylandDisplay *) data;
+
+ QRect outputRect = QRect(x, y, width, height);
+ waylandDisplay->createNewScreen(output, outputRect);
+}
+
+const struct wl_output_listener QWaylandDisplay::outputListener = {
+ QWaylandDisplay::outputHandleGeometry
+};
+
+void QWaylandDisplay::displayHandleGlobal(struct wl_display *display,
+ uint32_t id,
+ const char *interface,
+ uint32_t version, void *data)
+{
+ Q_UNUSED(version);
+ QWaylandDisplay *qwd = (QWaylandDisplay *) data;
+
+ if (strcmp(interface, "compositor") == 0) {
+ qwd->mCompositor = wl_compositor_create(display, id);
+ } else if (strcmp(interface, "drm") == 0) {
+ qwd->mDrm = wl_drm_create(display, id);
+ wl_drm_add_listener(qwd->mDrm, &drmListener, qwd);
+ } else if (strcmp(interface, "shm") == 0) {
+ qwd->mShm = wl_shm_create(display, id);
+ } else if (strcmp(interface, "shell") == 0) {
+ qwd->mShell = wl_shell_create(display, id);
+ wl_shell_add_listener(qwd->mShell, &shellListener, qwd);
+ } else if (strcmp(interface, "output") == 0) {
+ struct wl_output *output = wl_output_create(display, id);
+ wl_output_add_listener(output, &outputListener, qwd);
+ } else if (strcmp(interface, "input_device") == 0) {
+ QWaylandInputDevice *inputDevice =
+ new QWaylandInputDevice(display, id);
+ qwd->mInputDevices.append(inputDevice);
+ }
+}
+
+static void roundtripCallback(void *data)
+{
+ bool *done = (bool *) data;
+
+ *done = true;
+}
+
+static void forceRoundtrip(struct wl_display *display)
+{
+ bool done;
+
+ wl_display_sync_callback(display, roundtripCallback, &done);
+ wl_display_iterate(display, WL_DISPLAY_WRITABLE);
+ done = false;
+ while (!done)
+ wl_display_iterate(display, WL_DISPLAY_READABLE);
+}
+
+static const char *socket_name = NULL;
+
+void QWaylandDisplay::eventDispatcher(void)
+{
+ wl_display_iterate(mDisplay, WL_DISPLAY_READABLE);
+}
+
+int
+QWaylandDisplay::sourceUpdate(uint32_t mask, void *data)
+{
+ QWaylandDisplay *qwd = (QWaylandDisplay *) data;
+
+ /* FIXME: We get a callback here when we ask wl_display for the
+ * fd, but at that point we don't have the socket notifier as we
+ * need the fd to create that. We'll probably need to split that
+ * API into get_fd and set_update_func functions. */
+ if (qwd->mWriteNotifier == NULL)
+ return 0;
+
+ qwd->mWriteNotifier->setEnabled(mask & WL_DISPLAY_WRITABLE);
+
+ return 0;
+}
+
+void QWaylandDisplay::flushRequests(void)
+{
+ wl_display_iterate(mDisplay, WL_DISPLAY_WRITABLE);
+}
+
+QWaylandDisplay::QWaylandDisplay(void)
+ : mWriteNotifier(0)
+{
+ mDisplay = wl_display_connect(socket_name);
+ if (mDisplay == NULL) {
+ fprintf(stderr, "failed to create display: %m\n");
+ return;
+ }
+
+ wl_display_add_global_listener(mDisplay,
+ QWaylandDisplay::displayHandleGlobal, this);
+
+ /* Process connection events. */
+ wl_display_iterate(mDisplay, WL_DISPLAY_READABLE);
+ if (!mShm || !mDeviceName)
+ forceRoundtrip(mDisplay);
+
+ /* Force a roundtrip to finish the drm authentication so we
+ * initialize EGL before proceeding */
+ forceRoundtrip(mDisplay);
+ if (mEglDisplay == NULL)
+ qDebug("EGL not available");
+ else
+ qDebug("EGL initialized");
+
+ int fd = wl_display_get_fd(mDisplay, sourceUpdate, this);
+ mReadNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
+ connect(mReadNotifier,
+ SIGNAL(activated(int)), this, SLOT(eventDispatcher()));
+
+ mWriteNotifier = new QSocketNotifier(fd, QSocketNotifier::Write, this);
+ connect(mWriteNotifier,
+ SIGNAL(activated(int)), this, SLOT(flushRequests()));
+ mWriteNotifier->setEnabled(false);
+}
+
+QWaylandDisplay::~QWaylandDisplay(void)
+{
+ close(mFd);
+ wl_display_destroy(mDisplay);
+}
+
+void QWaylandDisplay::createNewScreen(struct wl_output *output, QRect geometry)
+{
+ QWaylandScreen *waylandScreen = new QWaylandScreen(this,output,geometry);
+ mScreens.append(waylandScreen);
+}
+
+void QWaylandDisplay::syncCallback(wl_display_sync_func_t func, void *data)
+{
+ wl_display_sync_callback(mDisplay, func, data);
+}
+
+void QWaylandDisplay::frameCallback(wl_display_frame_func_t func, void *data)
+{
+ wl_display_frame_callback(mDisplay, func, data);
+}
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
new file mode 100644
index 0000000..f179713
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDDISPLAY_H
+#define QWAYLANDDISPLAY_H
+
+#include <QtCore/QObject>
+#include <QtCore/QRect>
+
+#include <wayland-client.h>
+
+#define MESA_EGL_NO_X11_HEADERS
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+class QWaylandInputDevice;
+class QSocketNotifier;
+class QWaylandBuffer;
+class QPlatformScreen;
+class QWaylandScreen;
+
+class QWaylandDisplay : public QObject {
+ Q_OBJECT
+
+public:
+ QWaylandDisplay(void);
+ ~QWaylandDisplay(void);
+
+ void createNewScreen(struct wl_output *output, QRect geometry);
+ QList<QPlatformScreen *> screens() const { return mScreens; }
+ struct wl_surface *createSurface();
+ struct wl_buffer *createShmBuffer(int fd, int width, int height,
+ uint32_t stride,
+ struct wl_visual *visual);
+ struct wl_buffer *createDrmBuffer(int name, int width, int height,
+ uint32_t stride,
+ struct wl_visual *visual);
+ struct wl_visual *rgbVisual();
+ struct wl_visual *argbVisual();
+ struct wl_visual *argbPremultipliedVisual();
+ EGLDisplay eglDisplay() { return mEglDisplay; }
+
+ void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
+
+ void syncCallback(wl_display_sync_func_t func, void *data);
+ void frameCallback(wl_display_frame_func_t func, void *data);
+
+public slots:
+ void eventDispatcher(void);
+ void flushRequests(void);
+
+private:
+ struct wl_display *mDisplay;
+ struct wl_compositor *mCompositor;
+ struct wl_drm *mDrm;
+ struct wl_shm *mShm;
+ struct wl_shell *mShell;
+ char *mDeviceName;
+ int mFd;
+ QList<QPlatformScreen *> mScreens;
+ QList<QWaylandInputDevice *> mInputDevices;
+ QSocketNotifier *mReadNotifier;
+ QSocketNotifier *mWriteNotifier;
+ EGLDisplay mEglDisplay;
+
+ static void displayHandleGlobal(struct wl_display *display,
+ uint32_t id,
+ const char *interface,
+ uint32_t version, void *data);
+
+ static void drmHandleDevice(void *data,
+ struct wl_drm *drm, const char *device);
+ static void drmHandleAuthenticated(void *data, struct wl_drm *drm);
+
+ static void outputHandleGeometry(void *data,
+ struct wl_output *output,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height);
+
+ static void shellHandleConfigure(void *data, struct wl_shell *shell,
+ uint32_t time, uint32_t edges,
+ struct wl_surface *surface,
+ int32_t width, int32_t height);
+
+ static int sourceUpdate(uint32_t mask, void *data);
+
+ static const struct wl_drm_listener drmListener;
+ static const struct wl_output_listener outputListener;
+ static const struct wl_shell_listener shellListener;
+};
+
+#endif // QWAYLANDDISPLAY_H
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
new file mode 100644
index 0000000..76c8c33
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
@@ -0,0 +1,271 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qwaylanddrmsurface.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandwindow.h"
+#include "qwaylandscreen.h"
+
+#include <QtCore/qdebug.h>
+#include <QtGui/private/qapplication_p.h>
+#include <QtOpenGL/private/qgl_p.h>
+#include <QtGui/private/qpaintengine_p.h>
+
+#include <wayland-client.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ * Shared DRM surface for GL based drawing
+ */
+QWaylandDrmBuffer::QWaylandDrmBuffer(QWaylandDisplay *display,
+ const QSize &size, QImage::Format format)
+ : mDisplay(display)
+ , mSize(size)
+{
+ struct wl_visual *visual;
+ EGLint name, stride;
+ EGLint imageAttribs[] = {
+ EGL_WIDTH, size.width(),
+ EGL_HEIGHT, size.height(),
+ EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
+ EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SCANOUT_MESA,
+ EGL_NONE
+ };
+
+ mImage = eglCreateDRMImageMESA(mDisplay->eglDisplay(), imageAttribs);
+
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, mImage);
+ glGenTextures(1, &mTexture);
+ glBindTexture(GL_TEXTURE_2D, mTexture);
+ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, mImage);
+
+ eglExportDRMImageMESA(mDisplay->eglDisplay(),
+ mImage, &name, NULL, &stride);
+
+ switch (format) {
+ case QImage::Format_ARGB32:
+ visual = display->argbVisual();
+ break;
+ case QImage::Format_ARGB32_Premultiplied:
+ visual = display->argbPremultipliedVisual();
+ break;
+ default:
+ qDebug("unsupported buffer format %d requested\n", format);
+ visual = display->argbVisual();
+ break;
+ }
+
+ mBuffer = display->createDrmBuffer(name, size.width(), size.height(),
+ stride, visual);
+}
+
+QWaylandDrmBuffer::~QWaylandDrmBuffer(void)
+{
+ glDeleteTextures(1, &mTexture);
+ eglDestroyImageKHR(mDisplay->eglDisplay(), mImage);
+ wl_buffer_destroy(mBuffer);
+}
+
+void QWaylandDrmBuffer::bindToCurrentFbo()
+{
+ Q_ASSERT(QPlatformGLContext::currentContext());
+ glBindTexture(GL_TEXTURE_2D, mTexture);
+ glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, mTexture, 0);
+ QT_CHECK_GLERROR();
+}
+
+QWaylandPaintDevice::QWaylandPaintDevice(QWaylandDisplay *display, QWindowSurface *windowSurface, QPlatformGLContext *context)
+ : QGLPaintDevice()
+ , mDisplay(display)
+ , mPlatformGLContext(context)
+ , mWindowSurface(windowSurface)
+ , mBufferList(1)
+ , mCurrentPaintBuffer(0)
+ , mDepthStencil(0)
+{
+ for (int i = 0; i < mBufferList.size(); i++) {
+ mBufferList[i] = 0;
+ }
+
+ mPlatformGLContext->makeCurrent();
+ glGenFramebuffers(1, &m_thisFBO);
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO);
+
+ if (windowSurface->size().isValid())
+ resize(windowSurface->size());
+}
+
+QWaylandPaintDevice::~QWaylandPaintDevice()
+{
+ for(int i = 0; i < mBufferList.size(); i++) {
+ delete mBufferList[i];
+ }
+ glDeleteRenderbuffers(1,&mDepthStencil);
+ glDeleteFramebuffers(1,&m_thisFBO);
+}
+
+QSize QWaylandPaintDevice::size() const
+{
+ return mSize;
+}
+QGLContext *QWaylandPaintDevice::context() const
+{
+ return QGLContext::fromPlatformGLContext(mPlatformGLContext);
+}
+QPaintEngine *QWaylandPaintDevice::paintEngine() const
+{
+ return qt_qgl_paint_engine();
+}
+
+void QWaylandPaintDevice::beginPaint()
+{
+ QGLPaintDevice::beginPaint();
+ currentDrmBuffer()->bindToCurrentFbo();
+}
+
+bool QWaylandPaintDevice::isFlipped()const
+{
+ return true;
+}
+
+void QWaylandPaintDevice::resize(const QSize &size)
+{
+ QImage::Format format = QPlatformScreen::platformScreenForWidget(mWindowSurface->window())->format();
+ mPlatformGLContext->makeCurrent();
+ mSize = size;
+ for (int i = 0; i < mBufferList.size(); i++) {
+ if (!mBufferList.at(i) || mBufferList.at(i)->size() != size) {
+ delete mBufferList[i];
+ mBufferList[i] = new QWaylandDrmBuffer(mDisplay, size, format);
+ }
+ }
+
+ glDeleteRenderbuffers(1,&mDepthStencil);
+ glGenRenderbuffers(1,&mDepthStencil);
+ glBindRenderbuffer(GL_RENDERBUFFER_EXT,mDepthStencil);
+ glRenderbufferStorage(GL_RENDERBUFFER_EXT,
+ GL_DEPTH24_STENCIL8_EXT, size.width(), size.height());
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, mDepthStencil);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, mDepthStencil);
+
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
+
+ switch(status) {
+ case GL_NO_ERROR:
+ case GL_FRAMEBUFFER_COMPLETE_EXT:
+ qDebug() << "fbo ok";
+ break;
+ default:
+ qDebug() <<"QWaylandDrmBuffer error: "<< status;
+ break;
+ }
+ QT_CHECK_GLERROR();
+}
+
+QWaylandDrmBuffer *QWaylandPaintDevice::currentDrmBuffer() const
+{
+ return mBufferList[mCurrentPaintBuffer];
+}
+QWaylandDrmBuffer *QWaylandPaintDevice::currentDrmBufferAndSwap()
+{
+ QWaylandDrmBuffer *currentDrmBuffer = mBufferList[mCurrentPaintBuffer];
+ mCurrentPaintBuffer = (mCurrentPaintBuffer +1) % mBufferList.size();
+ return currentDrmBuffer;
+}
+
+QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window)
+ : QWindowSurface(window)
+ , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mPaintDevice(new QWaylandPaintDevice(mDisplay, this,window->platformWindow()->glContext()))
+{
+
+}
+
+QWaylandDrmWindowSurface::~QWaylandDrmWindowSurface()
+{
+ delete mPaintDevice;
+}
+
+void QWaylandDrmWindowSurface::beginPaint(const QRegion &)
+{
+ window()->platformWindow()->glContext()->makeCurrent();
+}
+
+QPaintDevice *QWaylandDrmWindowSurface::paintDevice()
+{
+ return mPaintDevice;
+}
+
+void QWaylandDrmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(offset);
+ QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow();
+
+ ww->attach(mPaintDevice->currentDrmBufferAndSwap());
+
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); i++) {
+ QRect r = rects.at(i);
+ wl_surface_damage(ww->surface(),
+ r.x(), r.y(), r.width(), r.height());
+ }
+}
+
+void QWaylandDrmWindowSurface::resize(const QSize &requestedSize)
+{
+ QWindowSurface::resize(requestedSize);
+ QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow();
+
+ ww->glContext()->makeCurrent();
+
+ mPaintDevice->resize(requestedSize);
+ ww->attach(mPaintDevice->currentDrmBuffer());
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.h b/src/plugins/platforms/wayland/qwaylanddrmsurface.h
new file mode 100644
index 0000000..eafea13
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** 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 config.tests 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDDRMSURFACE_H
+#define QWAYLANDDRMSURFACE_H
+
+#include "qwaylanddisplay.h"
+#include "qwaylandbuffer.h"
+
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QtCore/QVarLengthArray>
+#include <QtOpenGL/private/qglpaintdevice_p.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#define QT_RESET_GLERROR() \
+{ \
+ while (glGetError() != GL_NO_ERROR) {} \
+}
+#define QT_CHECK_GLERROR() \
+{ \
+ GLenum err = glGetError(); \
+ if (err != GL_NO_ERROR) { \
+ qDebug("[%s line %d] GL Error: 0x%x", \
+ __FILE__, __LINE__, (int)err); \
+ } \
+}
+
+class QWaylandDrmBuffer : public QWaylandBuffer {
+public:
+ QWaylandDrmBuffer(QWaylandDisplay *display,
+ const QSize &size, QImage::Format format);
+ ~QWaylandDrmBuffer();
+
+ void bindToCurrentFbo();
+ QSize size() const { return mSize; }
+
+private:
+ EGLImageKHR mImage;
+ QWaylandDisplay *mDisplay;
+ QSize mSize;
+ GLuint mTexture;
+
+};
+
+class QWaylandPaintDevice : public QGLPaintDevice
+{
+public:
+ QWaylandPaintDevice(QWaylandDisplay *display, QWindowSurface *windowSurface, QPlatformGLContext *context);
+ ~QWaylandPaintDevice();
+
+ QSize size() const;
+ QGLContext *context() const;
+ QPaintEngine *paintEngine() const;
+
+ void beginPaint();
+
+ bool isFlipped()const;
+
+ void resize(const QSize &size);
+
+ QWaylandDrmBuffer *currentDrmBuffer() const;
+ QWaylandDrmBuffer *currentDrmBufferAndSwap();
+
+private:
+ QWaylandDisplay *mDisplay;
+ QPlatformGLContext *mPlatformGLContext;
+ QWindowSurface *mWindowSurface;
+ QVarLengthArray<QWaylandDrmBuffer *> mBufferList;
+ int mCurrentPaintBuffer;
+ GLuint mDepthStencil;
+ QSize mSize;
+
+};
+
+class QWaylandDrmWindowSurface : public QWindowSurface
+{
+public:
+ QWaylandDrmWindowSurface(QWidget *window);
+ ~QWaylandDrmWindowSurface();
+
+ void beginPaint(const QRegion &);
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+
+private:
+
+ QWaylandDisplay *mDisplay;
+ QWaylandPaintDevice *mPaintDevice;
+};
+
+#endif // QWAYLANDDRMSURFACE_H
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/qwaylandglcontext.cpp
new file mode 100644
index 0000000..4bf68c4
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandglcontext.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandglcontext.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandwindow.h"
+#include "qwaylanddrmsurface.h"
+
+#include <QtGui/QPlatformGLContext>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <unistd.h>
+#include <fcntl.h>
+
+extern "C" {
+#include <xf86drm.h>
+}
+
+Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex);
+
+EGLint QWaylandGLContext::contextAttibutes[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+};
+
+QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format)
+ : QPlatformGLContext()
+ , mFormat(format)
+ , mDisplay(wd)
+{
+ QPlatformGLContext *sharePlatformContext;
+ if (format.useDefaultSharedContext()) {
+ if (!QPlatformGLContext::defaultSharedContext()) {
+ if (qt_defaultSharedContextMutex()->tryLock()){
+ createDefaultSharedContex(wd);
+ qt_defaultSharedContextMutex()->unlock();
+ } else {
+ qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created
+ qt_defaultSharedContextMutex()->unlock();
+ }
+ }
+ sharePlatformContext = QPlatformGLContext::defaultSharedContext();
+ } else {
+ sharePlatformContext = format.sharedGLContext();
+ }
+ mFormat.setSharedContext(sharePlatformContext);
+ EGLContext shareEGLContext = EGL_NO_CONTEXT;
+ if (sharePlatformContext)
+ shareEGLContext = static_cast<const QWaylandGLContext*>(sharePlatformContext)->mContext;
+
+ eglBindAPI(EGL_OPENGL_ES_API);
+ mContext = eglCreateContext(mDisplay->eglDisplay(), NULL,
+ shareEGLContext, contextAttibutes);
+
+ mFormat.setAccum(false);
+ mFormat.setAlphaBufferSize(8);
+ mFormat.setRedBufferSize(8);
+ mFormat.setGreenBufferSize(8);
+ mFormat.setBlueBufferSize(8);
+ mFormat.setDepth(false);
+// mFormat.setDepthBufferSize(8);
+ mFormat.setStencil(false);
+// mFormat.setStencilBufferSize(24);
+// mFormat.setSampleBuffers(false);
+
+}
+
+QWaylandGLContext::QWaylandGLContext()
+ : QPlatformGLContext()
+ , mDisplay(0)
+ , mContext(EGL_NO_CONTEXT)
+{ }
+
+QWaylandGLContext::~QWaylandGLContext()
+{
+ eglDestroyContext(mDisplay->eglDisplay(),mContext);
+}
+
+void QWaylandGLContext::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+ eglMakeCurrent(mDisplay->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, mContext);
+}
+
+void QWaylandGLContext::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+ eglMakeCurrent(mDisplay->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+}
+
+void QWaylandGLContext::swapBuffers()
+{
+}
+
+void *QWaylandGLContext::getProcAddress(const QString &string)
+{
+ return (void *) eglGetProcAddress(string.toLatin1().data());
+}
+
+void QWaylandGLContext::createDefaultSharedContex(QWaylandDisplay *display)
+{
+ QWaylandGLContext *defaultSharedContext = new QWaylandGLContext;
+ defaultSharedContext->mDisplay = display;
+ defaultSharedContext->mContext = eglCreateContext(mDisplay->eglDisplay(), NULL,
+ EGL_NO_CONTEXT, contextAttibutes);
+ QPlatformGLContext::setDefaultSharedContext(defaultSharedContext);
+}
+
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.h b/src/plugins/platforms/wayland/qwaylandglcontext.h
new file mode 100644
index 0000000..d9ba323
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandglcontext.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDGLCONTEXT_H
+#define QWAYLANDGLCONTEXT_H
+
+#include <QtGui/QPlatformGLContext>
+
+#include <QtCore/QMutex>
+class QWaylandDisplay;
+class QWaylandWindow;
+class QWaylandDrmWindowSurface;
+
+#define MESA_EGL_NO_X11_HEADERS
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+class QWaylandGLContext : public QPlatformGLContext {
+public:
+ QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format);
+ ~QWaylandGLContext();
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void* getProcAddress(const QString&);
+ QPlatformWindowFormat platformWindowFormat() const { return mFormat; }
+
+private:
+ QPlatformWindowFormat mFormat;
+ QWaylandDisplay *mDisplay;
+
+ static EGLint contextAttibutes[];
+ EGLContext mContext;
+
+ void createDefaultSharedContex(QWaylandDisplay *display);
+ QWaylandGLContext();
+
+};
+
+
+#endif // QWAYLANDGLCONTEXT_H
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
new file mode 100644
index 0000000..03edc07
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -0,0 +1,311 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandinputdevice.h"
+
+#include "qwaylandintegration.h"
+#include "qwaylandwindow.h"
+#include "qwaylandbuffer.h"
+
+#include <QWindowSystemInterface>
+
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <QtGui/QPlatformWindow>
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <X11/extensions/XKBcommon.h>
+#include <X11/keysym.h>
+
+QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
+ uint32_t id)
+ : mDisplay(display)
+ , mInputDevice(wl_input_device_create(display, id))
+ , mPointerFocus(NULL)
+ , mKeyboardFocus(NULL)
+ , mButtons(0)
+{
+ struct xkb_rule_names names;
+
+ wl_input_device_add_listener(mInputDevice,
+ &inputDeviceListener,
+ this);
+ wl_input_device_set_user_data(mInputDevice, this);
+
+ names.rules = "evdev";
+ names.model = "pc105";
+ names.layout = "us";
+ names.variant = "";
+ names.options = "";
+
+ mXkb = xkb_compile_keymap_from_rules(&names);
+}
+
+void QWaylandInputDevice::inputHandleMotion(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ int32_t x, int32_t y,
+ int32_t surface_x, int32_t surface_y)
+{
+ Q_UNUSED(input_device);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window = inputDevice->mPointerFocus;
+
+ inputDevice->mSurfacePos = QPoint(surface_x, surface_y);
+ inputDevice->mGlobalPos = QPoint(x, y);
+ inputDevice->mTime = time;
+ QWindowSystemInterface::handleMouseEvent(window->widget(),
+ time,
+ inputDevice->mSurfacePos,
+ inputDevice->mGlobalPos,
+ inputDevice->mButtons);
+}
+
+void QWaylandInputDevice::inputHandleButton(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t button, uint32_t state)
+{
+ Q_UNUSED(input_device);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window = inputDevice->mPointerFocus;
+ Qt::MouseButton qt_button;
+
+ switch (button) {
+ case 272:
+ qt_button = Qt::LeftButton;
+ break;
+ case 273:
+ qt_button = Qt::RightButton;
+ break;
+ case 274:
+ qt_button = Qt::MiddleButton;
+ break;
+ default:
+ return;
+ }
+
+ if (state)
+ inputDevice->mButtons |= qt_button;
+ else
+ inputDevice->mButtons &= ~qt_button;
+
+ inputDevice->mTime = time;
+ QWindowSystemInterface::handleMouseEvent(window->widget(),
+ time,
+ inputDevice->mSurfacePos,
+ inputDevice->mGlobalPos,
+ inputDevice->mButtons);
+}
+
+static Qt::KeyboardModifiers translateModifiers(int s)
+{
+ const uchar qt_alt_mask = XKB_COMMON_MOD1_MASK;
+ const uchar qt_meta_mask = XKB_COMMON_MOD4_MASK;
+
+ Qt::KeyboardModifiers ret = 0;
+ if (s & XKB_COMMON_SHIFT_MASK)
+ ret |= Qt::ShiftModifier;
+ if (s & XKB_COMMON_CONTROL_MASK)
+ ret |= Qt::ControlModifier;
+ if (s & qt_alt_mask)
+ ret |= Qt::AltModifier;
+ if (s & qt_meta_mask)
+ ret |= Qt::MetaModifier;
+
+ return ret;
+}
+
+static uint32_t translateKey(uint32_t sym, char *string, size_t size)
+{
+ Q_UNUSED(size);
+ string[0] = '\0';
+
+ switch (sym) {
+ case XK_Escape: return Qt::Key_Escape;
+ case XK_Tab: return Qt::Key_Tab;
+ case XK_ISO_Left_Tab: return Qt::Key_Backtab;
+ case XK_BackSpace: return Qt::Key_Backspace;
+ case XK_Return: return Qt::Key_Return;
+ case XK_Insert: return Qt::Key_Insert;
+ case XK_Delete: return Qt::Key_Delete;
+ case XK_Clear: return Qt::Key_Delete;
+ case XK_Pause: return Qt::Key_Pause;
+ case XK_Print: return Qt::Key_Print;
+
+ case XK_Home: return Qt::Key_Home;
+ case XK_End: return Qt::Key_End;
+ case XK_Left: return Qt::Key_Left;
+ case XK_Up: return Qt::Key_Up;
+ case XK_Right: return Qt::Key_Right;
+ case XK_Down: return Qt::Key_Down;
+ case XK_Prior: return Qt::Key_PageUp;
+ case XK_Next: return Qt::Key_PageDown;
+
+ case XK_Shift_L: return Qt::Key_Shift;
+ case XK_Shift_R: return Qt::Key_Shift;
+ case XK_Shift_Lock: return Qt::Key_Shift;
+ case XK_Control_L: return Qt::Key_Control;
+ case XK_Control_R: return Qt::Key_Control;
+ case XK_Meta_L: return Qt::Key_Meta;
+ case XK_Meta_R: return Qt::Key_Meta;
+ case XK_Alt_L: return Qt::Key_Alt;
+ case XK_Alt_R: return Qt::Key_Alt;
+ case XK_Caps_Lock: return Qt::Key_CapsLock;
+ case XK_Num_Lock: return Qt::Key_NumLock;
+ case XK_Scroll_Lock: return Qt::Key_ScrollLock;
+ case XK_Super_L: return Qt::Key_Super_L;
+ case XK_Super_R: return Qt::Key_Super_R;
+ case XK_Menu: return Qt::Key_Menu;
+
+ default:
+ string[0] = sym;
+ string[1] = '\0';
+ return toupper(sym);
+ }
+}
+
+void QWaylandInputDevice::inputHandleKey(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t key, uint32_t state)
+{
+ Q_UNUSED(input_device);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window = inputDevice->mKeyboardFocus;
+ uint32_t code, sym, level;
+ Qt::KeyboardModifiers modifiers;
+ QEvent::Type type;
+ char s[2];
+
+ code = key + inputDevice->mXkb->min_key_code;
+
+ level = 0;
+ if (inputDevice->mModifiers & Qt::ShiftModifier &&
+ XkbKeyGroupWidth(inputDevice->mXkb, code, 0) > 1)
+ level = 1;
+
+ sym = XkbKeySymEntry(inputDevice->mXkb, code, level, 0);
+
+ modifiers = translateModifiers(inputDevice->mXkb->map->modmap[code]);
+
+ if (state) {
+ inputDevice->mModifiers |= modifiers;
+ type = QEvent::KeyPress;
+ } else {
+ inputDevice->mModifiers &= ~modifiers;
+ type = QEvent::KeyRelease;
+ }
+
+ sym = translateKey(sym, s, sizeof s);
+
+ qWarning("keycode %d, sym %d, string %d, modifiers 0x%x",
+ code, sym, s[0], (int) inputDevice->mModifiers);
+
+ if (window) {
+ QWindowSystemInterface::handleKeyEvent(window->widget(),
+ time, type, sym,
+ inputDevice->mModifiers,
+ QString::fromLatin1(s));
+ }
+}
+
+void QWaylandInputDevice::inputHandlePointerFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, struct wl_surface *surface,
+ int32_t x, int32_t y, int32_t sx, int32_t sy)
+{
+ Q_UNUSED(input_device);
+ Q_UNUSED(x);
+ Q_UNUSED(y);
+ Q_UNUSED(sx);
+ Q_UNUSED(sy);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window;
+
+ if (inputDevice->mPointerFocus) {
+ window = inputDevice->mPointerFocus;
+ QWindowSystemInterface::handleLeaveEvent(window->widget());
+ inputDevice->mPointerFocus = NULL;
+ }
+
+ if (surface) {
+ window = (QWaylandWindow *) wl_surface_get_user_data(surface);
+ QWindowSystemInterface::handleEnterEvent(window->widget());
+ inputDevice->mPointerFocus = window;
+ }
+
+ inputDevice->mTime = time;
+}
+
+void QWaylandInputDevice::inputHandleKeyboardFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ struct wl_surface *surface,
+ struct wl_array *keys)
+{
+ Q_UNUSED(input_device);
+ Q_UNUSED(time);
+ Q_UNUSED(keys);
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ QWaylandWindow *window;
+
+ if (inputDevice->mKeyboardFocus) {
+ window = inputDevice->mKeyboardFocus;
+ inputDevice->mKeyboardFocus = NULL;
+ }
+
+ if (surface) {
+ window = (QWaylandWindow *) wl_surface_get_user_data(surface);
+ inputDevice->mKeyboardFocus = window;
+ }
+}
+
+const struct wl_input_device_listener QWaylandInputDevice::inputDeviceListener = {
+ QWaylandInputDevice::inputHandleMotion,
+ QWaylandInputDevice::inputHandleButton,
+ QWaylandInputDevice::inputHandleKey,
+ QWaylandInputDevice::inputHandlePointerFocus,
+ QWaylandInputDevice::inputHandleKeyboardFocus,
+};
+
+void QWaylandInputDevice::attach(QWaylandBuffer *buffer, int x, int y)
+{
+ wl_input_device_attach(mInputDevice, mTime, buffer->buffer(), x, y);
+}
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h
new file mode 100644
index 0000000..2328db8
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDINPUTDEVICE_H
+#define QWAYLANDINPUTDEVICE_H
+
+#include "qwaylandwindow.h"
+
+#include <QSocketNotifier>
+#include <QObject>
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+
+#include <wayland-client.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandWindow;
+
+class QWaylandInputDevice {
+public:
+ QWaylandInputDevice(struct wl_display *display, uint32_t id);
+ void attach(QWaylandBuffer *buffer, int x, int y);
+
+private:
+ struct wl_display *mDisplay;
+ struct wl_input_device *mInputDevice;
+ QWaylandWindow *mPointerFocus;
+ QWaylandWindow *mKeyboardFocus;
+ static const struct wl_input_device_listener inputDeviceListener;
+ Qt::MouseButtons mButtons;
+ QPoint mSurfacePos;
+ QPoint mGlobalPos;
+ struct xkb_desc *mXkb;
+ Qt::KeyboardModifiers mModifiers;
+ uint32_t mTime;
+
+ static void inputHandleMotion(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ int32_t x, int32_t y,
+ int32_t sx, int32_t sy);
+ static void inputHandleButton(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t button, uint32_t state);
+ static void inputHandleKey(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, uint32_t key, uint32_t state);
+ static void inputHandlePointerFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time, struct wl_surface *surface,
+ int32_t x, int32_t y, int32_t sx, int32_t sy);
+ static void inputHandleKeyboardFocus(void *data,
+ struct wl_input_device *input_device,
+ uint32_t time,
+ struct wl_surface *surface,
+ struct wl_array *keys);
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
new file mode 100644
index 0000000..02bc680
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** 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 config.tests 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandintegration.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandshmsurface.h"
+#include "qwaylanddrmsurface.h"
+#include "qwaylandwindow.h"
+
+#include "qfontconfigdatabase.h"
+
+#include <QtGui/QWindowSystemInterface>
+#include <QtGui/QPlatformCursor>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <QtGui/private/qpixmap_raster_p.h>
+#include <QtOpenGL/private/qpixmapdata_gl_p.h>
+
+QWaylandIntegration::QWaylandIntegration(bool useOpenGL)
+ : mFontDb(new QFontconfigDatabase())
+ , mDisplay(new QWaylandDisplay())
+ , mUseOpenGL(useOpenGL)
+{
+}
+
+QList<QPlatformScreen *>
+QWaylandIntegration::screens() const
+{
+ return mDisplay->screens();
+}
+
+QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ if (mUseOpenGL)
+ return new QGLPixmapData(type);
+ return new QRasterPixmapData(type);
+}
+
+
+
+QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QWaylandWindow(widget);
+}
+
+QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ Q_UNUSED(winId);
+
+ if (mUseOpenGL)
+ return new QWaylandDrmWindowSurface(widget);
+ return new QWaylandShmWindowSurface(widget);
+}
+
+QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h
new file mode 100644
index 0000000..d707612
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandintegration.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMINTEGRATION_WAYLAND_H
+#define QPLATFORMINTEGRATION_WAYLAND_H
+
+#include <QtGui/QPlatformIntegration>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandBuffer;
+class QWaylandDisplay;
+
+class QWaylandIntegration : public QPlatformIntegration
+{
+public:
+ QWaylandIntegration(bool useOpenGL = false);
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+private:
+ QPlatformFontDatabase *mFontDb;
+ QWaylandDisplay *mDisplay;
+ bool mUseOpenGL;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp
new file mode 100644
index 0000000..aa1083f
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandscreen.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandcursor.h"
+
+QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output, QRect geometry)
+ : QPlatformScreen()
+ , mWaylandDisplay(waylandDisplay)
+ , mOutput(output)
+ , mGeometry(geometry)
+ , mDepth(32)
+ , mFormat(QImage::Format_ARGB32_Premultiplied)
+ , mWaylandCursor(new QWaylandCursor(this))
+{
+}
+
+QWaylandScreen::~QWaylandScreen()
+{
+ delete mWaylandCursor;
+}
+
+QWaylandDisplay * QWaylandScreen::display() const
+{
+ return mWaylandDisplay;
+}
+
+QRect QWaylandScreen::geometry() const
+{
+ return mGeometry;
+}
+
+int QWaylandScreen::depth() const
+{
+ return mDepth;
+}
+
+QImage::Format QWaylandScreen::format() const
+{
+ return mFormat;
+}
+
+QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget)
+{
+ QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget);
+ return static_cast<QWaylandScreen *>(platformScreen);
+}
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h
new file mode 100644
index 0000000..368859f
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandscreen.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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$
+** 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDSCREEN_H
+#define QWAYLANDSCREEN_H
+
+#include <QtGui/QPlatformScreen>
+
+class QWaylandDisplay;
+class QWaylandCursor;
+
+class QWaylandScreen : public QPlatformScreen
+{
+public:
+ QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output *output, QRect geometry);
+ ~QWaylandScreen();
+
+ QWaylandDisplay *display() const;
+
+ QRect geometry() const;
+ int depth() const;
+ QImage::Format format() const;
+
+ static QWaylandScreen *waylandScreenFromWidget(QWidget *widget);
+
+private:
+ QWaylandDisplay *mWaylandDisplay;
+ struct wl_output *mOutput;
+ QRect mGeometry;
+ int mDepth;
+ QImage::Format mFormat;
+ QSize mPhysicalSize;
+ QWaylandCursor *mWaylandCursor;
+};
+
+#endif // QWAYLANDSCREEN_H
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
new file mode 100644
index 0000000..83bb993
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qwaylandshmsurface.h"
+
+#include <QtCore/qdebug.h>
+#include <QtGui/private/qapplication_p.h>
+
+#include "qwaylanddisplay.h"
+#include "qwaylandwindow.h"
+#include "qwaylandscreen.h"
+
+#include <wayland-client.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+QT_BEGIN_NAMESPACE
+
+QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+ const QSize &size, QImage::Format format)
+{
+ int stride = size.width() * 4;
+ int alloc = stride * size.height();
+ char filename[] = "/tmp/wayland-shm-XXXXXX";
+ int fd = mkstemp(filename);
+ if (fd < 0)
+ qWarning("open %s failed: %s", filename, strerror(errno));
+ if (ftruncate(fd, alloc) < 0) {
+ qWarning("ftruncate failed: %s", strerror(errno));
+ close(fd);
+ return;
+ }
+ uchar *data = (uchar *)
+ mmap(NULL, alloc, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ unlink(filename);
+
+ if (data == (uchar *) MAP_FAILED) {
+ qWarning("mmap /dev/zero failed: %s", strerror(errno));
+ close(fd);
+ return;
+ }
+
+ mImage = QImage(data, size.width(), size.height(), stride, format);
+ mBuffer = display->createShmBuffer(fd, size.width(), size.height(),
+ stride, display->argbVisual());
+ close(fd);
+}
+
+QWaylandShmBuffer::~QWaylandShmBuffer(void)
+{
+ munmap((void *) mImage.constBits(), mImage.byteCount());
+ wl_buffer_destroy(mBuffer);
+}
+
+QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window)
+ : QWindowSurface(window)
+ , mBuffer(0)
+ , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+{
+}
+
+QWaylandShmWindowSurface::~QWaylandShmWindowSurface()
+{
+}
+
+QPaintDevice *QWaylandShmWindowSurface::paintDevice()
+{
+ return mBuffer->image();
+}
+
+void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(offset);
+ QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow();
+ QVector<QRect> rects = region.rects();
+ const QRect *r;
+ int i;
+
+ for (i = 0; i < rects.size(); i++) {
+ r = &rects.at(i);
+ wl_surface_damage(ww->surface(),
+ r->x(), r->y(), r->width(), r->height());
+ }
+}
+
+void QWaylandShmWindowSurface::resize(const QSize &size)
+{
+ QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow();
+ QWindowSurface::resize(size);
+ QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
+
+ if (mBuffer != NULL && mBuffer->size() == size)
+ return;
+
+ if (mBuffer != NULL)
+ delete mBuffer;
+
+ mBuffer = new QWaylandShmBuffer(mDisplay, size, format);
+
+ ww->attach(mBuffer);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h
new file mode 100644
index 0000000..266b290
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSURFACE_WAYLAND_H
+#define QWINDOWSURFACE_WAYLAND_H
+
+#include "qwaylandbuffer.h"
+#include <QtGui/private/qwindowsurface_p.h>
+
+#include <QtGui/QPlatformWindow>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandDisplay;
+
+class QWaylandShmBuffer : public QWaylandBuffer {
+public:
+ QWaylandShmBuffer(QWaylandDisplay *display,
+ const QSize &size, QImage::Format format);
+ ~QWaylandShmBuffer();
+ QSize size() const { return mImage.size(); }
+ QImage *image() { return &mImage; }
+private:
+ QImage mImage;
+};
+
+class QWaylandShmWindowSurface : public QWindowSurface
+{
+public:
+ QWaylandShmWindowSurface(QWidget *window);
+ ~QWaylandShmWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+
+private:
+ QWaylandShmBuffer *mBuffer;
+ QWaylandDisplay *mDisplay;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
new file mode 100644
index 0000000..a28bdfe
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** 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 config.tests 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandwindow.h"
+
+#include "qwaylanddisplay.h"
+#include "qwaylandscreen.h"
+#include "qwaylandglcontext.h"
+#include "qwaylandbuffer.h"
+
+#include "qwaylanddrmsurface.h"
+
+#include <QtGui/QWidget>
+#include <QtGui/QWindowSystemInterface>
+
+#include <QDebug>
+
+QWaylandWindow::QWaylandWindow(QWidget *window)
+ : QPlatformWindow(window)
+ , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mGLContext(0)
+ , mBuffer(0)
+{
+ static WId id = 1;
+ mWindowId = id++;
+
+ mSurface = mDisplay->createSurface();
+}
+
+QWaylandWindow::~QWaylandWindow()
+{
+ if (mGLContext)
+ delete mGLContext;
+}
+
+WId QWaylandWindow::winId() const
+{
+ return mWindowId;
+}
+
+void QWaylandWindow::setParent(const QPlatformWindow *parent)
+{
+ QWaylandWindow *wParent = (QWaylandWindow *)parent;
+
+ mParentWindow = wParent;
+}
+
+void QWaylandWindow::setVisible(bool visible)
+{
+ if (visible) {
+ wl_surface_set_user_data(mSurface, this);
+ wl_surface_map_toplevel(mSurface);
+ } else {
+ wl_surface_destroy(mSurface);
+ mSurface = NULL;
+ }
+}
+
+void QWaylandWindow::attach(QWaylandBuffer *buffer)
+{
+ if (mSurface) {
+ wl_surface_attach(mSurface, buffer->buffer(),0,0);
+ }
+}
+
+void QWaylandWindow::configure(uint32_t time, uint32_t edges,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ Q_UNUSED(time);
+ Q_UNUSED(edges);
+ QRect geometry = QRect(x, y, width, height);
+
+ QWindowSystemInterface::handleGeometryChange(widget(), geometry);
+}
+
+QPlatformGLContext *QWaylandWindow::glContext() const
+{
+ if (!mGLContext) {
+ QWaylandWindow *that = const_cast<QWaylandWindow *>(this);
+ that->mGLContext = new QWaylandGLContext(mDisplay, widget()->platformWindowFormat());
+ }
+
+ return mGLContext;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h
new file mode 100644
index 0000000..8b047d7
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandwindow.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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 config.tests 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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDWINDOW_H
+#define QWAYLANDWINDOW_H
+
+#include <QtGui/QPlatformWindow>
+
+#include <stdint.h>
+
+class QWaylandDisplay;
+class QWaylandBuffer;
+
+class QWaylandWindow : public QPlatformWindow
+{
+public:
+ QWaylandWindow(QWidget *window);
+ ~QWaylandWindow();
+ struct wl_surface *surface() { return mSurface; }
+
+ void setVisible(bool visible);
+ void configure(uint32_t time, uint32_t edges,
+ int32_t x, int32_t y, int32_t width, int32_t height);
+ WId winId() const;
+ void setParent(const QPlatformWindow *parent);
+ QPlatformGLContext *glContext() const;
+ void attach(QWaylandBuffer *buffer);
+ QWaylandBuffer *getBuffer(void) { return mBuffer; }
+ QWaylandWindow *getParentWindow(void) { return mParentWindow; }
+
+private:
+ struct wl_surface *mSurface;
+ QWaylandDisplay *mDisplay;
+ QPlatformGLContext *mGLContext;
+ WId mWindowId;
+
+ QWaylandBuffer *mBuffer;
+ QWaylandWindow *mParentWindow;
+};
+
+
+#endif // QWAYLANDWINDOW_H
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
new file mode 100644
index 0000000..8ba1408
--- /dev/null
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -0,0 +1,39 @@
+TARGET = qwayland
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = main.cpp \
+ qwaylandintegration.cpp \
+ qwaylandshmsurface.cpp \
+ qwaylanddrmsurface.cpp \
+ qwaylandinputdevice.cpp \
+ qwaylandglcontext.cpp \
+ qwaylandcursor.cpp \
+ qwaylanddisplay.cpp \
+ qwaylandwindow.cpp \
+ qwaylandscreen.cpp
+
+HEADERS = qwaylandintegration.h \
+ qwaylandcursor.h \
+ qwaylanddisplay.h \
+ qwaylandwindow.h \
+ qwaylandscreen.h \
+ qwaylandglcontext.h \
+ qwaylandshmsurface.h \
+ qwaylanddrmsurface.h \
+ qwaylandbuffer.h
+
+contains(QT_CONFIG, opengl) {
+ QT += opengl
+}
+LIBS += -lwayland-client -lxkbcommon -lEGL
+unix {
+ CONFIG += link_pkgconfig
+ PKGCONFIG += libdrm
+}
+
+include (../fontdatabases/fontconfig/fontconfig.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target