summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-03-21 08:46:34 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-03-21 08:46:34 (GMT)
commita3c66f6898c560820ff5768159e4af1323219161 (patch)
tree143fa35cd328a2d9fb4690d703050d01eb407bbb /src
parent51c2b10379b0bbed5804f0f8e2eca82e5bb4d0bf (diff)
parent86ceda033eda6bd615134f71b9850081a0c808c9 (diff)
downloadQt-a3c66f6898c560820ff5768159e4af1323219161.zip
Qt-a3c66f6898c560820ff5768159e4af1323219161.tar.gz
Qt-a3c66f6898c560820ff5768159e4af1323219161.tar.bz2
Merge remote branch 'qt/master' into staging-master
Conflicts: src/gui/image/qpnghandler.cpp src/opengl/qwindowsurface_gl.cpp
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h3
-rw-r--r--src/corelib/corelib.pro13
-rw-r--r--src/corelib/global/global.pri4
-rw-r--r--src/corelib/global/qconfig-nacl.h (renamed from src/corelib/global/qconfig-minimal-system-dependencies.h)0
-rw-r--r--src/corelib/global/qfeatures.h5
-rw-r--r--src/corelib/global/qfeatures.txt10
-rw-r--r--src/corelib/global/qglobal.h6
-rw-r--r--src/corelib/io/qdiriterator.cpp10
-rw-r--r--src/corelib/io/qfilesystemiterator_p.h5
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp4
-rw-r--r--src/corelib/io/qprocess.cpp4
-rw-r--r--src/corelib/io/qsettings.cpp2
-rw-r--r--src/corelib/io/qtextstream.cpp1
-rw-r--r--src/corelib/kernel/kernel.pri7
-rw-r--r--src/corelib/kernel/qfunctions_nacl.cpp (renamed from src/corelib/global/qnaclunimplemented.cpp)2
-rw-r--r--src/corelib/kernel/qfunctions_nacl.h (renamed from src/corelib/global/qnaclunimplemented.h)2
-rw-r--r--src/corelib/kernel/qfunctions_p.h2
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp18
-rw-r--r--src/corelib/tools/qbytearray.cpp35
-rw-r--r--src/corelib/tools/qstringbuilder.cpp4
-rw-r--r--src/corelib/tools/qstringbuilder.h5
-rw-r--r--src/declarative/declarative.pro2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp17
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp6
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp4
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp63
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp2
-rw-r--r--src/declarative/util/qdeclarativeview.cpp7
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h3
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h6
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp17
-rw-r--r--src/gui/image/qpixmap.cpp28
-rw-r--r--src/gui/image/qpixmap_s60.cpp29
-rw-r--r--src/gui/image/qpnghandler.cpp2
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp3
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication_qpa.cpp11
-rw-r--r--src/gui/kernel/qclipboard_win.cpp15
-rw-r--r--src/gui/kernel/qdesktopwidget_s60.cpp14
-rw-r--r--src/gui/kernel/qevent.cpp1
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa.cpp1
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.cpp4
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.h3
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp20
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h12
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.cpp53
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.h65
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/kernel/qwidget_mac.mm6
-rw-r--r--src/gui/kernel/qwidget_x11.cpp10
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp30
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h11
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h12
-rw-r--r--src/gui/painting/painting.pri12
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp5
-rw-r--r--src/gui/painting/qpainterpath.cpp8
-rw-r--r--src/gui/styles/qmacstyle_mac.mm2
-rw-r--r--src/gui/styles/qs60style.cpp41
-rw-r--r--src/gui/styles/qs60style_p.h6
-rw-r--r--src/gui/styles/qs60style_s60.cpp16
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.cpp2
-rw-r--r--src/gui/text/qtextlayout.cpp47
-rw-r--r--src/gui/util/qscroller_mac.mm6
-rw-r--r--src/gui/util/qsystemtrayicon_win.cpp1
-rw-r--r--src/gui/widgets/qsplashscreen.cpp4
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp39
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h2
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp88
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h3
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp5
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp7
-rw-r--r--src/network/socket/qabstractsocket.cpp2
-rw-r--r--src/network/ssl/qssl.cpp7
-rw-r--r--src/network/ssl/qssl.h4
-rw-r--r--src/network/ssl/qsslconfiguration.cpp4
-rw-r--r--src/network/ssl/qsslconfiguration_p.h2
-rw-r--r--src/network/ssl/qsslsocket.cpp32
-rw-r--r--src/network/ssl/qsslsocket.h3
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp45
-rw-r--r--src/network/ssl/qsslsocket_openssl_p.h4
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp14
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols_p.h4
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager_p.h2
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadersource_p.h28
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp28
-rw-r--r--src/opengl/opengl.pro9
-rw-r--r--src/opengl/qgl.cpp22
-rw-r--r--src/opengl/qgl.h1
-rw-r--r--src/opengl/qgl_egl.cpp27
-rw-r--r--src/opengl/qgl_qpa.cpp4
-rw-r--r--src/opengl/qgl_symbian.cpp1
-rw-r--r--src/opengl/qgltexturepool.cpp241
-rw-r--r--src/opengl/qgltexturepool_p.h147
-rw-r--r--src/opengl/qgraphicssystem_gl.cpp11
-rw-r--r--src/opengl/qgraphicssystem_gl_p.h4
-rw-r--r--src/opengl/qpixmapdata_gl_p.h42
-rw-r--r--src/opengl/qpixmapdata_poolgl.cpp902
-rw-r--r--src/opengl/qwindowsurface_gl.cpp83
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp207
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h18
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp2
-rw-r--r--src/plugins/platforms/cocoa/main.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaautoreleasepool.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventloopintegration.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowsurface.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindowsurface.mm4
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h2
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm2
-rw-r--r--src/plugins/platforms/directfb/main.cpp2
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.cpp18
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.h6
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp5
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.h2
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp (renamed from src/plugins/platforms/testlite/qtestliteeglintegration.cpp)8
-rw-r--r--src/plugins/platforms/eglconvenience/qxlibeglintegration.h (renamed from src/plugins/platforms/testlite/qtestliteeglintegration.h)7
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp8
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h1
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/basicunix.pri6
-rw-r--r--src/plugins/platforms/linuxfb/main.cpp2
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp11
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.h4
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp8
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.h2
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.cpp9
-rw-r--r--src/plugins/platforms/openkode/qopenkodeintegration.h2
-rw-r--r--src/plugins/platforms/openvglite/main.cpp2
-rw-r--r--src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp2
-rw-r--r--src/plugins/platforms/openvglite/qgraphicssystem_vglite.h2
-rw-r--r--src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp4
-rw-r--r--src/plugins/platforms/openvglite/qwindowsurface_vglite.h2
-rw-r--r--src/plugins/platforms/qvfb/main.cpp2
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.cpp2
-rw-r--r--src/plugins/platforms/qvfb/qvfbintegration.h2
-rw-r--r--src/plugins/platforms/qvfb/qvfbwindowsurface.cpp4
-rw-r--r--src/plugins/platforms/qvfb/qvfbwindowsurface.h4
-rw-r--r--src/plugins/platforms/uikit/README45
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/main.mm74
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qml/main.qml112
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp110
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp196
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h80
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist28
-rwxr-xr-xsrc/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj463
-rw-r--r--src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch8
-rw-r--r--src/plugins/platforms/uikit/main.mm74
-rw-r--r--src/plugins/platforms/uikit/quikiteventloop.h68
-rw-r--r--src/plugins/platforms/uikit/quikiteventloop.mm160
-rw-r--r--src/plugins/platforms/uikit/quikitintegration.h72
-rw-r--r--src/plugins/platforms/uikit/quikitintegration.mm104
-rw-r--r--src/plugins/platforms/uikit/quikitscreen.h75
-rw-r--r--src/plugins/platforms/uikit/quikitscreen.mm81
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.h70
-rw-r--r--src/plugins/platforms/uikit/quikitwindow.mm89
-rw-r--r--src/plugins/platforms/uikit/quikitwindowsurface.h83
-rw-r--r--src/plugins/platforms/uikit/quikitwindowsurface.mm242
-rw-r--r--src/plugins/platforms/uikit/uikit.pro23
-rw-r--r--src/plugins/platforms/vnc/main.cpp2
-rw-r--r--src/plugins/platforms/vnc/qvnccursor.cpp4
-rw-r--r--src/plugins/platforms/vnc/qvnccursor.h4
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.cpp11
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.h3
-rw-r--r--src/plugins/platforms/vnc/qvncserver.cpp2
-rw-r--r--src/plugins/platforms/vnc/qvncserver.h2
-rw-r--r--src/plugins/platforms/wayland/main.cpp2
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.cpp7
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp134
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h26
-rw-r--r--src/plugins/platforms/wayland/qwaylanddrmsurface.cpp258
-rw-r--r--src/plugins/platforms/wayland/qwaylanddrmsurface.h70
-rw-r--r--src/plugins/platforms/wayland/qwaylandeglwindow.cpp113
-rw-r--r--src/plugins/platforms/wayland/qwaylandeglwindow.h68
-rw-r--r--src/plugins/platforms/wayland/qwaylandglcontext.cpp70
-rw-r--r--src/plugins/platforms/wayland/qwaylandglcontext.h17
-rw-r--r--src/plugins/platforms/wayland/qwaylandinclude.h63
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp32
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp32
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h3
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.cpp19
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.h3
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.cpp43
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.h8
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.cpp89
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.h63
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp37
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h25
-rw-r--r--src/plugins/platforms/wayland/wayland.pro57
-rw-r--r--src/plugins/platforms/xcb/README2
-rw-r--r--src/plugins/platforms/xcb/main.cpp72
-rw-r--r--src/plugins/platforms/xcb/qdri2context.cpp271
-rw-r--r--src/plugins/platforms/xcb/qdri2context.h77
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp360
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h87
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp557
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h294
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp142
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h82
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp967
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h82
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp185
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h75
-rw-r--r--src/plugins/platforms/xcb/qxcbobject.h62
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp99
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h74
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp588
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h98
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.cpp220
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.h70
-rw-r--r--src/plugins/platforms/xcb/xcb.pro69
-rw-r--r--src/plugins/platforms/xlib/main.cpp (renamed from src/plugins/platforms/testlite/main.cpp)24
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.cpp (renamed from src/plugins/platforms/testlite/qglxintegration.cpp)45
-rw-r--r--src/plugins/platforms/xlib/qglxintegration.h (renamed from src/plugins/platforms/testlite/qglxintegration.h)16
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.cpp (renamed from src/plugins/platforms/testlite/qtestliteclipboard.cpp)177
-rw-r--r--src/plugins/platforms/xlib/qxlibclipboard.h (renamed from src/plugins/platforms/testlite/qtestliteclipboard.h)16
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.cpp (renamed from src/plugins/platforms/testlite/qtestlitecursor.cpp)65
-rw-r--r--src/plugins/platforms/xlib/qxlibcursor.h (renamed from src/plugins/platforms/testlite/qtestlitecursor.h)12
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.cpp78
-rw-r--r--src/plugins/platforms/xlib/qxlibdisplay.h63
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.cpp (renamed from src/plugins/platforms/testlite/qtestliteintegration.cpp)51
-rw-r--r--src/plugins/platforms/xlib/qxlibintegration.h (renamed from src/plugins/platforms/testlite/qtestliteintegration.h)12
-rw-r--r--src/plugins/platforms/xlib/qxlibkeyboard.cpp (renamed from src/plugins/platforms/testlite/qtestlitekeyboard.cpp)25
-rw-r--r--src/plugins/platforms/xlib/qxlibkeyboard.h (renamed from src/plugins/platforms/testlite/qtestlitekeyboard.h)10
-rw-r--r--src/plugins/platforms/xlib/qxlibmime.cpp (renamed from src/plugins/platforms/testlite/qtestlitemime.cpp)74
-rw-r--r--src/plugins/platforms/xlib/qxlibmime.h (renamed from src/plugins/platforms/testlite/qtestlitemime.h)12
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.cpp (renamed from src/plugins/platforms/testlite/qtestlitescreen.cpp)125
-rw-r--r--src/plugins/platforms/xlib/qxlibscreen.h (renamed from src/plugins/platforms/testlite/qtestlitescreen.h)38
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.cpp (renamed from src/plugins/platforms/testlite/qtestlitestaticinfo.cpp)57
-rw-r--r--src/plugins/platforms/xlib/qxlibstatic.h (renamed from src/plugins/platforms/testlite/qtestlitestaticinfo.h)4
-rw-r--r--src/plugins/platforms/xlib/qxlibwindow.cpp (renamed from src/plugins/platforms/testlite/qtestlitewindow.cpp)299
-rw-r--r--src/plugins/platforms/xlib/qxlibwindow.h (renamed from src/plugins/platforms/testlite/qtestlitewindow.h)23
-rw-r--r--src/plugins/platforms/xlib/qxlibwindowsurface.cpp (renamed from src/plugins/platforms/testlite/qtestlitewindowsurface.cpp)60
-rw-r--r--src/plugins/platforms/xlib/qxlibwindowsurface.h (renamed from src/plugins/platforms/testlite/qtestlitewindowsurface.h)24
-rw-r--r--src/plugins/platforms/xlib/xlib.pro (renamed from src/plugins/platforms/testlite/testlite.pro)44
247 files changed, 11028 insertions, 1394 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
index 5abe9a1..cb4a963 100644
--- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
+++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
@@ -635,6 +635,9 @@
#define ENABLE_REPAINT_THROTTLING 1
#define HAVE_READLINE 1
#define WTF_PLATFORM_CF 1
+#endif
+
+#if OS(IPHONE_OS) && !PLATFORM(QT)
#define WTF_USE_PTHREADS 1
#define HAVE_PTHREAD_RWLOCK 1
#endif
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index f03550d..58d2c7b 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -20,14 +20,13 @@ include(statemachine/statemachine.pri)
include(xml/xml.pri)
!qpa:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
-qpa:mac|darwin {
- contains(QT_CONFIG, coreservices) {
- LIBS_PRIVATE += -framework CoreServices
- } else {
- LIBS_PRIVATE += -framework CoreFoundation
- }
+qpa {
+ contains(QT_CONFIG, coreservices) {
+ LIBS_PRIVATE += -framework CoreServices
+ }
+} else:mac|darwin {
+ LIBS_PRIVATE += -framework CoreFoundation
}
-
mac:lib_bundle:DEFINES += QT_NO_DEBUG_PLUGIN_CHECK
win32:DEFINES-=QT_NO_CAST_TO_ASCII
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 83caa96..d80706a 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -13,10 +13,6 @@ SOURCES += \
global/qmalloc.cpp \
global/qnumeric.cpp
-nacl {
- SOURCES += global/qnaclunimplemented.cpp
-}
-
# qlibraryinfo.cpp includes qconfig.cpp
INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global
diff --git a/src/corelib/global/qconfig-minimal-system-dependencies.h b/src/corelib/global/qconfig-nacl.h
index a44391c..a44391c 100644
--- a/src/corelib/global/qconfig-minimal-system-dependencies.h
+++ b/src/corelib/global/qconfig-nacl.h
diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h
index b26563a..604d08a 100644
--- a/src/corelib/global/qfeatures.h
+++ b/src/corelib/global/qfeatures.h
@@ -79,6 +79,9 @@
// Effects
//#define QT_NO_EFFECTS
+// QFileSystemIterator
+//#define QT_NO_FILESYSTEMITERATOR
+
// QFileSystemWatcher
//#define QT_NO_FILESYSTEMWATCHER
@@ -579,7 +582,7 @@
#endif
// Hyper Text Transfer Protocol
-#if !defined(QT_NO_HTTP) && (defined(QT_NO_HOSTINFO) || defined(QT_NO_NETWORKPROXY))
+#if !defined(QT_NO_HTTP) && defined(QT_NO_HOSTINFO)
#define QT_NO_HTTP
#endif
diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
index f07fbd5..6b861d4 100644
--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -242,6 +242,14 @@ Requires:
Name: QFileSystemWatcher
SeeAlso: ???
+Feature: FILESYSTEMITERATOR
+Description: Provides fast file-system iteration.
+for modications.
+Section: File I/O
+Requires:
+Name: QFileSystemIterator
+SeeAlso: ???
+
# Widgets
Feature: TREEWIDGET
@@ -1050,7 +1058,7 @@ SeeAlso: ???
Feature: HTTP
Description: Supports HTTP file access.
Section: Networking
-Requires: HOSTINFO NETWORKPROXY
+Requires: HOSTINFO
Name: Hyper Text Transfer Protocol
SeeAlso: ???
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index cf44b49..06e19dc 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1685,7 +1685,7 @@ inline void qUnused(T &x) { (void)x; }
#endif
#ifndef qPrintable
-# define qPrintable(string) (string).toLocal8Bit().constData()
+# define qPrintable(string) QString(string).toLocal8Bit().constData()
#endif
Q_CORE_EXPORT void qDebug(const char *, ...) /* print debug message */
@@ -2722,10 +2722,6 @@ QT_LICENSED_MODULE(DBus)
# define QT_NO_PROCESS
#endif
-#ifdef Q_OS_NACL
-#include <QtCore/qnaclunimplemented.h>
-#endif
-
#if defined (__ELF__)
# if defined (Q_OS_LINUX) || defined (Q_OS_SOLARIS) || defined (Q_OS_FREEBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_IRIX)
# define Q_OF_ELF
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index d293791..c7e56bd 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -142,7 +142,9 @@ public:
#endif
QDirIteratorPrivateIteratorStack<QAbstractFileEngineIterator> fileEngineIterators;
+#ifndef QT_NO_FILESYSTEMITERATOR
QDirIteratorPrivateIteratorStack<QFileSystemIterator> nativeIterators;
+#endif
QFileInfo currentFileInfo;
QFileInfo nextFileInfo;
@@ -204,9 +206,11 @@ void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
// No iterator; no entry list.
}
} else {
+#ifndef QT_NO_FILESYSTEMITERATOR
QFileSystemIterator *it = new QFileSystemIterator(fileInfo.d_ptr->fileEntry,
filters, nameFilters, iteratorFlags);
nativeIterators << it;
+#endif
}
}
@@ -244,6 +248,7 @@ void QDirIteratorPrivate::advance()
delete it;
}
} else {
+#ifndef QT_NO_FILESYSTEMITERATOR
QFileSystemEntry nextEntry;
QFileSystemMetaData nextMetaData;
@@ -260,6 +265,7 @@ void QDirIteratorPrivate::advance()
nativeIterators.pop();
delete it;
}
+#endif
}
currentFileInfo = nextFileInfo;
@@ -500,7 +506,11 @@ bool QDirIterator::hasNext() const
if (d->engine)
return !d->fileEngineIterators.isEmpty();
else
+#ifndef QT_NO_FILESYSTEMITERATOR
return !d->nativeIterators.isEmpty();
+#else
+ return false;
+#endif
}
/*!
diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h
index 2dc4a9f..fb8bfe6 100644
--- a/src/corelib/io/qfilesystemiterator_p.h
+++ b/src/corelib/io/qfilesystemiterator_p.h
@@ -54,6 +54,9 @@
//
#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_FILESYSTEMITERATOR
+
#include <QtCore/qdir.h>
#include <QtCore/qdiriterator.h>
#include <QtCore/qstringlist.h>
@@ -112,4 +115,6 @@ private:
QT_END_NAMESPACE
+#endif // QT_NO_FILESYSTEMITERATOR
+
#endif // include guard
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 3efdd9e..3d6012b 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -42,6 +42,8 @@
#include "qplatformdefs.h"
#include "qfilesystemiterator_p.h"
+#ifndef QT_NO_FILESYSTEMITERATOR
+
#include <stdlib.h>
#include <errno.h>
@@ -111,3 +113,5 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
}
QT_END_NAMESPACE
+
+#endif // QT_NO_FILESYSTEMITERATOR
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index a44c1e1..e11cef9 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -2232,10 +2232,10 @@ bool QProcess::startDetached(const QString &program)
}
QT_BEGIN_INCLUDE_NAMESPACE
-#ifdef Q_OS_MAC
+#if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-#elif defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
+#elif defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) || (defined(Q_OS_MAC) && defined(QT_NO_CORESERVICES))
static char *qt_empty_environ[] = { 0 };
#define environ qt_empty_environ
#elif !defined(Q_OS_WIN)
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 92f7636..b084ca5 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1004,7 +1004,7 @@ void QConfFileSettingsPrivate::initFormat()
readFunc = 0;
writeFunc = 0;
#if defined(Q_OS_MAC)
- caseSensitivity = (format == QSettings::NativeFormat) ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ caseSensitivity = (format == QSettings::NativeFormat) ? Qt::CaseSensitive : IniCaseSensitivity;
#else
caseSensitivity = IniCaseSensitivity;
#endif
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index b630502..a5837cb 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -1264,6 +1264,7 @@ qint64 QTextStream::pos() const
return qint64(-1);
}
thatd->readBufferOffset = oldReadBufferOffset;
+ thatd->readConverterSavedStateOffset = 0;
// Return the device position.
return d->device->pos();
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index c3a6721..a3628b1 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -90,6 +90,13 @@ mac:!nacl {
kernel/qcore_mac.cpp
}
+nacl {
+ SOURCES += \
+ kernel/qfunctions_nacl.cpp
+ HEADERS += \
+ kernel/qfunctions_nacl.h
+}
+
unix:!symbian {
SOURCES += \
kernel/qcore_unix.cpp \
diff --git a/src/corelib/global/qnaclunimplemented.cpp b/src/corelib/kernel/qfunctions_nacl.cpp
index 5116d80..f3d85ef 100644
--- a/src/corelib/global/qnaclunimplemented.cpp
+++ b/src/corelib/kernel/qfunctions_nacl.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qnaclunimplemented.h"
+#include "qfunctions_nacl.h"
#include <pthread.h>
#include <qglobal.h>
diff --git a/src/corelib/global/qnaclunimplemented.h b/src/corelib/kernel/qfunctions_nacl.h
index 09c6c49..db36ad5 100644
--- a/src/corelib/global/qnaclunimplemented.h
+++ b/src/corelib/kernel/qfunctions_nacl.h
@@ -44,6 +44,8 @@
#ifdef Q_OS_NACL
+#include <sys/types.h>
+
// pthread
#include <pthread.h>
#define PTHREAD_CANCEL_DISABLE 1
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 3d41c0c..d27fec3 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -59,6 +59,8 @@
# include "QtCore/qfunctions_wince.h"
#elif defined(Q_OS_VXWORKS)
# include "QtCore/qfunctions_vxworks.h"
+#elif defined(Q_OS_NACL)
+# include "QtCore/qfunctions_nacl.h"
#endif
#ifdef Q_CC_RVCT
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index 466350e..e32729a 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -56,9 +56,13 @@
#include <string.h>
#endif
+#if defined(Q_OS_VXWORKS) || defined (Q_OS_NACL)
+#define QT_NO_DYNAMIC_LIBRARY
+#endif
+
QT_BEGIN_NAMESPACE
-#if !defined(QT_HPUX_LD) && !defined(Q_OS_VXWORKS)
+#if !defined(QT_HPUX_LD) && !defined(QT_NO_DYNAMIC_LIBRARY)
QT_BEGIN_INCLUDE_NAMESPACE
#include <dlfcn.h>
QT_END_INCLUDE_NAMESPACE
@@ -66,8 +70,8 @@ QT_END_INCLUDE_NAMESPACE
static QString qdlerror()
{
-#if defined(Q_OS_VXWORKS)
- const char *err = "VxWorks does not support dynamic libraries.";
+#if defined(QT_NO_DYNAMIC_LIBRARY)
+ const char *err = "This platform does not support dynamic libraries.";
#elif !defined(QT_HPUX_LD)
const char *err = dlerror();
#else
@@ -79,7 +83,7 @@ static QString qdlerror()
bool QLibraryPrivate::load_sys()
{
QString attempt;
-#if !defined(Q_OS_VXWORKS)
+#if !defined(QT_NO_DYNAMIC_LIBRARY)
QFileInfo fi(fileName);
#if defined(Q_OS_SYMBIAN)
@@ -235,7 +239,7 @@ bool QLibraryPrivate::load_sys()
}
}
#endif
-#endif // Q_OS_VXWORKS
+#endif // QT_NO_DYNAMIC_LIBRARY
if (!pHnd) {
errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName).arg(qdlerror());
}
@@ -248,7 +252,7 @@ bool QLibraryPrivate::load_sys()
bool QLibraryPrivate::unload_sys()
{
-#if !defined(Q_OS_VXWORKS)
+#if !defined(QT_NO_DYNAMIC_LIBRARY)
# if defined(QT_HPUX_LD)
if (shl_unload((shl_t)pHnd)) {
# else
@@ -282,7 +286,7 @@ void* QLibraryPrivate::resolve_sys(const char* symbol)
void* address = 0;
if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
address = 0;
-#elif defined(Q_OS_VXWORKS)
+#elif defined (QT_NO_DYNAMIC_LIBRARY)
void *address = 0;
#else
void* address = dlsym(pHnd, symbol);
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index b281c1b..4799abd 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -687,12 +687,12 @@ QByteArray::Data QByteArray::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
values. To set all the bytes to a particular value, call fill().
To obtain a pointer to the actual character data, call data() or
- constData(). These functions return a pointer to the beginning of
- the data. The pointer is guaranteed to remain valid until a
- non-const function is called on the QByteArray. It is also
- guaranteed that the data ends with a '\\0' byte. This '\\0' byte
- is automatically provided by QByteArray and is not counted in
- size().
+ constData(). These functions return a pointer to the beginning of the data.
+ The pointer is guaranteed to remain valid until a non-const function is
+ called on the QByteArray. It is also guaranteed that the data ends with a
+ '\\0' byte unless the QByteArray was created from a \l{fromRawData()}{raw
+ data}. This '\\0' byte is automatically provided by QByteArray and is not
+ counted in size().
QByteArray provides the following basic functions for modifying
the byte data: append(), prepend(), insert(), replace(), and
@@ -925,11 +925,13 @@ QByteArray &QByteArray::operator=(const char *str)
Returns the number of bytes in this byte array.
- The last byte in the byte array is at position size() - 1. In
- addition, QByteArray ensures that the byte at position size() is
- always '\\0', so that you can use the return value of data() and
- constData() as arguments to functions that expect '\\0'-terminated
- strings.
+ The last byte in the byte array is at position size() - 1. In addition,
+ QByteArray ensures that the byte at position size() is always '\\0', so
+ that you can use the return value of data() and constData() as arguments to
+ functions that expect '\\0'-terminated strings. If the QByteArray object
+ was created from a \l{fromRawData()}{raw data} that didn't include the
+ trailing null-termination character then QByteArray doesn't add it
+ automaticall unless the \l{deep copy} is created.
Example:
\snippet doc/src/snippets/code/src_corelib_tools_qbytearray.cpp 6
@@ -1060,10 +1062,11 @@ QByteArray &QByteArray::operator=(const char *str)
/*! \fn const char *QByteArray::constData() const
- Returns a pointer to the data stored in the byte array. The
- pointer can be used to access the bytes that compose the array.
- The data is '\\0'-terminated. The pointer remains valid as long
- as the byte array isn't reallocated or destroyed.
+ Returns a pointer to the data stored in the byte array. The pointer can be
+ used to access the bytes that compose the array. The data is
+ '\\0'-terminated unless the QByteArray object was created from raw data.
+ The pointer remains valid as long as the byte array isn't reallocated or
+ destroyed.
This function is mostly useful to pass a byte array to a function
that accepts a \c{const char *}.
@@ -1072,7 +1075,7 @@ QByteArray &QByteArray::operator=(const char *str)
but most functions that take \c{char *} arguments assume that the
data ends at the first '\\0' they encounter.
- \sa data(), operator[]()
+ \sa data(), operator[](), fromRawData()
*/
/*! \fn void QByteArray::detach()
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 53368eb..7d75de7 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -150,8 +150,8 @@ QT_BEGIN_NAMESPACE
void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out)
{
#ifndef QT_NO_TEXTCODEC
- if (QString::codecForCStrings) {
- QString tmp = QString::fromAscii(a);
+ if (QString::codecForCStrings && len) {
+ QString tmp = QString::fromAscii(a, len > 0 ? len - 1 : -1);
memcpy(out, reinterpret_cast<const char *>(tmp.constData()), sizeof(QChar) * tmp.size());
out += tmp.length();
return;
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 8d9537c..d230d67 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -270,10 +270,11 @@ template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable
{
typedef QByteArray type;
enum { ExactSize = false };
- static int size(const QByteArray &ba) { return qstrnlen(ba.constData(), ba.size()); }
+ static int size(const QByteArray &ba) { return ba.size(); }
static inline void appendTo(const QByteArray &ba, QChar *&out)
{
- QAbstractConcatenable::convertFromAscii(ba.constData(), -1, out);
+ // adding 1 because convertFromAscii expects the size including the null-termination
+ QAbstractConcatenable::convertFromAscii(ba.constData(), ba.size() + 1, out);
}
};
#endif
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 6bd314f..b74b18c 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -36,6 +36,8 @@ symbian: {
}
}
+linux-g++-maemo:DEFINES += QDECLARATIVEVIEW_NOBACKGROUND
+
DEFINES += QT_NO_OPENTYPE
INCLUDEPATH += ../3rdparty/harfbuzz/src
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 1e2b70c..bfebff6 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -1409,8 +1409,10 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsScene *s = scene();
QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
+ QGraphicsItem *grabberItem = s ? s->mouseGrabberItem() : 0;
+ bool disabledItem = grabberItem && !grabberItem->isEnabled();
bool stealThisEvent = d->stealMouse;
- if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
+ if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab() || disabledItem)) {
mouseEvent.setAccepted(false);
for (int i = 0x1; i <= 0x10; i <<= 1) {
if (event->buttons() & i) {
@@ -1457,12 +1459,12 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
break;
}
grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
- if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) {
+ if ((grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) || disabledItem) {
d->clearDelayedPress();
grabMouse();
}
- return stealThisEvent || d->delayedPressEvent;
+ return stealThisEvent || d->delayedPressEvent || disabledItem;
} else if (d->lastPosTime.isValid()) {
d->lastPosTime.invalidate();
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 5c2f781..c0cbed0 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -2834,11 +2834,9 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
if (d->currentItem) {
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex));
- } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
- d->updateCurrent(0);
}
emit currentIndexChanged();
- } else if (d->itemCount == 0 && d->currentIndex == -1) {
+ } else if (d->itemCount == 0 && (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared))) {
setCurrentIndex(0);
}
@@ -2906,6 +2904,8 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex = -1;
if (d->itemCount)
d->updateCurrent(qMin(modelIndex, d->itemCount-1));
+ else
+ emit currentIndexChanged();
}
// update visibleIndex
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 2c9bde5..ed5d5fc 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -147,8 +147,8 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
/*!
\qmlproperty enumeration Image::fillMode
- Set this property to define what happens when the image set for the item is smaller
- than the size of the item.
+ Set this property to define what happens when the source image has a different size
+ than the item.
\list
\o Image.Stretch - the image is scaled to fit
@@ -234,6 +234,9 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
\endtable
+ Note that \c clip is \c false by default which means that the element might
+ paint outside its bounding rectangle even if the fillMode is set to \c PreserveAspectCrop.
+
\sa {declarative/imageelements/image}{Image example}
*/
QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const
@@ -386,14 +389,16 @@ void QDeclarativeImage::updatePaintedGeometry()
if (d->fillMode == PreserveAspectFit) {
if (!d->pix.width() || !d->pix.height())
return;
- qreal widthScale = width() / qreal(d->pix.width());
- qreal heightScale = height() / qreal(d->pix.height());
+ qreal w = widthValid() ? width() : d->pix.width();
+ qreal widthScale = w / qreal(d->pix.width());
+ qreal h = heightValid() ? height() : d->pix.height();
+ qreal heightScale = h / qreal(d->pix.height());
if (widthScale <= heightScale) {
- d->paintedWidth = width();
+ d->paintedWidth = w;
d->paintedHeight = widthScale * qreal(d->pix.height());
} else if(heightScale < widthScale) {
d->paintedWidth = heightScale * qreal(d->pix.width());
- d->paintedHeight = height();
+ d->paintedHeight = h;
}
if (widthValid() && !heightValid()) {
setImplicitHeight(d->paintedHeight);
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index 471c87f..2de3ba0 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -130,7 +130,7 @@ QSize QDeclarativeImageBase::sourceSize() const
int width = d->sourcesize.width();
int height = d->sourcesize.height();
- return QSize(width != -1 ? width : implicitWidth(), height != -1 ? height : implicitHeight());
+ return QSize(width != -1 ? width : d->pix.width(), height != -1 ? height : d->pix.height());
}
bool QDeclarativeImageBase::cache() const
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 2c23a1b..6ae1ddc 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -3272,10 +3272,10 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
if (d->currentItem) {
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->currentItem->position() + diff);
- } else if (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared)) {
- d->updateCurrent(0);
}
emit currentIndexChanged();
+ } else if (!d->itemCount && (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared))) {
+ d->updateCurrent(0);
}
// Update the indexes of the following visible items.
for (; index < d->visibleItems.count(); ++index) {
@@ -3356,6 +3356,8 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
d->currentIndex = -1;
if (d->itemCount)
d->updateCurrent(qMin(modelIndex, d->itemCount-1));
+ else
+ emit currentIndexChanged();
}
// update visibleIndex
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 4e401e9..778b8b9 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -796,6 +796,7 @@ void QDeclarativePathView::setPreferredHighlightBegin(qreal start)
return;
d->highlightRangeStart = start;
d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ refill();
emit preferredHighlightBeginChanged();
}
@@ -812,6 +813,7 @@ void QDeclarativePathView::setPreferredHighlightEnd(qreal end)
return;
d->highlightRangeEnd = end;
d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ refill();
emit preferredHighlightEndChanged();
}
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index d962919..8f59073 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE
void QDeclarativePen::setColor(const QColor &c)
{
_color = c;
- _valid = _color.alpha() ? true : false;
+ _valid = (_color.alpha() && _width >= 1) ? true : false;
emit penChanged();
}
@@ -80,7 +80,7 @@ void QDeclarativePen::setWidth(int w)
return;
_width = w;
- _valid = (_width < 1) ? false : true;
+ _valid = (_color.alpha() && _width >= 1) ? true : false;
emit penChanged();
}
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index ad03e10..e04cfc5 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -940,7 +940,7 @@ QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptParser::extra
if (l.currentLineNo() == startLine)
return rv;
- if (pragmaValue == QLatin1String("library")) {
+ if (pragmaValue == library) {
rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
replaceWithSpace(script, startOffset, endOffset - startOffset);
} else {
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 2d551f2..781e1b8 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -127,6 +127,22 @@ void QDeclarativeVME::runDeferred(QObject *object)
run(stack, ctxt, comp, start, count, QBitField());
}
+inline bool fastHasBinding(QObject *o, int index)
+{
+ QDeclarativeData *ddata = static_cast<QDeclarativeData *>(QObjectPrivate::get(o)->declarativeData);
+
+ return ddata && (ddata->bindingBitsSize > index) &&
+ (ddata->bindingBits[index / 32] & (1 << (index % 32)));
+}
+
+static void removeBindingOnProperty(QObject *o, int index)
+{
+ QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::setBinding(o, index, -1, 0);
+ if (binding) binding->destroy();
+}
+
+#define CLEAN_PROPERTY(o, index) if (fastHasBinding(o, index)) removeBindingOnProperty(o, index)
+
QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
QDeclarativeContextData *ctxt,
QDeclarativeCompiledData *comp,
@@ -336,6 +352,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreVariant:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
+
// XXX - can be more efficient
QVariant v = QDeclarativeStringConverters::variantFromString(primitives.at(instr.storeString.value));
void *a[] = { &v, 0, &status, &flags };
@@ -347,6 +365,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreVariantInteger:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
+
QVariant v(instr.storeInteger.value);
void *a[] = { &v, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -357,6 +377,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreVariantDouble:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
+
QVariant v(instr.storeDouble.value);
void *a[] = { &v, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -367,6 +389,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreVariantBool:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
+
QVariant v(instr.storeBool.value);
void *a[] = { &v, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -377,6 +401,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreString:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
+
void *a[] = { (void *)&primitives.at(instr.storeString.value), 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
instr.storeString.propertyIndex, a);
@@ -386,6 +412,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreUrl:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeUrl.propertyIndex);
+
void *a[] = { (void *)&urls.at(instr.storeUrl.value), 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
instr.storeUrl.propertyIndex, a);
@@ -395,6 +423,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreFloat:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeFloat.propertyIndex);
+
float f = instr.storeFloat.value;
void *a[] = { &f, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -405,6 +435,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreDouble:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeDouble.propertyIndex);
+
double d = instr.storeDouble.value;
void *a[] = { &d, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -415,6 +447,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreBool:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeBool.propertyIndex);
+
void *a[] = { (void *)&instr.storeBool.value, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
instr.storeBool.propertyIndex, a);
@@ -424,6 +458,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreInteger:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeInteger.propertyIndex);
+
void *a[] = { (void *)&instr.storeInteger.value, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
instr.storeInteger.propertyIndex, a);
@@ -433,6 +469,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreColor:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeColor.propertyIndex);
+
QColor c = QColor::fromRgba(instr.storeColor.value);
void *a[] = { &c, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -443,6 +481,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreDate:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeDate.propertyIndex);
+
QDate d = QDate::fromJulianDay(instr.storeDate.value);
void *a[] = { &d, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -453,6 +493,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreTime:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeTime.propertyIndex);
+
QTime t;
t.setHMS(intData.at(instr.storeTime.valueIndex),
intData.at(instr.storeTime.valueIndex+1),
@@ -467,6 +509,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreDateTime:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeDateTime.propertyIndex);
+
QTime t;
t.setHMS(intData.at(instr.storeDateTime.valueIndex+1),
intData.at(instr.storeDateTime.valueIndex+2),
@@ -482,6 +526,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StorePoint:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
+
QPoint p = QPointF(floatData.at(instr.storeRealPair.valueIndex),
floatData.at(instr.storeRealPair.valueIndex+1)).toPoint();
void *a[] = { &p, 0, &status, &flags };
@@ -493,6 +539,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StorePointF:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
+
QPointF p(floatData.at(instr.storeRealPair.valueIndex),
floatData.at(instr.storeRealPair.valueIndex+1));
void *a[] = { &p, 0, &status, &flags };
@@ -504,6 +552,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreSize:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
+
QSize p = QSizeF(floatData.at(instr.storeRealPair.valueIndex),
floatData.at(instr.storeRealPair.valueIndex+1)).toSize();
void *a[] = { &p, 0, &status, &flags };
@@ -515,6 +565,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreSizeF:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
+
QSizeF s(floatData.at(instr.storeRealPair.valueIndex),
floatData.at(instr.storeRealPair.valueIndex+1));
void *a[] = { &s, 0, &status, &flags };
@@ -526,6 +578,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreRect:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeRect.propertyIndex);
+
QRect r = QRectF(floatData.at(instr.storeRect.valueIndex),
floatData.at(instr.storeRect.valueIndex+1),
floatData.at(instr.storeRect.valueIndex+2),
@@ -539,6 +593,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreRectF:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeRect.propertyIndex);
+
QRectF r(floatData.at(instr.storeRect.valueIndex),
floatData.at(instr.storeRect.valueIndex+1),
floatData.at(instr.storeRect.valueIndex+2),
@@ -552,6 +608,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::StoreVector3D:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeVector3D.propertyIndex);
+
QVector3D p(floatData.at(instr.storeVector3D.valueIndex),
floatData.at(instr.storeVector3D.valueIndex+1),
floatData.at(instr.storeVector3D.valueIndex+2));
@@ -565,6 +623,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
{
QObject *assignObj = stack.pop();
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
void *a[] = { (void *)&assignObj, 0, &status, &flags };
QMetaObject::metacall(target, QMetaObject::WriteProperty,
@@ -576,6 +635,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::AssignCustomType:
{
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.assignCustomType.propertyIndex);
+
QDeclarativeCompiledData::CustomTypeData data = customTypeData.at(instr.assignCustomType.valueIndex);
const QString &primitive = primitives.at(data.index);
QDeclarativeMetaType::StringConverter converter =
@@ -780,6 +841,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
{
QObject *assign = stack.pop();
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
QVariant v = QVariant::fromValue(assign);
void *a[] = { &v, 0, &status, &flags };
@@ -792,6 +854,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
{
QObject *assign = stack.pop();
QObject *target = stack.top();
+ CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
int coreIdx = instr.storeObject.propertyIndex;
QMetaProperty prop = target->metaObject()->property(coreIdx);
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 2e8ab18..db8a2ae 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -313,7 +313,7 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
QScriptContext *ctxt = QScriptDeclarativeClass::pushCleanContext(workerEngine);
QScriptValue urlContext = workerEngine->newObject();
- urlContext.setData(QScriptValue(workerEngine, fileName));
+ urlContext.setData(QScriptValue(workerEngine, url.toString()));
ctxt->pushScope(urlContext);
ctxt->pushScope(activation);
ctxt->setActivationObject(activation);
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 99c29d5..1b50a56 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -293,6 +293,13 @@ void QDeclarativeViewPrivate::init()
q->setFocusPolicy(Qt::StrongFocus);
q->scene()->setStickyFocus(true); //### needed for correct focus handling
+
+#ifdef QDECLARATIVEVIEW_NOBACKGROUND
+ q->setAttribute(Qt::WA_OpaquePaintEvent);
+ q->setAttribute(Qt::WA_NoSystemBackground);
+ q->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
+ q->viewport()->setAttribute(Qt::WA_NoSystemBackground);
+#endif
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 2bf744d..0af36ac 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -417,6 +417,11 @@
click focus to items underneath when being clicked on. This flag
allows you create a non-focusable item that can be clicked on without
changing the focus. \endomit
+
+ \omitvalue ItemStopsFocusHandling \omit Same as
+ ItemStopsClickFocusPropagation, but also suppresses focus-out. This flag
+ allows you to completely take over focus handling.
+ This flag was introduced in Qt 4.7.
*/
/*!
@@ -11557,6 +11562,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)
case QGraphicsItem::ItemStopsClickFocusPropagation:
str = "ItemStopsClickFocusPropagation";
break;
+ case QGraphicsItem::ItemStopsFocusHandling:
+ str = "ItemStopsFocusHandling";
+ break;
}
debug << str;
return debug;
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index e59a7c9..67c9cd3 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -107,7 +107,8 @@ public:
ItemIsPanel = 0x4000,
ItemIsFocusScope = 0x8000, // internal
ItemSendsScenePositionChanges = 0x10000,
- ItemStopsClickFocusPropagation = 0x20000
+ ItemStopsClickFocusPropagation = 0x20000,
+ ItemStopsFocusHandling = 0x40000
// NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
};
Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 5c82116..90ff43f 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -559,7 +559,7 @@ public:
quint32 dirtyChildrenBoundingRect : 1;
// Packed 32 bits
- quint32 flags : 18;
+ quint32 flags : 19;
quint32 paintedViewBoundingRectsNeedRepaint : 1;
quint32 dirtySceneTransform : 1;
quint32 geometryChanged : 1;
@@ -573,9 +573,9 @@ public:
quint32 sceneTransformTranslateOnly : 1;
quint32 notifyBoundingRectChanged : 1;
quint32 notifyInvalidated : 1;
- quint32 mouseSetsFocus : 1;
// New 32 bits
+ quint32 mouseSetsFocus : 1;
quint32 explicitActivate : 1;
quint32 wantsActive : 1;
quint32 holesInSiblingIndex : 1;
@@ -586,7 +586,7 @@ public:
quint32 mayHaveChildWithGraphicsEffect : 1;
quint32 isDeclarativeItem : 1;
quint32 sendParentChangeNotification : 1;
- quint32 padding : 22;
+ quint32 padding : 21;
// Optional stacking order
int globalStackingOrder;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 6ff1d38..7932a73 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -1320,8 +1320,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// Set focus on the topmost enabled item that can take focus.
bool setFocus = false;
+
foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
- if (item->isBlockedByModalPanel()) {
+ if (item->isBlockedByModalPanel()
+ || (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)) {
// Make sure we don't clear focus.
setFocus = true;
break;
@@ -1334,10 +1336,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
break;
}
}
- if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
- break;
if (item->isPanel())
break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
+ break;
}
// Check for scene modality.
@@ -5913,6 +5915,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
// Set focus on the topmost enabled item that can take focus.
bool setFocus = false;
+
foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
@@ -5926,6 +5929,11 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
break;
if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) {
+ // Make sure we don't clear focus.
+ setFocus = true;
+ break;
+ }
}
// If nobody could take focus, clear it.
@@ -5958,7 +5966,8 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
}
if (item && item->isPanel())
break;
- if (item && (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation))
+ if (item && (item->d_ptr->flags
+ & (QGraphicsItem::ItemStopsClickFocusPropagation | QGraphicsItem::ItemStopsFocusHandling)))
break;
}
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 6e13324..34804e5 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -71,6 +71,10 @@
# include "private/qpixmap_mac_p.h"
#endif
+#ifdef Q_WS_QPA
+# include "qplatformintegration_qpa.h"
+#endif
+
#if defined(Q_WS_X11)
# include "qx11info_x11.h"
# include <private/qt_x11_p.h>
@@ -98,12 +102,26 @@ static bool qt_pixmap_thread_test()
qFatal("QPixmap: Must construct a QApplication before a QPaintDevice");
return false;
}
-#ifndef Q_WS_WIN
- if (!QApplication::testAttribute(Qt::AA_X11InitThreads) && qApp->thread() != QThread::currentThread()) {
- qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread");
- return false;
- }
+
+ if (qApp->thread() != QThread::currentThread()) {
+ bool fail = false;
+#if defined (Q_WS_X11)
+ if (!QApplication::testAttribute(Qt::AA_X11InitThreads))
+ fail = true;
+#elif defined (Q_WS_QPA)
+ if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) {
+ printf("Lighthouse plugin does not support threaded pixmaps!\n");
+ fail = true;
+ }
+#else
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
+ fail = true;
#endif
+ if (fail) {
+ qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread");
+ return false;
+ }
+ }
return true;
}
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp
index fbdebf3..32d8dd7 100644
--- a/src/gui/image/qpixmap_s60.cpp
+++ b/src/gui/image/qpixmap_s60.cpp
@@ -601,6 +601,9 @@ bool QS60PixmapData::scroll(int dx, int dy, const QRect &rect)
return res;
}
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
+
int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
{
if (!cfbsBitmap)
@@ -611,28 +614,18 @@ int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
return cfbsBitmap->SizeInPixels().iWidth;
case QPaintDevice::PdmHeight:
return cfbsBitmap->SizeInPixels().iHeight;
- case QPaintDevice::PdmWidthMM: {
- TInt twips = cfbsBitmap->SizeInTwips().iWidth;
- return (int)(twips * (25.4/KTwipsPerInch));
- }
- case QPaintDevice::PdmHeightMM: {
- TInt twips = cfbsBitmap->SizeInTwips().iHeight;
- return (int)(twips * (25.4/KTwipsPerInch));
- }
+ case QPaintDevice::PdmWidthMM:
+ return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX());
+ case QPaintDevice::PdmHeightMM:
+ return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY());
case QPaintDevice::PdmNumColors:
return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode());
case QPaintDevice::PdmDpiX:
- case QPaintDevice::PdmPhysicalDpiX: {
- TReal inches = cfbsBitmap->SizeInTwips().iWidth / (TReal)KTwipsPerInch;
- TInt pixels = cfbsBitmap->SizeInPixels().iWidth;
- return pixels / inches;
- }
+ case QPaintDevice::PdmPhysicalDpiX:
+ return qt_defaultDpiX();
case QPaintDevice::PdmDpiY:
- case QPaintDevice::PdmPhysicalDpiY: {
- TReal inches = cfbsBitmap->SizeInTwips().iHeight / (TReal)KTwipsPerInch;
- TInt pixels = cfbsBitmap->SizeInPixels().iHeight;
- return pixels / inches;
- }
+ case QPaintDevice::PdmPhysicalDpiY:
+ return qt_defaultDpiY();
case QPaintDevice::PdmDepth:
return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode());
default:
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 450e8c6..4d5694f 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -507,8 +507,10 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
png_read_end(png_ptr, end_info);
readPngTexts(end_info);
+#ifndef QT_NO_IMAGE_TEXT
for (int i = 0; i < readTexts.size()-1; i+=2)
outImage->setText(readTexts.at(i), readTexts.at(i+1));
+#endif
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
delete [] row_pointers;
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index 73aa982..9d8dd41 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -394,7 +394,8 @@ void QCoeFepInputContext::resetSplitViewWidget(bool keepInputWidget)
if (!alwaysResize) {
if (gv->scene()) {
- disconnect(gv->scene()->focusItem()->toGraphicsObject(), SIGNAL(cursorPositionChanged()), this, SLOT(translateInputWidget()));
+ if (gv->scene()->focusItem())
+ disconnect(gv->scene()->focusItem()->toGraphicsObject(), SIGNAL(cursorPositionChanged()), this, SLOT(translateInputWidget()));
QGraphicsItem *rootItem;
foreach (QGraphicsItem *item, gv->scene()->items()) {
if (!item->parentItem()) {
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 0ff3d88..32fa3d3 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -223,7 +223,8 @@ qpa {
kernel/qdesktopwidget_qpa_p.h \
kernel/qplatformeventloopintegration_qpa.h \
kernel/qplatformcursor_qpa.h \
- kernel/qplatformclipboard_qpa.h
+ kernel/qplatformclipboard_qpa.h \
+ kernel/qplatformnativeinterface_qpa.h
SOURCES += \
kernel/qapplication_qpa.cpp \
@@ -246,7 +247,8 @@ qpa {
kernel/qplatformeventloopintegration_qpa.cpp \
kernel/qplatformglcontext_qpa.cpp \
kernel/qplatformcursor_qpa.cpp \
- kernel/qplatformclipboard_qpa.cpp
+ kernel/qplatformclipboard_qpa.cpp \
+ kernel/qplatformnativeinterface_qpa.cpp
contains(QT_CONFIG, glib) {
SOURCES += \
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp
index cd76adf..cb5439c 100644
--- a/src/gui/kernel/qapplication_qpa.cpp
+++ b/src/gui/kernel/qapplication_qpa.cpp
@@ -51,6 +51,7 @@
#endif
#include "private/qwidget_p.h"
+#include "private/qevent_p.h"
#include "qgenericpluginfactory_qpa.h"
#include "qplatformintegrationfactory_qpa_p.h"
@@ -816,8 +817,14 @@ void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEven
if (app_do_modal && !qt_try_modal(focusW, e->keyType))
return;
- QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
- QApplication::sendSpontaneousEvent(focusW, &ev);
+ if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
+ QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
+ e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
+ QApplication::sendSpontaneousEvent(focusW, &ev);
+ } else {
+ QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
+ QApplication::sendSpontaneousEvent(focusW, &ev);
+ }
}
void QApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
diff --git a/src/gui/kernel/qclipboard_win.cpp b/src/gui/kernel/qclipboard_win.cpp
index 52b9663..ea41165 100644
--- a/src/gui/kernel/qclipboard_win.cpp
+++ b/src/gui/kernel/qclipboard_win.cpp
@@ -52,6 +52,7 @@
#include "qt_windows.h"
#include "qdnd_p.h"
#include <private/qwidget_p.h>
+#include <private/qsystemlibrary_p.h>
QT_BEGIN_NAMESPACE
@@ -70,6 +71,9 @@ void QtCeFlushClipboard();
#endif
+typedef BOOL (WINAPI *PtrIsHungAppWindow)(HWND);
+
+static PtrIsHungAppWindow ptrIsHungAppWindow = 0;
class QClipboardWatcher : public QInternalMimeData {
public:
@@ -327,9 +331,16 @@ bool QClipboard::event(QEvent *e)
d->releaseIData();
propagate = true;
}
-
if (propagate && d->nextClipboardViewer) {
- SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
+ if (ptrIsHungAppWindow == 0) {
+ QSystemLibrary library(QLatin1String("User32"));
+ ptrIsHungAppWindow = (PtrIsHungAppWindow)library.resolve("IsHungAppWindow");
+ }
+ if (ptrIsHungAppWindow && ptrIsHungAppWindow(d->nextClipboardViewer)) {
+ qWarning("%s: Cowardly refusing to send clipboard message to hung application...", Q_FUNC_INFO);
+ } else {
+ SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
+ }
}
return true;
diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp
index c3963f4..62a4d40 100644
--- a/src/gui/kernel/qdesktopwidget_s60.cpp
+++ b/src/gui/kernel/qdesktopwidget_s60.cpp
@@ -188,12 +188,14 @@ void QDesktopWidgetPrivate::cleanup()
void QDesktopWidgetPrivate::init_sys()
{
#if defined(Q_SYMBIAN_SUPPORTS_MULTIPLE_SCREENS)
- CWsScreenDevice *dev = S60->screenDevice(1);
- if (dev) {
- displayControl = static_cast<MDisplayControl *>(
- dev->GetInterface(MDisplayControl::ETypeId));
- if (displayControl) {
- displayControl->EnableDisplayChangeEvents(ETrue);
+ if (S60->screenCount() > 1) {
+ CWsScreenDevice *dev = S60->screenDevice(1);
+ if (dev) {
+ displayControl = static_cast<MDisplayControl *>(
+ dev->GetInterface(MDisplayControl::ETypeId));
+ if (displayControl) {
+ displayControl->EnableDisplayChangeEvents(ETrue);
+ }
}
}
#endif
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 698c94b..277a5e8 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -43,6 +43,7 @@
#include "qcursor.h"
#include "qapplication.h"
#include "private/qapplication_p.h"
+#include "private/qevent_p.h"
#include "private/qkeysequence_p.h"
#include "qwidget.h"
#include "qgraphicsview.h"
diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp
index 7701612..de53618 100644
--- a/src/gui/kernel/qeventdispatcher_qpa.cpp
+++ b/src/gui/kernel/qeventdispatcher_qpa.cpp
@@ -172,7 +172,6 @@ public:
{
if (qApp && (qApp->thread() == QThread::currentThread())) {
m_isEventLoopIntegrationRunning = true;
- QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
eventLoopIntegration->startEventLoop();
}
}
diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/kernel/qplatformclipboard_qpa.cpp
index e169f08..957a4df 100644
--- a/src/gui/kernel/qplatformclipboard_qpa.cpp
+++ b/src/gui/kernel/qplatformclipboard_qpa.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include "qplatformclipboard_qpa.h"
+#ifndef QT_NO_CLIPBOARD
+
QT_BEGIN_NAMESPACE
class QClipboardData
@@ -99,3 +101,5 @@ bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const
}
QT_END_NAMESPACE
+
+#endif //QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qplatformclipboard_qpa.h b/src/gui/kernel/qplatformclipboard_qpa.h
index 78cd444..3381c06 100644
--- a/src/gui/kernel/qplatformclipboard_qpa.h
+++ b/src/gui/kernel/qplatformclipboard_qpa.h
@@ -44,6 +44,8 @@
#include <qplatformdefs.h>
+#ifndef QT_NO_CLIPBOARD
+
#include <QtGui/QClipboard>
QT_BEGIN_HEADER
@@ -66,5 +68,6 @@ QT_END_NAMESPACE
QT_END_HEADER
+#endif // QT_NO_CLIPBOARD
#endif //QPLATFORMCLIPBOARD_QPA_H
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index 7fb7fbd..c45a953 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -102,6 +102,9 @@ QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
\sa QPlatformClipboard
*/
+
+#ifndef QT_NO_CLIPBOARD
+
QPlatformClipboard *QPlatformIntegration::clipboard() const
{
static QPlatformClipboard *clipboard = 0;
@@ -111,6 +114,13 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const
return clipboard;
}
+#endif
+
+QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
+{
+ return 0;
+}
+
/*!
\class QPlatformIntegration
\since 4.8
@@ -211,4 +221,14 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const
QRect(x,y,width,height).
*/
+
+bool QPlatformIntegration::hasCapability(Capability cap) const
+{
+ return false;
+}
+
+
+
+
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index e40cb48..0aacefa 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -60,12 +60,19 @@ class QWidget;
class QPlatformEventLoopIntegration;
class QPlatformFontDatabase;
class QPlatformClipboard;
+class QPlatformNativeInterface;
class Q_GUI_EXPORT QPlatformIntegration
{
public:
+ enum Capability {
+ ThreadedPixmaps = 1,
+ };
+
virtual ~QPlatformIntegration() { }
+ virtual bool hasCapability(Capability cap) const;
+
// GraphicsSystem functions
virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0;
@@ -79,7 +86,9 @@ public:
//Deeper window system integrations
virtual QPlatformFontDatabase *fontDatabase() const;
+#ifndef QT_NO_CLIPBOARD
virtual QPlatformClipboard *clipboard() const;
+#endif
// Experimental in mainthread eventloop integration
// This should only be used if it is only possible to do window system event processing in
@@ -89,7 +98,8 @@ public:
//jl:XXX should it be hasGLContext and do we need it at all?
virtual bool hasOpenGL() const;
-
+// Access native handles. The window handle is already available from Wid;
+ virtual QPlatformNativeInterface *nativeInterface() const;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.cpp b/src/gui/kernel/qplatformnativeinterface_qpa.cpp
new file mode 100644
index 0000000..ace4a7b
--- /dev/null
+++ b/src/gui/kernel/qplatformnativeinterface_qpa.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** 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 "qplatformnativeinterface_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+void *QPlatformNativeInterface::nativeResourceForWidget(const QByteArray &resource, QWidget *widget)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(widget);
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.h b/src/gui/kernel/qplatformnativeinterface_qpa.h
new file mode 100644
index 0000000..5ea2c13
--- /dev/null
+++ b/src/gui/kernel/qplatformnativeinterface_qpa.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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 QPLATFORMNATIVEINTERFACE_QPA_H
+#define QPLATFORMNATIVEINTERFACE_QPA_H
+
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWidget;
+
+class Q_GUI_EXPORT QPlatformNativeInterface
+{
+public:
+ virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMNATIVEINTERFACE_QPA_H
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 4e18940..23d063d 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1343,8 +1343,8 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
//give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later
#ifdef Q_OS_SYMBIAN
if (isGLWidget) {
- // Don't waste GPU mem for unnecessary large egl surface
- data.crect = QRect(0,0,2,2);
+ // Don't waste GPU mem for unnecessary large egl surface until resized by application
+ data.crect = QRect(0,0,1,1);
} else {
data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640);
}
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 9a5a5f1..34918e4 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2476,6 +2476,8 @@ void QWidgetPrivate::createWindow_sys()
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
{
Q_Q(QWidget);
+ QMacCocoaAutoReleasePool pool;
+
OSViewRef destroyid = 0;
#ifndef QT_MAC_USE_COCOA
window_event = 0;
@@ -3239,6 +3241,8 @@ void QWidgetPrivate::setWindowIcon_sys(bool forceReset)
ReleaseIconRef(previousIcon);
#else
QMacCocoaAutoReleasePool pool;
+ if (icon.isNull())
+ return;
NSButton *iconButton = [qt_mac_window_for(q) standardWindowButton:NSWindowDocumentIconButton];
if (iconButton == nil) {
QCFString string(q->windowTitle());
@@ -4421,6 +4425,8 @@ void QWidgetPrivate::adjustWithinMaxAndMinSize(int &w, int &h)
void QWidgetPrivate::applyMaxAndMinSizeOnWindow()
{
Q_Q(QWidget);
+ QMacCocoaAutoReleasePool pool;
+
const float max_f(20000);
#ifndef QT_MAC_USE_COCOA
#define SF(x) ((x > max_f) ? max_f : x)
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index 4bff5ac..c6753fc 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -346,7 +346,7 @@ Q_GUI_EXPORT void qt_x11_enforce_cursor(QWidget * w)
qt_x11_enforce_cursor(w, false);
}
-Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
+void qt_x11_wait_for_window_manager(QWidget *w, bool sendPostedEvents)
{
if (!w || (!w->isWindow() && !w->internalWinId()))
return;
@@ -361,7 +361,8 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
WId winid = w->internalWinId();
// first deliver events that are already in the local queue
- QApplication::sendPostedEvents();
+ if (sendPostedEvents)
+ QApplication::sendPostedEvents();
// the normal sequence is:
// ... ConfigureNotify ... ReparentNotify ... MapNotify ... Expose
@@ -396,6 +397,11 @@ Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget* w)
} while(1);
}
+Q_GUI_EXPORT void qt_x11_wait_for_window_manager(QWidget *w)
+{
+ qt_x11_wait_for_window_manager(w, true);
+}
+
void qt_change_net_wm_state(const QWidget* w, bool set, Atom one, Atom two = 0)
{
if (!w->isVisible()) // not managed by the window manager
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
index c53eedb..740bb82 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
@@ -150,6 +150,36 @@ void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEven
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
+void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep,
+ ushort count)
+{
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
+ text, autorep, count);
+}
+
+void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, int key,
+ Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep,
+ ushort count)
+{
+ if (tlw) {
+ QWidgetData *data = qt_qwidget_data(tlw);
+ if (data->in_destructor)
+ tlw = 0;
+ }
+
+ QWindowSystemInterfacePrivate::KeyEvent * e =
+ new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
+ nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
handleWheelEvent(w, time, local, global, d, o);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h
index 9dce7ea..a882fc1 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa.h
@@ -64,6 +64,17 @@ public:
static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
static void handleKeyEvent(QWidget *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+ static void handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+ static void handleExtendedKeyEvent(QWidget *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+
static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
index 3491a1a..6be86ad 100644
--- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
@@ -142,13 +142,23 @@ public:
public:
KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
:UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
- repeatCount(count), modifiers(mods), keyType(t) { }
+ repeatCount(count), modifiers(mods), keyType(t),
+ nativeScanCode(0), nativeVirtualKey(0), nativeModifiers(0) { }
+ KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
+ quint32 nativeSC, quint32 nativeVK, quint32 nativeMods,
+ const QString & text = QString(), bool autorep = false, ushort count = 1)
+ :UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
+ repeatCount(count), modifiers(mods), keyType(t),
+ nativeScanCode(nativeSC), nativeVirtualKey(nativeVK), nativeModifiers(nativeMods) { }
int key;
QString unicode;
bool repeat;
ushort repeatCount;
Qt::KeyboardModifiers modifiers;
QEvent::Type keyType;
+ quint32 nativeScanCode;
+ quint32 nativeVirtualKey;
+ quint32 nativeModifiers;
};
class TouchEvent : public UserEvent {
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 51f2538..65e7af4 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -234,8 +234,10 @@ x11 {
}
!embedded:!qpa:mac {
- HEADERS += painting/qwindowsurface_mac_p.h
- SOURCES += painting/qwindowsurface_mac.cpp
+ HEADERS += painting/qwindowsurface_mac_p.h \
+ painting/qunifiedtoolbarsurface_mac_p.h
+ SOURCES += painting/qwindowsurface_mac.cpp \
+ painting/qunifiedtoolbarsurface_mac.cpp
}
embedded {
@@ -260,12 +262,6 @@ symbian {
QMAKE_CXXFLAGS.ARMCC *= -O3
}
-mac {
- HEADERS += painting/qunifiedtoolbarsurface_mac_p.h
- SOURCES += painting/qunifiedtoolbarsurface_mac.cpp
-}
-
-
NEON_SOURCES += painting/qdrawhelper_neon.cpp
NEON_HEADERS += painting/qdrawhelper_neon_p.h
NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
index 93245ef..46a6f81 100644
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ b/src/gui/painting/qgraphicssystem_runtime.cpp
@@ -404,7 +404,10 @@ void QRuntimeGraphicsSystem::setGraphicsSystem(const QString &name)
if(m_windowSurfaceDestroyPolicy == DestroyAfterFirstFlush)
proxy->m_pendingWindowSurface.reset(proxy->m_windowSurface.take());
- proxy->m_windowSurface.reset(m_graphicsSystem->createWindowSurface(widget));
+ QWindowSurface *newWindowSurface = m_graphicsSystem->createWindowSurface(widget);
+ newWindowSurface->setGeometry(proxy->geometry());
+
+ proxy->m_windowSurface.reset(newWindowSurface);
qt_widget_private(widget)->invalidateBuffer(widget->rect());
}
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 8bff021..49f1a5f 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1724,7 +1724,7 @@ static void qt_painterpath_isect_line(const QPointF &p1,
}
static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
- int *winding)
+ int *winding, int depth = 0)
{
qreal y = pt.y();
qreal x = pt.x();
@@ -1739,7 +1739,7 @@ static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
// hit lower limit... This is a rough threshold, but its a
// tradeoff between speed and precision.
const qreal lower_bound = qreal(.001);
- if (bounds.width() < lower_bound && bounds.height() < lower_bound) {
+ if (depth == 32 || (bounds.width() < lower_bound && bounds.height() < lower_bound)) {
// We make the assumption here that the curve starts to
// approximate a line after while (i.e. that it doesn't
// change direction drastically during its slope)
@@ -1752,8 +1752,8 @@ static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
// split curve and try again...
QBezier first_half, second_half;
bezier.split(&first_half, &second_half);
- qt_painterpath_isect_curve(first_half, pt, winding);
- qt_painterpath_isect_curve(second_half, pt, winding);
+ qt_painterpath_isect_curve(first_half, pt, winding, depth + 1);
+ qt_painterpath_isect_curve(second_half, pt, winding, depth + 1);
}
}
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 64722c7..2d21628 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -3084,7 +3084,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
}
break;
case PE_PanelScrollAreaCorner: {
- const QBrush brush(qApp->palette().brush(QPalette::Base));
+ const QBrush brush(opt->palette.brush(QPalette::Base));
p->fillRect(opt->rect, brush);
p->setPen(QPen(QColor(217, 217, 217)));
p->drawLine(opt->rect.topLeft(), opt->rect.topRight());
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index c107511..6a35027 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -118,6 +118,7 @@ const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0];
// theme background texture
QPixmap *QS60StylePrivate::m_background = 0;
+QPixmap *QS60StylePrivate::m_placeHolderTexture = 0;
// theme palette
QPalette *QS60StylePrivate::m_themePalette = 0;
@@ -155,6 +156,10 @@ const double KTabFontMul = 0.72;
QS60StylePrivate::~QS60StylePrivate()
{
clearCaches(); //deletes also background image
+ if (m_placeHolderTexture) {
+ delete m_placeHolderTexture;
+ m_placeHolderTexture = 0;
+ }
deleteThemePalette();
#ifdef Q_WS_S60
removeAnimations();
@@ -505,7 +510,10 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const
{
Q_UNUSED(app)
QPalette applicationPalette = QApplication::palette();
- applicationPalette.setBrush(QPalette::Window, backgroundTexture());
+ // The initial QPalette::Window is just a placeHolder QPixmap to save RAM
+ // if the actual texture is not needed. The real texture is created just before
+ // painting it in qt_s60_fill_background().
+ applicationPalette.setBrush(QPalette::Window, placeHolderTexture());
setThemePalette(&applicationPalette);
}
@@ -630,25 +638,6 @@ QPixmap QS60StylePrivate::cachedFrame(SkinFrameElements frame, const QSize &size
return result;
}
-void QS60StylePrivate::refreshUI()
-{
- QList<QWidget *> widgets = QApplication::allWidgets();
-
- for (int i = 0; i < widgets.size(); ++i) {
- QWidget *widget = widgets.at(i);
- if (widget == 0)
- continue;
-
- if (widget->style()) {
- widget->style()->polish(widget);
- QEvent event(QEvent::StyleChange);
- qApp->sendEvent(widget, &event);
- }
- widget->update();
- widget->updateGeometry();
- }
-}
-
void QS60StylePrivate::setFont(QWidget *widget) const
{
QS60StyleEnums::FontCategories fontCategory = QS60StyleEnums::FC_Undefined;
@@ -719,8 +708,10 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const
palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker());
palette->setColor(QPalette::Highlight,
s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0));
- // set background image as a texture brush
- palette->setBrush(QPalette::Window, backgroundTexture());
+ // The initial QPalette::Window is just a placeHolder QPixmap to save RAM
+ // if the actual texture is not needed. The real texture is created just before
+ // painting it in qt_s60_fill_background().
+ palette->setBrush(QPalette::Window, placeHolderTexture());
// set as transparent so that styled full screen theme background is visible
palette->setBrush(QPalette::Base, Qt::transparent);
// set button color based on pixel colors
@@ -3548,10 +3539,12 @@ extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget);
bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush)
{
- const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture());
- if (backgroundTexture.cacheKey() != brush.texture().cacheKey())
+ const QPixmap placeHolder(QS60StylePrivate::placeHolderTexture());
+ if (placeHolder.cacheKey() != brush.texture().cacheKey())
return false;
+ const QPixmap backgroundTexture(QS60StylePrivate::backgroundTexture());
+
const QPaintDevice *target = painter->device();
if (target->devType() == QInternal::Widget) {
const QWidget *widget = static_cast<const QWidget *>(target);
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index 242c451..8c023bf 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -555,6 +555,7 @@ public:
static QPixmap frame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap backgroundTexture();
+ static QPixmap placeHolderTexture();
#ifdef Q_WS_S60
void handleDynamicLayoutVariantSwitch();
@@ -592,8 +593,6 @@ private:
static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
- static void refreshUI();
-
// set S60 font for widget
void setFont(QWidget *widget) const;
void setThemePalette(QWidget *widget) const;
@@ -616,6 +615,9 @@ private:
// Contains background texture.
static QPixmap *m_background;
+ // Placeholder pixmap for the real background texture.
+ static QPixmap *m_placeHolderTexture;
+
const static SkinElementFlags KDefaultSkinElementFlags;
// defined theme palette
static QPalette *m_themePalette;
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 600c631..1ff195d 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -66,7 +66,6 @@
#include <aknnavi.h>
#include <gulicon.h>
#include <AknBitmapAnimation.h>
-
#include <centralrepository.h>
#if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN)
@@ -1408,12 +1407,23 @@ QPixmap QS60StylePrivate::backgroundTexture()
if (createNewBackground) {
QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
- QSize(applicationRect.Width(), applicationRect.Height()), 0, SkinElementFlags());
+ QSize(applicationRect.Width(), applicationRect.Height()), 0, SkinElementFlags());
m_background = new QPixmap(background);
}
return *m_background;
}
+// Generates 1*1 red pixmap as a placeholder for real texture.
+// The actual theme texture is drawn in qt_s60_fill_background().
+QPixmap QS60StylePrivate::placeHolderTexture()
+{
+ if (!m_placeHolderTexture) {
+ m_placeHolderTexture = new QPixmap(1,1);
+ m_placeHolderTexture->fill(Qt::red);
+ }
+ return *m_placeHolderTexture;
+}
+
QSize QS60StylePrivate::screenSize()
{
return QSize(S60->screenWidthInPixels, S60->screenHeightInPixels);
@@ -1428,8 +1438,8 @@ QS60Style::QS60Style()
void QS60StylePrivate::handleDynamicLayoutVariantSwitch()
{
clearCaches(QS60StylePrivate::CC_LayoutChange);
+ setBackgroundTexture(qApp);
setActiveLayout();
- refreshUI();
foreach (QWidget *widget, QApplication::allWidgets())
widget->ensurePolished();
}
diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp
index ef4e565..6fa25e7 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.cpp
+++ b/src/gui/text/qplatformfontdatabase_qpa.cpp
@@ -214,7 +214,7 @@ QFontEngine *QPlatformFontDatabase::fontEngine(const QFontDef &fontDef, QUnicode
Q_UNUSED(handle);
QByteArray *fileDataPtr = static_cast<QByteArray *>(handle);
QFontEngineQPA *engine = new QFontEngineQPA(fontDef,*fileDataPtr);
- qDebug() << fontDef.pixelSize << fontDef.weight << fontDef.style << fontDef.stretch << fontDef.styleHint << fontDef.styleStrategy << fontDef.family << script;
+ //qDebug() << fontDef.pixelSize << fontDef.weight << fontDef.style << fontDef.stretch << fontDef.styleHint << fontDef.styleStrategy << fontDef.family << script;
return engine;
}
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 354e8a9..8eff7d2 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1754,6 +1754,7 @@ namespace {
int glyphCount;
int maxGlyphs;
int currentPosition;
+ glyph_t previousGlyph;
QFixed minw;
QFixed softHyphenWidth;
@@ -1781,6 +1782,15 @@ namespace {
return glyphs.glyphs[logClusters[currentPosition - 1]];
}
+ inline void saveCurrentGlyph()
+ {
+ previousGlyph = 0;
+ if (currentPosition > 0 &&
+ logClusters[currentPosition - 1] < glyphs.numGlyphs) {
+ previousGlyph = currentGlyph(); // needed to calculate right bearing later
+ }
+ }
+
inline void adjustRightBearing(glyph_t glyph)
{
qreal rb;
@@ -1795,6 +1805,12 @@ namespace {
adjustRightBearing(currentGlyph());
}
+ inline void adjustPreviousRightBearing()
+ {
+ if (previousGlyph > 0)
+ adjustRightBearing(previousGlyph);
+ }
+
inline void resetRightBearing()
{
rightBearing = QFixed(1); // Any positive number is defined as invalid since only
@@ -1871,22 +1887,7 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap);
int item = -1;
- int newItem = -1;
- int left = 0;
- int right = eng->layoutData->items.size()-1;
- while(left <= right) {
- int middle = ((right-left)/2)+left;
- if (line.from > eng->layoutData->items[middle].position)
- left = middle+1;
- else if(line.from < eng->layoutData->items[middle].position)
- right = middle-1;
- else {
- newItem = middle;
- break;
- }
- }
- if (newItem == -1)
- newItem = right;
+ int newItem = eng->findItem(line.from);
LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal());
@@ -1898,6 +1899,7 @@ void QTextLine::layout_helper(int maxGlyphs)
lbh.currentPosition = line.from;
int end = 0;
lbh.logClusters = eng->layoutData->logClustersPtr;
+ lbh.previousGlyph = 0;
while (newItem < eng->layoutData->items.size()) {
lbh.resetRightBearing();
@@ -1958,6 +1960,7 @@ void QTextLine::layout_helper(int maxGlyphs)
current, lbh.logClusters, lbh.glyphs);
} else {
lbh.tmpData.length++;
+ lbh.adjustPreviousRightBearing();
}
line += lbh.tmpData;
goto found;
@@ -1988,9 +1991,7 @@ void QTextLine::layout_helper(int maxGlyphs)
} else {
lbh.whiteSpaceOrObject = false;
bool sb_or_ws = false;
- glyph_t previousGlyph = 0;
- if (lbh.currentPosition > 0 && lbh.logClusters[lbh.currentPosition - 1] <lbh.glyphs.numGlyphs)
- previousGlyph = lbh.currentGlyph(); // needed to calculate right bearing later
+ lbh.saveCurrentGlyph();
do {
addNextCluster(lbh.currentPosition, end, lbh.tmpData, lbh.glyphCount,
current, lbh.logClusters, lbh.glyphs);
@@ -2015,7 +2016,7 @@ void QTextLine::layout_helper(int maxGlyphs)
// b) if we are so short of available width that the
// soft hyphen is the first breakable position, then
// we don't want to show it. However we initially
- // have to take the width for it into accoun so that
+ // have to take the width for it into account so that
// the text document layout sees the overflow and
// switch to break-anywhere mode, in which we
// want the soft-hyphen to slip into the next line
@@ -2043,8 +2044,9 @@ void QTextLine::layout_helper(int maxGlyphs)
// we are too wide, fix right bearing
if (rightBearing <= 0)
lbh.rightBearing = rightBearing; // take from cache
- else if (previousGlyph > 0)
- lbh.adjustRightBearing(previousGlyph);
+ else
+ lbh.adjustPreviousRightBearing();
+
if (!breakany) {
line.textWidth += lbh.softHyphenWidth;
}
@@ -2052,6 +2054,7 @@ void QTextLine::layout_helper(int maxGlyphs)
goto found;
}
}
+ lbh.saveCurrentGlyph();
}
if (lbh.currentPosition == end)
newItem = item + 1;
diff --git a/src/gui/util/qscroller_mac.mm b/src/gui/util/qscroller_mac.mm
index f544788..4bf69c1 100644
--- a/src/gui/util/qscroller_mac.mm
+++ b/src/gui/util/qscroller_mac.mm
@@ -39,12 +39,14 @@
**
****************************************************************************/
+#include <QtCore/qglobal.h>
+
+#ifdef Q_WS_MAC
+
#import <Cocoa/Cocoa.h>
#include "qscroller_p.h"
-#ifdef Q_WS_MAC
-
QPointF QScrollerPrivate::realDpi(int screen)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp
index 2b7935b..5a0e179 100644
--- a/src/gui/util/qsystemtrayicon_win.cpp
+++ b/src/gui/util/qsystemtrayicon_win.cpp
@@ -305,6 +305,7 @@ bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
case WM_CONTEXTMENU:
if (q->contextMenu()) {
q->contextMenu()->popup(gpos);
+ q->contextMenu()->activateWindow();
}
emit q->activated(QSystemTrayIcon::Context);
break;
diff --git a/src/gui/widgets/qsplashscreen.cpp b/src/gui/widgets/qsplashscreen.cpp
index 75280cb..9c486bf 100644
--- a/src/gui/widgets/qsplashscreen.cpp
+++ b/src/gui/widgets/qsplashscreen.cpp
@@ -223,8 +223,8 @@ void QSplashScreen::finish(QWidget *mainWin)
{
if (mainWin) {
#if defined(Q_WS_X11)
- extern void qt_x11_wait_for_window_manager(QWidget *mainWin);
- qt_x11_wait_for_window_manager(mainWin);
+ extern void qt_x11_wait_for_window_manager(QWidget *mainWin, bool);
+ qt_x11_wait_for_window_manager(mainWin, false);
#endif
}
close();
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 3502113..29ae5b0 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -487,7 +487,7 @@ void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair)
QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
}
-void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socket)
+bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket)
{
Q_ASSERT(socket);
@@ -500,8 +500,7 @@ void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socke
prepareRequest(messagePair);
channels[i].request = messagePair.first;
channels[i].reply = messagePair.second;
- channels[i].sendRequest();
- return;
+ return true;
}
if (!lowPriorityQueue.isEmpty()) {
@@ -511,9 +510,9 @@ void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socke
prepareRequest(messagePair);
channels[i].request = messagePair.first;
channels[i].reply = messagePair.second;
- channels[i].sendRequest();
- return;
+ return true;
}
+ return false;
}
// this is called from _q_startNextRequest and when a request has been sent down a socket from the channel
@@ -765,7 +764,7 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
//resend the necessary ones.
for (int i = 0; i < channelCount; ++i) {
- if (channels[i].resendCurrent) {
+ if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) {
channels[i].resendCurrent = false;
channels[i].state = QHttpNetworkConnectionChannel::IdleState;
@@ -784,17 +783,8 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
// try to get a free AND connected socket
for (int i = 0; i < channelCount; ++i) {
if (!channels[i].reply && !channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) {
- dequeueAndSendRequest(channels[i].socket);
- }
- }
-
- // return fast if there is nothing to do
- if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
- return;
- // try to get a free unconnected socket
- for (int i = 0; i < channelCount; ++i) {
- if (!channels[i].reply && !channels[i].isSocketBusy()) {
- dequeueAndSendRequest(channels[i].socket);
+ if (dequeueRequest(channels[i].socket))
+ channels[i].sendRequest();
}
}
@@ -811,6 +801,21 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
for (int i = 0; i < channelCount; i++)
if (channels[i].socket->state() == QAbstractSocket::ConnectedState)
fillPipeline(channels[i].socket);
+
+ // If there is not already any connected channels we need to connect a new one.
+ // We do not pair the channel with the request until we know if it is
+ // connected or not. This is to reuse connected channels before we connect new once.
+ int queuedRequest = highPriorityQueue.count() + lowPriorityQueue.count();
+ for (int i = 0; i < channelCount; ++i) {
+ if (channels[i].socket->state() == QAbstractSocket::ConnectingState)
+ queuedRequest--;
+ if ( queuedRequest <=0 )
+ break;
+ if (!channels[i].reply && !channels[i].isSocketBusy() && (channels[i].socket->state() == QAbstractSocket::UnconnectedState)) {
+ channels[i].ensureConnection();
+ queuedRequest--;
+ }
+ }
}
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index d4748c1..874ea22 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -161,7 +161,7 @@ public:
QHttpNetworkReply *queueRequest(const QHttpNetworkRequest &request);
void requeueRequest(const HttpMessagePair &pair); // e.g. after pipeline broke
- void dequeueAndSendRequest(QAbstractSocket *socket);
+ bool dequeueRequest(QAbstractSocket *socket);
void prepareRequest(HttpMessagePair &request);
void fillPipeline(QAbstractSocket *socket);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 41bc64a..6564b4b 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -91,8 +91,10 @@ void QHttpNetworkConnectionChannel::init()
#else
socket = new QTcpSocket;
#endif
+#ifndef QT_NO_NETWORKPROXY
// Set by QNAM anyway, but let's be safe here
socket->setProxy(QNetworkProxy::NoProxy);
+#endif
QObject::connect(socket, SIGNAL(bytesWritten(qint64)),
this, SLOT(_q_bytesWritten(qint64)),
@@ -145,10 +147,12 @@ void QHttpNetworkConnectionChannel::init()
void QHttpNetworkConnectionChannel::close()
{
- socket->blockSignals(true);
+ if (socket->state() == QAbstractSocket::UnconnectedState)
+ state = QHttpNetworkConnectionChannel::IdleState;
+ else
+ state = QHttpNetworkConnectionChannel::ClosingState;
+
socket->close();
- socket->blockSignals(false);
- state = QHttpNetworkConnectionChannel::IdleState;
}
@@ -500,6 +504,7 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
// called when unexpectedly reading a -1 or when data is expected but socket is closed
void QHttpNetworkConnectionChannel::handleUnexpectedEOF()
{
+ Q_ASSERT(reply);
if (reconnectAttempts <= 0) {
// too many errors reading/receiving/parsing the status, close the socket and emit error
requeueCurrentlyPipelinedRequests();
@@ -522,7 +527,8 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
// resend this request after we receive the disconnected signal
if (socketState == QAbstractSocket::ClosingState) {
- resendCurrent = true;
+ if (reply)
+ resendCurrent = true;
return false;
}
@@ -582,13 +588,15 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
#endif
} else {
// In case of no proxy we can use the Unbuffered QTcpSocket
+#ifndef QT_NO_NETWORKPROXY
if (connection->d_func()->networkProxy.type() == QNetworkProxy::NoProxy
&& connection->cacheProxy().type() == QNetworkProxy::NoProxy
&& connection->transparentProxy().type() == QNetworkProxy::NoProxy) {
+#endif
socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite | QIODevice::Unbuffered);
// For an Unbuffered QTcpSocket, the read buffer size has a special meaning.
socket->setReadBufferSize(1*1024);
-
+#ifndef QT_NO_NETWORKPROXY
} else {
socket->connectToHost(connectHost, connectPort);
@@ -597,6 +605,7 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
// here and there.
socket->setReadBufferSize(64*1024);
}
+#endif
}
return false;
}
@@ -644,6 +653,7 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete)
void QHttpNetworkConnectionChannel::allDone()
{
+ Q_ASSERT(reply);
#ifndef QT_NO_COMPRESS
// expand the whole data.
if (reply->d_func()->expectContent() && reply->d_func()->autoDecompress && !reply->d_func()->streamEnd) {
@@ -679,7 +689,8 @@ void QHttpNetworkConnectionChannel::allDone()
reconnectAttempts = 2;
// now the channel can be seen as free/idle again, all signal emissions for the reply have been done
- this->state = QHttpNetworkConnectionChannel::IdleState;
+ if (state != QHttpNetworkConnectionChannel::ClosingState)
+ state = QHttpNetworkConnectionChannel::IdleState;
// if it does not need to be sent again we can set it to 0
// the previous code did not do that and we had problems with accidental re-sending of a
@@ -729,7 +740,8 @@ void QHttpNetworkConnectionChannel::allDone()
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
} else if (alreadyPipelinedRequests.isEmpty()) {
if (connectionCloseEnabled)
- close();
+ if (socket->state() != QAbstractSocket::UnconnectedState)
+ close();
if (qobject_cast<QHttpNetworkConnection*>(connection))
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
}
@@ -737,6 +749,7 @@ void QHttpNetworkConnectionChannel::allDone()
void QHttpNetworkConnectionChannel::detectPipeliningSupport()
{
+ Q_ASSERT(reply);
// detect HTTP Pipelining support
QByteArray serverHeaderField;
if (
@@ -820,6 +833,7 @@ void QHttpNetworkConnectionChannel::handleStatus()
bool QHttpNetworkConnectionChannel::resetUploadData()
{
+ Q_ASSERT(reply);
QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();
if (!uploadByteDevice)
return true;
@@ -877,7 +891,8 @@ void QHttpNetworkConnectionChannel::closeAndResendCurrentRequest()
{
requeueCurrentlyPipelinedRequests();
close();
- resendCurrent = true;
+ if (reply)
+ resendCurrent = true;
if (qobject_cast<QHttpNetworkConnection*>(connection))
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
}
@@ -905,15 +920,18 @@ bool QHttpNetworkConnectionChannel::isSocketReading() const
//private slots
void QHttpNetworkConnectionChannel::_q_readyRead()
{
- // We got a readyRead but no bytes are available..
- // This happens for the Unbuffered QTcpSocket
- // Also check if socket is in ConnectedState since
- // this function may also be invoked via the event loop.
if (socket->state() == QAbstractSocket::ConnectedState && socket->bytesAvailable() == 0) {
+ // We got a readyRead but no bytes are available..
+ // This happens for the Unbuffered QTcpSocket
+ // Also check if socket is in ConnectedState since
+ // this function may also be invoked via the event loop.
char c;
qint64 ret = socket->peek(&c, 1);
if (ret < 0) {
- socket->disconnectFromHost();
+ _q_error(socket->error());
+ // We still need to handle the reply so it emits its signals etc.
+ if (reply)
+ _q_receiveReply();
return;
}
}
@@ -936,6 +954,12 @@ void QHttpNetworkConnectionChannel::_q_bytesWritten(qint64 bytes)
void QHttpNetworkConnectionChannel::_q_disconnected()
{
+ if (state == QHttpNetworkConnectionChannel::ClosingState) {
+ state = QHttpNetworkConnectionChannel::IdleState;
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ return;
+ }
+
// read the available data before closing
if (isSocketWaiting() || isSocketReading()) {
if (reply) {
@@ -973,10 +997,10 @@ void QHttpNetworkConnectionChannel::_q_connected()
//channels[i].reconnectAttempts = 2;
if (!pendingEncrypt) {
state = QHttpNetworkConnectionChannel::IdleState;
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
if (reply)
sendRequest();
- else
- close();
}
}
@@ -1004,8 +1028,20 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
} else {
errorCode = QNetworkReply::RemoteHostClosedError;
}
+ } else if (state == QHttpNetworkConnectionChannel::ReadingState) {
+ if (!reply->d_func()->expectContent()) {
+ // No content expected, this is a valid way to have the connection closed by the server
+ return;
+ }
+ if (reply->contentLength() == -1 && !reply->d_func()->isChunked()) {
+ // There was no content-length header and it's not chunked encoding,
+ // so this is a valid way to have the connection closed by the server
+ return;
+ }
+ // ok, we got a disconnect even though we did not expect it
+ errorCode = QNetworkReply::RemoteHostClosedError;
} else {
- return;
+ errorCode = QNetworkReply::RemoteHostClosedError;
}
break;
case QAbstractSocket::SocketTimeoutError:
@@ -1030,9 +1066,13 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
QPointer<QHttpNetworkConnection> that = connection;
QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString());
+ // Need to dequeu the request so that we can emit the error.
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
if (reply) {
reply->d_func()->errorString = errorString;
emit reply->finishedWithError(errorCode, errorString);
+ reply = 0;
}
// send the next request
QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection);
@@ -1044,7 +1084,11 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
#ifndef QT_NO_NETWORKPROXY
void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth)
{
- connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
+ // Need to dequeue the request before we can emit the error.
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
+ if (reply)
+ connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
}
#endif
@@ -1060,7 +1104,10 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
return; // ### error
state = QHttpNetworkConnectionChannel::IdleState;
pendingEncrypt = false;
- sendRequest();
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
+ if (reply)
+ sendRequest();
}
void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
@@ -1071,7 +1118,10 @@ void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
// Also pause the connection because socket notifiers may fire while an user
// dialog is displaying
connection->d_func()->pauseConnection();
- emit reply->sslErrors(errors);
+ if (pendingEncrypt && !reply)
+ connection->d_func()->dequeueRequest(socket);
+ if (reply)
+ emit reply->sslErrors(errors);
connection->d_func()->resumeConnection();
}
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index 8cbc689..893d75e 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -95,7 +95,8 @@ public:
WritingState = 2, // writing the data
WaitingState = 4, // waiting for reply
ReadingState = 8, // reading the reply
- BusyState = (ConnectingState|WritingState|WaitingState|ReadingState)
+ ClosingState = 16,
+ BusyState = (ConnectingState|WritingState|WaitingState|ReadingState|ClosingState)
};
QAbstractSocket *socket;
bool ssl;
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 4908e0a..a031cd0 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -233,6 +233,11 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest,
return;
}
+ // The disk cache API does not currently support partial content retrieval.
+ // That is why we don't use the disk cache for any such requests.
+ if (request().hasRawHeader("Range"))
+ return;
+
QAbstractNetworkCache *nc = networkCache();
if (!nc)
return; // no local cache
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 485f449..1c9fa3e 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -514,6 +514,13 @@ void QNetworkReplyImplPrivate::initCacheSaveDevice()
{
Q_Q(QNetworkReplyImpl);
+ // The disk cache does not support partial content, so don't even try to
+ // save any such content into the cache.
+ if (q->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 206) {
+ cacheEnabled = false;
+ return;
+ }
+
// save the meta data
QNetworkCacheMetaData metaData;
metaData.setUrl(url);
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 2a942cc..c7c2e82 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -2210,6 +2210,8 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
} else if (readBytes < 0) {
d->socketError = d->socketEngine->error();
setErrorString(d->socketEngine->errorString());
+ d->resetSocketLayer();
+ d->state = QAbstractSocket::UnconnectedState;
} else if (!d->socketEngine->isReadNotificationEnabled()) {
// Only do this when there was no error
d->socketEngine->setReadNotificationEnabled(true);
diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp
index e9e7d21..5594296 100644
--- a/src/network/ssl/qssl.cpp
+++ b/src/network/ssl/qssl.cpp
@@ -101,12 +101,17 @@ QT_BEGIN_NAMESPACE
Describes the protocol of the cipher.
- \value SslV3 SSLv3 - the default protocol.
+ \value SslV3 SSLv3
\value SslV2 SSLv2
\value TlsV1 TLSv1
\value UnknownProtocol The cipher's protocol cannot be determined.
\value AnyProtocol The socket understands SSLv2, SSLv3, and TLSv1. This
value is used by QSslSocket only.
+ \value TlsV1SslV3 On the client side, this will send
+ a TLS 1.0 Client Hello, enabling TLSv1 and SSLv3 connections.
+ On the server side, this will enable both SSLv3 and TLSv1 connections.
+ \value SecureProtocols The default option, using protocols known to be secure;
+ currently behaves like TlsV1SslV3.
Note: most servers using SSL understand both versions (2 and 3),
but it is recommended to use the latest version only for security
diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h
index 4c035fd..24dbb09 100644
--- a/src/network/ssl/qssl.h
+++ b/src/network/ssl/qssl.h
@@ -75,8 +75,10 @@ namespace QSsl {
enum SslProtocol {
SslV3,
SslV2,
- TlsV1,
+ TlsV1, // ### Qt 5: rename to TlsV1_0 or so
AnyProtocol,
+ TlsV1SslV3,
+ SecureProtocols,
UnknownProtocol = -1
};
}
diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp
index 3592226..150f77e 100644
--- a/src/network/ssl/qsslconfiguration.cpp
+++ b/src/network/ssl/qsslconfiguration.cpp
@@ -213,7 +213,7 @@ bool QSslConfiguration::isNull() const
*/
QSsl::SslProtocol QSslConfiguration::protocol() const
{
- return d ? d->protocol : QSsl::SslV3;
+ return d ? d->protocol : QSsl::SecureProtocols;
}
/*!
@@ -518,7 +518,7 @@ void QSslConfiguration::setCaCertificates(const QList<QSslCertificate> &certific
\list
\o no local certificate and no private key
- \o protocol SSLv3
+ \o protocol SecureProtocols (meaning either TLS 1.0 or SSL 3 will be used)
\o the system's default CA certificate list
\o the cipher list equal to the list of the SSL libraries'
supported SSL ciphers
diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h
index b039e69..a5af51a 100644
--- a/src/network/ssl/qsslconfiguration_p.h
+++ b/src/network/ssl/qsslconfiguration_p.h
@@ -80,7 +80,7 @@ class QSslConfigurationPrivate: public QSharedData
{
public:
QSslConfigurationPrivate()
- : protocol(QSsl::SslV3),
+ : protocol(QSsl::SecureProtocols),
peerVerifyMode(QSslSocket::AutoVerifyPeer),
peerVerifyDepth(0)
{ }
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 61f27fe..98e2dc5 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -56,7 +56,7 @@
QSslSocket establishes a secure, encrypted TCP connection you can
use for transmitting encrypted data. It can operate in both client
and server mode, and it supports modern SSL protocols, including
- SSLv3 and TLSv1. By default, QSslSocket uses SSLv3, but you can
+ SSLv3 and TLSv1. By default, QSslSocket uses TLSv1, but you can
change the SSL protocol by calling setProtocol() as long as you do
it before the handshake has started.
@@ -552,7 +552,7 @@ bool QSslSocket::isEncrypted() const
}
/*!
- Returns the socket's SSL protocol. By default, \l QSsl::SslV3 is used.
+ Returns the socket's SSL protocol. By default, \l QSsl::SecureProtocols is used.
\sa setProtocol()
*/
@@ -659,6 +659,34 @@ void QSslSocket::setPeerVerifyDepth(int depth)
}
/*!
+ \since 4.8
+
+ Returns the different hostname for the certificate validation, as set by
+ setPeerVerifyName or by connectToHostEncrypted.
+
+ \sa setPeerVerifyName(), connectToHostEncrypted()
+*/
+QString QSslSocket::peerVerifyName() const
+{
+ Q_D(const QSslSocket);
+ return d->verificationPeerName;
+}
+
+/*!
+ \since 4.8
+
+ Sets a different hostname for the certificate validation instead of the one used for the TCP
+ connection.
+
+ \sa connectToHostEncrypted()
+*/
+void QSslSocket::setPeerVerifyName(const QString &hostName)
+{
+ Q_D(QSslSocket);
+ d->verificationPeerName = hostName;
+}
+
+/*!
\reimp
Returns the number of decrypted bytes that are immediately available for
diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h
index 703a1fb..648fd8c 100644
--- a/src/network/ssl/qsslsocket.h
+++ b/src/network/ssl/qsslsocket.h
@@ -106,6 +106,9 @@ public:
int peerVerifyDepth() const;
void setPeerVerifyDepth(int depth);
+ QString peerVerifyName() const;
+ void setPeerVerifyName(const QString &hostName);
+
// From QIODevice
qint64 bytesAvailable() const;
qint64 bytesToWrite() const;
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 83714ed..c1b1712 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -60,6 +60,12 @@
#include <QtCore/qvarlengtharray.h>
#include <QLibrary> // for loading the security lib for the CA store
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+// Symbian does not seem to have the symbol for SNI defined
+#ifndef SSL_CTRL_SET_TLSEXT_HOSTNAME
+#define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
+#endif
+#endif
QT_BEGIN_NAMESPACE
#if defined(Q_OS_MAC)
@@ -253,6 +259,8 @@ init_context:
case QSsl::SslV3:
ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());
break;
+ case QSsl::SecureProtocols: // SslV2 will be disabled below
+ case QSsl::TlsV1SslV3: // SslV2 will be disabled below
case QSsl::AnyProtocol:
default:
ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
@@ -278,7 +286,11 @@ init_context:
}
// Enable all bug workarounds.
- q_SSL_CTX_set_options(ctx, SSL_OP_ALL);
+ if (configuration.protocol == QSsl::TlsV1SslV3 || configuration.protocol == QSsl::SecureProtocols) {
+ q_SSL_CTX_set_options(ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2);
+ } else {
+ q_SSL_CTX_set_options(ctx, SSL_OP_ALL);
+ }
// Initialize ciphers
QByteArray cipherString;
@@ -313,9 +325,18 @@ init_context:
q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle());
}
}
+
+ bool addExpiredCerts = true;
+#if defined(Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_5)
+ //On Leopard SSL does not work if we add the expired certificates.
+ if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_5)
+ addExpiredCerts = false;
+#endif
// now add the expired certs
- foreach (const QSslCertificate &caCertificate, expiredCerts) {
- q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle());
+ if (addExpiredCerts) {
+ foreach (const QSslCertificate &caCertificate, expiredCerts) {
+ q_X509_STORE_add_cert(ctx->cert_store, (X509 *)caCertificate.handle());
+ }
}
if (s_loadRootCertsOnDemand && allowRootCertOnDemandLoading) {
@@ -386,6 +407,24 @@ init_context:
return false;
}
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+ if ((configuration.protocol == QSsl::TlsV1SslV3 ||
+ configuration.protocol == QSsl::TlsV1 ||
+ configuration.protocol == QSsl::SecureProtocols ||
+ configuration.protocol == QSsl::AnyProtocol) &&
+ client && q_SSLeay() >= 0x00090806fL) {
+ // Set server hostname on TLS extension. RFC4366 section 3.1 requires it in ACE format.
+ QString tlsHostName = verificationPeerName.isEmpty() ? q->peerName() : verificationPeerName;
+ if (tlsHostName.isEmpty())
+ tlsHostName = hostName;
+ QByteArray ace = QUrl::toAce(tlsHostName);
+ if (!ace.isEmpty()) {
+ if (!q_SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, ace.constData()))
+ qWarning("could not set SSL_CTRL_SET_TLSEXT_HOSTNAME, Server Name Indication disabled");
+ }
+ }
+#endif
+
// Clear the session.
q_SSL_clear(ssl);
errorList.clear();
diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
index 5a7963e..ca49fab 100644
--- a/src/network/ssl/qsslsocket_openssl_p.h
+++ b/src/network/ssl/qsslsocket_openssl_p.h
@@ -79,6 +79,10 @@
#include <openssl/x509_vfy.h>
#include <openssl/dsa.h>
#include <openssl/rsa.h>
+#include <openssl/crypto.h>
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+#include <openssl/tls1.h>
+#endif
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
typedef _STACK STACK;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index b9a05f3..b1310cc 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -208,6 +208,9 @@ DEFINEFUNC(long, SSL_get_verify_result, SSL *a, a, return -1, return)
DEFINEFUNC(int, SSL_library_init, void, DUMMYARG, return -1, return)
DEFINEFUNC(void, SSL_load_error_strings, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return 0, return)
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, const void *parg, parg, return -1, return)
+#endif
DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)
DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG)
DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG)
@@ -263,6 +266,7 @@ DEFINEFUNC3(DSA *, d2i_DSAPrivateKey, DSA **a, a, unsigned char **b, b, long c,
DEFINEFUNC(void, OPENSSL_add_all_algorithms_noconf, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
+DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)
#ifdef Q_OS_SYMBIAN
#define RESOLVEFUNC(func, ordinal, lib) \
@@ -586,6 +590,9 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(SSL_library_init, 137, libs.first )
RESOLVEFUNC(SSL_load_error_strings, 139, libs.first )
RESOLVEFUNC(SSL_new, 140, libs.first )
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+ RESOLVEFUNC(SSL_ctrl, 95, libs.first )
+#endif
RESOLVEFUNC(SSL_read, 143, libs.first )
RESOLVEFUNC(SSL_set_accept_state, 148, libs.first )
RESOLVEFUNC(SSL_set_bio, 149, libs.first )
@@ -600,6 +607,7 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(SSLv3_server_method, 197, libs.first )
RESOLVEFUNC(SSLv23_server_method, 191, libs.first )
RESOLVEFUNC(TLSv1_server_method, 200, libs.first )
+ RESOLVEFUNC(SSL_CTX_load_verify_locations, 34, libs.first )
RESOLVEFUNC(X509_NAME_oneline, 1830, libs.second )
RESOLVEFUNC(X509_PUBKEY_get, 1844, libs.second )
RESOLVEFUNC(X509_STORE_free, 1939, libs.second )
@@ -631,7 +639,7 @@ bool q_resolveOpenSslSymbols()
#endif
RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf, 1153, libs.second )
RESOLVEFUNC(OPENSSL_add_all_algorithms_conf, 1152, libs.second )
- RESOLVEFUNC(SSL_CTX_load_verify_locations, 34, libs.second )
+ RESOLVEFUNC(SSLeay, 1504, libs.second )
#else // Q_OS_SYMBIAN
#ifdef SSLEAY_MACROS
RESOLVEFUNC(ASN1_dup)
@@ -711,6 +719,9 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(SSL_library_init)
RESOLVEFUNC(SSL_load_error_strings)
RESOLVEFUNC(SSL_new)
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+ RESOLVEFUNC(SSL_ctrl)
+#endif
RESOLVEFUNC(SSL_read)
RESOLVEFUNC(SSL_set_accept_state)
RESOLVEFUNC(SSL_set_bio)
@@ -757,6 +768,7 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
RESOLVEFUNC(SSL_CTX_load_verify_locations)
+ RESOLVEFUNC(SSLeay)
#endif // Q_OS_SYMBIAN
symbolsResolved = true;
delete libs.first;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
index c05dfe11..49830ac 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -316,6 +316,9 @@ long q_SSL_get_verify_result(SSL *a);
int q_SSL_library_init();
void q_SSL_load_error_strings();
SSL *q_SSL_new(SSL_CTX *a);
+#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+long q_SSL_ctrl(SSL *ssl,int cmd, long larg, const void *parg);
+#endif
int q_SSL_read(SSL *a, void *b, int c);
void q_SSL_set_bio(SSL *a, BIO *b, BIO *c);
void q_SSL_set_accept_state(SSL *a);
@@ -413,6 +416,7 @@ DSA *q_d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
void q_OPENSSL_add_all_algorithms_noconf();
void q_OPENSSL_add_all_algorithms_conf();
int q_SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath);
+long q_SSLeay();
// Helper function
class QDateTime;
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
index 16a7d66..7cc9dc3 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h
@@ -259,7 +259,7 @@ static const GLuint QT_PMV_MATRIX_3_ATTR = 5;
class QGLEngineShaderProg;
-class QGLEngineSharedShaders
+class Q_OPENGL_EXPORT QGLEngineSharedShaders
{
Q_GADGET
public:
diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
index 1aacc96..fc8b9ef 100644
--- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h
+++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h
@@ -148,7 +148,7 @@ static const char* const qglslAffinePositionWithPatternBrushVertexShader
= qglslPositionWithPatternBrushVertexShader;
static const char* const qglslPatternBrushSrcFragmentShader = "\n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
uniform lowp vec4 patternColor; \n\
varying highp vec2 patternTexCoords;\n\
lowp vec4 srcPixel() \n\
@@ -183,7 +183,7 @@ static const char* const qglslAffinePositionWithLinearGradientBrushVertexShader
= qglslPositionWithLinearGradientBrushVertexShader;
static const char* const qglslLinearGradientBrushSrcFragmentShader = "\n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
varying mediump float index; \n\
lowp vec4 srcPixel() \n\
{ \n\
@@ -218,7 +218,7 @@ static const char* const qglslAffinePositionWithConicalGradientBrushVertexShader
static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\
#define INVERSE_2PI 0.1591549430918953358 \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
uniform mediump float angle; \n\
varying highp vec2 A; \n\
lowp vec4 srcPixel() \n\
@@ -260,7 +260,7 @@ static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader
= qglslPositionWithRadialGradientBrushVertexShader;
static const char* const qglslRadialGradientBrushSrcFragmentShader = "\n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
uniform highp float fmp2_m_radius2; \n\
uniform highp float inverse_2_fmp2_m_radius2; \n\
varying highp float b; \n\
@@ -304,14 +304,14 @@ static const char* const qglslAffinePositionWithTextureBrushVertexShader
// TODO: Special case POT textures which don't need this emulation
static const char* const qglslTextureBrushSrcFragmentShader = "\n\
varying highp vec2 brushTextureCoords; \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
lowp vec4 srcPixel() { \n\
return texture2D(brushTexture, fract(brushTextureCoords)); \n\
}\n";
#else
static const char* const qglslTextureBrushSrcFragmentShader = "\n\
varying highp vec2 brushTextureCoords; \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return texture2D(brushTexture, brushTextureCoords); \n\
@@ -321,7 +321,7 @@ static const char* const qglslTextureBrushSrcFragmentShader = "\n\
static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\n\
varying highp vec2 brushTextureCoords; \n\
uniform lowp vec4 patternColor; \n\
- uniform lowp sampler2D brushTexture; \n\
+ uniform sampler2D brushTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return patternColor * (1.0 - texture2D(brushTexture, brushTextureCoords).r); \n\
@@ -337,7 +337,7 @@ static const char* const qglslSolidBrushSrcFragmentShader = "\n\
static const char* const qglslImageSrcFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n"
"return texture2D(imageTexture, textureCoords); \n"
@@ -345,7 +345,7 @@ static const char* const qglslImageSrcFragmentShader = "\n\
static const char* const qglslCustomSrcFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return customShader(imageTexture, textureCoords); \n\
@@ -354,7 +354,7 @@ static const char* const qglslCustomSrcFragmentShader = "\n\
static const char* const qglslImageSrcWithPatternFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
uniform lowp vec4 patternColor; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\
@@ -362,7 +362,7 @@ static const char* const qglslImageSrcWithPatternFragmentShader = "\n\
static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\n\
varying highp vec2 textureCoords; \n\
- uniform lowp sampler2D imageTexture; \n\
+ uniform sampler2D imageTexture; \n\
lowp vec4 srcPixel() \n\
{ \n\
lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\
@@ -454,7 +454,7 @@ static const char* const qglslMainFragmentShader = "\n\
static const char* const qglslMaskFragmentShader = "\n\
varying highp vec2 textureCoords;\n\
- uniform lowp sampler2D maskTexture;\n\
+ uniform sampler2D maskTexture;\n\
lowp vec4 applyMask(lowp vec4 src) \n\
{\n\
lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
@@ -478,7 +478,7 @@ static const char* const qglslMaskFragmentShader = "\n\
static const char* const qglslRgbMaskFragmentShaderPass1 = "\n\
varying highp vec2 textureCoords;\n\
- uniform lowp sampler2D maskTexture;\n\
+ uniform sampler2D maskTexture;\n\
lowp vec4 applyMask(lowp vec4 src) \n\
{ \n\
lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
@@ -487,7 +487,7 @@ static const char* const qglslRgbMaskFragmentShaderPass1 = "\n\
static const char* const qglslRgbMaskFragmentShaderPass2 = "\n\
varying highp vec2 textureCoords;\n\
- uniform lowp sampler2D maskTexture;\n\
+ uniform sampler2D maskTexture;\n\
lowp vec4 applyMask(lowp vec4 src) \n\
{ \n\
lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index fa38b5d..a134078 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1349,11 +1349,14 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c
ensureActive();
d->transferMode(ImageDrawingMode);
+ QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption|QGLContext::CanFlipNativePixmapBindOption;
+#ifdef QGL_USE_TEXTURE_POOL
+ bindOptions |= QGLContext::TemporarilyCachedBindOption;
+#endif
+
glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
QGLTexture *texture =
- ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA,
- QGLContext::InternalBindOption
- | QGLContext::CanFlipNativePixmapBindOption);
+ ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, bindOptions);
GLfloat top = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.top()) : src.top();
GLfloat bottom = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.bottom()) : src.bottom();
@@ -1365,6 +1368,12 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c
d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
state()->renderHints & QPainter::SmoothPixmapTransform, texture->id);
d->drawTexture(dest, srcRect, pixmap.size(), isOpaque, isBitmap);
+
+ if (texture->options&QGLContext::TemporarilyCachedBindOption) {
+ // pixmap was temporarily cached as a QImage texture by pooling system
+ // and should be destroyed immediately
+ QGLTextureCache::instance()->remove(ctx, texture->id);
+ }
}
void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const QRectF& src,
@@ -1389,12 +1398,23 @@ void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const
glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
- QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
+ QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption;
+#ifdef QGL_USE_TEXTURE_POOL
+ bindOptions |= QGLContext::TemporarilyCachedBindOption;
+#endif
+
+ QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, bindOptions);
GLuint id = texture->id;
d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,
state()->renderHints & QPainter::SmoothPixmapTransform, id);
d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel());
+
+ if (texture->options&QGLContext::TemporarilyCachedBindOption) {
+ // image was temporarily cached by texture pooling system
+ // and should be destroyed immediately
+ QGLTextureCache::instance()->remove(ctx, texture->id);
+ }
}
void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index 08ae774..b512146 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -157,11 +157,16 @@ embedded {
}
symbian {
+ DEFINES += QGL_USE_TEXTURE_POOL
+ SOURCES -= qpixmapdata_gl.cpp
SOURCES += qgl_symbian.cpp \
+ qpixmapdata_poolgl.cpp \
qglpixelbuffer_egl.cpp \
- qgl_egl.cpp
+ qgl_egl.cpp \
+ qgltexturepool.cpp
- HEADERS += qgl_egl_p.h
+ HEADERS += qgl_egl_p.h \
+ qgltexturepool_p.h
contains(QT_CONFIG, freetype) {
DEFINES += QT_NO_FONTCONFIG
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 76621e9..9e39389 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -97,9 +97,12 @@
#include "qlibrary.h"
#include <qmutex.h>
-#ifdef QT_OPENGL_ES
+#if defined(QT_OPENGL_ES) && !defined(QT_NO_EGL)
#include <EGL/egl.h>
#endif
+#ifdef QGL_USE_TEXTURE_POOL
+#include <private/qgltexturepool_p.h>
+#endif
// #define QT_GL_CONTEXT_RESOURCE_DEBUG
@@ -2033,6 +2036,10 @@ struct DDSFormat {
the pixmap/image that it stems from, e.g. installing destruction
hooks in them.
+ \omitvalue TemporarilyCachedBindOption Used by paint engines on some
+ platforms to indicate that the pixmap or image texture is possibly
+ cached only temporarily and must be destroyed immediately after the use.
+
\omitvalue InternalBindOption
*/
@@ -2537,8 +2544,18 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
#endif
const QImage &constRef = img; // to avoid detach in bits()...
+#ifdef QGL_USE_TEXTURE_POOL
+ QGLTexturePool::instance()->createPermanentTexture(tx_id,
+ target,
+ 0, internalFormat,
+ img.width(), img.height(),
+ externalFormat,
+ pixel_type,
+ constRef.bits());
+#else
glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
pixel_type, constRef.bits());
+#endif
#if defined(QT_OPENGL_ES_2)
if (genMipmap)
glGenerateMipmap(target);
@@ -2577,7 +2594,6 @@ QGLTexture *QGLContextPrivate::textureCacheLookup(const qint64 key, GLenum targe
return 0;
}
-
/*! \internal */
QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options)
{
@@ -3310,8 +3326,10 @@ bool QGLContext::create(const QGLContext* shareContext)
QWidgetPrivate *wd = qt_widget_private(static_cast<QWidget *>(d->paintDevice));
wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer();
}
+#ifndef Q_WS_QPA //We do this in choose context->setupSharing()
if (d->sharing) // ok, we managed to share
QGLContextGroup::addShare(this, shareContext);
+#endif
return d->valid;
}
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index 9a51a77..ff73d88 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -333,6 +333,7 @@ public:
MemoryManagedBindOption = 0x0010, // internal flag
CanFlipNativePixmapBindOption = 0x0020, // internal flag
+ TemporarilyCachedBindOption = 0x0040, // internal flag
DefaultBindOption = LinearFilteringBindOption
| InvertedYBindOption
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 674d80d..d6b2d3b 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include <QtCore/qdebug.h>
#include <QtOpenGL/qgl.h>
#include <QtOpenGL/qglpixelbuffer.h>
#include "qgl_p.h"
@@ -195,6 +196,7 @@ void QGLContext::makeCurrent()
// PowerVR MBX/SGX chips needs to clear all buffers when starting to render
// a new frame, otherwise there will be a performance penalty to pay for
// each frame.
+ qDebug() << "Found SGX/MBX driver, enabling FullClearOnEveryFrame";
d->workaround_needsFullClearOnEveryFrame = true;
// Older PowerVR SGX drivers (like the one in the N900) have a
@@ -202,10 +204,31 @@ void QGLContext::makeCurrent()
// or GL_ALPHA texture bound to an FBO. The only way to
// identify that driver is to check the EGL version number for it.
const char *egl_version = eglQueryString(d->eglContext->display(), EGL_VERSION);
- if (egl_version && strstr(egl_version, "1.3"))
+
+ if (egl_version && strstr(egl_version, "1.3")) {
+ qDebug() << "Found v1.3 driver, enabling brokenFBOReadBack";
d->workaround_brokenFBOReadBack = true;
- else if (egl_version && strstr(egl_version, "1.4"))
+ } else if (egl_version && strstr(egl_version, "1.4")) {
+ qDebug() << "Found v1.4 driver, enabling brokenTexSubImage";
d->workaround_brokenTexSubImage = true;
+
+ // this is a bit complicated; 1.4 version SGX drivers from
+ // Nokia have fixed the brokenFBOReadBack problem, but
+ // official drivers from TI haven't, meaning that things
+ // like the beagleboard are broken unless we hack around it
+ // - but at the same time, we want to not reduce performance
+ // by not enabling this elsewhere.
+ //
+ // so, let's check for a Nokia-specific addon, and only
+ // enable if it isn't present.
+ // (see MeeGo bug #5616)
+ if (!QEgl::hasExtension("EGL_NOK_image_shared")) {
+ // no Nokia extension, this is probably a standard SGX
+ // driver, so enable the workaround
+ qDebug() << "Found non-Nokia v1.4 driver, enabling brokenFBOReadBack";
+ d->workaround_brokenFBOReadBack = true;
+ }
+ }
}
}
}
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index f7991b7..4bac1fb 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -324,20 +324,20 @@ void QGLWidget::setMouseTracking(bool enable)
bool QGLWidget::event(QEvent *e)
{
- Q_D(QGLWidget);
return QWidget::event(e);
}
void QGLWidget::resizeEvent(QResizeEvent *e)
{
Q_D(QGLWidget);
+
+ QWidget::resizeEvent(e);
if (!isValid())
return;
makeCurrent();
if (!d->glcx->initialized())
glInit();
resizeGL(width(), height());
- return QWidget::resizeEvent(e);
}
diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp
index a9e2248..2978514 100644
--- a/src/opengl/qgl_symbian.cpp
+++ b/src/opengl/qgl_symbian.cpp
@@ -52,6 +52,7 @@
#include <private/qwidget_p.h> // to access QWExtra
#include "qgl_egl_p.h"
#include "qpixmapdata_gl_p.h"
+#include "qgltexturepool_p.h"
#include "qcolormap.h"
#include <QDebug>
diff --git a/src/opengl/qgltexturepool.cpp b/src/opengl/qgltexturepool.cpp
new file mode 100644
index 0000000..61a88c3
--- /dev/null
+++ b/src/opengl/qgltexturepool.cpp
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** 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 "qgltexturepool_p.h"
+#include "qpixmapdata_gl_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget();
+
+static QGLTexturePool *qt_gl_texture_pool = 0;
+
+class QGLTexturePoolPrivate
+{
+public:
+ QGLTexturePoolPrivate() : lruFirst(0), lruLast(0) {}
+
+ QGLPixmapData *lruFirst;
+ QGLPixmapData *lruLast;
+};
+
+QGLTexturePool::QGLTexturePool()
+ : d_ptr(new QGLTexturePoolPrivate())
+{
+}
+
+QGLTexturePool::~QGLTexturePool()
+{
+}
+
+QGLTexturePool *QGLTexturePool::instance()
+{
+ if (!qt_gl_texture_pool)
+ qt_gl_texture_pool = new QGLTexturePool();
+ return qt_gl_texture_pool;
+}
+
+GLuint QGLTexturePool::createTextureForPixmap(GLenum target,
+ GLint level,
+ GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ QGLPixmapData *data)
+{
+ GLuint texture;
+ glGenTextures(1, &texture);
+ glBindTexture(target, texture);
+ do {
+ glTexImage2D(target, level, internalformat, width, height, 0, format, type, 0);
+ GLenum error = glGetError();
+ if (error == GL_NO_ERROR) {
+ if (data)
+ moveToHeadOfLRU(data);
+ return texture;
+ } else if (error != GL_OUT_OF_MEMORY) {
+ qWarning("QGLTexturePool: cannot create temporary texture because of invalid params");
+ return 0;
+ }
+ } while (reclaimSpace(internalformat, width, height, format, type, data));
+ qWarning("QGLTexturePool: cannot reclaim sufficient space for a %dx%d pixmap",
+ width, height);
+ return 0;
+}
+
+bool QGLTexturePool::createPermanentTexture(GLuint texture,
+ GLenum target,
+ GLint level,
+ GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ const GLvoid *data)
+{
+ glBindTexture(target, texture);
+ do {
+ glTexImage2D(target, level, internalformat, width, height, 0, format, type, data);
+
+ GLenum error = glGetError();
+ if (error == GL_NO_ERROR) {
+ return true;
+ } else if (error != GL_OUT_OF_MEMORY) {
+ qWarning("QGLTexturePool: cannot create permanent texture because of invalid params");
+ return false;
+ }
+ } while (reclaimSpace(internalformat, width, height, format, type, 0));
+ qWarning("QGLTexturePool: cannot reclaim sufficient space for a %dx%d pixmap",
+ width, height);
+ return 0;
+}
+
+void QGLTexturePool::releaseTexture(QGLPixmapData *data, GLuint texture)
+{
+ // Very simple strategy at the moment: just destroy the texture.
+ if (data)
+ removeFromLRU(data);
+
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ glDeleteTextures(1, &texture);
+}
+
+void QGLTexturePool::useTexture(QGLPixmapData *data)
+{
+ moveToHeadOfLRU(data);
+}
+
+void QGLTexturePool::detachTexture(QGLPixmapData *data)
+{
+ removeFromLRU(data);
+}
+
+bool QGLTexturePool::reclaimSpace(GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ QGLPixmapData *data)
+{
+ Q_UNUSED(internalformat); // For future use in picking the best texture to eject.
+ Q_UNUSED(width);
+ Q_UNUSED(height);
+ Q_UNUSED(format);
+ Q_UNUSED(type);
+
+ bool succeeded = false;
+ bool wasInLRU = false;
+ if (data) {
+ wasInLRU = data->inLRU;
+ moveToHeadOfLRU(data);
+ }
+
+ QGLPixmapData *lrudata = pixmapLRU();
+ if (lrudata && lrudata != data) {
+ lrudata->reclaimTexture();
+ succeeded = true;
+ }
+
+ if (data && !wasInLRU)
+ removeFromLRU(data);
+
+ return succeeded;
+}
+
+void QGLTexturePool::hibernate()
+{
+ Q_D(QGLTexturePool);
+ QGLPixmapData *pd = d->lruLast;
+ while (pd) {
+ QGLPixmapData *prevLRU = pd->prevLRU;
+ pd->inTexturePool = false;
+ pd->inLRU = false;
+ pd->nextLRU = 0;
+ pd->prevLRU = 0;
+ pd->hibernate();
+ pd = prevLRU;
+ }
+ d->lruFirst = 0;
+ d->lruLast = 0;
+}
+
+void QGLTexturePool::moveToHeadOfLRU(QGLPixmapData *data)
+{
+ Q_D(QGLTexturePool);
+ if (data->inLRU) {
+ if (!data->prevLRU)
+ return; // Already at the head of the list.
+ removeFromLRU(data);
+ }
+ data->inLRU = true;
+ data->nextLRU = d->lruFirst;
+ data->prevLRU = 0;
+ if (d->lruFirst)
+ d->lruFirst->prevLRU = data;
+ else
+ d->lruLast = data;
+ d->lruFirst = data;
+}
+
+void QGLTexturePool::removeFromLRU(QGLPixmapData *data)
+{
+ Q_D(QGLTexturePool);
+ if (!data->inLRU)
+ return;
+ if (data->nextLRU)
+ data->nextLRU->prevLRU = data->prevLRU;
+ else
+ d->lruLast = data->prevLRU;
+ if (data->prevLRU)
+ data->prevLRU->nextLRU = data->nextLRU;
+ else
+ d->lruFirst = data->nextLRU;
+ data->inLRU = false;
+}
+
+QGLPixmapData *QGLTexturePool::pixmapLRU()
+{
+ Q_D(QGLTexturePool);
+ return d->lruLast;
+}
+
+QT_END_NAMESPACE
diff --git a/src/opengl/qgltexturepool_p.h b/src/opengl/qgltexturepool_p.h
new file mode 100644
index 0000000..8b6f726
--- /dev/null
+++ b/src/opengl/qgltexturepool_p.h
@@ -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 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 QGLTEXTUREPOOL_P_H
+#define QGLTEXTUREPOOL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgl.h"
+#include <QtCore/qscopedpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGLPixmapData;
+class QGLTexturePoolPrivate;
+
+class QGLTexturePool
+{
+public:
+ QGLTexturePool();
+ virtual ~QGLTexturePool();
+
+ static QGLTexturePool *instance();
+
+ // Create a new texture with the specified parameters and associate
+ // it with "data". The QGLPixmapData will be notified when the
+ // texture needs to be reclaimed by the pool.
+ //
+ // This function will call reclaimSpace() when texture creation fails.
+ GLuint createTextureForPixmap(GLenum target,
+ GLint level,
+ GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ QGLPixmapData *data);
+
+ // Create a permanent texture with the specified parameters.
+ // If there is insufficient space for the texture,
+ // then this function will call reclaimSpace() and try again.
+ //
+ // The caller is responsible for calling glDeleteTextures()
+ // when it no longer needs the texture, as the texture is not
+ // recorded in the texture pool.
+ bool createPermanentTexture(GLuint texture,
+ GLenum target,
+ GLint level,
+ GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ const GLvoid *data);
+
+ // Release a texture that is no longer required.
+ void releaseTexture(QGLPixmapData *data, GLuint texture);
+
+ // Notify the pool that a QGLPixmapData object is using
+ // an texture again. This allows the pool to move the texture
+ // within a least-recently-used list of QGLPixmapData objects.
+ void useTexture(QGLPixmapData *data);
+
+ // Notify the pool that the texture associated with a
+ // QGLPixmapData is being detached from the pool. The caller
+ // will become responsible for calling glDeleteTextures().
+ void detachTexture(QGLPixmapData *data);
+
+ // Reclaim space for an image allocation with the specified parameters.
+ // Returns true if space was reclaimed, or false if there is no
+ // further space that can be reclaimed. The "data" parameter
+ // indicates the pixmap that is trying to obtain space which should
+ // not itself be reclaimed.
+ bool reclaimSpace(GLint internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ QGLPixmapData *data);
+
+ // Hibernate the image pool because the context is about to be
+ // destroyed. All textures left in the pool should be released.
+ void hibernate();
+
+protected:
+ // Helper functions for managing the LRU list of QGLPixmapData objects.
+ void moveToHeadOfLRU(QGLPixmapData *data);
+ void removeFromLRU(QGLPixmapData *data);
+ QGLPixmapData *pixmapLRU();
+
+private:
+ QScopedPointer<QGLTexturePoolPrivate> d_ptr;
+
+ Q_DECLARE_PRIVATE(QGLTexturePool)
+ Q_DISABLE_COPY(QGLTexturePool)
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp
index 3574756..0aa3c2e 100644
--- a/src/opengl/qgraphicssystem_gl.cpp
+++ b/src/opengl/qgraphicssystem_gl.cpp
@@ -57,6 +57,10 @@
#include <QtGui/private/qapplication_p.h>
#endif
+#ifdef QGL_USE_TEXTURE_POOL
+#include "private/qgltexturepool_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
extern QGLWidget *qt_gl_getShareWidget();
@@ -100,6 +104,11 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
return new QGLWindowSurface(widget);
}
-
+#ifdef QGL_USE_TEXTURE_POOL
+void QGLGraphicsSystem::releaseCachedResources()
+{
+ QGLTexturePool::instance()->hibernate();
+}
+#endif
QT_END_NAMESPACE
diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h
index 4630da1..5829dcc 100644
--- a/src/opengl/qgraphicssystem_gl_p.h
+++ b/src/opengl/qgraphicssystem_gl_p.h
@@ -66,6 +66,10 @@ public:
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QWindowSurface *createWindowSurface(QWidget *widget) const;
+
+#ifdef QGL_USE_TEXTURE_POOL
+ void releaseCachedResources();
+#endif
private:
bool m_useX11GL;
};
diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h
index a4066fd..55cc29d 100644
--- a/src/opengl/qpixmapdata_gl_p.h
+++ b/src/opengl/qpixmapdata_gl_p.h
@@ -66,6 +66,12 @@ class QGLFramebufferObject;
class QGLFramebufferObjectFormat;
class QGLPixmapData;
+#ifdef QGL_USE_TEXTURE_POOL
+void qt_gl_register_pixmap(QGLPixmapData *pd);
+void qt_gl_unregister_pixmap(QGLPixmapData *pd);
+void qt_gl_hibernate_pixmaps();
+#endif
+
class QGLFramebufferObjectPool
{
public:
@@ -129,7 +135,24 @@ public:
GLuint bind(bool copyBack = true) const;
QGLTexture *texture() const;
-#if defined(Q_OS_SYMBIAN)
+#ifdef QGL_USE_TEXTURE_POOL
+ void destroyTexture();
+ // Detach this image from the image pool.
+ void detachTextureFromPool();
+ // Release the GL resources associated with this pixmap and copy
+ // the pixmap's contents out of the GPU back into main memory.
+ // The GL resource will be automatically recreated the next time
+ // ensureCreated() is called. Does nothing if the pixmap cannot be
+ // hibernated for some reason (e.g. texture is shared with another
+ // process via a SgImage).
+ void hibernate();
+ // Called when the QGLTexturePool wants to reclaim this pixmap's
+ // texture objects to reuse storage.
+ void reclaimTexture();
+ void forceToImage();
+#endif
+
+#ifdef Q_OS_SYMBIAN
void* toNativeType(NativeType type);
void fromNativeType(void* pixmap, NativeType type);
#endif
@@ -176,6 +199,23 @@ private:
mutable QGLPixmapGLPaintDevice m_glDevice;
+#ifdef QGL_USE_TEXTURE_POOL
+ QGLPixmapData *nextLRU;
+ QGLPixmapData *prevLRU;
+ mutable bool inLRU;
+ mutable bool failedToAlloc;
+ mutable bool inTexturePool;
+
+ QGLPixmapData *next;
+ QGLPixmapData *prev;
+
+ friend class QGLTexturePool;
+
+ friend void qt_gl_register_pixmap(QGLPixmapData *pd);
+ friend void qt_gl_unregister_pixmap(QGLPixmapData *pd);
+ friend void qt_gl_hibernate_pixmaps();
+#endif
+
friend class QGLPixmapGLPaintDevice;
friend class QMeeGoPixmapData;
friend class QMeeGoLivePixmapData;
diff --git a/src/opengl/qpixmapdata_poolgl.cpp b/src/opengl/qpixmapdata_poolgl.cpp
new file mode 100644
index 0000000..f1220b1
--- /dev/null
+++ b/src/opengl/qpixmapdata_poolgl.cpp
@@ -0,0 +1,902 @@
+/****************************************************************************
+**
+** 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 QtOpenGL 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 "qpixmap.h"
+#include "qglframebufferobject.h"
+
+#include <private/qpaintengine_raster_p.h>
+
+#include "qpixmapdata_gl_p.h"
+
+#include <private/qgl_p.h>
+#include <private/qdrawhelper_p.h>
+#include <private/qimage_p.h>
+
+#include <private/qpaintengineex_opengl2_p.h>
+
+#include <qdesktopwidget.h>
+#include <qfile.h>
+#include <qimagereader.h>
+#include <qbuffer.h>
+
+#include "qgltexturepool_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget();
+
+/*!
+ \class QGLFramebufferObjectPool
+ \since 4.6
+
+ \brief The QGLFramebufferObject class provides a pool of framebuffer
+ objects for offscreen rendering purposes.
+
+ When requesting an FBO of a given size and format, an FBO of the same
+ format and a size at least as big as the requested size will be returned.
+
+ \internal
+*/
+
+static inline int areaDiff(const QSize &size, const QGLFramebufferObject *fbo)
+{
+ return qAbs(size.width() * size.height() - fbo->width() * fbo->height());
+}
+
+extern int qt_next_power_of_two(int v);
+
+static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz)
+{
+#ifdef QT_OPENGL_ES_2
+ QSize rounded(qt_next_power_of_two(sz.width()), qt_next_power_of_two(sz.height()));
+ if (rounded.width() * rounded.height() < 1.20 * sz.width() * sz.height())
+ return rounded;
+#endif
+ return sz;
+}
+
+
+QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat, bool strictSize)
+{
+ QGLFramebufferObject *chosen = 0;
+ QGLFramebufferObject *candidate = 0;
+ for (int i = 0; !chosen && i < m_fbos.size(); ++i) {
+ QGLFramebufferObject *fbo = m_fbos.at(i);
+
+ if (strictSize) {
+ if (fbo->size() == requestSize && fbo->format() == requestFormat) {
+ chosen = fbo;
+ break;
+ } else {
+ continue;
+ }
+ }
+
+ if (fbo->format() == requestFormat) {
+ // choose the fbo with a matching format and the closest size
+ if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo))
+ candidate = fbo;
+ }
+
+ if (candidate) {
+ m_fbos.removeOne(candidate);
+
+ const QSize fboSize = candidate->size();
+ QSize sz = fboSize;
+
+ if (sz.width() < requestSize.width())
+ sz.setWidth(qMax(requestSize.width(), qRound(sz.width() * 1.5)));
+ if (sz.height() < requestSize.height())
+ sz.setHeight(qMax(requestSize.height(), qRound(sz.height() * 1.5)));
+
+ // wasting too much space?
+ if (sz.width() * sz.height() > requestSize.width() * requestSize.height() * 4)
+ sz = requestSize;
+
+ if (sz != fboSize) {
+ delete candidate;
+ candidate = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(sz), requestFormat);
+ }
+
+ chosen = candidate;
+ }
+ }
+
+ if (!chosen) {
+ if (strictSize)
+ chosen = new QGLFramebufferObject(requestSize, requestFormat);
+ else
+ chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat);
+ }
+
+ if (!chosen->isValid()) {
+ delete chosen;
+ chosen = 0;
+ }
+
+ return chosen;
+}
+
+void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo)
+{
+ if (fbo)
+ m_fbos << fbo;
+}
+
+
+QPaintEngine* QGLPixmapGLPaintDevice::paintEngine() const
+{
+ return data->paintEngine();
+}
+
+void QGLPixmapGLPaintDevice::beginPaint()
+{
+ if (!data->isValid())
+ return;
+
+ // QGLPaintDevice::beginPaint will store the current binding and replace
+ // it with m_thisFBO:
+ m_thisFBO = data->m_renderFbo->handle();
+ QGLPaintDevice::beginPaint();
+
+ Q_ASSERT(data->paintEngine()->type() == QPaintEngine::OpenGL2);
+
+ // QPixmap::fill() is deferred until now, where we actually need to do the fill:
+ if (data->needsFill()) {
+ const QColor &c = data->fillColor();
+ float alpha = c.alphaF();
+ glDisable(GL_SCISSOR_TEST);
+ glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+ else if (!data->isUninitialized()) {
+ // If the pixmap (GL Texture) has valid content (it has been
+ // uploaded from an image or rendered into before), we need to
+ // copy it from the texture to the render FBO.
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_BLEND);
+
+#if !defined(QT_OPENGL_ES_2)
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, data->width(), data->height(), 0, -999999, 999999);
+#endif
+
+ glViewport(0, 0, data->width(), data->height());
+
+ // Pass false to bind so it doesn't copy the FBO into the texture!
+ context()->drawTexture(QRect(0, 0, data->width(), data->height()), data->bind(false));
+ }
+}
+
+void QGLPixmapGLPaintDevice::endPaint()
+{
+ if (!data->isValid())
+ return;
+
+ data->copyBackFromRenderFbo(false);
+
+ // Base's endPaint will restore the previous FBO binding
+ QGLPaintDevice::endPaint();
+
+ qgl_fbo_pool()->release(data->m_renderFbo);
+ data->m_renderFbo = 0;
+}
+
+QGLContext* QGLPixmapGLPaintDevice::context() const
+{
+ data->ensureCreated();
+ return data->m_ctx;
+}
+
+QSize QGLPixmapGLPaintDevice::size() const
+{
+ return data->size();
+}
+
+bool QGLPixmapGLPaintDevice::alphaRequested() const
+{
+ return data->m_hasAlpha;
+}
+
+void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d)
+{
+ data = d;
+}
+
+static int qt_gl_pixmap_serial = 0;
+
+QGLPixmapData::QGLPixmapData(PixelType type)
+ : QPixmapData(type, OpenGLClass)
+ , m_renderFbo(0)
+ , m_engine(0)
+ , m_ctx(0)
+ , m_dirty(false)
+ , m_hasFillColor(false)
+ , m_hasAlpha(false)
+ , inLRU(false)
+ , failedToAlloc(false)
+ , inTexturePool(false)
+{
+ setSerialNumber(++qt_gl_pixmap_serial);
+ m_glDevice.setPixmapData(this);
+
+ qt_gl_register_pixmap(this);
+}
+
+QGLPixmapData::~QGLPixmapData()
+{
+ delete m_engine;
+
+ destroyTexture();
+ qt_gl_unregister_pixmap(this);
+}
+
+void QGLPixmapData::destroyTexture()
+{
+ if (inTexturePool) {
+ QGLTexturePool *pool = QGLTexturePool::instance();
+ if (m_texture.id)
+ pool->releaseTexture(this, m_texture.id);
+ } else {
+ if (m_texture.id) {
+ QGLWidget *shareWidget = qt_gl_share_widget();
+ if (shareWidget) {
+ QGLShareContextScope ctx(shareWidget->context());
+ glDeleteTextures(1, &m_texture.id);
+ }
+ }
+ }
+ m_texture.id = 0;
+ inTexturePool = false;
+}
+
+QPixmapData *QGLPixmapData::createCompatiblePixmapData() const
+{
+ return new QGLPixmapData(pixelType());
+}
+
+bool QGLPixmapData::isValid() const
+{
+ return w > 0 && h > 0;
+}
+
+bool QGLPixmapData::isValidContext(const QGLContext *ctx) const
+{
+ if (ctx == m_ctx)
+ return true;
+
+ const QGLContext *share_ctx = qt_gl_share_widget()->context();
+ return ctx == share_ctx || QGLContext::areSharing(ctx, share_ctx);
+}
+
+void QGLPixmapData::resize(int width, int height)
+{
+ if (width == w && height == h)
+ return;
+
+ if (width <= 0 || height <= 0) {
+ width = 0;
+ height = 0;
+ }
+
+ w = width;
+ h = height;
+ is_null = (w <= 0 || h <= 0);
+ d = pixelType() == QPixmapData::PixmapType ? 32 : 1;
+
+ destroyTexture();
+
+ m_source = QImage();
+ m_dirty = isValid();
+ setSerialNumber(++qt_gl_pixmap_serial);
+}
+
+void QGLPixmapData::ensureCreated() const
+{
+ if (!m_dirty)
+ return;
+
+ m_dirty = false;
+
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ m_ctx = ctx;
+
+ const GLenum internal_format = m_hasAlpha ? GL_RGBA : GL_RGB;
+#ifdef QT_OPENGL_ES_2
+ const GLenum external_format = internal_format;
+#else
+ const GLenum external_format = qt_gl_preferredTextureFormat();
+#endif
+ const GLenum target = GL_TEXTURE_2D;
+
+ m_texture.options &= ~QGLContext::MemoryManagedBindOption;
+
+ if (!m_texture.id) {
+ m_texture.id = QGLTexturePool::instance()->createTextureForPixmap(
+ target,
+ 0, internal_format,
+ w, h,
+ external_format,
+ GL_UNSIGNED_BYTE,
+ const_cast<QGLPixmapData*>(this));
+ if (!m_texture.id) {
+ failedToAlloc = true;
+ return;
+ }
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ inTexturePool = true;
+ } else if (inTexturePool) {
+ glBindTexture(target, m_texture.id);
+ QGLTexturePool::instance()->useTexture(const_cast<QGLPixmapData*>(this));
+ }
+
+ if (!m_source.isNull() && m_texture.id) {
+ if (external_format == GL_RGB) {
+ const QImage tx = m_source.convertToFormat(QImage::Format_RGB888).mirrored(false, true);
+
+ glBindTexture(target, m_texture.id);
+ glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
+ GL_UNSIGNED_BYTE, tx.bits());
+ } else {
+ // do byte swizzling ARGB -> RGBA
+ const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format);
+ glBindTexture(target, m_texture.id);
+ glTexSubImage2D(target, 0, 0, 0, w, h, external_format,
+ GL_UNSIGNED_BYTE, tx.bits());
+ }
+
+ if (useFramebufferObjects())
+ m_source = QImage();
+ }
+}
+
+
+void QGLPixmapData::fromImage(const QImage &image,
+ Qt::ImageConversionFlags flags)
+{
+ QImage img = image;
+ createPixmapForImage(img, flags, false);
+}
+
+void QGLPixmapData::fromImageReader(QImageReader *imageReader,
+ Qt::ImageConversionFlags flags)
+{
+ QImage image = imageReader->read();
+ if (image.isNull())
+ return;
+
+ createPixmapForImage(image, flags, true);
+}
+
+bool QGLPixmapData::fromFile(const QString &filename, const char *format,
+ Qt::ImageConversionFlags flags)
+{
+ if (pixelType() == QPixmapData::BitmapType)
+ return QPixmapData::fromFile(filename, format, flags);
+ QFile file(filename);
+ if (file.open(QIODevice::ReadOnly)) {
+ QByteArray data = file.peek(64);
+ bool alpha;
+ if (m_texture.canBindCompressedTexture
+ (data.constData(), data.size(), format, &alpha)) {
+ resize(0, 0);
+ data = file.readAll();
+ file.close();
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QSize size = m_texture.bindCompressedTexture
+ (data.constData(), data.size(), format);
+ if (!size.isEmpty()) {
+ w = size.width();
+ h = size.height();
+ is_null = false;
+ d = 32;
+ m_hasAlpha = alpha;
+ m_source = QImage();
+ m_dirty = isValid();
+ return true;
+ }
+ return false;
+ }
+ }
+
+ QImage image = QImageReader(filename, format).read();
+ if (image.isNull())
+ return false;
+
+ createPixmapForImage(image, flags, true);
+
+ return !isNull();
+}
+
+bool QGLPixmapData::fromData(const uchar *buffer, uint len, const char *format,
+ Qt::ImageConversionFlags flags)
+{
+ bool alpha;
+ const char *buf = reinterpret_cast<const char *>(buffer);
+ if (m_texture.canBindCompressedTexture(buf, int(len), format, &alpha)) {
+ resize(0, 0);
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ QSize size = m_texture.bindCompressedTexture(buf, int(len), format);
+ if (!size.isEmpty()) {
+ w = size.width();
+ h = size.height();
+ is_null = false;
+ d = 32;
+ m_hasAlpha = alpha;
+ m_source = QImage();
+ m_dirty = isValid();
+ return true;
+ }
+ }
+
+ QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer), len);
+ QBuffer b(&a);
+ b.open(QIODevice::ReadOnly);
+ QImage image = QImageReader(&b, format).read();
+ if (image.isNull())
+ return false;
+
+ createPixmapForImage(image, flags, true);
+
+ return !isNull();
+}
+
+/*!
+ out-of-place conversion (inPlace == false) will always detach()
+ */
+void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
+{
+ if (image.size() == QSize(w, h))
+ setSerialNumber(++qt_gl_pixmap_serial);
+
+ resize(image.width(), image.height());
+
+ if (pixelType() == BitmapType) {
+ m_source = image.convertToFormat(QImage::Format_MonoLSB);
+
+ } else {
+ QImage::Format format = QImage::Format_RGB32;
+ if (qApp->desktop()->depth() == 16)
+ format = QImage::Format_RGB16;
+
+ if (image.hasAlphaChannel()
+ && ((flags & Qt::NoOpaqueDetection)
+ || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()))
+ format = QImage::Format_ARGB32_Premultiplied;
+
+ if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
+ m_source = image;
+ } else {
+ m_source = image.convertToFormat(format);
+
+ // convertToFormat won't detach the image if format stays the same.
+ if (image.format() == format)
+ m_source.detach();
+ }
+ }
+
+ m_dirty = true;
+ m_hasFillColor = false;
+
+ m_hasAlpha = m_source.hasAlphaChannel();
+ w = image.width();
+ h = image.height();
+ is_null = (w <= 0 || h <= 0);
+ d = m_source.depth();
+
+ destroyTexture();
+}
+
+bool QGLPixmapData::scroll(int dx, int dy, const QRect &rect)
+{
+ Q_UNUSED(dx);
+ Q_UNUSED(dy);
+ Q_UNUSED(rect);
+ return false;
+}
+
+void QGLPixmapData::copy(const QPixmapData *data, const QRect &rect)
+{
+ if (data->classId() != QPixmapData::OpenGLClass || !static_cast<const QGLPixmapData *>(data)->useFramebufferObjects()) {
+ QPixmapData::copy(data, rect);
+ return;
+ }
+
+ const QGLPixmapData *other = static_cast<const QGLPixmapData *>(data);
+ if (other->m_renderFbo) {
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+
+ resize(rect.width(), rect.height());
+ m_hasAlpha = other->m_hasAlpha;
+ ensureCreated();
+
+ if (!ctx->d_ptr->fbo)
+ glGenFramebuffers(1, &ctx->d_ptr->fbo);
+
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo);
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, m_texture.id, 0);
+
+ if (!other->m_renderFbo->isBound())
+ glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, other->m_renderFbo->handle());
+
+ glDisable(GL_SCISSOR_TEST);
+ if (ctx->d_ptr->active_engine && ctx->d_ptr->active_engine->type() == QPaintEngine::OpenGL2)
+ static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine)->invalidateState();
+
+ glBlitFramebufferEXT(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(),
+ 0, 0, w, h,
+ GL_COLOR_BUFFER_BIT,
+ GL_NEAREST);
+
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
+ } else {
+ QPixmapData::copy(data, rect);
+ }
+}
+
+void QGLPixmapData::fill(const QColor &color)
+{
+ if (!isValid())
+ return;
+
+ bool hasAlpha = color.alpha() != 255;
+ if (hasAlpha && !m_hasAlpha) {
+ if (m_texture.id) {
+ destroyTexture();
+ m_dirty = true;
+ }
+ m_hasAlpha = color.alpha() != 255;
+ }
+
+ if (useFramebufferObjects()) {
+ m_source = QImage();
+ m_hasFillColor = true;
+ m_fillColor = color;
+ } else {
+
+ if (m_source.isNull()) {
+ m_fillColor = color;
+ m_hasFillColor = true;
+
+ } else if (m_source.depth() == 32) {
+ m_source.fill(PREMUL(color.rgba()));
+
+ } else if (m_source.depth() == 1) {
+ if (color == Qt::color1)
+ m_source.fill(1);
+ else
+ m_source.fill(0);
+ }
+ }
+}
+
+bool QGLPixmapData::hasAlphaChannel() const
+{
+ return m_hasAlpha;
+}
+
+QImage QGLPixmapData::fillImage(const QColor &color) const
+{
+ QImage img;
+ if (pixelType() == BitmapType) {
+ img = QImage(w, h, QImage::Format_MonoLSB);
+
+ img.setColorCount(2);
+ img.setColor(0, QColor(Qt::color0).rgba());
+ img.setColor(1, QColor(Qt::color1).rgba());
+
+ if (color == Qt::color1)
+ img.fill(1);
+ else
+ img.fill(0);
+ } else {
+ img = QImage(w, h,
+ m_hasAlpha
+ ? QImage::Format_ARGB32_Premultiplied
+ : QImage::Format_RGB32);
+ img.fill(PREMUL(color.rgba()));
+ }
+ return img;
+}
+
+extern QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha);
+
+QImage QGLPixmapData::toImage() const
+{
+ if (!isValid())
+ return QImage();
+
+ if (m_renderFbo) {
+ copyBackFromRenderFbo(true);
+ } else if (!m_source.isNull()) {
+ QImageData *data = const_cast<QImage &>(m_source).data_ptr();
+ if (data->paintEngine && data->paintEngine->isActive()
+ && data->paintEngine->paintDevice() == &m_source)
+ {
+ return m_source.copy();
+ }
+ return m_source;
+ } else if (m_dirty || m_hasFillColor) {
+ return fillImage(m_fillColor);
+ } else {
+ ensureCreated();
+ }
+
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ glBindTexture(GL_TEXTURE_2D, m_texture.id);
+ return qt_gl_read_texture(QSize(w, h), true, true);
+}
+
+struct TextureBuffer
+{
+ QGLFramebufferObject *fbo;
+ QGL2PaintEngineEx *engine;
+};
+
+Q_GLOBAL_STATIC(QGLFramebufferObjectPool, _qgl_fbo_pool)
+QGLFramebufferObjectPool* qgl_fbo_pool()
+{
+ return _qgl_fbo_pool();
+}
+
+void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const
+{
+ if (!isValid())
+ return;
+
+ m_hasFillColor = false;
+
+ const QGLContext *share_ctx = qt_gl_share_widget()->context();
+ QGLShareContextScope ctx(share_ctx);
+
+ ensureCreated();
+
+ if (!ctx->d_ptr->fbo)
+ glGenFramebuffers(1, &ctx->d_ptr->fbo);
+
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo);
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, m_texture.id, 0);
+
+ const int x0 = 0;
+ const int x1 = w;
+ const int y0 = 0;
+ const int y1 = h;
+
+ if (!m_renderFbo->isBound())
+ glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_renderFbo->handle());
+
+ glDisable(GL_SCISSOR_TEST);
+
+ glBlitFramebufferEXT(x0, y0, x1, y1,
+ x0, y0, x1, y1,
+ GL_COLOR_BUFFER_BIT,
+ GL_NEAREST);
+
+ if (keepCurrentFboBound) {
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo);
+ } else {
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_renderFbo->handle());
+ ctx->d_ptr->current_fbo = m_renderFbo->handle();
+ }
+}
+
+bool QGLPixmapData::useFramebufferObjects() const
+{
+#ifdef Q_OS_SYMBIAN
+ // We don't want to use FBOs on Symbian
+ return false;
+#else
+ return QGLFramebufferObject::hasOpenGLFramebufferObjects()
+ && QGLFramebufferObject::hasOpenGLFramebufferBlit()
+ && qt_gl_preferGL2Engine()
+ && (w * h > 32*32); // avoid overhead of FBOs for small pixmaps
+#endif
+}
+
+QPaintEngine* QGLPixmapData::paintEngine() const
+{
+ if (!isValid())
+ return 0;
+
+ if (m_renderFbo)
+ return m_engine;
+
+ if (useFramebufferObjects()) {
+ extern QGLWidget* qt_gl_share_widget();
+
+ if (!QGLContext::currentContext())
+ qt_gl_share_widget()->makeCurrent();
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
+
+ QGLFramebufferObjectFormat format;
+ format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ format.setSamples(4);
+ format.setInternalTextureFormat(GLenum(m_hasAlpha ? GL_RGBA : GL_RGB));
+
+ m_renderFbo = qgl_fbo_pool()->acquire(size(), format);
+
+ if (m_renderFbo) {
+ if (!m_engine)
+ m_engine = new QGL2PaintEngineEx;
+ return m_engine;
+ }
+
+ qWarning() << "Failed to create pixmap texture buffer of size " << size() << ", falling back to raster paint engine";
+ }
+
+ // If the application wants to paint into the QPixmap, we first
+ // force it to QImage format and then paint into that.
+ // This is simpler than juggling multiple GL contexts.
+ const_cast<QGLPixmapData *>(this)->forceToImage();
+
+ if (m_hasFillColor) {
+ m_source.fill(PREMUL(m_fillColor.rgba()));
+ m_hasFillColor = false;
+ }
+ return m_source.paintEngine();
+}
+
+extern QRgb qt_gl_convertToGLFormat(QRgb src_pixel, GLenum texture_format);
+
+// If copyBack is true, bind will copy the contents of the render
+// FBO to the texture (which is not bound to the texture, as it's
+// a multisample FBO).
+GLuint QGLPixmapData::bind(bool copyBack) const
+{
+ if (m_renderFbo && copyBack) {
+ copyBackFromRenderFbo(true);
+ } else {
+ ensureCreated();
+ }
+
+ GLuint id = m_texture.id;
+ glBindTexture(GL_TEXTURE_2D, id);
+
+ if (m_hasFillColor) {
+ if (!useFramebufferObjects()) {
+ m_source = QImage(w, h, QImage::Format_ARGB32_Premultiplied);
+ m_source.fill(PREMUL(m_fillColor.rgba()));
+ }
+
+ m_hasFillColor = false;
+
+ GLenum format = qt_gl_preferredTextureFormat();
+ QImage tx(w, h, QImage::Format_ARGB32_Premultiplied);
+ tx.fill(qt_gl_convertToGLFormat(m_fillColor.rgba(), format));
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, GL_UNSIGNED_BYTE, tx.bits());
+ }
+
+ return id;
+}
+
+QGLTexture* QGLPixmapData::texture() const
+{
+ return &m_texture;
+}
+
+void QGLPixmapData::detachTextureFromPool()
+{
+ if (inTexturePool) {
+ QGLTexturePool::instance()->detachTexture(this);
+ inTexturePool = false;
+ }
+}
+
+void QGLPixmapData::hibernate()
+{
+ // If the texture was imported (e.g, from an SgImage under Symbian),
+ // then we cannot copy it back to main memory for storage.
+ if (m_texture.id && m_source.isNull())
+ return;
+
+ forceToImage();
+ destroyTexture();
+}
+
+void QGLPixmapData::reclaimTexture()
+{
+ if (!inTexturePool)
+ return;
+ forceToImage();
+ destroyTexture();
+}
+
+Q_GUI_EXPORT int qt_defaultDpiX();
+Q_GUI_EXPORT int qt_defaultDpiY();
+
+int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
+{
+ if (w == 0)
+ return 0;
+
+ switch (metric) {
+ case QPaintDevice::PdmWidth:
+ return w;
+ case QPaintDevice::PdmHeight:
+ return h;
+ case QPaintDevice::PdmNumColors:
+ return 0;
+ case QPaintDevice::PdmDepth:
+ return d;
+ case QPaintDevice::PdmWidthMM:
+ return qRound(w * 25.4 / qt_defaultDpiX());
+ case QPaintDevice::PdmHeightMM:
+ return qRound(h * 25.4 / qt_defaultDpiY());
+ case QPaintDevice::PdmDpiX:
+ case QPaintDevice::PdmPhysicalDpiX:
+ return qt_defaultDpiX();
+ case QPaintDevice::PdmDpiY:
+ case QPaintDevice::PdmPhysicalDpiY:
+ return qt_defaultDpiY();
+ default:
+ qWarning("QGLPixmapData::metric(): Invalid metric");
+ return 0;
+ }
+}
+
+// Force the pixmap data to be backed by some valid data.
+void QGLPixmapData::forceToImage()
+{
+ if (!isValid())
+ return;
+
+ if (m_source.isNull())
+ m_source = QImage(w, h, QImage::Format_ARGB32_Premultiplied);
+
+ m_dirty = true;
+}
+
+QGLPaintDevice *QGLPixmapData::glDevice() const
+{
+ return &m_glDevice;
+}
+
+QT_END_NAMESPACE
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index ea1f765..4ac7b22 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -181,17 +181,15 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
//
// QGLWindowSurface
//
-
#ifndef Q_WS_QPA
class QGLGlobalShareWidget
{
public:
- QGLGlobalShareWidget() : widget(0), initializing(false) {}
+ QGLGlobalShareWidget() : firstPixmap(0), widgetRefCount(0), widget(0), initializing(false) {}
QGLWidget *shareWidget() {
if (!initializing && !widget && !cleanedUp) {
initializing = true;
-
widget = new QGLWidget(QGLFormat(QGL::SingleBuffer | QGL::NoDepthBuffer | QGL::NoStencilBuffer));
widget->resize(1, 1);
@@ -227,6 +225,9 @@ public:
static bool cleanedUp;
+ QGLPixmapData *firstPixmap;
+ int widgetRefCount;
+
private:
QGLWidget *widget;
bool initializing;
@@ -274,6 +275,43 @@ const QGLContext *qt_gl_share_context()
#endif
}
+#ifdef QGL_USE_TEXTURE_POOL
+void qt_gl_register_pixmap(QGLPixmapData *pd)
+{
+ QGLGlobalShareWidget *shared = _qt_gl_share_widget();
+ pd->next = shared->firstPixmap;
+ pd->prev = 0;
+ if (shared->firstPixmap)
+ shared->firstPixmap->prev = pd;
+ shared->firstPixmap = pd;
+}
+
+void qt_gl_unregister_pixmap(QGLPixmapData *pd)
+{
+ if (pd->next)
+ pd->next->prev = pd->prev;
+ if (pd->prev) {
+ pd->prev->next = pd->next;
+ } else {
+ QGLGlobalShareWidget *shared = _qt_gl_share_widget();
+ if (shared)
+ shared->firstPixmap = pd->next;
+ }
+}
+
+void qt_gl_hibernate_pixmaps()
+{
+ QGLGlobalShareWidget *shared = _qt_gl_share_widget();
+
+ // Scan all QGLPixmapData objects in the system and hibernate them.
+ QGLPixmapData *pd = shared->firstPixmap;
+ while (pd != 0) {
+ pd->hibernate();
+ pd = pd->next;
+ }
+}
+#endif
+
struct QGLWindowSurfacePrivate
{
QGLFramebufferObject *fbo;
@@ -369,6 +407,27 @@ QGLWindowSurface::~QGLWindowSurface()
delete d_ptr->pb;
delete d_ptr->fbo;
delete d_ptr;
+
+ if (QGLGlobalShareWidget::cleanedUp)
+ return;
+
+ --(_qt_gl_share_widget()->widgetRefCount);
+
+#ifdef QGL_USE_TEXTURE_POOL
+ if (_qt_gl_share_widget()->widgetRefCount <= 0) {
+ // All of the widget window surfaces have been destroyed
+ // but we still have GL pixmaps active. Ask them to hibernate
+ // to free up GPU resources until a widget is shown again.
+ // This may eventually cause the EGLContext to be destroyed
+ // because nothing in the system needs a context, which will
+ // free up even more GPU resources.
+ qt_gl_hibernate_pixmaps();
+
+ // Destroy the context if necessary.
+ if (!qt_gl_share_widget()->context()->isSharing())
+ qt_destroy_gl_share_widget();
+ }
+#endif
}
void QGLWindowSurface::deleted(QObject *object)
@@ -418,6 +477,9 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
ctx->create(qt_gl_share_context());
+ if (widget != qt_gl_share_widget())
+ ++(_qt_gl_share_widget()->widgetRefCount);
+
#ifndef QT_NO_EGL
static bool checkedForNOKSwapRegion = false;
static bool haveNOKSwapRegion = false;
@@ -429,10 +491,10 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
if (haveNOKSwapRegion)
qDebug() << "Found EGL_NOK_swap_region2 extension. Using partial updates.";
}
-
- if (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED &&
- ! haveNOKSwapRegion)
- d_ptr->partialUpdateSupport = false; // Force full-screen updates
+ bool swapBehaviourPreserved = (ctx->d_func()->eglContext->configAttrib(EGL_SWAP_BEHAVIOR) != EGL_BUFFER_PRESERVED)
+ || (ctx->d_func()->eglContext->configAttrib(EGL_SURFACE_TYPE)&EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
+ if (!swapBehaviourPreserved && !haveNOKSwapRegion)
+ setPartialUpdateSupport(false); // Force full-screen updates
else
d_ptr->partialUpdateSupport = true;
#else
@@ -447,7 +509,9 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
voidPtrPtr = &widgetPrivate->extraData()->glContext;
d_ptr->contexts << ctxPtrPtr;
+#ifndef Q_OS_SYMBIAN
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
+#endif
}
QGLContext *QGLWindowSurface::context() const
@@ -946,8 +1010,9 @@ void QGLWindowSurface::updateGeometry() {
if (d_ptr->destructive_swap_buffers)
initializeOffscreenTexture(surfSize);
#endif
-
- qDebug() << "QGLWindowSurface: Using plain widget as window surface" << this;;
+#ifndef Q_OS_SYMBIAN
+ qDebug() << "QGLWindowSurface: Using plain widget as window surface" << this;
+#endif
d_ptr->ctx = ctx;
d_ptr->ctx->d_ptr->internal_context = true;
}
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
index 13eab7f..cb66695 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
@@ -59,10 +59,14 @@
#include "qmeegographicssystem.h"
#include "qmeegoextensions.h"
+#include <QTimer>
+
bool QMeeGoGraphicsSystem::surfaceWasCreated = false;
QHash <Qt::HANDLE, QPixmap*> QMeeGoGraphicsSystem::liveTexturePixmaps;
+QList<QMeeGoSwitchCallback> QMeeGoGraphicsSystem::switchCallbacks;
+
QMeeGoGraphicsSystem::QMeeGoGraphicsSystem()
{
qDebug("Using the meego graphics system");
@@ -74,6 +78,113 @@ QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem()
qt_destroy_gl_share_widget();
}
+class QMeeGoGraphicsSystemSwitchHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QMeeGoGraphicsSystemSwitchHandler();
+
+ void addWidget(QWidget *widget);
+ bool eventFilter(QObject *, QEvent *);
+
+ void handleMapNotify();
+
+private slots:
+ void removeWidget(QObject *object);
+ void switchToRaster();
+ void switchToMeeGo();
+
+private:
+ int visibleWidgets() const;
+
+private:
+ QList<QWidget *> m_widgets;
+};
+
+typedef bool(*QX11FilterFunction)(XEvent *event);
+Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func);
+
+static bool x11EventFilter(XEvent *event);
+
+QMeeGoGraphicsSystemSwitchHandler::QMeeGoGraphicsSystemSwitchHandler()
+{
+ qt_installX11EventFilter(x11EventFilter);
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::addWidget(QWidget *widget)
+{
+ if (widget != qt_gl_share_widget() && !m_widgets.contains(widget)) {
+ widget->installEventFilter(this);
+ connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(removeWidget(QObject *)));
+ m_widgets << widget;
+ }
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::handleMapNotify()
+{
+ if (m_widgets.isEmpty())
+ QTimer::singleShot(0, this, SLOT(switchToMeeGo()));
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::removeWidget(QObject *object)
+{
+ m_widgets.removeOne(static_cast<QWidget *>(object));
+ if (m_widgets.isEmpty())
+ QTimer::singleShot(0, this, SLOT(switchToRaster()));
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::switchToRaster()
+{
+ QMeeGoGraphicsSystem::switchToRaster();
+}
+
+void QMeeGoGraphicsSystemSwitchHandler::switchToMeeGo()
+{
+ QMeeGoGraphicsSystem::switchToMeeGo();
+}
+
+int QMeeGoGraphicsSystemSwitchHandler::visibleWidgets() const
+{
+ int count = 0;
+ for (int i = 0; i < m_widgets.size(); ++i)
+ count += m_widgets.at(i)->isVisible() && !(m_widgets.at(i)->windowState() & Qt::WindowMinimized);
+ return count;
+}
+
+bool QMeeGoGraphicsSystemSwitchHandler::eventFilter(QObject *object, QEvent *event)
+{
+ if (event->type() == QEvent::WindowStateChange) {
+ QWindowStateChangeEvent *change = static_cast<QWindowStateChangeEvent *>(event);
+ QWidget *widget = static_cast<QWidget *>(object);
+
+ Qt::WindowStates current = widget->windowState();
+ Qt::WindowStates old = change->oldState();
+
+ // did minimized flag change?
+ if ((current ^ old) & Qt::WindowMinimized) {
+ if (current & Qt::WindowMinimized) {
+ if (visibleWidgets() == 0)
+ QMeeGoGraphicsSystem::switchToRaster();
+ } else {
+ if (visibleWidgets() == 1)
+ QMeeGoGraphicsSystem::switchToMeeGo();
+ }
+ }
+ }
+
+ // resume processing of event
+ return false;
+}
+
+Q_GLOBAL_STATIC(QMeeGoGraphicsSystemSwitchHandler, switch_handler)
+
+bool x11EventFilter(XEvent *event)
+{
+ if (event->type == MapNotify)
+ switch_handler()->handleMapNotify();
+ return false;
+}
+
QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
{
QGLWidget *shareWidget = qt_gl_share_widget();
@@ -83,6 +194,9 @@ QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
QGLShareContextScope ctx(shareWidget->context());
+ if (QApplicationPrivate::instance()->graphics_system_name == QLatin1String("runtime"))
+ switch_handler()->addWidget(widget);
+
QMeeGoGraphicsSystem::surfaceWasCreated = true;
QWindowSurface *surface = new QGLWindowSurface(widget);
return surface;
@@ -203,18 +317,7 @@ QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h)
bool QMeeGoGraphicsSystem::meeGoRunning()
{
- if (! QApplicationPrivate::instance()) {
- qWarning("Application not running just yet... hard to know what system running!");
- return false;
- }
-
- QString name = QApplicationPrivate::instance()->graphics_system_name;
- if (name == "runtime") {
- QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
- name = rsystem->graphicsSystemName();
- }
-
- return (name == "meego");
+ return runningGraphicsSystemName() == "meego";
}
QPixmapData* QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format)
@@ -259,6 +362,69 @@ void QMeeGoGraphicsSystem::destroyFenceSync(void *fenceSync)
QMeeGoExtensions::eglDestroySyncKHR(QEgl::display(), fenceSync);
}
+QString QMeeGoGraphicsSystem::runningGraphicsSystemName()
+{
+ if (!QApplicationPrivate::instance()) {
+ qWarning("Querying graphics system but application not running yet!");
+ return QString();
+ }
+
+ QString name = QApplicationPrivate::instance()->graphics_system_name;
+ if (name == QLatin1String("runtime")) {
+ QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
+ name = rsystem->graphicsSystemName();
+ }
+
+ return name;
+}
+
+void QMeeGoGraphicsSystem::switchToMeeGo()
+{
+ if (meeGoRunning())
+ return;
+
+ if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
+ qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system.");
+ else {
+ triggerSwitchCallbacks(0, "meego");
+
+ QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
+ app->setGraphicsSystem(QLatin1String("meego"));
+
+ triggerSwitchCallbacks(1, "meego");
+ }
+}
+
+void QMeeGoGraphicsSystem::switchToRaster()
+{
+ if (runningGraphicsSystemName() == QLatin1String("raster"))
+ return;
+
+ if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
+ qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system.");
+ else {
+ triggerSwitchCallbacks(0, "raster");
+
+ QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
+ app->setGraphicsSystem(QLatin1String("raster"));
+
+ QMeeGoLivePixmapData::invalidateSurfaces();
+
+ triggerSwitchCallbacks(1, "raster");
+ }
+}
+
+void QMeeGoGraphicsSystem::registerSwitchCallback(QMeeGoSwitchCallback callback)
+{
+ switchCallbacks << callback;
+}
+
+void QMeeGoGraphicsSystem::triggerSwitchCallbacks(int type, const char *name)
+{
+ for (int i = 0; i < switchCallbacks.size(); ++i)
+ switchCallbacks.at(i)(type, name);
+}
+
/* C API */
int qt_meego_image_to_egl_shared_image(const QImage &image)
@@ -340,3 +506,20 @@ void qt_meego_invalidate_live_surfaces(void)
{
return QMeeGoLivePixmapData::invalidateSurfaces();
}
+
+void qt_meego_switch_to_raster(void)
+{
+ QMeeGoGraphicsSystem::switchToRaster();
+}
+
+void qt_meego_switch_to_meego(void)
+{
+ QMeeGoGraphicsSystem::switchToMeeGo();
+}
+
+void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback)
+{
+ QMeeGoGraphicsSystem::registerSwitchCallback(callback);
+}
+
+#include "qmeegographicssystem.moc"
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
index 27a4e7a..ecc85b2 100644
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h
+++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
@@ -47,6 +47,8 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+extern "C" typedef void (*QMeeGoSwitchCallback)(int type, const char *name);
+
class QMeeGoGraphicsSystem : public QGraphicsSystem
{
public:
@@ -76,13 +78,22 @@ public:
static void* createFenceSync();
static void destroyFenceSync(void* fenceSync);
+ static void switchToRaster();
+ static void switchToMeeGo();
+ static QString runningGraphicsSystemName();
+
+ static void registerSwitchCallback(QMeeGoSwitchCallback callback);
+
private:
static bool meeGoRunning();
static EGLSurface getSurfaceForLiveTexturePixmap(QPixmap *pixmap);
static void destroySurfaceForLiveTexturePixmap(QPixmapData* pmd);
+ static void triggerSwitchCallbacks(int type, const char *name);
static bool surfaceWasCreated;
- static QHash <Qt::HANDLE, QPixmap*> liveTexturePixmaps;
+ static QHash<Qt::HANDLE, QPixmap*> liveTexturePixmaps;
+ static QList<QMeeGoSwitchCallback> switchCallbacks;
+
};
/* C api */
@@ -95,7 +106,7 @@ extern "C" {
Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle);
Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height);
Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height);
- Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
+ Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format);
Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle);
Q_DECL_EXPORT QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync);
@@ -104,6 +115,9 @@ extern "C" {
Q_DECL_EXPORT void* qt_meego_create_fence_sync(void);
Q_DECL_EXPORT void qt_meego_destroy_fence_sync(void* fs);
Q_DECL_EXPORT void qt_meego_invalidate_live_surfaces(void);
+ Q_DECL_EXPORT void qt_meego_switch_to_raster(void);
+ Q_DECL_EXPORT void qt_meego_switch_to_meego(void);
+ Q_DECL_EXPORT void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback);
}
#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
index 2a2a098..0970b89 100644
--- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
+++ b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
@@ -219,7 +219,7 @@ QImage* QMeeGoLivePixmapData::lock(EGLSyncKHR fenceSync)
return &lockedImage;
}
- lockedImage = QImage((uchar *) data, width(), height(), format);
+ lockedImage = QImage((uchar *) data, width(), height(), pitch, format);
return &lockedImage;
}
diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm
index 8be8883..da7af3f 100644
--- a/src/plugins/platforms/cocoa/main.mm
+++ b/src/plugins/platforms/cocoa/main.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h
index 47b94d1..6e41e9a 100644
--- a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h
+++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm
index 9a18fe2..35750cd 100644
--- a/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm
+++ b/src/plugins/platforms/cocoa/qcocoaautoreleasepool.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h
index 87998e3..81e272e 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm
index 844751c..885916e 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventloopintegration.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index e7ecf2a..2a04e8c 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -75,6 +75,7 @@ public:
QCocoaIntegration();
~QCocoaIntegration();
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 28e894c..7c4319c 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -94,9 +94,19 @@ QCocoaIntegration::~QCocoaIntegration()
delete mPool;
}
+bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+
+
QPixmapData *QCocoaIntegration::createPixmapData(QPixmapData::PixelType type) const
{
- return new QRasterPixmapData(type);
+ return new QRasterPixmapData(type);
}
QPlatformWindow *QCocoaIntegration::createPlatformWindow(QWidget *widget, WId winId) const
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 660e9f8..b71879d 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 4e233ee..aa54fe9 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.h b/src/plugins/platforms/cocoa/qcocoawindowsurface.h
index 35f4064..5ae7be1 100644
--- a/src/plugins/platforms/cocoa/qcocoawindowsurface.h
+++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm
index 443a486..ecf6879 100644
--- a/src/plugins/platforms/cocoa/qcocoawindowsurface.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindowsurface.mm
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 0523725..fc946e2 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 60de6ba..6fda27b 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index 9fc1d63..f4dcec7 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index c04602b..58dffb7 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/directfb/main.cpp b/src/plugins/platforms/directfb/main.cpp
index f4ece32..d9caa70 100644
--- a/src/plugins/platforms/directfb/main.cpp
+++ b/src/plugins/platforms/directfb/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
index 24c21e6..ec4577a 100644
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
@@ -206,7 +206,7 @@ bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes)
return false;
}
-EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format)
+EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat)
{
EGLConfig cfg = 0;
QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
@@ -227,14 +227,14 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW
if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching)
continue;
-// // If we want the best pixel format, then return the first
-// // matching configuration.
-// if (match == QEgl::BestPixelFormat) {
-// eglChooseConfig(display, props.properties(), &cfg, 1, &matching);
-// if (matching < 1)
-// continue;
-// return cfg;
-// }
+ // If we want the best pixel format, then return the first
+ // matching configuration.
+ if (highestPixelFormat) {
+ eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching);
+ if (matching < 1)
+ continue;
+ return cfg;
+ }
// Fetch all of the matching configurations and find the
// first that matches the pixel format we wanted.
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h
index f624e97..8668095 100644
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.h
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h
@@ -46,12 +46,16 @@
#include <QtGui/QPlatformWindowFormat>
#include <QtCore/QVector>
+#ifdef Q_PLATFORM_WAYLAND
+#include "qwaylandinclude.h"
+#else
#include <EGL/egl.h>
+#endif
QT_BEGIN_NAMESPACE
QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format);
bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes);
-EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format);
+EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false);
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config);
bool q_hasEglExtension(EGLDisplay display,const char* extensionName);
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
index 126dc74..9a2bc61 100644
--- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
+++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
@@ -155,3 +155,8 @@ QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const
{
return m_windowFormat;
}
+
+EGLContext QEGLPlatformContext::eglContext() const
+{
+ return m_eglContext;
+}
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
index 4b98619..d688660 100644
--- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
+++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
@@ -59,6 +59,8 @@ public:
void makeDefaultSharedContext();
QPlatformWindowFormat platformWindowFormat() const;
+
+ EGLContext eglContext() const;
private:
EGLContext m_eglContext;
EGLDisplay m_eglDisplay;
diff --git a/src/plugins/platforms/testlite/qtestliteeglintegration.cpp b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp
index 532c63d..7f296c5 100644
--- a/src/plugins/platforms/testlite/qtestliteeglintegration.cpp
+++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qtestliteeglintegration.h"
+#include "qxlibeglintegration.h"
static int countBits(unsigned long mask)
{
@@ -52,7 +52,7 @@ static int countBits(unsigned long mask)
return count;
}
-VisualID QTestLiteEglIntegration::getCompatibleVisualId(Display *display, EGLConfig config)
+VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLConfig config)
{
VisualID visualId = 0;
EGLint eglValue = 0;
diff --git a/src/plugins/platforms/testlite/qtestliteeglintegration.h b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h
index 99e9018..51996da 100644
--- a/src/plugins/platforms/testlite/qtestliteeglintegration.h
+++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -42,10 +42,9 @@
#ifndef QTESTLITEEGLINTEGRATION_H
#define QTESTLITEEGLINTEGRATION_H
-#include "qtestlitestaticinfo.h"
-#include "../eglconvenience/qeglconvenience.h"
+#include "qeglconvenience.h"
-class QTestLiteEglIntegration
+class QXlibEglIntegration
{
public:
static VisualID getCompatibleVisualId(Display *display, EGLConfig config);
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index f4a97fc..78981f9 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -65,6 +65,14 @@ QEglFSIntegration::QEglFSIntegration()
#endif
}
+bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
QPixmapData *QEglFSIntegration::createPixmapData(QPixmapData::PixelType type) const
{
#ifdef QEGL_EXTRA_DEBUG
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h
index c199653..65b834f 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h
@@ -56,6 +56,7 @@ class QEglFSIntegration : public QPlatformIntegration
public:
QEglFSIntegration();
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
diff --git a/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri b/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri
index 21aedba..da4698d 100644
--- a/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri
+++ b/src/plugins/platforms/fontdatabases/basicunix/basicunix.pri
@@ -73,7 +73,11 @@ contains(QT_CONFIG, freetype) {
$$QT_SOURCE_TREE/src/3rdparty/freetype/src \
$$QT_SOURCE_TREE/src/3rdparty/freetype/include
- DEFINES += FT2_BUILD_LIBRARY FT_CONFIG_OPTION_SYSTEM_ZLIB
+ DEFINES += FT2_BUILD_LIBRARY
+ contains(QT_CONFIG, system-zlib) {
+ DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB
+ }
+
} else:contains(QT_CONFIG, system-freetype) {
# pull in the proper freetype2 include directory
include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
diff --git a/src/plugins/platforms/linuxfb/main.cpp b/src/plugins/platforms/linuxfb/main.cpp
index c5f7fe0..fb14ef4 100644
--- a/src/plugins/platforms/linuxfb/main.cpp
+++ b/src/plugins/platforms/linuxfb/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
index aa1d401..a088a31 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -782,6 +782,15 @@ void QLinuxFbIntegration::blank(bool on)
d_ptr->blank = on;
}
+bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+
QPixmapData *QLinuxFbIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QRasterPixmapData(type);
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
index e93495c..f361843 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -77,6 +77,8 @@ public:
QLinuxFbIntegration();
~QLinuxFbIntegration();
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId WinId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId WinId) const;
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp
index f72fadb..3a545e4 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.cpp
+++ b/src/plugins/platforms/minimal/qminimalintegration.cpp
@@ -56,6 +56,14 @@ QMinimalIntegration::QMinimalIntegration()
mScreens.append(mPrimaryScreen);
}
+bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QRasterPixmapData(type);
diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h
index 133feee..5f93443 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.h
+++ b/src/plugins/platforms/minimal/qminimalintegration.h
@@ -69,6 +69,8 @@ class QMinimalIntegration : public QPlatformIntegration
public:
QMinimalIntegration();
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp
index 5176397..35e744be 100644
--- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp
+++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp
@@ -185,6 +185,15 @@ QOpenKODEIntegration::~QOpenKODEIntegration()
delete mFontDb;
}
+
+bool QOpenKODEIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
QPixmapData *QOpenKODEIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QGLPixmapData(type);
diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h
index ade3366..7582e60 100644
--- a/src/plugins/platforms/openkode/qopenkodeintegration.h
+++ b/src/plugins/platforms/openkode/qopenkodeintegration.h
@@ -90,6 +90,8 @@ public:
QOpenKODEIntegration();
~QOpenKODEIntegration();
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
diff --git a/src/plugins/platforms/openvglite/main.cpp b/src/plugins/platforms/openvglite/main.cpp
index dc0b4a8..97321fa 100644
--- a/src/plugins/platforms/openvglite/main.cpp
+++ b/src/plugins/platforms/openvglite/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp
index 41b2303..5f7106e 100644
--- a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp
+++ b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h
index 512793d..9d45bf9 100644
--- a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h
+++ b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp b/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp
index c73e35a..8432ad6 100644
--- a/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp
+++ b/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.h b/src/plugins/platforms/openvglite/qwindowsurface_vglite.h
index b7d0a92..6d66c42 100644
--- a/src/plugins/platforms/openvglite/qwindowsurface_vglite.h
+++ b/src/plugins/platforms/openvglite/qwindowsurface_vglite.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/qvfb/main.cpp b/src/plugins/platforms/qvfb/main.cpp
index 997e544..5c3b72b 100644
--- a/src/plugins/platforms/qvfb/main.cpp
+++ b/src/plugins/platforms/qvfb/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/qvfb/qvfbintegration.cpp b/src/plugins/platforms/qvfb/qvfbintegration.cpp
index 0cc3938..ddde800 100644
--- a/src/plugins/platforms/qvfb/qvfbintegration.cpp
+++ b/src/plugins/platforms/qvfb/qvfbintegration.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/qvfb/qvfbintegration.h b/src/plugins/platforms/qvfb/qvfbintegration.h
index 198a45c..33e31a5 100644
--- a/src/plugins/platforms/qvfb/qvfbintegration.h
+++ b/src/plugins/platforms/qvfb/qvfbintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp b/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp
index 6699072..85918eb 100644
--- a/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp
+++ b/src/plugins/platforms/qvfb/qvfbwindowsurface.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/qvfb/qvfbwindowsurface.h b/src/plugins/platforms/qvfb/qvfbwindowsurface.h
index 9228189..9f828d3 100644
--- a/src/plugins/platforms/qvfb/qvfbwindowsurface.h
+++ b/src/plugins/platforms/qvfb/qvfbwindowsurface.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/uikit/README b/src/plugins/platforms/uikit/README
new file mode 100644
index 0000000..b2984fc
--- /dev/null
+++ b/src/plugins/platforms/uikit/README
@@ -0,0 +1,45 @@
+This is a proof-of-concept implemenation of a UIKit based
+QPA plugin. Note that this is completely unsupported, and it is probable
+that many parts of QtCore and other Qt Modules don't work properly.
+
+1) Build Qt
+
+The example Xcode project in the examples subdirectory requires that you do shadow
+builds of Qt in qt-lighthouse-ios-simulator and qt-lighthouse-ios-device directories
+parallel to the sources. To build for simulator make sure that both the Simulator
+configuration *and* the simulator specific target are active. To build for device
+make sure that both the Device configuration *and* the device specific target are
+active.
+
+The setup is configured to use the iOS 4.2 SDKs, you might want to edit the mkspecs
+to fit your need.
+
+After configuring and building Qt you need to also build src/plugins/platforms/uikit.
+
+Simulator:
+----------
+configure -qpa -xplatform qws/macx-iphonesimulator-g++ -arch i386 -developer-build -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -no-opengl -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations
+
+Device:
+-------
+configure -qpa -xplatform qws/macx-iphonedevice-g++ -arch armv7 -developer-build -release -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -no-opengl -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations
+
+2) XCode setup:
+- there are examples in the examples subdirectory of the platform plugin
+- to create something fresh do something like:
+ - Xcode: Create a "View-based Appplication"
+ - remove the nibs and view controller and app controller files
+ - remove the reference to "Main nib file" from plist file
+ - create a main.mm like in the examples
+ - add the qmlapplicationviewer sources to your project (including the moc_*.h)
+ (best to link, not copy), the code for this is from the Qt Creator
+ mobile Qt Quick application template
+ - Add the Qt .a libraries, uikit platform plugin and libz (v1.2.3) to Frameworks
+ - add "$(SRCROOT)/../../../../qt-lighthouse-ios-device/include" (or -simulator)
+ to the include search paths.
+ - add "$(SRCROOT)/../qmltest" to the include search path if you didn't copy but
+ linked to the qmlapplicationviewer
+ - for device set the architecture to armv7 only
+
+3) Done: Build and Run.
+
diff --git a/src/plugins/platforms/uikit/examples/qmltest/main.mm b/src/plugins/platforms/uikit/examples/qmltest/main.mm
new file mode 100644
index 0000000..6fd5629
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/main.mm
@@ -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$
+**
+****************************************************************************/
+
+//
+// main.m
+// qmltest
+//
+// Created by Eike Troll on 18.02.11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#include "qmlapplicationviewer/qmlapplicationviewer.h"
+
+#include <QtGui/QApplication>
+#include <QtCore/QtPlugin>
+
+Q_IMPORT_PLUGIN(UIKit)
+
+int main(int argc, char *argv[]) {
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+
+ setenv("QT_QPA_PLATFORM","uikit",1);
+
+ QApplication app(argc, argv);
+ QmlApplicationViewer viewer;
+ viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
+ NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
+ viewer.setMainQmlFile(QString::fromUtf8([[resourcePath stringByAppendingPathComponent:@"qml/main.qml"] UTF8String]));
+ viewer.showMaximized();
+ int retVal = app.exec();
+ [pool release];
+ return retVal;
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qml/main.qml b/src/plugins/platforms/uikit/examples/qmltest/qml/main.qml
new file mode 100644
index 0000000..889a6d0
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qml/main.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Rectangle {
+ id: box
+ width: 350; height: 250
+
+ Rectangle {
+ id: redSquare
+ width: 80; height: 80
+ anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10
+ color: "red"
+
+ Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ onEntered: info.text = 'Entered'
+ onExited: info.text = 'Exited (pressed=' + pressed + ')'
+
+ onPressed: {
+ info.text = 'Pressed (button=' + (mouse.button == Qt.RightButton ? 'right' : 'left')
+ + ' shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')'
+ var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y)
+ posInfo.text = + mouse.x + ',' + mouse.y + ' in square'
+ + ' (' + posInBox.x + ',' + posInBox.y + ' in window)'
+ }
+
+ onReleased: {
+ info.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')'
+ posInfo.text = ''
+ }
+
+ onPressAndHold: info.text = 'Press and hold'
+ onClicked: info.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')'
+ onDoubleClicked: info.text = 'Double clicked'
+ }
+ }
+
+ Rectangle {
+ id: blueSquare
+ width: 80; height: 80
+ x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors
+ color: "blue"
+
+ Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: blueSquare
+ drag.axis: Drag.XandYAxis
+ drag.minimumX: 0
+ drag.maximumX: box.width - parent.width
+ drag.minimumY: 0
+ drag.maximumY: box.height - parent.width
+ }
+ }
+
+ Text {
+ id: info
+ anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30
+
+ onTextChanged: console.log(text)
+ }
+
+ Text {
+ id: posInfo
+ anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30
+ }
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp
new file mode 100644
index 0000000..a2b40ec
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/moc_qmlapplicationviewer.cpp
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/****************************************************************************
+** Meta object code from reading C++ file 'qmlapplicationviewer.h'
+**
+** Created: Fri Feb 18 17:53:42 2011
+** by: The Qt Meta Object Compiler version 62 (Qt 4.7.2)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "qmlapplicationviewer.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'qmlapplicationviewer.h' doesn't include <QObject>."
+#elif Q_MOC_OUTPUT_REVISION != 62
+#error "This file was generated using the moc from 4.7.2. It"
+#error "cannot be used with the include files from this version of Qt."
+#error "(The moc has changed too much.)"
+#endif
+
+QT_BEGIN_MOC_NAMESPACE
+static const uint qt_meta_data_QmlApplicationViewer[] = {
+
+ // content:
+ 5, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 0, 0, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 0, // signalCount
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_QmlApplicationViewer[] = {
+ "QmlApplicationViewer\0"
+};
+
+const QMetaObject QmlApplicationViewer::staticMetaObject = {
+ { &QDeclarativeView::staticMetaObject, qt_meta_stringdata_QmlApplicationViewer,
+ qt_meta_data_QmlApplicationViewer, 0 }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &QmlApplicationViewer::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *QmlApplicationViewer::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *QmlApplicationViewer::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_QmlApplicationViewer))
+ return static_cast<void*>(const_cast< QmlApplicationViewer*>(this));
+ return QDeclarativeView::qt_metacast(_clname);
+}
+
+int QmlApplicationViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QDeclarativeView::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ return _id;
+}
+QT_END_MOC_NAMESPACE
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp
new file mode 100644
index 0000000..72f8c52
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.cpp
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+// checksum 0x17fa version 0x3000a
+/*
+ This file was generated by the Qt Quick Application wizard of Qt Creator.
+ QmlApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#include "qmlapplicationviewer.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtDeclarative/QDeclarativeComponent>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeContext>
+
+#if defined(QMLJSDEBUGGER)
+#include <qt_private/qdeclarativedebughelper_p.h>
+#endif
+
+#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER)
+#include <jsdebuggeragent.h>
+#endif
+#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER)
+#include <qdeclarativeviewobserver.h>
+#endif
+
+#if defined(QMLJSDEBUGGER)
+
+// Enable debugging before any QDeclarativeEngine is created
+struct QmlJsDebuggingEnabler
+{
+ QmlJsDebuggingEnabler()
+ {
+ QDeclarativeDebugHelper::enableDebugging();
+ }
+};
+
+// Execute code in constructor before first QDeclarativeEngine is instantiated
+static QmlJsDebuggingEnabler enableDebuggingHelper;
+
+#endif // QMLJSDEBUGGER
+
+class QmlApplicationViewerPrivate
+{
+ QString mainQmlFile;
+ friend class QmlApplicationViewer;
+ static QString adjustPath(const QString &path);
+};
+
+QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
+{
+#ifdef Q_OS_UNIX
+#ifdef Q_OS_MAC
+ if (!QDir::isAbsolutePath(path))
+ return QCoreApplication::applicationDirPath()
+ + QLatin1String("/../Resources/") + path;
+#else
+ const QString pathInShareDir = QCoreApplication::applicationDirPath()
+ + QLatin1String("/../share/")
+ + QFileInfo(QCoreApplication::applicationFilePath()).fileName()
+ + QLatin1Char('/') + path;
+ if (QFileInfo(pathInShareDir).exists())
+ return pathInShareDir;
+#endif
+#endif
+ return path;
+}
+
+QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) :
+ QDeclarativeView(parent),
+ m_d(new QmlApplicationViewerPrivate)
+{
+ connect(engine(), SIGNAL(quit()), SLOT(close()));
+ setResizeMode(QDeclarativeView::SizeRootObjectToView);
+#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER)
+ new QmlJSDebugger::JSDebuggerAgent(engine());
+#endif
+#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER)
+ new QmlJSDebugger::QDeclarativeViewObserver(this, parent);
+#endif
+}
+
+QmlApplicationViewer::~QmlApplicationViewer()
+{
+ delete m_d;
+}
+
+void QmlApplicationViewer::setMainQmlFile(const QString &file)
+{
+ m_d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
+ setSource(QUrl::fromLocalFile(m_d->mainQmlFile));
+}
+
+void QmlApplicationViewer::addImportPath(const QString &path)
+{
+ engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path));
+}
+
+void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
+{
+//#if defined(Q_OS_SYMBIAN)
+// // If the version of Qt on the device is < 4.7.2, that attribute won't work
+// if (orientation != ScreenOrientationAuto) {
+// const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
+// if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
+// qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
+// return;
+// }
+// }
+//#endif // Q_OS_SYMBIAN
+//
+// Qt::WidgetAttribute attribute;
+// switch (orientation) {
+//#if QT_VERSION < 0x040702
+// // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
+// case ScreenOrientationLockPortrait:
+// attribute = static_cast<Qt::WidgetAttribute>(128);
+// break;
+// case ScreenOrientationLockLandscape:
+// attribute = static_cast<Qt::WidgetAttribute>(129);
+// break;
+// default:
+// case ScreenOrientationAuto:
+// attribute = static_cast<Qt::WidgetAttribute>(130);
+// break;
+//#else // QT_VERSION < 0x040702
+// case ScreenOrientationLockPortrait:
+// attribute = Qt::WA_LockPortraitOrientation;
+// break;
+// case ScreenOrientationLockLandscape:
+// attribute = Qt::WA_LockLandscapeOrientation;
+// break;
+// default:
+// case ScreenOrientationAuto:
+// attribute = Qt::WA_AutoOrientation;
+// break;
+//#endif // QT_VERSION < 0x040702
+// };
+// setAttribute(attribute, true);
+}
+
+void QmlApplicationViewer::showExpanded()
+{
+#ifdef Q_OS_SYMBIAN
+ showFullScreen();
+#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ showMaximized();
+#else
+ show();
+#endif
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.h
new file mode 100644
index 0000000..01b2af0
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmlapplicationviewer/qmlapplicationviewer.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$
+**
+****************************************************************************/
+
+// checksum 0x5a59 version 0x3000a
+/*
+ This file was generated by the Qt Quick Application wizard of Qt Creator.
+ QmlApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#ifndef QMLAPPLICATIONVIEWER_H
+#define QMLAPPLICATIONVIEWER_H
+
+#include <QtDeclarative/QDeclarativeView>
+
+class QmlApplicationViewer : public QDeclarativeView
+{
+ Q_OBJECT
+
+public:
+ enum ScreenOrientation {
+ ScreenOrientationLockPortrait,
+ ScreenOrientationLockLandscape,
+ ScreenOrientationAuto
+ };
+
+ explicit QmlApplicationViewer(QWidget *parent = 0);
+ virtual ~QmlApplicationViewer();
+
+ void setMainQmlFile(const QString &file);
+ void addImportPath(const QString &path);
+ void setOrientation(ScreenOrientation orientation);
+ void showExpanded();
+
+private:
+ class QmlApplicationViewerPrivate *m_d;
+};
+
+#endif // QMLAPPLICATIONVIEWER_H
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist b/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist
new file mode 100644
index 0000000..1566585
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest-Info.plist
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+</dict>
+</plist>
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj
new file mode 100755
index 0000000..fc4f1df
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj
@@ -0,0 +1,463 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
+ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
+ 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
+ D3CAA7C813264AAD008BB877 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7C713264AAD008BB877 /* main.mm */; };
+ D3CAA7E613264EA6008BB877 /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */; };
+ D3CAA7E713264EA6008BB877 /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */; };
+ D3CAA7EC13264F52008BB877 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7C713264AAD008BB877 /* main.mm */; };
+ D3CAA7ED13264F52008BB877 /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */; };
+ D3CAA7EE13264F52008BB877 /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */; };
+ D3CAA7F013264F52008BB877 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
+ D3CAA7F113264F52008BB877 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
+ D3CAA7F213264F52008BB877 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
+ D3CAA7FA13264F8A008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; };
+ D3CAA81113264FF0008BB877 /* libz.1.2.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */; };
+ D3CAA81B13265056008BB877 /* libQtCore_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81613265056008BB877 /* libQtCore_debug.a */; };
+ D3CAA81C13265056008BB877 /* libQtDeclarative_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81713265056008BB877 /* libQtDeclarative_debug.a */; };
+ D3CAA81D13265056008BB877 /* libQtGui_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81813265056008BB877 /* libQtGui_debug.a */; };
+ D3CAA81E13265056008BB877 /* libQtScript_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81913265056008BB877 /* libQtScript_debug.a */; };
+ D3CAA81F13265056008BB877 /* libQtSql_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA81A13265056008BB877 /* libQtSql_debug.a */; };
+ D3CAA8211326507D008BB877 /* libquikit_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA8201326507D008BB877 /* libquikit_debug.a */; };
+ D3CAA82813265220008BB877 /* libQtNetwork_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3CAA82713265220008BB877 /* libQtNetwork_debug.a */; };
+ D3CAA88A132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; };
+ D3CAA88B132652E5008BB877 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA836132652E5008BB877 /* fonts */; };
+ D3CAA89113265310008BB877 /* qml in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA88E13265310008BB877 /* qml */; };
+ D3CAA89213265310008BB877 /* qml in Resources */ = {isa = PBXBuildFile; fileRef = D3CAA88E13265310008BB877 /* qml */; };
+ D3D817B2132A2CFD00CDE422 /* libQtCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AA132A2CFD00CDE422 /* libQtCore.a */; };
+ D3D817B3132A2CFD00CDE422 /* libQtDeclarative.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */; };
+ D3D817B4132A2CFD00CDE422 /* libQtGui.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AC132A2CFD00CDE422 /* libQtGui.a */; };
+ D3D817B5132A2CFD00CDE422 /* libQtNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */; };
+ D3D817B6132A2CFD00CDE422 /* libQtScript.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AE132A2CFD00CDE422 /* libQtScript.a */; };
+ D3D817B7132A2CFD00CDE422 /* libQtSql.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817AF132A2CFD00CDE422 /* libQtSql.a */; };
+ D3D817B8132A2CFD00CDE422 /* libQtXml.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817B0132A2CFD00CDE422 /* libQtXml.a */; };
+ D3D817B9132A2CFD00CDE422 /* libQtXmlPatterns.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */; };
+ D3D817BB132A2D0E00CDE422 /* libquikit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3D817BA132A2D0E00CDE422 /* libquikit.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 1D6058910D05DD3D006BFB54 /* qmltest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = qmltest.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 32CA4F630368D1EE00C91783 /* qmltest_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = qmltest_Prefix.pch; sourceTree = "<group>"; };
+ 8D1107310486CEB800E47090 /* qmltest-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "qmltest-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
+ D3CAA7C713264AAD008BB877 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
+ D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_qmlapplicationviewer.cpp; path = qmlapplicationviewer/moc_qmlapplicationviewer.cpp; sourceTree = "<group>"; };
+ D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = qmlapplicationviewer.cpp; path = qmlapplicationviewer/qmlapplicationviewer.cpp; sourceTree = "<group>"; };
+ D3CAA7E513264EA6008BB877 /* qmlapplicationviewer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qmlapplicationviewer.h; path = qmlapplicationviewer/qmlapplicationviewer.h; sourceTree = "<group>"; };
+ D3CAA7F613264F52008BB877 /* qmltest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = qmltest.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.1.2.3.dylib; path = usr/lib/libz.1.2.3.dylib; sourceTree = SDKROOT; };
+ D3CAA81613265056008BB877 /* libQtCore_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtCore_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtCore_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81713265056008BB877 /* libQtDeclarative_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtDeclarative_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtDeclarative_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81813265056008BB877 /* libQtGui_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtGui_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtGui_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81913265056008BB877 /* libQtScript_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtScript_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA81A13265056008BB877 /* libQtSql_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtSql_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA8201326507D008BB877 /* libquikit_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libquikit_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/plugins/platforms/libquikit_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA82713265220008BB877 /* libQtNetwork_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtNetwork_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtNetwork_debug.a"; sourceTree = SOURCE_ROOT; };
+ D3CAA836132652E5008BB877 /* fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = fonts; path = ../../../../../../lib/fonts; sourceTree = SOURCE_ROOT; };
+ D3CAA88E13265310008BB877 /* qml */ = {isa = PBXFileReference; lastKnownFileType = folder; path = qml; sourceTree = SOURCE_ROOT; };
+ D3D817AA132A2CFD00CDE422 /* libQtCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtCore.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtCore.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtDeclarative.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtDeclarative.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AC132A2CFD00CDE422 /* libQtGui.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtGui.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtGui.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtNetwork.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtNetwork.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AE132A2CFD00CDE422 /* libQtScript.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtScript.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtScript.a"; sourceTree = SOURCE_ROOT; };
+ D3D817AF132A2CFD00CDE422 /* libQtSql.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtSql.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtSql.a"; sourceTree = SOURCE_ROOT; };
+ D3D817B0132A2CFD00CDE422 /* libQtXml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXml.a"; sourceTree = SOURCE_ROOT; };
+ D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtXmlPatterns.a"; sourceTree = SOURCE_ROOT; };
+ D3D817BA132A2D0E00CDE422 /* libquikit.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libquikit.a; path = "../../../../../../../qt-lighthouse-ios-device/plugins/platforms/libquikit.a"; sourceTree = SOURCE_ROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
+ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
+ 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */,
+ D3CAA7FA13264F8A008BB877 /* libz.1.2.3.dylib in Frameworks */,
+ D3CAA81B13265056008BB877 /* libQtCore_debug.a in Frameworks */,
+ D3CAA81C13265056008BB877 /* libQtDeclarative_debug.a in Frameworks */,
+ D3CAA81D13265056008BB877 /* libQtGui_debug.a in Frameworks */,
+ D3CAA81E13265056008BB877 /* libQtScript_debug.a in Frameworks */,
+ D3CAA81F13265056008BB877 /* libQtSql_debug.a in Frameworks */,
+ D3CAA8211326507D008BB877 /* libquikit_debug.a in Frameworks */,
+ D3CAA82813265220008BB877 /* libQtNetwork_debug.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D3CAA7EF13264F52008BB877 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA7F013264F52008BB877 /* Foundation.framework in Frameworks */,
+ D3CAA7F113264F52008BB877 /* UIKit.framework in Frameworks */,
+ D3CAA7F213264F52008BB877 /* CoreGraphics.framework in Frameworks */,
+ D3CAA81113264FF0008BB877 /* libz.1.2.3.dylib in Frameworks */,
+ D3D817B2132A2CFD00CDE422 /* libQtCore.a in Frameworks */,
+ D3D817B3132A2CFD00CDE422 /* libQtDeclarative.a in Frameworks */,
+ D3D817B4132A2CFD00CDE422 /* libQtGui.a in Frameworks */,
+ D3D817B5132A2CFD00CDE422 /* libQtNetwork.a in Frameworks */,
+ D3D817B6132A2CFD00CDE422 /* libQtScript.a in Frameworks */,
+ D3D817B7132A2CFD00CDE422 /* libQtSql.a in Frameworks */,
+ D3D817B8132A2CFD00CDE422 /* libQtXml.a in Frameworks */,
+ D3D817B9132A2CFD00CDE422 /* libQtXmlPatterns.a in Frameworks */,
+ D3D817BB132A2D0E00CDE422 /* libquikit.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 19C28FACFE9D520D11CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 1D6058910D05DD3D006BFB54 /* qmltest.app */,
+ D3CAA7F613264F52008BB877 /* qmltest.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
+ isa = PBXGroup;
+ children = (
+ 29B97315FDCFA39411CA2CEA /* Other Sources */,
+ 29B97317FDCFA39411CA2CEA /* Resources */,
+ D3CAA7E213264E8C008BB877 /* QMLApplicationViewer */,
+ 29B97323FDCFA39411CA2CEA /* Frameworks */,
+ 19C28FACFE9D520D11CA2CBB /* Products */,
+ );
+ name = CustomTemplate;
+ sourceTree = "<group>";
+ };
+ 29B97315FDCFA39411CA2CEA /* Other Sources */ = {
+ isa = PBXGroup;
+ children = (
+ 32CA4F630368D1EE00C91783 /* qmltest_Prefix.pch */,
+ D3CAA7C713264AAD008BB877 /* main.mm */,
+ );
+ name = "Other Sources";
+ sourceTree = "<group>";
+ };
+ 29B97317FDCFA39411CA2CEA /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA88E13265310008BB877 /* qml */,
+ D3CAA836132652E5008BB877 /* fonts */,
+ 8D1107310486CEB800E47090 /* qmltest-Info.plist */,
+ );
+ name = Resources;
+ sourceTree = "<group>";
+ };
+ 29B97323FDCFA39411CA2CEA /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA81513265035008BB877 /* Simulator */,
+ D3CAA8141326500A008BB877 /* Device */,
+ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
+ 1D30AB110D05D00D00671497 /* Foundation.framework */,
+ 288765A40DF7441C002DB57D /* CoreGraphics.framework */,
+ D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ D3CAA7E213264E8C008BB877 /* QMLApplicationViewer */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */,
+ D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */,
+ D3CAA7E513264EA6008BB877 /* qmlapplicationviewer.h */,
+ );
+ name = QMLApplicationViewer;
+ sourceTree = "<group>";
+ };
+ D3CAA8141326500A008BB877 /* Device */ = {
+ isa = PBXGroup;
+ children = (
+ D3D817BA132A2D0E00CDE422 /* libquikit.a */,
+ D3D817AA132A2CFD00CDE422 /* libQtCore.a */,
+ D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */,
+ D3D817AC132A2CFD00CDE422 /* libQtGui.a */,
+ D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */,
+ D3D817AE132A2CFD00CDE422 /* libQtScript.a */,
+ D3D817AF132A2CFD00CDE422 /* libQtSql.a */,
+ D3D817B0132A2CFD00CDE422 /* libQtXml.a */,
+ D3D817B1132A2CFD00CDE422 /* libQtXmlPatterns.a */,
+ );
+ name = Device;
+ sourceTree = "<group>";
+ };
+ D3CAA81513265035008BB877 /* Simulator */ = {
+ isa = PBXGroup;
+ children = (
+ D3CAA8201326507D008BB877 /* libquikit_debug.a */,
+ D3CAA81613265056008BB877 /* libQtCore_debug.a */,
+ D3CAA81713265056008BB877 /* libQtDeclarative_debug.a */,
+ D3CAA81813265056008BB877 /* libQtGui_debug.a */,
+ D3CAA82713265220008BB877 /* libQtNetwork_debug.a */,
+ D3CAA81913265056008BB877 /* libQtScript_debug.a */,
+ D3CAA81A13265056008BB877 /* libQtSql_debug.a */,
+ );
+ name = Simulator;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 1D6058900D05DD3D006BFB54 /* qmltest simulator */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "qmltest simulator" */;
+ buildPhases = (
+ 1D60588D0D05DD3D006BFB54 /* Resources */,
+ 1D60588E0D05DD3D006BFB54 /* Sources */,
+ 1D60588F0D05DD3D006BFB54 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "qmltest simulator";
+ productName = qmltest;
+ productReference = 1D6058910D05DD3D006BFB54 /* qmltest.app */;
+ productType = "com.apple.product-type.application";
+ };
+ D3CAA7E813264F52008BB877 /* qmltest device */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = D3CAA7F313264F52008BB877 /* Build configuration list for PBXNativeTarget "qmltest device" */;
+ buildPhases = (
+ D3CAA7E913264F52008BB877 /* Resources */,
+ D3CAA7EB13264F52008BB877 /* Sources */,
+ D3CAA7EF13264F52008BB877 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "qmltest device";
+ productName = qmltest;
+ productReference = D3CAA7F613264F52008BB877 /* qmltest.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 29B97313FDCFA39411CA2CEA /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "qmltest" */;
+ compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
+ hasScannedForEncodings = 1;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ );
+ mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 1D6058900D05DD3D006BFB54 /* qmltest simulator */,
+ D3CAA7E813264F52008BB877 /* qmltest device */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 1D60588D0D05DD3D006BFB54 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA88A132652E5008BB877 /* fonts in Resources */,
+ D3CAA89113265310008BB877 /* qml in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D3CAA7E913264F52008BB877 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA88B132652E5008BB877 /* fonts in Resources */,
+ D3CAA89213265310008BB877 /* qml in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 1D60588E0D05DD3D006BFB54 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA7C813264AAD008BB877 /* main.mm in Sources */,
+ D3CAA7E613264EA6008BB877 /* moc_qmlapplicationviewer.cpp in Sources */,
+ D3CAA7E713264EA6008BB877 /* qmlapplicationviewer.cpp in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ D3CAA7EB13264F52008BB877 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D3CAA7EC13264F52008BB877 /* main.mm in Sources */,
+ D3CAA7ED13264F52008BB877 /* moc_qmlapplicationviewer.cpp in Sources */,
+ D3CAA7EE13264F52008BB877 /* qmlapplicationviewer.cpp in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1D6058940D05DD3E006BFB54 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ };
+ name = Debug;
+ };
+ 1D6058950D05DD3E006BFB54 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-simulator/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ C01FCF4F08A954540054247B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ PREBINDING = NO;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ C01FCF5008A954540054247B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ PREBINDING = NO;
+ SDKROOT = iphoneos;
+ };
+ name = Release;
+ };
+ D3CAA7F413264F52008BB877 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ };
+ name = Debug;
+ };
+ D3CAA7F513264F52008BB877 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
+ COPY_PHASE_STRIP = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = qmltest_Prefix.pch;
+ HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/include\"/**";
+ INFOPLIST_FILE = "qmltest-Info.plist";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/lib\"",
+ "\"$(SRCROOT)/../../../../../../../qt-lighthouse-ios-device/plugins/platforms\"",
+ );
+ PRODUCT_NAME = qmltest;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "qmltest simulator" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1D6058940D05DD3E006BFB54 /* Debug */,
+ 1D6058950D05DD3E006BFB54 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ C01FCF4E08A954540054247B /* Build configuration list for PBXProject "qmltest" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C01FCF4F08A954540054247B /* Debug */,
+ C01FCF5008A954540054247B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ D3CAA7F313264F52008BB877 /* Build configuration list for PBXNativeTarget "qmltest device" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ D3CAA7F413264F52008BB877 /* Debug */,
+ D3CAA7F513264F52008BB877 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
+}
diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch b/src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch
new file mode 100644
index 0000000..c06715c
--- /dev/null
+++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest_Prefix.pch
@@ -0,0 +1,8 @@
+//
+// Prefix header for all source files of the 'qmltest' target in the 'qmltest' project
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+ #import <UIKit/UIKit.h>
+#endif
diff --git a/src/plugins/platforms/uikit/main.mm b/src/plugins/platforms/uikit/main.mm
new file mode 100644
index 0000000..1ef69fa
--- /dev/null
+++ b/src/plugins/platforms/uikit/main.mm
@@ -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$
+**
+****************************************************************************/
+
+#include <UIKit/UIKit.h>
+
+#include <QtGui/QPlatformIntegrationPlugin>
+#include "quikitintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QUIKitIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "UIKit";
+ return list;
+}
+
+QPlatformIntegration * QUIKitIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "uikit")
+ return new QUIKitIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(UIKit, QUIKitIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikiteventloop.h b/src/plugins/platforms/uikit/quikiteventloop.h
new file mode 100644
index 0000000..cf5c682
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikiteventloop.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 QUIKITEVENTLOOP_H
+#define QUIKITEVENTLOOP_H
+
+#include <QtGui/QPlatformEventLoopIntegration>
+
+@class EventLoopHelper;
+@class NSTimer;
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitEventLoop : public QPlatformEventLoopIntegration
+{
+public:
+ QUIKitEventLoop();
+ ~QUIKitEventLoop();
+
+ void startEventLoop();
+ void quitEventLoop();
+ void qtNeedsToProcessEvents();
+
+ EventLoopHelper *mHelper;
+ NSTimer *mTimer;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/uikit/quikiteventloop.mm b/src/plugins/platforms/uikit/quikiteventloop.mm
new file mode 100644
index 0000000..70757b1
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikiteventloop.mm
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** 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 "quikiteventloop.h"
+#include "quikitwindow.h"
+#include "quikitwindowsurface.h"
+
+#include <UIKit/UIKit.h>
+
+#include <QtGui/QApplication>
+#include <QtGui/QWidget>
+#include <QtDebug>
+
+@interface QUIKitAppDelegate : NSObject <UIApplicationDelegate> {
+}
+@end
+
+@interface EventLoopHelper : NSObject {
+ QUIKitEventLoop *mIntegration;
+}
+
+- (id)initWithEventLoopIntegration:(QUIKitEventLoop *)integration;
+
+- (void)processEvents;
+- (void)processEventsAndSchedule;
+
+@end
+
+@implementation QUIKitAppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ Q_UNUSED(launchOptions)
+ foreach (QWidget *widget, qApp->topLevelWidgets()) {
+ QRect geom = widget->geometry();
+ CGRect bar = application.statusBarFrame;
+ if (geom.y() <= bar.size.height) {
+ geom.setY(bar.size.height);
+ widget->setGeometry(geom);
+ }
+ QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(widget->platformWindow());
+ platformWindow->ensureNativeWindow();
+ QUIKitWindowSurface *surface = static_cast<QUIKitWindowSurface*>(widget->windowSurface());
+ UIView *view = surface->nativeView();
+ [platformWindow->nativeWindow() addSubview:view];
+ [platformWindow->nativeWindow() makeKeyAndVisible];
+ }
+ return YES;
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ Q_UNUSED(application)
+ // TODO this isn't called for some reason
+ qDebug() << "quit";
+ qApp->quit();
+}
+
+@end
+
+@implementation EventLoopHelper
+
+- (id)initWithEventLoopIntegration:(QUIKitEventLoop *)integration
+{
+ if ((self = [self init])) {
+ mIntegration = integration;
+ }
+ return self;
+}
+
+- (void)processEvents
+{
+ QPlatformEventLoopIntegration::processEvents();
+}
+
+- (void)processEventsAndSchedule
+{
+ QPlatformEventLoopIntegration::processEvents();
+ qint64 nextTime = mIntegration->nextTimerEvent();
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ NSDate *nextDate = [[NSDate date] dateByAddingTimeInterval:((double)nextTime/1000)];
+ [mIntegration->mTimer setFireDate:nextDate];
+ [pool release];
+}
+
+@end
+
+QT_BEGIN_NAMESPACE
+
+QUIKitEventLoop::QUIKitEventLoop()
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ mHelper = [[EventLoopHelper alloc] initWithEventLoopIntegration:this];
+ mTimer = [[NSTimer timerWithTimeInterval:0.030 target:mHelper selector:@selector(processEventsAndSchedule) userInfo:nil repeats:YES] retain];
+ [pool release];
+}
+
+QUIKitEventLoop::~QUIKitEventLoop()
+{
+ [mTimer release];
+ [mHelper release];
+}
+
+void QUIKitEventLoop::startEventLoop()
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ [[NSRunLoop currentRunLoop] addTimer:[mTimer autorelease] forMode:NSDefaultRunLoopMode];
+ UIApplicationMain(qApp->argc(), qApp->argv(), nil, @"QUIKitAppDelegate");
+ [pool release];
+}
+
+void QUIKitEventLoop::quitEventLoop()
+{
+
+}
+
+void QUIKitEventLoop::qtNeedsToProcessEvents()
+{
+ [mHelper performSelectorOnMainThread:@selector(processEvents) withObject:nil waitUntilDone:NO];
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitintegration.h b/src/plugins/platforms/uikit/quikitintegration.h
new file mode 100644
index 0000000..a986e92
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitintegration.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** 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 QPLATFORMINTEGRATION_UIKIT_H
+#define QPLATFORMINTEGRATION_UIKIT_H
+
+#include <QtGui/QPlatformIntegration>
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitIntegration : public QPlatformIntegration
+{
+public:
+ QUIKitIntegration();
+ ~QUIKitIntegration();
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+ QPlatformEventLoopIntegration *createEventLoopIntegration() const;
+
+private:
+ QList<QPlatformScreen *> mScreens;
+};
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/plugins/platforms/uikit/quikitintegration.mm b/src/plugins/platforms/uikit/quikitintegration.mm
new file mode 100644
index 0000000..d4b4192
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitintegration.mm
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** 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 "quikitintegration.h"
+#include "quikitwindow.h"
+#include "quikitwindowsurface.h"
+#include "quikitscreen.h"
+#include "quikiteventloop.h"
+
+#include <QtGui/QApplication>
+
+#include <private/qpixmap_raster_p.h>
+
+#include <UIKit/UIKit.h>
+
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QUIKitIntegration::QUIKitIntegration()
+{
+ mScreens << new QUIKitScreen(0);
+}
+
+QUIKitIntegration::~QUIKitIntegration()
+{
+}
+
+QPixmapData *QUIKitIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QPlatformWindow *QUIKitIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QUIKitWindow(widget);
+}
+
+QList<QPlatformScreen *> QUIKitIntegration::screens() const
+{
+ return mScreens;
+}
+
+QWindowSurface *QUIKitIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QUIKitWindowSurface(widget);
+}
+
+QPlatformEventLoopIntegration *QUIKitIntegration::createEventLoopIntegration() const
+{
+ return new QUIKitEventLoop();
+}
+
+QPlatformFontDatabase * QUIKitIntegration::fontDatabase() const
+{
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ setenv("QT_QPA_FONTDIR",[[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"fonts"] UTF8String],1);
+ }
+ return QPlatformIntegration::fontDatabase();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitscreen.h b/src/plugins/platforms/uikit/quikitscreen.h
new file mode 100644
index 0000000..15c7d69
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitscreen.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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 QUIKITSCREEN_H
+#define QUIKITSCREEN_H
+
+#include <UIKit/UIKit.h>
+
+#include <QtGui/QPlatformScreen>
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitScreen : public QPlatformScreen
+{
+public:
+ QUIKitScreen(int screenIndex);
+ ~QUIKitScreen();
+
+ QRect geometry() const { return m_geometry; }
+ int depth() const { return m_depth; }
+ QImage::Format format() const { return m_format; }
+ QSize physicalSize() const { return m_physicalSize; }
+
+ UIScreen *uiScreen() const;
+
+private:
+ QRect m_geometry;
+ int m_depth;
+ QImage::Format m_format;
+ QSize m_physicalSize;
+ int m_index;
+};
+
+QT_END_NAMESPACE
+
+
+#endif
diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm
new file mode 100644
index 0000000..ec94e3a
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitscreen.mm
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** 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 "quikitscreen.h"
+
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QUIKitScreen::QUIKitScreen(int screenIndex)
+ : QPlatformScreen(),
+ m_index(screenIndex)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ UIScreen *screen = [[UIScreen screens] objectAtIndex:screenIndex];
+ UIScreenMode *mode = [screen currentMode];
+ CGSize size = [mode size];
+ m_geometry = QRect(0, 0, size.width, size.height);
+ CGRect bounds = [screen bounds]; // in 'points', 1p == 1/160in
+
+// qreal xDpi = size.width * 160. / bounds.size.width;
+// qreal yDpi = size.height * 160. / bounds.size.height;
+// qDebug() << xDpi << yDpi;
+
+ m_format = QImage::Format_ARGB32;
+
+ m_depth = 24;
+
+ const qreal inch = 25.4;
+ m_physicalSize = QSize(qRound(bounds.size.width * inch / 160.), qRound(bounds.size.height * inch / 160.));
+ [pool release];
+}
+
+QUIKitScreen::~QUIKitScreen()
+{
+}
+
+UIScreen *QUIKitScreen::uiScreen() const
+{
+ return [[UIScreen screens] objectAtIndex:m_index];
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitwindow.h b/src/plugins/platforms/uikit/quikitwindow.h
new file mode 100644
index 0000000..d5a6690
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindow.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 QUIKITWINDOW_H
+#define QUIKITWINDOW_H
+
+#include <QPlatformWindow>
+#include <UIKit/UIKit.h>
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitScreen;
+
+class QUIKitWindow : public QPlatformWindow
+{
+public:
+ explicit QUIKitWindow(QWidget *tlw);
+ ~QUIKitWindow();
+
+ UIWindow *nativeWindow() const { return mWindow; }
+ void setGeometry(const QRect &rect);
+
+ UIWindow *ensureNativeWindow();
+
+private:
+ QUIKitScreen *mScreen;
+ UIWindow *mWindow;
+};
+
+QT_END_NAMESPACE
+
+#endif // QUIKITWINDOW_H
diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm
new file mode 100644
index 0000000..ebdee06
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindow.mm
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** 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 "quikitwindow.h"
+
+#include "quikitscreen.h"
+
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QUIKitWindow::QUIKitWindow(QWidget *tlw) :
+ QPlatformWindow(tlw),
+ mWindow(nil)
+{
+ mScreen = static_cast<QUIKitScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
+ CGRect screenBounds = [mScreen->uiScreen() bounds];
+ QRect geom(screenBounds.origin.x, screenBounds.origin.y, screenBounds.size.width, screenBounds.size.height);
+ setGeometry(geom);
+ // TODO ensure the native window if the application is already running
+}
+
+QUIKitWindow::~QUIKitWindow()
+{
+ [mWindow release];
+}
+
+void QUIKitWindow::setGeometry(const QRect &rect)
+{
+ if (mWindow) {
+ mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
+ [mWindow setNeedsDisplay];
+ }
+ QPlatformWindow::setGeometry(rect);
+}
+
+UIWindow *QUIKitWindow::ensureNativeWindow()
+{
+ if (!mWindow) {
+ CGRect screenBounds = [mScreen->uiScreen() bounds];
+ QRect geom = geometry();
+ CGRect frame = CGRectMake(geom.x(), geom.y(), geom.width(), geom.height());
+ mWindow = [[UIWindow alloc] initWithFrame:frame];
+ mWindow.screen = mScreen->uiScreen();
+ mWindow.frame = frame; // for some reason setting the screen resets frame.origin
+ [mWindow setNeedsDisplay];
+ }
+ return mWindow;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.h b/src/plugins/platforms/uikit/quikitwindowsurface.h
new file mode 100644
index 0000000..50d02b4
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindowsurface.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 QUIKITWINDOWSURFACE_H
+#define QUIKITWINDOWSURFACE_H
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QImage>
+#include <QtGui/QWindowSystemInterface>
+
+#include <UIKit/UIKit.h>
+
+@interface QImageView : UIView
+{
+ CGImageRef m_cgImage;
+ QWidget *m_widget;
+}
+
+- (void)setImage:(QImage *)image;
+- (void)setWidget:(QWidget *)widget;
+
+//- (QList<struct QWindowSystemInterface::TouchPoint>)touchPointsForTouches:(NSSet *)touches;
+- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons;
+@end
+
+QT_BEGIN_NAMESPACE
+
+class QUIKitWindowSurface : public QWindowSurface
+{
+public:
+ QUIKitWindowSurface(QWidget *window);
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize (const QSize &size);
+
+ QImageView *nativeView() const { return mView; }
+private:
+ QImage *mImage;
+ QImageView *mView;
+};
+
+QT_END_NAMESPACE
+
+#endif // QUIKITWINDOWSURFACE_H
diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.mm b/src/plugins/platforms/uikit/quikitwindowsurface.mm
new file mode 100644
index 0000000..1274fca
--- /dev/null
+++ b/src/plugins/platforms/uikit/quikitwindowsurface.mm
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** 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 "quikitwindowsurface.h"
+#include "quikitwindow.h"
+
+#include <QtDebug>
+
+@implementation QImageView
+
+- (void)dealloc
+{
+ CGImageRelease(m_cgImage);
+ [super dealloc];
+}
+
+- (void)setImage:(QImage *)image
+{
+ CGImageRelease(m_cgImage);
+
+ const uchar *imageData = image->bits();
+ int bitDepth = image->depth();
+ int colorBufferSize = 8;
+ int bytesPrLine = image->bytesPerLine();
+ int width = image->width();
+ int height = image->height();
+
+ CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB();
+
+ CGDataProviderRef cgDataProviderRef = CGDataProviderCreateWithData(
+ NULL,
+ imageData,
+ image->byteCount(),
+ NULL);
+
+ m_cgImage = CGImageCreate(width,
+ height,
+ colorBufferSize,
+ bitDepth,
+ bytesPrLine,
+ cgColourSpaceRef,
+ kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
+ cgDataProviderRef,
+ NULL,
+ false,
+ kCGRenderingIntentDefault);
+
+ CGDataProviderRelease(cgDataProviderRef);
+ CGColorSpaceRelease(cgColourSpaceRef);
+}
+
+- (void)setWidget:(QWidget *)widget
+{
+ m_widget = widget;
+}
+
+- (void)drawRect:(CGRect)rect
+{
+
+ if (!m_cgImage)
+ return;
+
+ CGContextRef cgContext = UIGraphicsGetCurrentContext();
+ CGContextSaveGState( cgContext );
+
+ int dy = rect.origin.y + CGRectGetMaxY(rect);
+ CGContextTranslateCTM(cgContext, 0, dy);
+ CGContextScaleCTM(cgContext, 1, -1);
+ CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, rect);
+ CGContextDrawImage(cgContext,rect,subImage);
+ CGImageRelease(subImage);
+
+ CGContextRestoreGState(cgContext);
+}
+
+//- (QList<struct QWindowSystemInterface::TouchPoint>)touchPointsForTouches:(NSSet *)touches
+//{
+// NSEnumerator *enumerator = [touches objectEnumerator];
+// id touch;
+// int count = 0;
+// QList<struct QWindowSystemInterface::TouchPoint> result;
+// while ((touch = [enumerator nextObject])) {
+// CGPoint locationInView = [touch locationInView:self];
+// CGRect bounds = [self bounds];
+// struct QWindowSystemInterface::TouchPoint p;
+// p.id = count;
+// p.isPrimary = true;
+// p.normalPosition = QPointF(locationInView.x / bounds.size.width,
+// locationInView.y / bounds.size.height);
+// p.area = QRectF(locationInView.x, locationInView.y, 1, 1);
+// p.pressure = 1.;
+// switch ([touch phase]) {
+// case UITouchPhaseBegan:
+// p.state = Qt::TouchPointPressed;
+// break;
+// case UITouchPhaseMoved:
+// p.state = Qt::TouchPointMoved;
+// break;
+// case UITouchPhaseStationary:
+// p.state = Qt::TouchPointStationary;
+// break;
+// case UITouchPhaseEnded:
+// case UITouchPhaseCancelled:
+// p.state = Qt::TouchPointReleased;
+// break;
+// }
+// result << p;
+// qDebug() << p.id << ":" << p.normalPosition << p.area << p.state;
+// ++count;
+// }
+// qDebug() << result.size();
+// return result;
+//}
+
+- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons
+{
+ UITouch *touch = [touches anyObject];
+ CGPoint locationInView = [touch locationInView:self];
+ QPoint p(locationInView.x, locationInView.y);
+ // TODO handle global touch point? for status bar?
+ QWindowSystemInterface::handleMouseEvent(m_widget, (ulong)(event.timestamp*1000),
+ p, p, buttons);
+}
+
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchBegin, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton];
+}
+
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchUpdate, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton];
+}
+
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchEnd, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton];
+}
+
+- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000),
+ // QEvent::TouchEnd, QTouchEvent::TouchScreen,
+ // [self touchPointsForTouches:touches]);
+ [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton];
+}
+
+@end
+
+QT_BEGIN_NAMESPACE
+
+QUIKitWindowSurface::QUIKitWindowSurface(QWidget *window)
+ : QWindowSurface(window)
+{
+ QUIKitWindow *platformWindow = static_cast<QUIKitWindow *>(window->platformWindow());
+ Q_ASSERT(platformWindow);
+ const QRect geo = window->geometry();
+ mView = [[QImageView alloc] initWithFrame:CGRectMake(geo.x(),geo.y(),geo.width(),geo.height())];
+ [mView setMultipleTouchEnabled:YES];
+ [mView setWidget:window];
+ mImage = new QImage(window->size(),QImage::Format_ARGB32_Premultiplied);
+ [mView setImage:mImage];
+ if (platformWindow->nativeWindow()) {
+ [platformWindow->nativeWindow() addSubview:mView];
+ [mView setNeedsDisplay];
+ }
+}
+
+QPaintDevice *QUIKitWindowSurface::paintDevice()
+{
+ return mImage;
+}
+
+void QUIKitWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(widget);
+ Q_UNUSED(offset);
+
+ QRect geo = region.boundingRect();
+ [mView setNeedsDisplayInRect:CGRectMake(geo.x(),geo.y(),geo.width(),geo.height())];
+}
+
+void QUIKitWindowSurface::resize (const QSize &size)
+{
+ QWindowSurface::resize(size);
+
+ delete mImage;
+ mImage = new QImage(size,QImage::Format_ARGB32_Premultiplied);
+ [mView setImage:mImage];
+ const QRect geo = geometry();
+ [mView setFrame:CGRectMake(geo.x(), geo.y(), size.width(), size.height())];
+ [mView setNeedsDisplay];
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/uikit/uikit.pro b/src/plugins/platforms/uikit/uikit.pro
new file mode 100644
index 0000000..b73c334
--- /dev/null
+++ b/src/plugins/platforms/uikit/uikit.pro
@@ -0,0 +1,23 @@
+TARGET = quikit
+include(../../qpluginbase.pri)
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+OBJECTIVE_SOURCES = main.mm \
+ quikitintegration.mm \
+ quikitwindow.mm \
+ quikitscreen.mm \
+ quikiteventloop.mm \
+ quikitwindowsurface.mm
+
+OBJECTIVE_HEADERS = quikitintegration.h \
+ quikitwindow.h \
+ quikitscreen.h \
+ quikiteventloop.h \
+ quikitwindowsurface.h
+
+#add libz for freetype.
+LIBS += -lz
+
+#include(../fontdatabases/basicunix/basicunix.pri)
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp
index e051e2d..890b8f8 100644
--- a/src/plugins/platforms/vnc/main.cpp
+++ b/src/plugins/platforms/vnc/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/vnc/qvnccursor.cpp b/src/plugins/platforms/vnc/qvnccursor.cpp
index e83696d..dbcdef3 100644
--- a/src/plugins/platforms/vnc/qvnccursor.cpp
+++ b/src/plugins/platforms/vnc/qvnccursor.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/vnc/qvnccursor.h b/src/plugins/platforms/vnc/qvnccursor.h
index eeb3686..8eb26e0 100644
--- a/src/plugins/platforms/vnc/qvnccursor.h
+++ b/src/plugins/platforms/vnc/qvnccursor.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp
index b36ff33..b99ff3f 100644
--- a/src/plugins/platforms/vnc/qvncintegration.cpp
+++ b/src/plugins/platforms/vnc/qvncintegration.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -152,6 +152,15 @@ QVNCIntegration::QVNCIntegration(const QStringList& paramList)
screen->setDirty(screenRect);
}
+bool QVNCIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+
QPixmapData *QVNCIntegration::createPixmapData(QPixmapData::PixelType type) const
{
return new QRasterPixmapData(type);
diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h
index dfc0e6b..ef16dfa 100644
--- a/src/plugins/platforms/vnc/qvncintegration.h
+++ b/src/plugins/platforms/vnc/qvncintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -81,6 +81,7 @@ class QVNCIntegration : public QPlatformIntegration
public:
QVNCIntegration(const QStringList& paramList);
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp
index 288d1bc..be2de7c 100644
--- a/src/plugins/platforms/vnc/qvncserver.cpp
+++ b/src/plugins/platforms/vnc/qvncserver.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/vnc/qvncserver.h b/src/plugins/platforms/vnc/qvncserver.h
index 7244bdf..3b514a5 100644
--- a/src/plugins/platforms/vnc/qvncserver.h
+++ b/src/plugins/platforms/vnc/qvncserver.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/wayland/main.cpp b/src/plugins/platforms/wayland/main.cpp
index 1bca661..6dc1c2b 100644
--- a/src/plugins/platforms/wayland/main.cpp
+++ b/src/plugins/platforms/wayland/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp
index 29c6abd..614686f 100644
--- a/src/plugins/platforms/wayland/qwaylandcursor.cpp
+++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -48,7 +48,7 @@
#include <QtGui/QImageReader>
-#define DATADIR "/home/jlind/install/share"
+#define DATADIR "/usr/share"
static const struct pointer_image {
const char *filename;
@@ -164,6 +164,9 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget)
QImageReader reader(p->filename);
+ if (!reader.canRead())
+ return;
+
if (mBuffer == NULL || mBuffer->size() != reader.size()) {
if (mBuffer)
delete mBuffer;
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h
index 19e6047..254cb94 100644
--- a/src/plugins/platforms/wayland/qwaylandcursor.h
+++ b/src/plugins/platforms/wayland/qwaylandcursor.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
index 70713ec..27f4334 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -50,10 +50,6 @@
#include <fcntl.h>
#include <stdio.h>
-extern "C" {
-#include <xf86drm.h>
-}
-
struct wl_surface *QWaylandDisplay::createSurface()
{
return wl_compositor_create_surface(mCompositor);
@@ -67,14 +63,6 @@ struct wl_buffer *QWaylandDisplay::createShmBuffer(int fd,
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);
@@ -90,62 +78,11 @@ 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)
+struct wl_egl_display *QWaylandDisplay::nativeDisplay()
{
- 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);
+ return mNativeEglDisplay;
}
-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,
@@ -189,9 +126,6 @@ void QWaylandDisplay::displayHandleGlobal(struct wl_display *display,
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) {
@@ -207,27 +141,12 @@ void QWaylandDisplay::displayHandleGlobal(struct wl_display *display,
}
}
-static void roundtripCallback(void *data)
+void QWaylandDisplay::iterate()
{
- 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);
+ wl_display_iterate(mDisplay, WL_DISPLAY_READABLE | WL_DISPLAY_WRITABLE);
}
-static const char *socket_name = NULL;
-
-void QWaylandDisplay::eventDispatcher(void)
+void QWaylandDisplay::readEvents(void)
{
wl_display_iterate(mDisplay, WL_DISPLAY_READABLE);
}
@@ -257,7 +176,10 @@ void QWaylandDisplay::flushRequests(void)
QWaylandDisplay::QWaylandDisplay(void)
: mWriteNotifier(0)
{
- mDisplay = wl_display_connect(socket_name);
+#ifdef QT_WAYLAND_GL_SUPPORT
+ EGLint major, minor;
+#endif
+ mDisplay = wl_display_connect(NULL);
if (mDisplay == NULL) {
fprintf(stderr, "failed to create display: %m\n");
return;
@@ -266,23 +188,32 @@ QWaylandDisplay::QWaylandDisplay(void)
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");
+#ifdef QT_WAYLAND_GL_SUPPORT
+ mNativeEglDisplay = wl_egl_display_create(mDisplay);
+#else
+ mNativeEglDisplay = 0;
+#endif
+
+ readEvents();
+
+#ifdef QT_WAYLAND_GL_SUPPORT
+ mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay);
+ if (mEglDisplay == NULL) {
+ qWarning("EGL not available");
+ } else {
+ if (!eglInitialize(mEglDisplay, &major, &minor)) {
+ qWarning("failed to initialize EGL display");
+ return;
+ }
+ }
+#else
+ mEglDisplay = 0;
+#endif
int fd = wl_display_get_fd(mDisplay, sourceUpdate, this);
mReadNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(mReadNotifier,
- SIGNAL(activated(int)), this, SLOT(eventDispatcher()));
+ SIGNAL(activated(int)), this, SLOT(readEvents()));
mWriteNotifier = new QSocketNotifier(fd, QSocketNotifier::Write, this);
connect(mWriteNotifier,
@@ -293,6 +224,9 @@ QWaylandDisplay::QWaylandDisplay(void)
QWaylandDisplay::~QWaylandDisplay(void)
{
close(mFd);
+#ifdef QT_WAYLAND_GL_SUPPORT
+ eglTerminate(mEglDisplay);
+#endif
wl_display_destroy(mDisplay);
}
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
index f179713..d994ffe 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.h
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -44,13 +44,12 @@
#include <QtCore/QObject>
#include <QtCore/QRect>
+#include <QtCore/QDataStream>
+#include <QtCore/QTextStream>
+#include <QtCore/QMetaType>
+#include <QtGui>
-#include <wayland-client.h>
-
-#define MESA_EGL_NO_X11_HEADERS
-#define EGL_EGLEXT_PROTOTYPES
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
+#include "qwaylandinclude.h"
class QWaylandInputDevice;
class QSocketNotifier;
@@ -71,12 +70,10 @@ public:
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();
+ struct wl_egl_display *nativeDisplay();
EGLDisplay eglDisplay() { return mEglDisplay; }
void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y);
@@ -84,14 +81,15 @@ public:
void syncCallback(wl_display_sync_func_t func, void *data);
void frameCallback(wl_display_frame_func_t func, void *data);
+ void iterate();
+
public slots:
- void eventDispatcher(void);
+ void readEvents(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;
@@ -101,16 +99,13 @@ private:
QSocketNotifier *mReadNotifier;
QSocketNotifier *mWriteNotifier;
EGLDisplay mEglDisplay;
+ struct wl_egl_display *mNativeEglDisplay;
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,
@@ -123,7 +118,6 @@ private:
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;
};
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
index 76c8c33..a8bc352 100644
--- a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -38,191 +38,104 @@
** $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 <QtOpenGL/QGLFramebufferObject>
+#include <QtOpenGL/QGLContext>
-#include <wayland-client.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/mman.h>
+#include <QtOpenGL/private/qglengineshadermanager_p.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)
+static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br)
{
- glDeleteTextures(1, &mTexture);
- eglDestroyImageKHR(mDisplay->eglDisplay(), mImage);
- wl_buffer_destroy(mBuffer);
-}
+ const GLenum target = GL_TEXTURE_2D;
+ QRectF src = br.isEmpty()
+ ? QRectF(QPointF(), texSize)
+ : QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size());
-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();
-}
+ if (target == GL_TEXTURE_2D) {
+ qreal width = texSize.width();
+ qreal height = texSize.height();
-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;
+ src.setLeft(src.left() / width);
+ src.setRight(src.right() / width);
+ src.setTop(src.top() / height);
+ src.setBottom(src.bottom() / height);
}
- mPlatformGLContext->makeCurrent();
- glGenFramebuffers(1, &m_thisFBO);
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO);
+ const GLfloat tx1 = src.left();
+ const GLfloat tx2 = src.right();
+ const GLfloat ty1 = src.top();
+ const GLfloat ty2 = src.bottom();
- if (windowSurface->size().isValid())
- resize(windowSurface->size());
-}
+ GLfloat texCoordArray[4*2] = {
+ tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1
+ };
-QWaylandPaintDevice::~QWaylandPaintDevice()
-{
- for(int i = 0; i < mBufferList.size(); i++) {
- delete mBufferList[i];
- }
- glDeleteRenderbuffers(1,&mDepthStencil);
- glDeleteFramebuffers(1,&m_thisFBO);
-}
+ GLfloat vertexArray[4*2];
+ vertexArray[0] = rect.left(); vertexArray[1] = rect.top();
+ vertexArray[2] = rect.right(); vertexArray[3] = rect.top();
+ vertexArray[4] = rect.right(); vertexArray[5] = rect.bottom();
+ vertexArray[6] = rect.left(); vertexArray[7] = rect.bottom();
-QSize QWaylandPaintDevice::size() const
-{
- return mSize;
-}
-QGLContext *QWaylandPaintDevice::context() const
-{
- return QGLContext::fromPlatformGLContext(mPlatformGLContext);
-}
-QPaintEngine *QWaylandPaintDevice::paintEngine() const
-{
- return qt_qgl_paint_engine();
-}
+ glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray);
+ glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray);
-void QWaylandPaintDevice::beginPaint()
-{
- QGLPaintDevice::beginPaint();
- currentDrmBuffer()->bindToCurrentFbo();
-}
+ glBindTexture(target, tex_id);
-bool QWaylandPaintDevice::isFlipped()const
-{
- return true;
+ glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
+ glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
+ glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR);
+
+ glBindTexture(target, 0);
}
-void QWaylandPaintDevice::resize(const QSize &size)
+static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect)
{
- 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);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_BLEND);
+ glViewport(0, 0, viewport.width(), viewport.height());
- GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
+ QGLShaderProgram *blitProgram =
+ QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram();
+ blitProgram->bind();
+ blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/);
- switch(status) {
- case GL_NO_ERROR:
- case GL_FRAMEBUFFER_COMPLETE_EXT:
- qDebug() << "fbo ok";
- break;
- default:
- qDebug() <<"QWaylandDrmBuffer error: "<< status;
- break;
- }
- QT_CHECK_GLERROR();
-}
+ // The shader manager's blit program does not multiply the
+ // vertices by the pmv matrix, so we need to do the effect
+ // of the orthographic projection here ourselves.
+ QRectF r;
+ qreal w = viewport.width();
+ qreal h = viewport.height();
+ r.setLeft((targetRect.left() / w) * 2.0f - 1.0f);
+ if (targetRect.right() == (viewport.width() - 1))
+ r.setRight(1.0f);
+ else
+ r.setRight((targetRect.right() / w) * 2.0f - 1.0f);
+ r.setBottom((targetRect.top() / h) * 2.0f - 1.0f);
+ if (targetRect.bottom() == (viewport.height() - 1))
+ r.setTop(1.0f);
+ else
+ r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f);
-QWaylandDrmBuffer *QWaylandPaintDevice::currentDrmBuffer() const
-{
- return mBufferList[mCurrentPaintBuffer];
-}
-QWaylandDrmBuffer *QWaylandPaintDevice::currentDrmBufferAndSwap()
-{
- QWaylandDrmBuffer *currentDrmBuffer = mBufferList[mCurrentPaintBuffer];
- mCurrentPaintBuffer = (mCurrentPaintBuffer +1) % mBufferList.size();
- return currentDrmBuffer;
+ drawTexture(r, texture, texSize, sourceRect);
}
QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window)
: QWindowSurface(window)
, mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
- , mPaintDevice(new QWaylandPaintDevice(mDisplay, this,window->platformWindow()->glContext()))
+ , mPaintDevice(0)
{
}
@@ -232,40 +145,39 @@ QWaylandDrmWindowSurface::~QWaylandDrmWindowSurface()
delete mPaintDevice;
}
-void QWaylandDrmWindowSurface::beginPaint(const QRegion &)
+QPaintDevice *QWaylandDrmWindowSurface::paintDevice()
{
- window()->platformWindow()->glContext()->makeCurrent();
+ return mPaintDevice;
}
-QPaintDevice *QWaylandDrmWindowSurface::paintDevice()
+void QWaylandDrmWindowSurface::beginPaint(const QRegion &)
{
- return mPaintDevice;
+ window()->platformWindow()->glContext()->makeCurrent();
+ glClearColor(0,0,0,0xff);
+ glClear(GL_COLOR_BUFFER_BIT);
}
void QWaylandDrmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(offset);
+ Q_UNUSED(region);
QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow();
- ww->attach(mPaintDevice->currentDrmBufferAndSwap());
+ if (mPaintDevice->isBound())
+ mPaintDevice->release();
- 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());
- }
+ QRect rect(0,0,size().width(),size().height());
+ QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext());
+ blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect);
+ ww->glContext()->swapBuffers();
}
-void QWaylandDrmWindowSurface::resize(const QSize &requestedSize)
+void QWaylandDrmWindowSurface::resize(const QSize &size)
{
- QWindowSurface::resize(requestedSize);
- QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow();
-
- ww->glContext()->makeCurrent();
-
- mPaintDevice->resize(requestedSize);
- ww->attach(mPaintDevice->currentDrmBuffer());
+ QWindowSurface::resize(size);
+ window()->platformWindow()->glContext()->makeCurrent();
+ delete mPaintDevice;
+ mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil,GL_TEXTURE_2D,GL_RGBA);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.h b/src/plugins/platforms/wayland/qwaylanddrmsurface.h
index eafea13..78418ee 100644
--- a/src/plugins/platforms/wayland/qwaylanddrmsurface.h
+++ b/src/plugins/platforms/wayland/qwaylanddrmsurface.h
@@ -43,75 +43,10 @@
#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 QGLFramebufferObject;
class QWaylandDrmWindowSurface : public QWindowSurface
{
@@ -123,12 +58,13 @@ public:
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+
void resize(const QSize &size);
private:
QWaylandDisplay *mDisplay;
- QWaylandPaintDevice *mPaintDevice;
+ QGLFramebufferObject *mPaintDevice;
};
#endif // QWAYLANDDRMSURFACE_H
diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/qwaylandeglwindow.cpp
new file mode 100644
index 0000000..ed54bb9
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandeglwindow.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** 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 "qwaylandeglwindow.h"
+
+#include "qwaylandscreen.h"
+#include "qwaylandglcontext.h"
+#include "qwaylandinclude.h"
+
+QWaylandEglWindow::QWaylandEglWindow(QWidget *window)
+ : QWaylandWindow(window)
+ , mGLContext(0)
+ , mWaylandEglWindow(0)
+{
+ //super creates a new surface
+ newSurfaceCreated();
+}
+
+QWaylandEglWindow::~QWaylandEglWindow()
+{
+ if (mGLContext)
+ delete mGLContext;
+}
+
+QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
+{
+ return QWaylandWindow::Egl;
+}
+
+void QWaylandEglWindow::setGeometry(const QRect &rect)
+{
+ QWaylandWindow::setGeometry(rect);
+ if (mWaylandEglWindow) {
+ wl_egl_window_resize(mWaylandEglWindow,rect.width(),rect.height(),0,0);
+ }
+}
+
+void QWaylandEglWindow::setParent(const QPlatformWindow *parent)
+{
+ const QWaylandWindow *wParent = static_cast<const QWaylandWindow *>(parent);
+
+ mParentWindow = wParent;
+}
+
+QPlatformGLContext * QWaylandEglWindow::glContext() const
+{
+ if (!mGLContext) {
+ QWaylandEglWindow *that = const_cast<QWaylandEglWindow *>(this);
+ that->mGLContext = new QWaylandGLContext(that->mDisplay,widget()->platformWindowFormat());
+
+ EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
+ EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL);
+ that->mGLContext->setEglSurface(surface);
+ }
+
+ return mGLContext;
+}
+
+void QWaylandEglWindow::newSurfaceCreated()
+{
+ if (mWaylandEglWindow) {
+ wl_egl_window_destroy(mWaylandEglWindow);
+ }
+ wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual();
+ QSize size = geometry().size();
+ if (!size.isValid())
+ size = QSize(0,0);
+
+ mWaylandEglWindow = wl_egl_window_create(mDisplay->nativeDisplay(),mSurface,size.width(),size.height(),visual);
+ if (mGLContext) {
+ EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
+ EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL);
+ mGLContext->setEglSurface(surface);
+ }
+}
diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.h b/src/plugins/platforms/wayland/qwaylandeglwindow.h
new file mode 100644
index 0000000..4b3bb5b
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandeglwindow.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 QWAYLANDEGLWINDOW_H
+#define QWAYLANDEGLWINDOW_H
+
+#include "qwaylandwindow.h"
+
+class QWaylandGLContext;
+
+class QWaylandEglWindow : public QWaylandWindow
+{
+public:
+ QWaylandEglWindow(QWidget *window);
+ ~QWaylandEglWindow();
+ WindowType windowType() const;
+ void setGeometry(const QRect &rect);
+ void setParent(const QPlatformWindow *parent);
+ QPlatformGLContext *glContext() const;
+protected:
+ void newSurfaceCreated();
+private:
+ QWaylandGLContext *mGLContext;
+ struct wl_egl_window *mWaylandEglWindow;
+ EGLConfig mConfig;
+
+ const QWaylandWindow *mParentWindow;
+};
+
+#endif // QWAYLANDEGLWINDOW_H
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/qwaylandglcontext.cpp
index 4bf68c4..3720567 100644
--- a/src/plugins/platforms/wayland/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/wayland/qwaylandglcontext.cpp
@@ -45,29 +45,21 @@
#include "qwaylandwindow.h"
#include "qwaylanddrmsurface.h"
+#include "../eglconvenience/qeglconvenience.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
-};
+Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex)
QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format)
: QPlatformGLContext()
- , mFormat(format)
, mDisplay(wd)
+ , mSurface(EGL_NO_SURFACE)
+ , mConfig(q_configFromQPlatformWindowFormat(mDisplay->eglDisplay(),format,true))
+ , mFormat(qt_qPlatformWindowFormatFromConfig(mDisplay->eglDisplay(),mConfig))
{
- QPlatformGLContext *sharePlatformContext;
+ QPlatformGLContext *sharePlatformContext = 0;
if (format.useDefaultSharedContext()) {
if (!QPlatformGLContext::defaultSharedContext()) {
if (qt_defaultSharedContextMutex()->tryLock()){
@@ -88,26 +80,22 @@ QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowF
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);
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
+ mContext = eglCreateContext(mDisplay->eglDisplay(), mConfig,
+ shareEGLContext, eglContextAttrs.constData());
}
QWaylandGLContext::QWaylandGLContext()
: QPlatformGLContext()
, mDisplay(0)
, mContext(EGL_NO_CONTEXT)
+ , mSurface(EGL_NO_SURFACE)
+ , mConfig(0)
{ }
QWaylandGLContext::~QWaylandGLContext()
@@ -118,7 +106,10 @@ QWaylandGLContext::~QWaylandGLContext()
void QWaylandGLContext::makeCurrent()
{
QPlatformGLContext::makeCurrent();
- eglMakeCurrent(mDisplay->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, mContext);
+ if (mSurface == EGL_NO_SURFACE) {
+ qWarning("makeCurrent with EGL_NO_SURFACE");
+ }
+ eglMakeCurrent(mDisplay->eglDisplay(), mSurface, mSurface, mContext);
}
void QWaylandGLContext::doneCurrent()
@@ -129,6 +120,7 @@ void QWaylandGLContext::doneCurrent()
void QWaylandGLContext::swapBuffers()
{
+ eglSwapBuffers(mDisplay->eglDisplay(),mSurface);
}
void *QWaylandGLContext::getProcAddress(const QString &string)
@@ -138,10 +130,26 @@ void *QWaylandGLContext::getProcAddress(const QString &string)
void QWaylandGLContext::createDefaultSharedContex(QWaylandDisplay *display)
{
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
QWaylandGLContext *defaultSharedContext = new QWaylandGLContext;
defaultSharedContext->mDisplay = display;
- defaultSharedContext->mContext = eglCreateContext(mDisplay->eglDisplay(), NULL,
- EGL_NO_CONTEXT, contextAttibutes);
+ defaultSharedContext->mContext = eglCreateContext(mDisplay->eglDisplay(),mConfig,
+ EGL_NO_CONTEXT, eglContextAttrs.constData());
QPlatformGLContext::setDefaultSharedContext(defaultSharedContext);
}
+void QWaylandGLContext::setEglSurface(EGLSurface surface)
+{
+ doneCurrent();
+ mSurface = surface;
+}
+
+EGLConfig QWaylandGLContext::eglConfig() const
+{
+ return mConfig;
+}
+
diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.h b/src/plugins/platforms/wayland/qwaylandglcontext.h
index d9ba323..dd319fd 100644
--- a/src/plugins/platforms/wayland/qwaylandglcontext.h
+++ b/src/plugins/platforms/wayland/qwaylandglcontext.h
@@ -42,17 +42,14 @@
#ifndef QWAYLANDGLCONTEXT_H
#define QWAYLANDGLCONTEXT_H
+#include "qwaylanddisplay.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>
+#include "qwaylandinclude.h"
class QWaylandGLContext : public QPlatformGLContext {
public:
@@ -62,14 +59,18 @@ public:
void doneCurrent();
void swapBuffers();
void* getProcAddress(const QString&);
+
QPlatformWindowFormat platformWindowFormat() const { return mFormat; }
+ void setEglSurface(EGLSurface surface);
+ EGLConfig eglConfig() const;
private:
- QPlatformWindowFormat mFormat;
QWaylandDisplay *mDisplay;
- static EGLint contextAttibutes[];
EGLContext mContext;
+ EGLSurface mSurface;
+ EGLConfig mConfig;
+ QPlatformWindowFormat mFormat;
void createDefaultSharedContex(QWaylandDisplay *display);
QWaylandGLContext();
diff --git a/src/plugins/platforms/wayland/qwaylandinclude.h b/src/plugins/platforms/wayland/qwaylandinclude.h
new file mode 100644
index 0000000..0135251
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandinclude.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 QWAYLANDINCLUDE_H
+#define QWAYLANDINCLUDE_H
+
+#include <wayland-client.h>
+
+#ifdef QT_WAYLAND_GL_SUPPORT
+#include <wayland-egl.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#define EGL_EGLEXT_PROTOTYPES
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+
+#else
+typedef void* EGLDisplay;
+typedef void* EGLConfig;
+#endif
+
+#endif // QWAYLANDINCLUDE_H
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
index 03edc07..47f9c91 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -52,8 +52,11 @@
#include <unistd.h>
#include <fcntl.h>
+
+#ifndef QT_NO_WAYLAND_XKB
#include <X11/extensions/XKBcommon.h>
#include <X11/keysym.h>
+#endif
QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
uint32_t id)
@@ -63,13 +66,13 @@ QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
, 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);
+#ifndef QT_NO_WAYLAND_XKB
+ struct xkb_rule_names names;
names.rules = "evdev";
names.model = "pc105";
names.layout = "us";
@@ -77,6 +80,7 @@ QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
names.options = "";
mXkb = xkb_compile_keymap_from_rules(&names);
+#endif
}
void QWaylandInputDevice::inputHandleMotion(void *data,
@@ -135,6 +139,7 @@ void QWaylandInputDevice::inputHandleButton(void *data,
inputDevice->mButtons);
}
+#ifndef QT_NO_WAYLAND_XKB
static Qt::KeyboardModifiers translateModifiers(int s)
{
const uchar qt_alt_mask = XKB_COMMON_MOD1_MASK;
@@ -201,11 +206,13 @@ static uint32_t translateKey(uint32_t sym, char *string, size_t size)
return toupper(sym);
}
}
+#endif
void QWaylandInputDevice::inputHandleKey(void *data,
struct wl_input_device *input_device,
uint32_t time, uint32_t key, uint32_t state)
{
+#ifndef QT_NO_WAYLAND_XKB
Q_UNUSED(input_device);
QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
QWaylandWindow *window = inputDevice->mKeyboardFocus;
@@ -244,6 +251,7 @@ void QWaylandInputDevice::inputHandleKey(void *data,
inputDevice->mModifiers,
QString::fromLatin1(s));
}
+#endif
}
void QWaylandInputDevice::inputHandlePointerFocus(void *data,
@@ -280,21 +288,31 @@ void QWaylandInputDevice::inputHandleKeyboardFocus(void *data,
struct wl_surface *surface,
struct wl_array *keys)
{
+#ifndef QT_NO_WAYLAND_XKB
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;
+ uint32_t *k, *end;
+ uint32_t code;
+
+ end = (uint32_t *) ((char *) keys->data + keys->size);
+ inputDevice->mModifiers = 0;
+ for (k = (uint32_t *) keys->data; k < end; k++) {
+ code = *k + inputDevice->mXkb->min_key_code;
+ inputDevice->mModifiers |=
+ translateModifiers(inputDevice->mXkb->map->modmap[code]);
}
if (surface) {
window = (QWaylandWindow *) wl_surface_get_user_data(surface);
inputDevice->mKeyboardFocus = window;
+ QWindowSystemInterface::handleWindowActivated(window->widget());
+ } else {
+ inputDevice->mKeyboardFocus = NULL;
+ QWindowSystemInterface::handleWindowActivated(0);
}
+#endif
}
const struct wl_input_device_listener QWaylandInputDevice::inputDeviceListener = {
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index 02bc680..267a037 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -44,19 +44,22 @@
#include "qwaylanddisplay.h"
#include "qwaylandshmsurface.h"
#include "qwaylanddrmsurface.h"
-#include "qwaylandwindow.h"
+#include "qwaylandshmwindow.h"
+#include "qwaylandeglwindow.h"
-#include "qfontconfigdatabase.h"
+#include "qgenericunixfontdatabase.h"
#include <QtGui/QWindowSystemInterface>
#include <QtGui/QPlatformCursor>
#include <QtGui/QPlatformWindowFormat>
#include <QtGui/private/qpixmap_raster_p.h>
+#ifdef QT_WAYLAND_GL_SUPPORT
#include <QtOpenGL/private/qpixmapdata_gl_p.h>
+#endif
QWaylandIntegration::QWaylandIntegration(bool useOpenGL)
- : mFontDb(new QFontconfigDatabase())
+ : mFontDb(new QGenericUnixFontDatabase())
, mDisplay(new QWaylandDisplay())
, mUseOpenGL(useOpenGL)
{
@@ -68,28 +71,41 @@ QWaylandIntegration::screens() const
return mDisplay->screens();
}
+bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const
{
+#ifdef QT_WAYLAND_GL_SUPPORT
if (mUseOpenGL)
return new QGLPixmapData(type);
+#endif
return new QRasterPixmapData(type);
}
-
-
QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
- return new QWaylandWindow(widget);
+ bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
+ if (useOpenGL)
+ return new QWaylandEglWindow(widget);
+
+ return new QWaylandShmWindow(widget);
}
QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const
{
Q_UNUSED(winId);
Q_UNUSED(winId);
-
- if (mUseOpenGL)
+ bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
+ if (useOpenGL)
return new QWaylandDrmWindowSurface(widget);
+
return new QWaylandShmWindowSurface(widget);
}
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h
index d707612..067b6e4 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.h
+++ b/src/plugins/platforms/wayland/qwaylandintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -54,6 +54,7 @@ class QWaylandIntegration : public QPlatformIntegration
public:
QWaylandIntegration(bool useOpenGL = false);
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp
index aa1083f..35e2532 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen.cpp
+++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp
@@ -85,3 +85,22 @@ QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget)
QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget);
return static_cast<QWaylandScreen *>(platformScreen);
}
+
+wl_visual * QWaylandScreen::visual() const
+{
+ struct wl_visual *visual;
+
+ switch (format()) {
+ case QImage::Format_ARGB32:
+ visual = mWaylandDisplay->argbVisual();
+ break;
+ case QImage::Format_ARGB32_Premultiplied:
+ visual = mWaylandDisplay->argbPremultipliedVisual();
+ break;
+ default:
+ qDebug("unsupported buffer format %d requested\n", format());
+ visual = mWaylandDisplay->argbVisual();
+ break;
+ }
+ return visual;
+}
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h
index 368859f..7784646 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen.h
+++ b/src/plugins/platforms/wayland/qwaylandscreen.h
@@ -46,6 +46,7 @@
class QWaylandDisplay;
class QWaylandCursor;
+struct wl_visual;
class QWaylandScreen : public QPlatformScreen
{
@@ -59,6 +60,8 @@ public:
int depth() const;
QImage::Format format() const;
+ wl_visual *visual() const;
+
static QWaylandScreen *waylandScreenFromWidget(QWidget *widget);
private:
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
index 83bb993..54da9a1 100644
--- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -44,7 +44,7 @@
#include <QtGui/private/qapplication_p.h>
#include "qwaylanddisplay.h"
-#include "qwaylandwindow.h"
+#include "qwaylandshmwindow.h"
#include "qwaylandscreen.h"
#include <wayland-client.h>
@@ -95,6 +95,7 @@ QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window)
: QWindowSurface(window)
, mBuffer(0)
, mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mWaitingForFrameSync(false)
{
}
@@ -107,27 +108,41 @@ QPaintDevice *QWaylandShmWindowSurface::paintDevice()
return mBuffer->image();
}
+void QWaylandShmWindowSurface::beginPaint(const QRegion &)
+{
+ while (mWaitingForFrameSync) {
+ mDisplay->iterate();
+ }
+}
+
+void QWaylandShmWindowSurface::frameCallback(void *data, uint32_t time)
+{
+ QWaylandShmWindowSurface *self = static_cast<QWaylandShmWindowSurface*>(data);
+ self->mWaitingForFrameSync = false;
+}
+
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;
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
- for (i = 0; i < rects.size(); i++) {
- r = &rects.at(i);
- wl_surface_damage(ww->surface(),
- r->x(), r->y(), r->width(), r->height());
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); i++) {
+ waylandWindow->damage(rects.at(i));
}
+ mWaitingForFrameSync = true;
+ mDisplay->frameCallback(QWaylandShmWindowSurface::frameCallback, this);
}
void QWaylandShmWindowSurface::resize(const QSize &size)
{
- QWaylandWindow *ww = (QWaylandWindow *) window()->platformWindow();
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
+
QWindowSurface::resize(size);
- QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
+ QImage::Format format = QPlatformScreen::platformScreenForWidget(window())->format();
if (mBuffer != NULL && mBuffer->size() == size)
return;
@@ -137,7 +152,7 @@ void QWaylandShmWindowSurface::resize(const QSize &size)
mBuffer = new QWaylandShmBuffer(mDisplay, size, format);
- ww->attach(mBuffer);
+ waylandWindow->attach(mBuffer);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h
index 266b290..02b324a 100644
--- a/src/plugins/platforms/wayland/qwaylandshmsurface.h
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -71,10 +71,14 @@ public:
QPaintDevice *paintDevice();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
+ void beginPaint(const QRegion &);
private:
+ static void frameCallback(void *data, uint32_t time);\
+
QWaylandShmBuffer *mBuffer;
QWaylandDisplay *mDisplay;
+ bool mWaitingForFrameSync;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
new file mode 100644
index 0000000..cafd2d0
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** 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 "qwaylandshmwindow.h"
+
+#include "qwaylandbuffer.h"
+
+QWaylandShmWindow::QWaylandShmWindow(QWidget *widget)
+ : QWaylandWindow(widget)
+ , mBuffer(0)
+{
+ newSurfaceCreated();
+}
+
+QWaylandShmWindow::~QWaylandShmWindow()
+{
+
+}
+
+QWaylandWindow::WindowType QWaylandShmWindow::windowType() const
+{
+ return QWaylandWindow::Shm;
+}
+
+QPlatformGLContext * QWaylandShmWindow::glContext() const
+{
+ qWarning("Trying to retrieve a glContext from a Raster window surface!");
+ return 0;
+}
+
+void QWaylandShmWindow::attach(QWaylandBuffer *buffer)
+{
+ mBuffer = buffer;
+ if (mSurface) {
+ wl_surface_attach(mSurface, buffer->buffer(),0,0);
+ }
+}
+
+
+void QWaylandShmWindow::damage(const QRect &rect)
+{
+ wl_surface_damage(mSurface,
+ rect.x(), rect.y(), rect.width(), rect.height());
+}
+
+void QWaylandShmWindow::newSurfaceCreated()
+{
+ if (mBuffer) {
+ wl_surface_attach(mSurface,mBuffer->buffer(),0,0);
+ }
+}
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h
new file mode 100644
index 0000000..14a29d2
--- /dev/null
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 QWAYLANDSHMWINDOW_H
+#define QWAYLANDSHMWINDOW_H
+
+#include "qwaylandwindow.h"
+
+class QWaylandShmWindow : public QWaylandWindow
+{
+public:
+ QWaylandShmWindow(QWidget *widget);
+ ~QWaylandShmWindow();
+
+ WindowType windowType() const;
+ QPlatformGLContext *glContext() const;
+ void attach(QWaylandBuffer *buffer);
+ void damage(const QRect &rect);
+protected:
+ void newSurfaceCreated();
+private:
+ QWaylandBuffer *mBuffer;
+};
+
+#endif // QWAYLANDSHMWINDOW_H
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index a28bdfe..a912a83 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -43,10 +43,6 @@
#include "qwaylanddisplay.h"
#include "qwaylandscreen.h"
-#include "qwaylandglcontext.h"
-#include "qwaylandbuffer.h"
-
-#include "qwaylanddrmsurface.h"
#include <QtGui/QWidget>
#include <QtGui/QWindowSystemInterface>
@@ -56,8 +52,6 @@
QWaylandWindow::QWaylandWindow(QWidget *window)
: QPlatformWindow(window)
, mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
- , mGLContext(0)
- , mBuffer(0)
{
static WId id = 1;
mWindowId = id++;
@@ -67,8 +61,6 @@ QWaylandWindow::QWaylandWindow(QWidget *window)
QWaylandWindow::~QWaylandWindow()
{
- if (mGLContext)
- delete mGLContext;
}
WId QWaylandWindow::winId() const
@@ -78,13 +70,17 @@ WId QWaylandWindow::winId() const
void QWaylandWindow::setParent(const QPlatformWindow *parent)
{
- QWaylandWindow *wParent = (QWaylandWindow *)parent;
-
- mParentWindow = wParent;
+ Q_UNUSED(parent);
+ qWarning("Trying to add a raster window as a sub-window");
}
void QWaylandWindow::setVisible(bool visible)
{
+ if (!mSurface) {
+ mSurface = mDisplay->createSurface();
+ newSurfaceCreated();
+ }
+
if (visible) {
wl_surface_set_user_data(mSurface, this);
wl_surface_map_toplevel(mSurface);
@@ -94,13 +90,6 @@ void QWaylandWindow::setVisible(bool visible)
}
}
-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)
@@ -109,15 +98,7 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges,
Q_UNUSED(edges);
QRect geometry = QRect(x, y, width, height);
- QWindowSystemInterface::handleGeometryChange(widget(), geometry);
-}
+ setGeometry(geometry);
-QPlatformGLContext *QWaylandWindow::glContext() const
-{
- if (!mGLContext) {
- QWaylandWindow *that = const_cast<QWaylandWindow *>(this);
- that->mGLContext = new QWaylandGLContext(mDisplay, widget()->platformWindowFormat());
- }
-
- return mGLContext;
+ QWindowSystemInterface::handleGeometryChange(widget(), geometry);
}
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h
index 8b047d7..3b51ee7 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandwindow.h
@@ -45,35 +45,38 @@
#include <QtGui/QPlatformWindow>
#include <stdint.h>
+#include "qwaylanddisplay.h"
class QWaylandDisplay;
class QWaylandBuffer;
+struct wl_egl_window;
class QWaylandWindow : public QPlatformWindow
{
public:
+ enum WindowType {
+ Shm,
+ Egl
+ };
+
QWaylandWindow(QWidget *window);
~QWaylandWindow();
- struct wl_surface *surface() { return mSurface; }
+ virtual WindowType windowType() const = 0;
+ WId winId() const;
void setVisible(bool visible);
+ void setParent(const QPlatformWindow *parent);
+
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:
+protected:
struct wl_surface *mSurface;
+ virtual void newSurfaceCreated() = 0;
QWaylandDisplay *mDisplay;
- QPlatformGLContext *mGLContext;
WId mWindowId;
- QWaylandBuffer *mBuffer;
- QWaylandWindow *mParentWindow;
+
};
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
index 8ba1408..face860 100644
--- a/src/plugins/platforms/wayland/wayland.pro
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -3,37 +3,56 @@ include(../../qpluginbase.pri)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+DEFINES += Q_PLATFORM_WAYLAND
+DEFINES += $$QMAKE_DEFINES_WAYLAND
+
SOURCES = main.cpp \
qwaylandintegration.cpp \
qwaylandshmsurface.cpp \
- qwaylanddrmsurface.cpp \
qwaylandinputdevice.cpp \
- qwaylandglcontext.cpp \
- qwaylandcursor.cpp \
- qwaylanddisplay.cpp \
- qwaylandwindow.cpp \
- qwaylandscreen.cpp
+ qwaylandcursor.cpp \
+ qwaylanddisplay.cpp \
+ qwaylandwindow.cpp \
+ qwaylandscreen.cpp \
+ qwaylandshmwindow.cpp
HEADERS = qwaylandintegration.h \
- qwaylandcursor.h \
- qwaylanddisplay.h \
- qwaylandwindow.h \
- qwaylandscreen.h \
- qwaylandglcontext.h \
- qwaylandshmsurface.h \
- qwaylanddrmsurface.h \
- qwaylandbuffer.h
-
-contains(QT_CONFIG, opengl) {
+ qwaylandcursor.h \
+ qwaylanddisplay.h \
+ qwaylandwindow.h \
+ qwaylandscreen.h \
+ qwaylandshmsurface.h \
+ qwaylanddrmsurface.h \
+ qwaylandbuffer.h \
+ qwaylandinclude.h \
+ qwaylandeglwindow.h \
+ qwaylandshmwindow.h
+
+INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND
+LIBS += $$QMAKE_LIBS_WAYLAND
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
+
+contains(QT_CONFIG, opengles2) {
QT += opengl
+ LIBS += -lwayland-egl -lEGL
+
+ SOURCES += qwaylanddrmsurface.cpp \
+ qwaylandglcontext.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ qwaylandeglwindow.cpp
+
+ HEADERS += qwaylandglcontext.h \
+ ../eglconvenience/qeglconvenience.h \
+
+ DEFINES += QT_WAYLAND_GL_SUPPORT
}
-LIBS += -lwayland-client -lxkbcommon -lEGL
-unix {
+
+unix:isEmpty(QMAKE_INCDIR_WAYLAND) {
CONFIG += link_pkgconfig
PKGCONFIG += libdrm
}
-include (../fontdatabases/fontconfig/fontconfig.pri)
+include (../fontdatabases/genericunix/genericunix.pri)
target.path += $$[QT_INSTALL_PLUGINS]/platforms
INSTALLS += target
diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README
new file mode 100644
index 0000000..e88596b
--- /dev/null
+++ b/src/plugins/platforms/xcb/README
@@ -0,0 +1,2 @@
+Required packages:
+libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev
diff --git a/src/plugins/platforms/xcb/main.cpp b/src/plugins/platforms/xcb/main.cpp
new file mode 100644
index 0000000..89bc66e
--- /dev/null
+++ b/src/plugins/platforms/xcb/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** 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 <QtGui/QPlatformIntegrationPlugin>
+#include "qxcbintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QXcbIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QXcbIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "xcb";
+ return list;
+}
+
+QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "xcb")
+ return new QXcbIntegration;
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(xcb, QXcbIntegrationPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qdri2context.cpp b/src/plugins/platforms/xcb/qdri2context.cpp
new file mode 100644
index 0000000..0079f91
--- /dev/null
+++ b/src/plugins/platforms/xcb/qdri2context.cpp
@@ -0,0 +1,271 @@
+/****************************************************************************
+**
+** 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 "qdri2context.h"
+
+#include "qxcbwindow.h"
+#include "qxcbconnection.h"
+
+#include <QtCore/QDebug>
+#include <QtGui/QWidget>
+
+#include <xcb/dri2.h>
+#include <xcb/xfixes.h>
+
+#define MESA_EGL_NO_X11_HEADERS
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#define GL_GLEXT_PROTOTYPES
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+class QDri2ContextPrivate
+{
+public:
+ QDri2ContextPrivate(QXcbWindow *window)
+ : qXcbWindow(window)
+ , windowFormat(window->widget()->platformWindowFormat())
+ , image(0)
+ {
+ }
+
+ xcb_window_t xcbWindow() { return qXcbWindow->window(); }
+ xcb_connection_t *xcbConnection() { return qXcbWindow->xcb_connection(); }
+
+ QXcbWindow *qXcbWindow;
+ QPlatformWindowFormat windowFormat;
+
+ EGLContext eglContext;
+
+ EGLImageKHR image;
+
+ GLuint fbo;
+ GLuint rbo;
+ GLuint depth;
+
+ QSize size;
+};
+
+QDri2Context::QDri2Context(QXcbWindow *window)
+ : d_ptr(new QDri2ContextPrivate(window))
+{
+ Q_D(QDri2Context);
+
+ static const EGLint contextAttribs[] = {
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_NONE
+ };
+
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ EGLContext shareContext = EGL_NO_CONTEXT;
+ if (window->widget()->platformWindowFormat().sharedGLContext()) {
+ QDri2Context *context = static_cast<QDri2Context *>(window->widget()->platformWindowFormat().sharedGLContext());
+ shareContext = context->d_func()->eglContext;
+ }
+ d->eglContext = eglCreateContext(EGL_DISPLAY_FROM_XCB(d->qXcbWindow), NULL,
+ shareContext, contextAttribs);
+
+ if (d->eglContext == EGL_NO_CONTEXT) {
+ qDebug() << "No eglContext!" << eglGetError();
+ }
+
+ EGLBoolean makeCurrentSuccess = eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext);
+ if (!makeCurrentSuccess) {
+ qDebug() << "eglMakeCurrent failed!" << eglGetError();
+ }
+
+ xcb_dri2_create_drawable (d->xcbConnection(), d->xcbWindow());
+
+ glGenFramebuffers(1,&d->fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER,d->fbo);
+ glActiveTexture(GL_TEXTURE0);
+
+ glGenRenderbuffers(1, &d->rbo);
+ glBindRenderbuffer(GL_RENDERBUFFER, d->rbo);
+
+ glGenRenderbuffers(1,&d->depth);
+ glBindRenderbuffer(GL_RENDERBUFFER, d->depth);
+
+ resize(d->qXcbWindow->widget()->geometry().size());
+
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, d->rbo);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERER,d->depth);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERER,d->depth);
+
+ //restore the old current context
+ const QPlatformGLContext *currentContext = QPlatformGLContext::currentContext();
+ if (currentContext)
+ const_cast<QPlatformGLContext*>(currentContext)->makeCurrent();
+}
+
+QDri2Context::~QDri2Context()
+{
+ //cleanup
+}
+
+void QDri2Context::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+ Q_D(QDri2Context);
+
+ eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext);
+ glBindFramebuffer(GL_FRAMEBUFFER,d->fbo);
+
+}
+
+void QDri2Context::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+ Q_D(QDri2Context);
+ eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
+}
+
+void QDri2Context::swapBuffers()
+{
+ Q_D(QDri2Context);
+ xcb_rectangle_t rectangle;
+ rectangle.x = 0;
+ rectangle.y = 0;
+ rectangle.width = d->qXcbWindow->widget()->geometry().width();
+ rectangle.height = d->qXcbWindow->widget()->geometry().height();
+
+ xcb_xfixes_region_t xfixesRegion = xcb_generate_id(d->xcbConnection());
+ xcb_xfixes_create_region(d->xcbConnection(), xfixesRegion,
+ 1, &rectangle);
+
+ xcb_dri2_copy_region_cookie_t cookie = xcb_dri2_copy_region_unchecked(d->xcbConnection(),
+ d->qXcbWindow->window(),
+ xfixesRegion,
+ XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT,
+ XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT);
+
+ xcb_dri2_copy_region_reply_t *reply = xcb_dri2_copy_region_reply(d->xcbConnection(),cookie,NULL);
+
+ //cleanup
+ delete reply;
+ xcb_xfixes_destroy_region(d->xcbConnection(), xfixesRegion);
+
+}
+
+void * QDri2Context::getProcAddress(const QString &procName)
+{
+ return (void *)eglGetProcAddress(qPrintable(procName));
+}
+
+void QDri2Context::resize(const QSize &size)
+{
+ Q_D(QDri2Context);
+ d->size= size;
+
+ glBindFramebuffer(GL_FRAMEBUFFER,d->fbo);
+
+ xcb_dri2_dri2_buffer_t *backBfr = backBuffer();
+
+ if (d->image) {
+ qDebug() << "destroing image";
+ eglDestroyImageKHR(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),d->image);
+ }
+
+ EGLint imgAttribs[] = {
+ EGL_WIDTH, d->size.width(),
+ EGL_HEIGHT, d->size.height(),
+ EGL_DRM_BUFFER_STRIDE_MESA, backBfr->pitch /4,
+ EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
+ EGL_NONE
+ };
+
+ d->image = eglCreateImageKHR(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),
+ EGL_NO_CONTEXT,
+ EGL_DRM_BUFFER_MESA,
+ (EGLClientBuffer) backBfr->name,
+ imgAttribs);
+
+ glBindRenderbuffer(GL_RENDERBUFFER, d->rbo);
+ glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER,
+ d->image);
+
+ glBindRenderbuffer(GL_RENDERBUFFER, d->depth);
+ glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH24_STENCIL8_OES,d->size.width(), d->size.height());
+
+}
+
+QPlatformWindowFormat QDri2Context::platformWindowFormat() const
+{
+ Q_D(const QDri2Context);
+ return d->windowFormat;
+}
+
+xcb_dri2_dri2_buffer_t * QDri2Context::backBuffer()
+{
+ Q_D(QDri2Context);
+
+ unsigned int backBufferAttachment = XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT;
+ xcb_dri2_get_buffers_cookie_t cookie = xcb_dri2_get_buffers_unchecked (d->xcbConnection(),
+ d->xcbWindow(),
+ 1, 1, &backBufferAttachment);
+
+ xcb_dri2_get_buffers_reply_t *reply = xcb_dri2_get_buffers_reply (d->xcbConnection(), cookie, NULL);
+ if (!reply) {
+ qDebug() << "failed to get buffers reply";
+ return 0;
+ }
+
+ xcb_dri2_dri2_buffer_t *buffers = xcb_dri2_get_buffers_buffers (reply);
+ if (!buffers) {
+ qDebug() << "failed to get buffers";
+ return 0;
+ }
+
+ Q_ASSERT(reply->count == 1);
+
+ delete reply;
+
+ return buffers;
+}
+
+void * QDri2Context::eglContext() const
+{
+ Q_D(QDri2Context);
+ return d->eglContext;
+}
diff --git a/src/plugins/platforms/xcb/qdri2context.h b/src/plugins/platforms/xcb/qdri2context.h
new file mode 100644
index 0000000..42dd6bd
--- /dev/null
+++ b/src/plugins/platforms/xcb/qdri2context.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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 QDRI2CONTEXT_H
+#define QDRI2CONTEXT_H
+
+#include <QtGui/QPlatformGLContext>
+
+class QXcbWindow;
+class QDri2ContextPrivate;
+
+struct xcb_dri2_dri2_buffer_t;
+
+class QDri2Context : public QPlatformGLContext
+{
+ Q_DECLARE_PRIVATE(QDri2Context);
+public:
+ QDri2Context(QXcbWindow *window);
+ ~QDri2Context();
+
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void* getProcAddress(const QString& procName);
+
+ void resize(const QSize &size);
+
+ QPlatformWindowFormat platformWindowFormat() const;
+
+ void *eglContext() const;
+
+protected:
+ xcb_dri2_dri2_buffer_t *backBuffer();
+ QScopedPointer<QDri2ContextPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QDri2Context)
+};
+
+#endif // QDRI2CONTEXT_H
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
new file mode 100644
index 0000000..e94b6a6
--- /dev/null
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -0,0 +1,360 @@
+/****************************************************************************
+**
+** 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 <QDebug>
+#include <QLibrary>
+#include <QGLFormat>
+
+#include "qxcbwindow.h"
+#include "qxcbscreen.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <GL/glx.h>
+
+#include "qglxintegration.h"
+
+#if defined(Q_OS_LINUX) || defined(Q_OS_BSD4)
+#include <dlfcn.h>
+#endif
+
+QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive);
+
+QVector<int> QGLXContext::buildSpec(const QPlatformWindowFormat &format)
+{
+ QVector<int> spec(48);
+ int i = 0;
+
+ spec[i++] = GLX_LEVEL;
+ spec[i++] = 0;
+ spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT;
+
+ if (format.rgba()) {
+ spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
+ spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
+ spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
+ spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
+ if (format.alpha()) {
+ spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
+ }
+
+ spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+
+ if (format.alpha()) {
+ spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
+ }
+
+ } else {
+ spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
+ spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
+ }
+
+ spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False;
+ spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
+
+ if (format.depth()) {
+ spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
+ }
+
+ if (format.stencil()) {
+ spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
+ }
+ if (format.sampleBuffers()) {
+ spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
+ spec[i++] = 1;
+ spec[i++] = GLX_SAMPLES_ARB;
+ spec[i++] = format.samples() == -1 ? 4 : format.samples();
+ }
+
+ spec[i++] = None;
+ return spec;
+}
+
+GLXFBConfig QGLXContext::findConfig(const QXcbScreen *screen, const QPlatformWindowFormat &format)
+{
+ bool reduced = true;
+ GLXFBConfig chosenConfig = 0;
+ QPlatformWindowFormat reducedFormat = format;
+ while (!chosenConfig && reduced) {
+ QVector<int> spec = buildSpec(reducedFormat);
+ int confcount = 0;
+ GLXFBConfig *configs;
+ configs = glXChooseFBConfig(DISPLAY_FROM_XCB(screen), screen->screenNumber(), spec.constData(), &confcount);
+ if (confcount)
+ {
+ for (int i = 0; i < confcount; i++) {
+ chosenConfig = configs[i];
+ // Make sure we try to get an ARGB visual if the format asked for an alpha:
+ if (reducedFormat.alpha()) {
+ int alphaSize;
+ glXGetFBConfigAttrib(DISPLAY_FROM_XCB(screen), configs[i], GLX_ALPHA_SIZE, &alphaSize);
+ if (alphaSize > 0)
+ break;
+ } else {
+ break; // Just choose the first in the list if there's no alpha requested
+ }
+ }
+
+ XFree(configs);
+ }
+ reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced);
+ }
+
+ if (!chosenConfig)
+ qWarning("Warning no context created");
+
+ return chosenConfig;
+}
+
+XVisualInfo *QGLXContext::findVisualInfo(const QXcbScreen *screen, const QPlatformWindowFormat &format)
+{
+ GLXFBConfig config = QGLXContext::findConfig(screen,format);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config);
+ return visualInfo;
+}
+
+QPlatformWindowFormat QGLXContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
+{
+ QPlatformWindowFormat format;
+ int redSize = 0;
+ int greenSize = 0;
+ int blueSize = 0;
+ int alphaSize = 0;
+ int depthSize = 0;
+ int stencilSize = 0;
+ int sampleBuffers = 0;
+ int sampleCount = 0;
+ int level = 0;
+ int rgba = 0;
+ int stereo = 0;
+ int accumSizeA = 0;
+ int accumSizeR = 0;
+ int accumSizeG = 0;
+ int accumSizeB = 0;
+
+ XVisualInfo *vi = glXGetVisualFromFBConfig(display,config);
+ glXGetConfig(display,vi,GLX_RGBA,&rgba);
+ XFree(vi);
+ glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize);
+ glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize);
+ glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize);
+ glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize);
+ glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize);
+ glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize);
+ glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers);
+ glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level);
+ glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG);
+ glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB);
+
+ format.setRedBufferSize(redSize);
+ format.setGreenBufferSize(greenSize);
+ format.setBlueBufferSize(blueSize);
+ format.setAlphaBufferSize(alphaSize);
+ format.setDepthBufferSize(depthSize);
+ format.setStencilBufferSize(stencilSize);
+ format.setSampleBuffers(sampleBuffers);
+ if (format.sampleBuffers()) {
+ glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
+ format.setSamples(sampleCount);
+ }
+
+ format.setDirectRendering(glXIsDirect(display, ctx));
+ format.setRgba(rgba);
+ format.setStereo(stereo);
+ format.setAccumBufferSize(accumSizeB);
+
+ return format;
+}
+
+QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
+{
+ QPlatformWindowFormat retFormat = format;
+ *reduced = true;
+
+ if (retFormat.sampleBuffers()) {
+ retFormat.setSampleBuffers(false);
+ } else if (retFormat.stereo()) {
+ retFormat.setStereo(false);
+ } else if (retFormat.accum()) {
+ retFormat.setAccum(false);
+ }else if (retFormat.stencil()) {
+ retFormat.setStencil(false);
+ }else if (retFormat.alpha()) {
+ retFormat.setAlpha(false);
+ }else if (retFormat.depth()) {
+ retFormat.setDepth(false);
+ }else if (retFormat.doubleBuffer()) {
+ retFormat.setDoubleBuffer(false);
+ }else{
+ *reduced = false;
+ }
+ return retFormat;
+}
+
+QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format)
+ : QPlatformGLContext()
+ , m_screen(screen)
+ , m_drawable((Drawable)window)
+ , m_context(0)
+{
+
+ const QPlatformGLContext *sharePlatformContext;
+ if (format.useDefaultSharedContext()) {
+ if (!QPlatformGLContext::defaultSharedContext()) {
+ if (m_defaultSharedContextMutex.tryLock()){
+ createDefaultSharedContex(screen);
+ m_defaultSharedContextMutex.unlock();
+ } else {
+ m_defaultSharedContextMutex.lock(); //wait to the the shared context is created
+ m_defaultSharedContextMutex.unlock();
+ }
+ }
+ sharePlatformContext = QPlatformGLContext::defaultSharedContext();
+ } else {
+ sharePlatformContext = format.sharedGLContext();
+ }
+ GLXContext shareGlxContext = 0;
+ if (sharePlatformContext)
+ shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
+
+ GLXFBConfig config = findConfig(screen,format);
+ m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
+ m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
+}
+
+QGLXContext::QGLXContext(QXcbScreen *screen, Drawable drawable, GLXContext context)
+ : QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
+{
+
+}
+
+QGLXContext::~QGLXContext()
+{
+ if (m_context)
+ glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context);
+}
+
+void QGLXContext::createDefaultSharedContex(QXcbScreen *screen)
+{
+ int x = 0;
+ int y = 0;
+ int w = 3;
+ int h = 3;
+
+ QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat();
+ GLXContext context;
+ GLXFBConfig config = findConfig(screen,format);
+ if (config) {
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config);
+ Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(screen), screen->root(), visualInfo->visual, AllocNone);
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ Window sharedWindow = XCreateWindow(DISPLAY_FROM_XCB(screen), screen->root(), x, y, w, h,
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+
+ context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, TRUE);
+ QPlatformGLContext *sharedContext = new QGLXContext(screen, sharedWindow, context);
+ QPlatformGLContext::setDefaultSharedContext(sharedContext);
+ } else {
+ qWarning("Warning no shared context created");
+ }
+}
+
+void QGLXContext::makeCurrent()
+{
+ QPlatformGLContext::makeCurrent();
+ glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context);
+}
+
+void QGLXContext::doneCurrent()
+{
+ QPlatformGLContext::doneCurrent();
+ glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0);
+}
+
+void QGLXContext::swapBuffers()
+{
+ glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable);
+}
+
+void* QGLXContext::getProcAddress(const QString& procName)
+{
+ typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *);
+ static qt_glXGetProcAddressARB glXGetProcAddressARB = 0;
+ static bool resolved = false;
+
+ if (resolved && !glXGetProcAddressARB)
+ return 0;
+ if (!glXGetProcAddressARB) {
+ QList<QByteArray> glxExt = QByteArray(glXGetClientString(DISPLAY_FROM_XCB(m_screen), 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);
+ if (handle) {
+ glXGetProcAddressARB = (qt_glXGetProcAddressARB) dlsym(handle, "glXGetProcAddressARB");
+ dlclose(handle);
+ }
+ if (!glXGetProcAddressARB)
+#endif
+ {
+ extern const QString qt_gl_library_name();
+// QLibrary lib(qt_gl_library_name());
+ QLibrary lib(QLatin1String("GL"));
+ glXGetProcAddressARB = (qt_glXGetProcAddressARB) lib.resolve("glXGetProcAddressARB");
+ }
+ }
+ resolved = true;
+ }
+ if (!glXGetProcAddressARB)
+ return 0;
+ return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
+}
+
+QPlatformWindowFormat QGLXContext::platformWindowFormat() const
+{
+ return m_windowFormat;
+}
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
new file mode 100644
index 0000000..f2e20c4
--- /dev/null
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -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$
+**
+****************************************************************************/
+
+#ifndef QGLXINTEGRATION_H
+#define QGLXINTEGRATION_H
+
+#include "qxcbwindow.h"
+
+#include <QtGui/QPlatformGLContext>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <QtCore/QMutex>
+
+#include <GL/glx.h>
+
+class QGLXContext : public QPlatformGLContext
+{
+public:
+ QGLXContext(Window window, QXcbScreen *xd, const QPlatformWindowFormat &format);
+ ~QGLXContext();
+
+ virtual void makeCurrent();
+ virtual void doneCurrent();
+ virtual void swapBuffers();
+ virtual void* getProcAddress(const QString& procName);
+
+ GLXContext glxContext() const { return m_context; }
+
+ QPlatformWindowFormat platformWindowFormat() const;
+
+ static XVisualInfo *findVisualInfo(const QXcbScreen *xd, const QPlatformWindowFormat &format);
+
+private:
+ static GLXFBConfig findConfig(const QXcbScreen *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);
+
+ QXcbScreen *m_screen;
+ Drawable m_drawable;
+ GLXContext m_context;
+ QPlatformWindowFormat m_windowFormat;
+
+ QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context);
+ static QMutex m_defaultSharedContextMutex;
+ static void createDefaultSharedContex(QXcbScreen *xd);
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
new file mode 100644
index 0000000..191699b
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -0,0 +1,557 @@
+/****************************************************************************
+**
+** 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 "qxcbconnection.h"
+#include "qxcbkeyboard.h"
+#include "qxcbscreen.h"
+#include "qxcbwindow.h"
+
+#include <QtAlgorithms>
+#include <QSocketNotifier>
+#include <QtGui/private/qapplication_p.h>
+
+#include <QtCore/QDebug>
+
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef XCB_USE_XLIB
+#include <X11/Xlib.h>
+#include <X11/Xlib-xcb.h>
+#endif
+
+#ifdef XCB_USE_EGL //dont pull in eglext prototypes
+#include <EGL/egl.h>
+#endif
+
+#ifdef XCB_USE_DRI2
+#include <xcb/dri2.h>
+#include <xcb/xfixes.h>
+extern "C" {
+#include <xf86drm.h>
+}
+#define MESA_EGL_NO_X11_HEADERS
+#define EGL_EGLEXT_PROTOTYPES
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#endif
+
+QXcbConnection::QXcbConnection(const char *displayName)
+ : m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
+#ifdef XCB_USE_DRI2
+ , m_dri2_major(0)
+ , m_dri2_minor(0)
+ , m_dri2_support_probed(false)
+ , m_has_support_for_dri2(false)
+#endif
+{
+ int primaryScreen = 0;
+
+#ifdef XCB_USE_XLIB
+ Display *dpy = XOpenDisplay(m_displayName.constData());
+ primaryScreen = DefaultScreen(dpy);
+ m_connection = XGetXCBConnection(dpy);
+ XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
+ m_xlib_display = dpy;
+#ifdef XCB_USE_EGL
+ EGLDisplay eglDisplay = eglGetDisplay(dpy);
+ m_egl_display = eglDisplay;
+ EGLint major, minor;
+ eglBindAPI(EGL_OPENGL_ES_API);
+ m_has_egl = eglInitialize(eglDisplay,&major,&minor);
+#endif //XCB_USE_EGL
+#else
+ m_connection = xcb_connect(m_displayName.constData(), &primaryScreen);
+
+#endif //XCB_USE_XLIB
+ m_setup = xcb_get_setup(xcb_connection());
+
+ xcb_screen_iterator_t it = xcb_setup_roots_iterator(m_setup);
+
+ int screenNumber = 0;
+ while (it.rem) {
+ m_screens << new QXcbScreen(this, it.data, screenNumber++);
+ xcb_screen_next(&it);
+ }
+
+ QSocketNotifier *socket = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this);
+ connect(socket, SIGNAL(activated(int)), this, SLOT(eventDispatcher()));
+
+ m_keyboard = new QXcbKeyboard(this);
+
+ initializeAllAtoms();
+
+#ifdef XCB_USE_DRI2
+ initializeDri2();
+#endif
+}
+
+QXcbConnection::~QXcbConnection()
+{
+ qDeleteAll(m_screens);
+
+#ifdef XCB_USE_XLIB
+ XCloseDisplay((Display *)m_xlib_display);
+#else
+ xcb_disconnect(xcb_connection());
+#endif
+
+ delete m_keyboard;
+}
+
+QXcbWindow *platformWindowFromId(xcb_window_t id)
+{
+ QWidget *widget = QWidget::find(id);
+ if (widget)
+ return static_cast<QXcbWindow *>(widget->platformWindow());
+ return 0;
+}
+
+#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \
+{ \
+ event_t *e = (event_t *)event; \
+ if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) \
+ platformWindow->handler(e); \
+} \
+break;
+
+#define HANDLE_KEYBOARD_EVENT(event_t, handler) \
+{ \
+ event_t *e = (event_t *)event; \
+ if (QXcbWindow *platformWindow = platformWindowFromId(e->event)) \
+ m_keyboard->handler(platformWindow->widget(), e); \
+} \
+break;
+
+//#define XCB_EVENT_DEBUG
+
+void printXcbEvent(const char *message, xcb_generic_event_t *event)
+{
+#ifdef XCB_EVENT_DEBUG
+#define PRINT_XCB_EVENT(event) \
+ case event: \
+ printf("%s: %d - %s\n", message, event, #event); \
+ break;
+
+ switch (event->response_type & ~0x80) {
+ PRINT_XCB_EVENT(XCB_KEY_PRESS);
+ PRINT_XCB_EVENT(XCB_KEY_RELEASE);
+ PRINT_XCB_EVENT(XCB_BUTTON_PRESS);
+ PRINT_XCB_EVENT(XCB_BUTTON_RELEASE);
+ PRINT_XCB_EVENT(XCB_MOTION_NOTIFY);
+ PRINT_XCB_EVENT(XCB_ENTER_NOTIFY);
+ PRINT_XCB_EVENT(XCB_LEAVE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_FOCUS_IN);
+ PRINT_XCB_EVENT(XCB_FOCUS_OUT);
+ PRINT_XCB_EVENT(XCB_KEYMAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_EXPOSE);
+ PRINT_XCB_EVENT(XCB_GRAPHICS_EXPOSURE);
+ PRINT_XCB_EVENT(XCB_VISIBILITY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CREATE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_DESTROY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_UNMAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_MAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_MAP_REQUEST);
+ PRINT_XCB_EVENT(XCB_REPARENT_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CONFIGURE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CONFIGURE_REQUEST);
+ PRINT_XCB_EVENT(XCB_GRAVITY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_RESIZE_REQUEST);
+ PRINT_XCB_EVENT(XCB_CIRCULATE_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CIRCULATE_REQUEST);
+ PRINT_XCB_EVENT(XCB_PROPERTY_NOTIFY);
+ PRINT_XCB_EVENT(XCB_SELECTION_CLEAR);
+ PRINT_XCB_EVENT(XCB_SELECTION_REQUEST);
+ PRINT_XCB_EVENT(XCB_SELECTION_NOTIFY);
+ PRINT_XCB_EVENT(XCB_COLORMAP_NOTIFY);
+ PRINT_XCB_EVENT(XCB_CLIENT_MESSAGE);
+ PRINT_XCB_EVENT(XCB_MAPPING_NOTIFY);
+ default:
+ printf("%s: %d - %s\n", message, event->response_type, "unknown");
+ }
+#else
+ Q_UNUSED(message);
+ Q_UNUSED(event);
+#endif
+}
+
+void QXcbConnection::eventDispatcher()
+{
+ while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) {
+ bool handled = true;
+ switch (event->response_type & ~0x80) {
+ case XCB_EXPOSE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent);
+ case XCB_BUTTON_PRESS:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
+ case XCB_BUTTON_RELEASE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
+ case XCB_MOTION_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
+ case XCB_CONFIGURE_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent);
+ case XCB_CLIENT_MESSAGE:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent);
+ case XCB_ENTER_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent);
+ case XCB_LEAVE_NOTIFY:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent);
+ case XCB_FOCUS_IN:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent);
+ case XCB_FOCUS_OUT:
+ HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent);
+ case XCB_KEY_PRESS:
+ HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent);
+ case XCB_KEY_RELEASE:
+ HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent);
+ case XCB_MAPPING_NOTIFY:
+ m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event);
+ break;
+ default:
+ handled = false;
+ return;
+ }
+ if (handled)
+ printXcbEvent("Handled XCB event", event);
+ else
+ printXcbEvent("Unhandled XCB event", event);
+ }
+}
+
+static const char * xcb_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"
+};
+
+xcb_atom_t QXcbConnection::atom(QXcbAtom::Atom atom)
+{
+ return m_allAtoms[atom];
+}
+
+void QXcbConnection::initializeAllAtoms() {
+ const char *names[QXcbAtom::NAtoms];
+ const char *ptr = xcb_atomnames;
+
+ int i = 0;
+ while (*ptr) {
+ names[i++] = ptr;
+ while (*ptr)
+ ++ptr;
+ ++ptr;
+ }
+
+ Q_ASSERT(i == QXcbAtom::NPredefinedAtoms);
+
+ QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
+ settings_atom_name += m_displayName;
+ names[i++] = settings_atom_name;
+
+ xcb_intern_atom_cookie_t cookies[QXcbAtom::NAtoms];
+
+ Q_ASSERT(i == QXcbAtom::NAtoms);
+ for (i = 0; i < QXcbAtom::NAtoms; ++i)
+ cookies[i] = xcb_intern_atom(xcb_connection(), false, strlen(names[i]), names[i]);
+
+ for (i = 0; i < QXcbAtom::NAtoms; ++i)
+ m_allAtoms[i] = xcb_intern_atom_reply(xcb_connection(), cookies[i], 0)->atom;
+}
+
+#if defined(XCB_USE_EGL)
+bool QXcbConnection::hasEgl() const
+{
+ return m_has_egl;
+}
+#endif // defined(XCB_USE_EGL)
+
+#ifdef XCB_USE_DRI2
+void QXcbConnection::initializeDri2()
+{
+ xcb_dri2_connect_cookie_t connect_cookie = xcb_dri2_connect_unchecked (m_connection,
+ m_screens[0]->root(),
+ XCB_DRI2_DRIVER_TYPE_DRI);
+
+ xcb_dri2_connect_reply_t *connect = xcb_dri2_connect_reply (m_connection,
+ connect_cookie, NULL);
+
+ if (! connect || connect->driver_name_length + connect->device_name_length == 0) {
+ qDebug() << "Failed to connect to dri2";
+ return;
+ }
+
+ m_dri2_device_name = QByteArray(xcb_dri2_connect_device_name (connect),
+ xcb_dri2_connect_device_name_length (connect));
+ delete connect;
+
+ int fd = open(m_dri2_device_name.constData(), O_RDWR);
+ if (fd < 0) {
+ qDebug() << "InitializeDri2: Could'nt open device << dri2DeviceName";
+ m_dri2_device_name = QByteArray();
+ return;
+ }
+
+ drm_magic_t magic;
+ if (drmGetMagic(fd, &magic)) {
+ qDebug() << "Failed to get drmMagic";
+ return;
+ }
+
+ xcb_dri2_authenticate_cookie_t authenticate_cookie = xcb_dri2_authenticate_unchecked(m_connection,
+ m_screens[0]->root(), magic);
+ xcb_dri2_authenticate_reply_t *authenticate = xcb_dri2_authenticate_reply(m_connection,
+ authenticate_cookie, NULL);
+ if (authenticate == NULL || !authenticate->authenticated) {
+ fprintf(stderr, "DRI2: failed to authenticate\n");
+ free(authenticate);
+ return;
+ }
+
+ delete authenticate;
+
+ EGLDisplay display = eglGetDRMDisplayMESA(fd);
+ if (!display) {
+ fprintf(stderr, "failed to create display\n");
+ return;
+ }
+
+ m_egl_display = display;
+ EGLint major,minor;
+ if (!eglInitialize(display, &major, &minor)) {
+ fprintf(stderr, "failed to initialize display\n");
+ return;
+ }
+}
+
+bool QXcbConnection::hasSupportForDri2() const
+{
+ if (!m_dri2_support_probed) {
+ xcb_generic_error_t *error = 0;
+
+ xcb_prefetch_extension_data (m_connection, &xcb_xfixes_id);
+ xcb_prefetch_extension_data (m_connection, &xcb_dri2_id);
+
+ xcb_xfixes_query_version_cookie_t xfixes_query_cookie = xcb_xfixes_query_version(m_connection,
+ XCB_XFIXES_MAJOR_VERSION,
+ XCB_XFIXES_MINOR_VERSION);
+
+ xcb_dri2_query_version_cookie_t dri2_query_cookie = xcb_dri2_query_version (m_connection,
+ XCB_DRI2_MAJOR_VERSION,
+ XCB_DRI2_MINOR_VERSION);
+
+ xcb_xfixes_query_version_reply_t *xfixes_query = xcb_xfixes_query_version_reply (m_connection,
+ xfixes_query_cookie, &error);
+ if (!xfixes_query || error || xfixes_query->major_version < 2) {
+ delete error;
+ delete xfixes_query;
+ return false;
+ }
+ delete xfixes_query;
+
+ xcb_dri2_query_version_reply_t *dri2_query = xcb_dri2_query_version_reply (m_connection,
+ dri2_query_cookie, &error);
+ if (!dri2_query || error) {
+ delete error;
+ delete dri2_query;
+ return false;
+ }
+
+ QXcbConnection *that = const_cast<QXcbConnection *>(this);
+ that->m_dri2_major = dri2_query->major_version;
+ that->m_dri2_minor = dri2_query->minor_version;
+
+ that->m_has_support_for_dri2 = true;
+ that->m_dri2_support_probed = true;
+ }
+ return m_has_support_for_dri2;
+}
+#endif //XCB_USE_DRI2
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
new file mode 100644
index 0000000..e00fbb1
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -0,0 +1,294 @@
+/****************************************************************************
+**
+** 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 QXCBCONNECTION_H
+#define QXCBCONNECTION_H
+
+#include <xcb/xcb.h>
+
+#include <QList>
+#include <QObject>
+
+class QXcbScreen;
+
+namespace QXcbAtom {
+ enum Atom {
+ // 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
+ };
+}
+
+class QXcbKeyboard;
+
+class QXcbConnection : public QObject
+{
+ Q_OBJECT
+public:
+ QXcbConnection(const char *displayName = 0);
+ ~QXcbConnection();
+
+ QList<QXcbScreen *> screens() const { return m_screens; }
+ int primaryScreen() const { return m_primaryScreen; }
+
+ xcb_atom_t atom(QXcbAtom::Atom atom);
+
+ const char *displayName() const { return m_displayName.constData(); }
+
+ xcb_connection_t *xcb_connection() const { return m_connection; }
+
+ QXcbKeyboard *keyboard() const { return m_keyboard; }
+
+#ifdef XCB_USE_XLIB
+ void *xlib_display() const { return m_xlib_display; }
+#endif
+
+#ifdef XCB_USE_DRI2
+ bool hasSupportForDri2() const;
+ QByteArray dri2DeviceName() const { return m_dri2_device_name; }
+#endif
+#ifdef XCB_USE_EGL
+ bool hasEgl() const;
+#endif
+#if defined(XCB_USE_EGL) || defined(XCB_USE_DRI2)
+ void *egl_display() const { return m_egl_display; }
+#endif
+
+private slots:
+ void eventDispatcher();
+
+private:
+ void initializeAllAtoms();
+#ifdef XCB_USE_DRI2
+ void initializeDri2();
+#endif
+
+ xcb_connection_t *m_connection;
+ const xcb_setup_t *m_setup;
+
+ QList<QXcbScreen *> m_screens;
+ int m_primaryScreen;
+
+ xcb_atom_t m_allAtoms[QXcbAtom::NAtoms];
+
+ QByteArray m_displayName;
+
+ QXcbKeyboard *m_keyboard;
+
+#if defined(XCB_USE_XLIB)
+ void *m_xlib_display;
+#endif
+
+#ifdef XCB_USE_DRI2
+ uint32_t m_dri2_major;
+ uint32_t m_dri2_minor;
+ bool m_dri2_support_probed;
+ bool m_has_support_for_dri2;
+ QByteArray m_dri2_device_name;
+#endif
+#if defined(XCB_USE_EGL) || defined(XCB_USE_DRI2)
+ void *m_egl_display;
+ bool m_has_egl;
+#endif
+};
+
+#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
+
+#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
+#define EGL_DISPLAY_FROM_XCB(object) ((EGLDisplay)(object->connection()->egl_display()))
+#endif //endifXCB_USE_DRI2
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
new file mode 100644
index 0000000..63c26a1
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** 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 "qxcbintegration.h"
+#include "qxcbconnection.h"
+#include "qxcbscreen.h"
+#include "qxcbwindow.h"
+#include "qxcbwindowsurface.h"
+#include "qxcbnativeinterface.h"
+
+#include <xcb/xcb.h>
+
+#include <private/qpixmap_raster_p.h>
+
+#include "qgenericunixfontdatabase.h"
+
+#include <stdio.h>
+
+#ifdef XCB_USE_EGL
+#include <EGL/egl.h>
+#endif
+
+QXcbIntegration::QXcbIntegration()
+ : m_connection(new QXcbConnection)
+{
+ foreach (QXcbScreen *screen, m_connection->screens())
+ m_screens << screen;
+
+ m_fontDatabase = new QGenericUnixFontDatabase();
+ m_nativeInterface = new QXcbNativeInterface;
+}
+
+QXcbIntegration::~QXcbIntegration()
+{
+ delete m_connection;
+}
+
+QPixmapData *QXcbIntegration::createPixmapData(QPixmapData::PixelType type) const
+{
+ return new QRasterPixmapData(type);
+}
+
+QPlatformWindow *QXcbIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QXcbWindow(widget);
+}
+
+QWindowSurface *QXcbIntegration::createWindowSurface(QWidget *widget, WId winId) const
+{
+ Q_UNUSED(winId);
+ return new QXcbWindowSurface(widget);
+}
+
+QList<QPlatformScreen *> QXcbIntegration::screens() const
+{
+ return m_screens;
+}
+
+void QXcbIntegration::moveToScreen(QWidget *window, int screen)
+{
+ Q_UNUSED(window);
+ Q_UNUSED(screen);
+}
+
+bool QXcbIntegration::isVirtualDesktop()
+{
+ return false;
+}
+
+QPlatformFontDatabase *QXcbIntegration::fontDatabase() const
+{
+ return m_fontDatabase;
+}
+
+QPixmap QXcbIntegration::grabWindow(WId window, int x, int y, int width, int height) const
+{
+ Q_UNUSED(window);
+ Q_UNUSED(x);
+ Q_UNUSED(y);
+ Q_UNUSED(width);
+ Q_UNUSED(height);
+ return QPixmap();
+}
+
+
+bool QXcbIntegration::hasOpenGL() const
+{
+#if defined(XCB_USE_GLX)
+ return true;
+#elif defined(XCB_USE_EGL)
+ return m_connection->hasEgl();
+#elif defined(XCB_USE_DRI2)
+ if (m_connection->hasSupportForDri2()) {
+ return true;
+ }
+#endif
+ return false;
+}
+
+QPlatformNativeInterface * QXcbIntegration::nativeInterface() const
+{
+ return m_nativeInterface;
+}
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
new file mode 100644
index 0000000..6c9634e
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 QXCBINTEGRATION_H
+#define QXCBINTEGRATION_H
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QPlatformScreen>
+
+QT_BEGIN_NAMESPACE
+
+class QXcbConnection;
+
+class QXcbIntegration : public QPlatformIntegration
+{
+public:
+ QXcbIntegration();
+ ~QXcbIntegration();
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
+ QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
+ QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+
+ QList<QPlatformScreen *> screens() const;
+ void moveToScreen(QWidget *window, int screen);
+ bool isVirtualDesktop();
+ QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+ bool hasOpenGL() const;
+
+ QPlatformNativeInterface *nativeInterface()const;
+
+private:
+ QList<QPlatformScreen *> m_screens;
+ QXcbConnection *m_connection;
+
+ QPlatformFontDatabase *m_fontDatabase;
+ QPlatformNativeInterface *m_nativeInterface;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
new file mode 100644
index 0000000..ec9a009
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -0,0 +1,967 @@
+/****************************************************************************
+**
+** 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 "qxcbkeyboard.h"
+
+#include <xcb/xcb_keysyms.h>
+
+#include <X11/keysym.h>
+
+#include <QtGui/QWindowSystemInterface>
+#include <QtCore/QTextCodec>
+
+#include <stdio.h>
+
+#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 QXcbKeyboard::translateModifiers(int s)
+{
+ Qt::KeyboardModifiers ret = 0;
+ if (s & XCB_MOD_MASK_SHIFT)
+ ret |= Qt::ShiftModifier;
+ if (s & XCB_MOD_MASK_CONTROL)
+ ret |= Qt::ControlModifier;
+ if (s & m_alt_mask)
+ ret |= Qt::AltModifier;
+ if (s & m_meta_mask)
+ ret |= Qt::MetaModifier;
+ return ret;
+}
+
+int QXcbKeyboard::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 QXcbKeyboard::translateKeySym(xcb_keysym_t 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;
+}
+
+QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection)
+ : QXcbObject(connection)
+ , m_alt_mask(0)
+ , m_super_mask(0)
+ , m_hyper_mask(0)
+ , m_meta_mask(0)
+{
+ m_key_symbols = xcb_key_symbols_alloc(xcb_connection());
+}
+
+QXcbKeyboard::~QXcbKeyboard()
+{
+ xcb_key_symbols_free(m_key_symbols);
+}
+
+// #define XCB_KEYBOARD_DEBUG
+
+void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time)
+{
+ int col = state & XCB_MOD_MASK_SHIFT ? 1 : 0;
+
+ const int altGrOffset = 4;
+ if (state & 128)
+ col += altGrOffset;
+
+#ifdef XCB_KEYBOARD_DEBUG
+ printf("key code: %d, state: %d, syms: ", code, state);
+ for (int i = 0; i <= 5; ++i) {
+ printf("%d ", xcb_key_symbols_get_keysym(m_key_symbols, code, i));
+ }
+ printf("\n");
+#endif
+
+ xcb_keysym_t sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col);
+ if (sym == XCB_NO_SYMBOL)
+ sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col ^ 0x1);
+
+ if (state & XCB_MOD_MASK_LOCK && sym <= 0x7f && isprint(sym)) {
+ if (isupper(sym))
+ sym = tolower(sym);
+ else
+ sym = toupper(sym);
+ }
+
+ QByteArray chars;
+
+ Qt::KeyboardModifiers modifiers;
+ int qtcode = 0;
+ int count = 0;
+
+ QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count);
+
+ QWindowSystemInterface::handleExtendedKeyEvent(widget, time, type, qtcode, modifiers, code, 0, state, string.left(count));
+}
+
+void QXcbKeyboard::handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event)
+{
+ handleKeyEvent(widget, QEvent::KeyPress, event->detail, event->state, event->time);
+}
+
+void QXcbKeyboard::handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event)
+{
+ handleKeyEvent(widget, QEvent::KeyRelease, event->detail, event->state, event->time);
+}
+
+void QXcbKeyboard::handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event)
+{
+ xcb_refresh_keyboard_mapping(m_key_symbols, const_cast<xcb_mapping_notify_event_t *>(event));
+}
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
new file mode 100644
index 0000000..ddade79
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 QXCBKEYBOARD_H
+#define QXCBKEYBOARD_H
+
+#include "qxcbobject.h"
+
+#include "xcb/xcb_keysyms.h"
+
+#include <QEvent>
+
+class QXcbKeyboard : public QXcbObject
+{
+public:
+ QXcbKeyboard(QXcbConnection *connection);
+ ~QXcbKeyboard();
+
+ void handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event);
+ void handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event);
+
+ void handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event);
+
+ Qt::KeyboardModifiers translateModifiers(int s);
+
+private:
+ void handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
+
+ int translateKeySym(uint key) const;
+ QString translateKeySym(xcb_keysym_t keysym, uint xmodifiers,
+ int &code, Qt::KeyboardModifiers &modifiers,
+ QByteArray &chars, int &count);
+
+ 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;
+
+ xcb_key_symbols_t *m_key_symbols;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
new file mode 100644
index 0000000..b2ca1be
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** 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 "qxcbnativeinterface.h"
+
+#include "qxcbscreen.h"
+
+#include <QtGui/private/qapplication_p.h>
+#include <QtCore/QMap>
+
+#include <QtCore/QDebug>
+
+#if defined(XCB_USE_EGL)
+#include "../eglconvenience/qeglplatformcontext.h"
+#elif defined (XCB_USE_DRI2)
+#include "qdri2context.h"
+#endif
+
+class QXcbResourceMap : public QMap<QByteArray, QXcbNativeInterface::ResourceType>
+{
+public:
+ QXcbResourceMap()
+ :QMap<QByteArray, QXcbNativeInterface::ResourceType>()
+ {
+ insert("display",QXcbNativeInterface::Display);
+ insert("egldisplay",QXcbNativeInterface::EglDisplay);
+ insert("connection",QXcbNativeInterface::Connection);
+ insert("screen",QXcbNativeInterface::Screen);
+ insert("graphicsdevice",QXcbNativeInterface::GraphicsDevice);
+ insert("eglcontext",QXcbNativeInterface::EglContext);
+ }
+};
+
+Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
+
+void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+{
+ QByteArray lowerCaseResource = resourceString.toLower();
+ ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
+ void *result = 0;
+ switch(resource) {
+ case Display:
+ result = displayForWidget(widget);
+ break;
+ case EglDisplay:
+ result = eglDisplayForWidget(widget);
+ break;
+ case Connection:
+ result = connectionForWidget(widget);
+ break;
+ case Screen:
+ result = qPlatformScreenForWidget(widget);
+ break;
+ case GraphicsDevice:
+ result = graphicsDeviceForWidget(widget);
+ break;
+ case EglContext:
+ result = eglContextForWidget(widget);
+ break;
+ default:
+ result = 0;
+ }
+ return result;
+}
+
+QXcbScreen *QXcbNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+{
+ QXcbScreen *screen;
+ if (widget) {
+ screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ }else {
+ screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ }
+ return screen;
+}
+
+void *QXcbNativeInterface::displayForWidget(QWidget *widget)
+{
+#if defined(XCB_USE_XLIB)
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->connection()->xlib_display();
+#else
+ Q_UNUSED(widget);
+ return 0;
+#endif
+}
+
+void *QXcbNativeInterface::eglDisplayForWidget(QWidget *widget)
+{
+#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->connection()->egl_display();
+#else
+ Q_UNUSED(widget)
+ return 0;
+#endif
+}
+
+void *QXcbNativeInterface::connectionForWidget(QWidget *widget)
+{
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->xcb_connection();
+}
+
+void *QXcbNativeInterface::screenForWidget(QWidget *widget)
+{
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ return screen->screen();
+}
+
+void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget)
+{
+#if defined(XCB_USE_DRI2)
+ QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QByteArray deviceName = screen->connection()->dri2DeviceName();
+ return deviceName.data();
+#else
+ Q_UNUSED(widget);
+ return 0;
+#endif
+
+}
+
+void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
+{
+ Q_ASSERT(widget);
+ if (!widget->platformWindow()) {
+ qDebug() << "QPlatformWindow does not exist for widget" << widget
+ << "cannot return EGLContext";
+ return 0;
+ }
+ QPlatformGLContext *platformContext = widget->platformWindow()->glContext();
+ if (!platformContext) {
+ qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext"
+ << "cannot return EGLContext";
+ return 0;
+ }
+#if defined(XCB_USE_EGL)
+ QEGLPlatformContext *eglPlatformContext = static_cast<QEGLPlatformContext *>(platformContext);
+ return eglPlatformContext->eglContext();
+#elif defined (XCB_USE_DRI2)
+ QDri2Context *dri2Context = static_cast<QDri2Context *>(platformContext);
+ return dri2Context->eglContext();
+#else
+ return 0;
+#endif
+}
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
new file mode 100644
index 0000000..f60905c
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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 QXCBNATIVEINTERFACE_H
+#define QXCBNATIVEINTERFACE_H
+
+#include <QtGui/QPlatformNativeInterface>
+
+class QWidget;
+class QXcbScreen;
+
+class QXcbNativeInterface : public QPlatformNativeInterface
+{
+public:
+ enum ResourceType {
+ Display,
+ EglDisplay,
+ Connection,
+ Screen,
+ GraphicsDevice,
+ EglContext
+ };
+
+ void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget);
+
+ void *displayForWidget(QWidget *widget);
+ void *eglDisplayForWidget(QWidget *widget);
+ void *connectionForWidget(QWidget *widget);
+ void *screenForWidget(QWidget *widget);
+ void *graphicsDeviceForWidget(QWidget *widget);
+ void *eglContextForWidget(QWidget *widget);
+
+private:
+ static QXcbScreen *qPlatformScreenForWidget(QWidget *widget);
+};
+
+#endif // QXCBNATIVEINTERFACE_H
diff --git a/src/plugins/platforms/xcb/qxcbobject.h b/src/plugins/platforms/xcb/qxcbobject.h
new file mode 100644
index 0000000..69494b0
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbobject.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 QXCBOBJECT_H
+#define QXCBOBJECT_H
+
+#include "qxcbconnection.h"
+
+class QXcbObject
+{
+public:
+ QXcbObject(QXcbConnection *connection = 0) : m_connection(connection) {}
+
+ void setConnection(QXcbConnection *connection) { m_connection = connection; }
+ QXcbConnection *connection() const { return m_connection; }
+
+ xcb_atom_t atom(QXcbAtom::Atom atom) const { return m_connection->atom(atom); }
+ xcb_connection_t *xcb_connection() const { return m_connection->xcb_connection(); }
+
+private:
+ QXcbConnection *m_connection;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
new file mode 100644
index 0000000..fffeb2e
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbscreen.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 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 "qxcbscreen.h"
+
+#include <stdio.h>
+
+QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number)
+ : QXcbObject(connection)
+ , m_screen(screen)
+ , m_number(number)
+{
+ printf ("\n");
+ printf ("Information of screen %d:\n", screen->root);
+ printf (" width.........: %d\n", screen->width_in_pixels);
+ printf (" height........: %d\n", screen->height_in_pixels);
+ printf (" depth.........: %d\n", screen->root_depth);
+ printf (" white pixel...: %x\n", screen->white_pixel);
+ printf (" black pixel...: %x\n", screen->black_pixel);
+ printf ("\n");
+
+ const quint32 mask = XCB_CW_EVENT_MASK;
+ const quint32 values[] = {
+ // XCB_CW_EVENT_MASK
+ XCB_EVENT_MASK_KEYMAP_STATE
+ | XCB_EVENT_MASK_ENTER_WINDOW
+ | XCB_EVENT_MASK_LEAVE_WINDOW
+ | XCB_EVENT_MASK_PROPERTY_CHANGE
+ };
+
+ xcb_change_window_attributes(xcb_connection(), screen->root, mask, values);
+}
+
+QXcbScreen::~QXcbScreen()
+{
+}
+
+QRect QXcbScreen::geometry() const
+{
+ return QRect(0, 0, m_screen->width_in_pixels, m_screen->height_in_pixels);
+}
+
+int QXcbScreen::depth() const
+{
+ return m_screen->root_depth;
+}
+
+QImage::Format QXcbScreen::format() const
+{
+ return QImage::Format_RGB32;
+}
+
+QSize QXcbScreen::physicalSize() const
+{
+ return QSize(m_screen->width_in_millimeters, m_screen->height_in_millimeters);
+}
+
+int QXcbScreen::screenNumber() const
+{
+ return m_number;
+}
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
new file mode 100644
index 0000000..6f69fc7
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbscreen.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 QXCBSCREEN_H
+#define QXCBSCREEN_H
+
+#include <QtGui/QPlatformScreen>
+
+#include <xcb/xcb.h>
+
+#include "qxcbobject.h"
+
+class QXcbConnection;
+
+class QXcbScreen : public QXcbObject, public QPlatformScreen
+{
+public:
+ QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number);
+ ~QXcbScreen();
+
+ QRect geometry() const;
+ int depth() const;
+ QImage::Format format() const;
+ QSize physicalSize() const;
+
+ int screenNumber() const;
+
+ xcb_screen_t *screen() const { return m_screen; }
+ xcb_window_t root() const { return m_screen->root; }
+
+private:
+ xcb_screen_t *m_screen;
+ int m_number;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
new file mode 100644
index 0000000..cbf50f7
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -0,0 +1,588 @@
+/****************************************************************************
+**
+** 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 "qxcbwindow.h"
+
+#include "qxcbconnection.h"
+#include "qxcbscreen.h"
+#ifdef XCB_USE_DRI2
+#include "qdri2context.h"
+#endif
+
+#include <xcb/xcb_icccm.h>
+
+#include <private/qapplication_p.h>
+#include <private/qwindowsurface_p.h>
+
+#include <QtGui/QWindowSystemInterface>
+
+#include <stdio.h>
+
+#ifdef XCB_USE_XLIB
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#endif
+
+#if defined(XCB_USE_GLX)
+#include "qglxintegration.h"
+#elif defined(XCB_USE_EGL)
+#include "../eglconvenience/qeglplatformcontext.h"
+#include "../eglconvenience/qeglconvenience.h"
+#include "../eglconvenience/qxlibeglintegration.h"
+#endif
+
+// Returns true if we should set WM_TRANSIENT_FOR on \a w
+static inline bool isTransient(const QWidget *w)
+{
+ return ((w->windowType() == Qt::Dialog
+ || w->windowType() == Qt::Sheet
+ || w->windowType() == Qt::Tool
+ || w->windowType() == Qt::SplashScreen
+ || w->windowType() == Qt::ToolTip
+ || w->windowType() == Qt::Drawer
+ || w->windowType() == Qt::Popup)
+ && !w->testAttribute(Qt::WA_X11BypassTransientForHint));
+}
+
+QXcbWindow::QXcbWindow(QWidget *tlw)
+ : QPlatformWindow(tlw)
+ , m_context(0)
+{
+ m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
+
+ setConnection(m_screen->connection());
+
+ const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK;
+ const quint32 values[] = {
+ // XCB_CW_BACK_PIXMAP
+ XCB_NONE,
+ // XCB_CW_EVENT_MASK
+ XCB_EVENT_MASK_EXPOSURE
+ | XCB_EVENT_MASK_STRUCTURE_NOTIFY
+ | XCB_EVENT_MASK_KEY_PRESS
+ | XCB_EVENT_MASK_KEY_RELEASE
+ | XCB_EVENT_MASK_BUTTON_PRESS
+ | XCB_EVENT_MASK_BUTTON_RELEASE
+ | XCB_EVENT_MASK_BUTTON_MOTION
+ | XCB_EVENT_MASK_ENTER_WINDOW
+ | XCB_EVENT_MASK_LEAVE_WINDOW
+ | XCB_EVENT_MASK_PROPERTY_CHANGE
+ | XCB_EVENT_MASK_FOCUS_CHANGE
+ };
+
+#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
+ if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
+ && QApplicationPrivate::platformIntegration()->hasOpenGL() ) {
+#if defined(XCB_USE_GLX)
+ XVisualInfo *visualInfo = QGLXContext::findVisualInfo(m_screen, tlw->platformWindowFormat());
+#elif defined(XCB_USE_EGL)
+ EGLDisplay eglDisplay = eglGetDisplay(DISPLAY_FROM_XCB(this));
+ EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true);
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this),eglConfig);
+
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
+
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
+#endif //XCB_USE_GLX
+ if (visualInfo) {
+ Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone);
+
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(),
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
+
+ printf("created GL window: %d\n", m_window);
+ } else {
+ qFatal("no window!");
+ }
+ } else
+#endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
+ {
+ m_window = xcb_generate_id(xcb_connection());
+
+ xcb_create_window(xcb_connection(),
+ XCB_COPY_FROM_PARENT, // depth -- same as root
+ m_window, // window id
+ m_screen->root(), // parent window id
+ tlw->x(),
+ tlw->y(),
+ tlw->width(),
+ tlw->height(),
+ 0, // border width
+ XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
+ m_screen->screen()->root_visual, // visual
+ 0, // value mask
+ 0); // value list
+
+ printf("created regular window: %d\n", m_window);
+ }
+
+ xcb_change_window_attributes(xcb_connection(), m_window, mask, values);
+
+ xcb_atom_t properties[4];
+ int propertyCount = 0;
+ properties[propertyCount++] = atom(QXcbAtom::WM_DELETE_WINDOW);
+ properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS);
+ properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING);
+
+ if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint)
+ properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP);
+
+ xcb_change_property(xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_window,
+ atom(QXcbAtom::WM_PROTOCOLS),
+ 4,
+ 32,
+ propertyCount,
+ properties);
+
+ if (isTransient(tlw) && tlw->parentWidget()) {
+ // ICCCM 4.1.2.6
+ QWidget *p = tlw->parentWidget()->window();
+ xcb_window_t parentWindow = p->winId();
+ xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
+ XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,
+ 1, &parentWindow);
+
+ }
+}
+
+QXcbWindow::~QXcbWindow()
+{
+ xcb_destroy_window(xcb_connection(), m_window);
+}
+
+void QXcbWindow::setGeometry(const QRect &rect)
+{
+ QPlatformWindow::setGeometry(rect);
+
+ const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
+ const quint32 values[] = { rect.x(), rect.y(), rect.width(), rect.height() };
+
+ xcb_configure_window(xcb_connection(), m_window, mask, values);
+}
+
+void QXcbWindow::setVisible(bool visible)
+{
+ xcb_wm_hints_t hints;
+ if (visible) {
+ if (widget()->isMinimized())
+ xcb_wm_hints_set_iconic(&hints);
+ else
+ xcb_wm_hints_set_normal(&hints);
+ xcb_set_wm_hints(xcb_connection(), m_window, &hints);
+ xcb_map_window(xcb_connection(), m_window);
+ } else {
+ xcb_unmap_window(xcb_connection(), m_window);
+
+ // send synthetic UnmapNotify event according to icccm 4.1.4
+ xcb_unmap_notify_event_t event;
+ event.response_type = XCB_UNMAP_NOTIFY;
+ event.sequence = 0; // does this matter?
+ event.event = m_screen->root();
+ event.window = m_window;
+ event.from_configure = false;
+ xcb_send_event(xcb_connection(), false, m_screen->root(),
+ XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event);
+
+ xcb_flush(xcb_connection());
+ }
+}
+
+struct QtMWMHints {
+ quint32 flags, functions, decorations;
+ qint32 input_mode;
+ quint32 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
+};
+
+Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+
+ if (type == Qt::ToolTip)
+ flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint;
+ if (type == Qt::Popup)
+ flags |= Qt::X11BypassWindowManagerHint;
+
+ bool topLevel = (flags & Qt::Window);
+ bool popup = (type == Qt::Popup);
+ bool dialog = (type == Qt::Dialog
+ || type == Qt::Sheet);
+ bool desktop = (type == Qt::Desktop);
+ bool tool = (type == Qt::Tool || type == Qt::SplashScreen
+ || type == Qt::ToolTip || type == Qt::Drawer);
+
+ Q_UNUSED(topLevel);
+ Q_UNUSED(dialog);
+ Q_UNUSED(desktop);
+ Q_UNUSED(tool);
+
+ bool tooltip = (type == Qt::ToolTip);
+
+ QtMWMHints mwmhints;
+ mwmhints.flags = 0L;
+ mwmhints.functions = 0L;
+ mwmhints.decorations = 0;
+ mwmhints.input_mode = 0L;
+ mwmhints.status = 0L;
+
+ if (type != Qt::SplashScreen) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
+
+ bool customize = flags & Qt::CustomizeWindowHint;
+ if (!(flags & Qt::FramelessWindowHint) && !(customize && !(flags & Qt::WindowTitleHint))) {
+ mwmhints.decorations |= MWM_DECOR_BORDER;
+ mwmhints.decorations |= MWM_DECOR_RESIZEH;
+
+ if (flags & Qt::WindowTitleHint)
+ mwmhints.decorations |= MWM_DECOR_TITLE;
+
+ if (flags & Qt::WindowSystemMenuHint)
+ mwmhints.decorations |= MWM_DECOR_MENU;
+
+ if (flags & Qt::WindowMinimizeButtonHint) {
+ mwmhints.decorations |= MWM_DECOR_MINIMIZE;
+ mwmhints.functions |= MWM_FUNC_MINIMIZE;
+ }
+
+ if (flags & Qt::WindowMaximizeButtonHint) {
+ mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
+ mwmhints.functions |= MWM_FUNC_MAXIMIZE;
+ }
+
+ if (flags & Qt::WindowCloseButtonHint)
+ mwmhints.functions |= MWM_FUNC_CLOSE;
+ }
+ } else {
+ // if type == Qt::SplashScreen
+ mwmhints.decorations = MWM_DECOR_ALL;
+ }
+
+ if (mwmhints.functions != 0) {
+ mwmhints.flags |= MWM_HINTS_FUNCTIONS;
+ mwmhints.functions |= MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
+ } else {
+ mwmhints.functions = MWM_FUNC_ALL;
+ }
+
+ if (!(flags & Qt::FramelessWindowHint)
+ && flags & Qt::CustomizeWindowHint
+ && flags & Qt::WindowTitleHint
+ && !(flags &
+ (Qt::WindowMinimizeButtonHint
+ | Qt::WindowMaximizeButtonHint
+ | Qt::WindowCloseButtonHint)))
+ {
+ // a special case - only the titlebar without any button
+ mwmhints.flags = MWM_HINTS_FUNCTIONS;
+ mwmhints.functions = MWM_FUNC_MOVE | MWM_FUNC_RESIZE;
+ mwmhints.decorations = 0;
+ }
+
+ if (mwmhints.flags != 0l) {
+ xcb_change_property(xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_window,
+ atom(QXcbAtom::_MOTIF_WM_HINTS),
+ atom(QXcbAtom::_MOTIF_WM_HINTS),
+ 32,
+ 5,
+ &mwmhints);
+ } else {
+ xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS));
+ }
+
+ if (popup || tooltip) {
+ const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER;
+ const quint32 values[] = { true, true };
+
+ xcb_change_window_attributes(xcb_connection(), m_window, mask, values);
+ }
+
+ return QPlatformWindow::setWindowFlags(flags);
+}
+
+WId QXcbWindow::winId() const
+{
+ return m_window;
+}
+
+void QXcbWindow::setParent(const QPlatformWindow *parent)
+{
+ QPoint topLeft = geometry().topLeft();
+ xcb_reparent_window(xcb_connection(), window(), static_cast<const QXcbWindow *>(parent)->window(), topLeft.x(), topLeft.y());
+}
+
+void QXcbWindow::setWindowTitle(const QString &title)
+{
+ QByteArray ba = title.toUtf8();
+ xcb_change_property (xcb_connection(),
+ XCB_PROP_MODE_REPLACE,
+ m_window,
+ atom(QXcbAtom::_NET_WM_NAME),
+ atom(QXcbAtom::UTF8_STRING),
+ 8,
+ ba.length(),
+ ba.constData());
+}
+
+void QXcbWindow::raise()
+{
+ const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
+ const quint32 values[] = { XCB_STACK_MODE_ABOVE };
+ xcb_configure_window(xcb_connection(), m_window, mask, values);
+}
+
+void QXcbWindow::lower()
+{
+ const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE;
+ const quint32 values[] = { XCB_STACK_MODE_BELOW };
+ xcb_configure_window(xcb_connection(), m_window, mask, values);
+}
+
+void QXcbWindow::requestActivateWindow()
+{
+ xcb_set_input_focus(xcb_connection(), m_window, XCB_INPUT_FOCUS_PARENT, XCB_TIME_CURRENT_TIME);
+}
+
+QPlatformGLContext *QXcbWindow::glContext() const
+{
+ if (!QApplicationPrivate::platformIntegration()->hasOpenGL()) {
+ printf("no opengl\n");
+ return 0;
+ }
+#if defined(XCB_USE_GLX)
+ if (!m_context) {
+ QXcbWindow *that = const_cast<QXcbWindow *>(this);
+ that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat());
+ }
+#elif defined(XCB_USE_EGL)
+ if (!m_context) {
+ EGLDisplay display = eglGetDisplay(DISPLAY_FROM_XCB(this));
+
+ EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true);
+ QVector<EGLint> eglContextAttrs;
+ eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
+ eglContextAttrs.append(2);
+ eglContextAttrs.append(EGL_NONE);
+
+ EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)m_window,0);
+ QXcbWindow *that = const_cast<QXcbWindow *>(this);
+ that->m_context = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API);
+ }
+#elif defined(XCB_USE_DRI2)
+ if (!m_context) {
+ QXcbWindow *that = const_cast<QXcbWindow *>(this);
+ that->m_context = new QDri2Context(that);
+ }
+
+#endif
+ return m_context;
+}
+
+void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
+{
+ QWindowSurface *surface = widget()->windowSurface();
+ if (surface) {
+ QRect rect(event->x, event->y, event->width, event->height);
+
+ surface->flush(widget(), rect, QPoint());
+ }
+}
+
+void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *event)
+{
+ if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) {
+ if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) {
+ QWindowSystemInterface::handleCloseEvent(widget());
+ }
+ }
+}
+
+void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event)
+{
+ int xpos = geometry().x();
+ int ypos = geometry().y();
+
+ if ((event->width == geometry().width() && event->height == geometry().height()) || event->x != 0 || event->y != 0) {
+ xpos = event->x;
+ ypos = event->y;
+ }
+
+ QRect rect(xpos, ypos, event->width, event->height);
+ QPlatformWindow::setGeometry(rect);
+
+ QWindowSystemInterface::handleGeometryChange(widget(), rect);
+
+#if XCB_USE_DRI2
+ if (m_context)
+ static_cast<QDri2Context *>(m_context)->resize(rect.size());
+#endif
+}
+
+static Qt::MouseButtons translateMouseButtons(int s)
+{
+ Qt::MouseButtons ret = 0;
+ if (s & XCB_BUTTON_MASK_1)
+ ret |= Qt::LeftButton;
+ if (s & XCB_BUTTON_MASK_2)
+ ret |= Qt::MidButton;
+ if (s & XCB_BUTTON_MASK_3)
+ ret |= Qt::RightButton;
+ return ret;
+}
+
+static Qt::MouseButton translateMouseButton(xcb_button_t s)
+{
+ switch (s) {
+ case 1:
+ return Qt::LeftButton;
+ case 2:
+ return Qt::MidButton;
+ case 3:
+ return Qt::RightButton;
+ default:
+ return Qt::NoButton;
+ }
+}
+
+void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
+{
+ QPoint local(event->event_x, event->event_y);
+ QPoint global(event->root_x, event->root_y);
+
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+
+ if (event->detail >= 4 && event->detail <= 7) {
+ //logic borrowed from qapplication_x11.cpp
+ int delta = 120 * ((event->detail == 4 || event->detail == 6) ? 1 : -1);
+ bool hor = (((event->detail == 4 || event->detail == 5)
+ && (modifiers & Qt::AltModifier))
+ || (event->detail == 6 || event->detail == 7));
+
+ QWindowSystemInterface::handleWheelEvent(widget(), event->time,
+ local, global, delta, hor ? Qt::Horizontal : Qt::Vertical);
+ return;
+ }
+
+ handleMouseEvent(event->detail, event->state, event->time, local, global);
+}
+
+void QXcbWindow::handleButtonReleaseEvent(const xcb_button_release_event_t *event)
+{
+ QPoint local(event->event_x, event->event_y);
+ QPoint global(event->root_x, event->root_y);
+
+ handleMouseEvent(event->detail, event->state, event->time, local, global);
+}
+
+void QXcbWindow::handleMotionNotifyEvent(const xcb_motion_notify_event_t *event)
+{
+ QPoint local(event->event_x, event->event_y);
+ QPoint global(event->root_x, event->root_y);
+
+ handleMouseEvent(event->detail, event->state, event->time, local, global);
+}
+
+void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global)
+{
+ Qt::MouseButtons buttons = translateMouseButtons(state);
+ Qt::MouseButton button = translateMouseButton(detail);
+
+ buttons ^= button; // X event uses state *before*, Qt uses state *after*
+
+ QWindowSystemInterface::handleMouseEvent(widget(), time, local, global, buttons);
+}
+
+void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
+{
+ QWindowSystemInterface::handleEnterEvent(widget());
+}
+
+void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
+{
+ QWindowSystemInterface::handleLeaveEvent(widget());
+}
+
+void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *)
+{
+ QWindowSystemInterface::handleWindowActivated(widget());
+}
+
+void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *)
+{
+ QWindowSystemInterface::handleWindowActivated(0);
+}
+
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
new file mode 100644
index 0000000..1e9930d
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 QXCBWINDOW_H
+#define QXCBWINDOW_H
+
+#include <QtGui/QPlatformWindow>
+#include <QtGui/QPlatformWindowFormat>
+
+#include <xcb/xcb.h>
+
+#include "qxcbobject.h"
+
+class QXcbScreen;
+
+class QXcbWindow : public QXcbObject, public QPlatformWindow
+{
+public:
+ QXcbWindow(QWidget *tlw);
+ ~QXcbWindow();
+
+ void setGeometry(const QRect &rect);
+
+ void setVisible(bool visible);
+ Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
+ WId winId() const;
+ void setParent(const QPlatformWindow *window);
+
+ void setWindowTitle(const QString &title);
+ void raise();
+ void lower();
+
+ void requestActivateWindow();
+
+ QPlatformGLContext *glContext() const;
+
+ xcb_window_t window() const { return m_window; }
+
+ void handleExposeEvent(const xcb_expose_event_t *event);
+ void handleClientMessageEvent(const xcb_client_message_event_t *event);
+ void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *event);
+ void handleButtonPressEvent(const xcb_button_press_event_t *event);
+ void handleButtonReleaseEvent(const xcb_button_release_event_t *event);
+ void handleMotionNotifyEvent(const xcb_motion_notify_event_t *event);
+
+ void handleEnterNotifyEvent(const xcb_enter_notify_event_t *event);
+ void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event);
+ void handleFocusInEvent(const xcb_focus_in_event_t *event);
+ void handleFocusOutEvent(const xcb_focus_out_event_t *event);
+
+ void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global);
+
+private:
+ QXcbScreen *m_screen;
+
+ xcb_window_t m_window;
+ QPlatformGLContext *m_context;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
new file mode 100644
index 0000000..7fed230
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** 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 "qxcbwindowsurface.h"
+
+#include "qxcbconnection.h"
+#include "qxcbscreen.h"
+#include "qxcbwindow.h"
+
+#include <xcb/shm.h>
+#include <xcb/xcb_image.h>
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#include <stdio.h>
+
+class QXcbShmImage : public QXcbObject
+{
+public:
+ QXcbShmImage(QXcbScreen *connection, const QSize &size);
+ ~QXcbShmImage() { destroy(); }
+
+ QImage *image() { return &m_qimage; }
+
+ void put(xcb_window_t window, const QPoint &dst, const QRect &source);
+ void preparePaint(const QRegion &region);
+
+private:
+ void destroy();
+
+ xcb_shm_segment_info_t m_shm_info;
+
+ xcb_image_t *m_xcb_image;
+
+ QImage m_qimage;
+
+ xcb_gcontext_t m_gc;
+ xcb_window_t m_gc_window;
+
+ QRegion m_dirty;
+};
+
+QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size)
+ : QXcbObject(screen->connection())
+ , m_gc(0)
+ , m_gc_window(0)
+{
+ m_xcb_image = xcb_image_create_native(xcb_connection(),
+ size.width(),
+ size.height(),
+ XCB_IMAGE_FORMAT_Z_PIXMAP,
+ screen->depth(),
+ 0,
+ ~0,
+ 0);
+ m_shm_info.shmid = shmget (IPC_PRIVATE,
+ m_xcb_image->stride * m_xcb_image->height, IPC_CREAT|0777);
+
+ m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0);
+ m_shm_info.shmseg = xcb_generate_id(xcb_connection());
+
+ xcb_shm_attach(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false);
+
+ m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, screen->format());
+}
+
+void QXcbShmImage::destroy()
+{
+ xcb_shm_detach(xcb_connection(), m_shm_info.shmseg);
+ xcb_image_destroy(m_xcb_image);
+ shmdt(m_shm_info.shmaddr);
+ shmctl(m_shm_info.shmid, IPC_RMID, 0);
+
+ xcb_free_gc(xcb_connection(), m_gc);
+}
+
+void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source)
+{
+ if (m_gc_window != window) {
+ xcb_free_gc(xcb_connection(), m_gc);
+
+ m_gc = xcb_generate_id(xcb_connection());
+ xcb_create_gc(xcb_connection(), m_gc, window, 0, 0);
+
+ m_gc_window = window;
+ }
+
+ xcb_image_shm_put(xcb_connection(),
+ window,
+ m_gc,
+ m_xcb_image,
+ m_shm_info,
+ source.x(),
+ source.y(),
+ target.x(),
+ target.y(),
+ source.width(),
+ source.height(),
+ false);
+
+ m_dirty = m_dirty | source;
+
+ xcb_flush(xcb_connection());
+}
+
+void QXcbShmImage::preparePaint(const QRegion &region)
+{
+ // to prevent X from reading from the image region while we're writing to it
+ if (m_dirty.intersects(region)) {
+ // from xcb_aux_sync
+ free(xcb_get_input_focus_reply(xcb_connection(), xcb_get_input_focus(xcb_connection()), 0));
+ m_dirty = QRegion();
+ }
+}
+
+QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface)
+ : QWindowSurface(widget, setDefaultSurface)
+ , m_image(0)
+{
+ setStaticContentsSupport(false);
+ setPartialUpdateSupport(true);
+
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ setConnection(screen->connection());
+}
+
+QXcbWindowSurface::~QXcbWindowSurface()
+{
+}
+
+QPaintDevice *QXcbWindowSurface::paintDevice()
+{
+ return m_image->image();
+}
+
+void QXcbWindowSurface::beginPaint(const QRegion &region)
+{
+ m_image->preparePaint(region);
+}
+
+void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+ QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow());
+
+ extern QWidgetData* qt_widget_data(QWidget *);
+ QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
+
+ QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset));
+}
+
+void QXcbWindowSurface::resize(const QSize &size)
+{
+ QWindowSurface::resize(size);
+
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
+
+ delete m_image;
+ m_image = new QXcbShmImage(screen, size);
+}
+
+extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
+
+bool QXcbWindowSurface::scroll(const QRegion &area, int dx, int dy)
+{
+ if (m_image->image()->isNull())
+ return false;
+
+ m_image->preparePaint(area);
+
+ const QVector<QRect> rects = area.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ qt_scrollRectInImage(*m_image->image(), rects.at(i), QPoint(dx, dy));
+
+ return true;
+}
+
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h
new file mode 100644
index 0000000..61689b1
--- /dev/null
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** 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 QXCBWINDOWSURFACE_H
+#define QXCBWINDOWSURFACE_H
+
+#include <private/qwindowsurface_p.h>
+
+#include <xcb/xcb.h>
+
+#include "qxcbobject.h"
+
+class QXcbShmImage;
+
+class QXcbWindowSurface : public QXcbObject, public QWindowSurface
+{
+public:
+ QXcbWindowSurface(QWidget *widget, bool setDefaultSurface = true);
+ ~QXcbWindowSurface();
+
+ QPaintDevice *paintDevice();
+ void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size);
+ bool scroll(const QRegion &area, int dx, int dy);
+
+ void beginPaint(const QRegion &);
+
+private:
+ QXcbShmImage *m_image;
+};
+
+#endif
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
new file mode 100644
index 0000000..fdbe2cd
--- /dev/null
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -0,0 +1,69 @@
+TARGET = xcb
+
+include(../../qpluginbase.pri)
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
+
+SOURCES = \
+ qxcbconnection.cpp \
+ qxcbintegration.cpp \
+ qxcbkeyboard.cpp \
+ qxcbscreen.cpp \
+ qxcbwindow.cpp \
+ qxcbwindowsurface.cpp \
+ main.cpp \
+ qxcbnativeinterface.cpp
+
+HEADERS = \
+ qxcbconnection.h \
+ qxcbintegration.h \
+ qxcbkeyboard.h \
+ qxcbobject.h \
+ qxcbscreen.h \
+ qxcbwindow.h \
+ qxcbwindowsurface.h \
+ qxcbnativeinterface.h
+
+contains(QT_CONFIG, opengl) {
+ QT += opengl
+
+# DEFINES += XCB_USE_DRI2
+ contains(DEFINES, XCB_USE_DRI2) {
+ LIBS += -lxcb-dri2 -lxcb-xfixes -lEGL
+
+ CONFIG += link_pkgconfig
+ PKGCONFIG += libdrm
+
+ HEADERS += qdri2context.h
+ SOURCES += qdri2context.cpp
+
+ } else {
+ DEFINES += XCB_USE_XLIB
+ LIBS += -lX11 -lX11-xcb
+
+ contains(QT_CONFIG, opengles2) {
+ DEFINES += XCB_USE_EGL
+ HEADERS += \
+ ../eglconvenience/qeglplatformcontext.h \
+ ../eglconvenience/qeglconvenience.h \
+ ../eglconvenience/qxlibeglintegration.h
+
+ SOURCES += \
+ ../eglconvenience/qeglplatformcontext.cpp \
+ ../eglconvenience/qeglconvenience.cpp \
+ ../eglconvenience/qxlibeglintegration.cpp
+
+ LIBS += -lEGL
+ } else {
+ DEFINES += XCB_USE_GLX
+ HEADERS += qglxintegration.h
+ SOURCES += qglxintegration.cpp
+ }
+ }
+}
+
+LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm
+
+include (../fontdatabases/genericunix/genericunix.pri)
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
diff --git a/src/plugins/platforms/testlite/main.cpp b/src/plugins/platforms/xlib/main.cpp
index 2f6aa8b..f0bf6ff 100644
--- a/src/plugins/platforms/testlite/main.cpp
+++ b/src/plugins/platforms/xlib/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -40,40 +40,40 @@
****************************************************************************/
#include <QtGui/QPlatformIntegrationPlugin>
-#include "qtestliteintegration.h"
+#include "qxlibintegration.h"
QT_BEGIN_NAMESPACE
-class QTestLiteIntegrationPlugin : public QPlatformIntegrationPlugin
+class QXlibIntegrationPlugin : public QPlatformIntegrationPlugin
{
public:
QStringList keys() const;
QPlatformIntegration *create(const QString&, const QStringList&);
};
-QStringList QTestLiteIntegrationPlugin::keys() const
+QStringList QXlibIntegrationPlugin::keys() const
{
QStringList list;
- list << "TestLite";
+ list << "Xlib";
#ifndef QT_NO_OPENGL
- list << "TestLiteGL";
+ list << "XlibGL";
#endif
return list;
}
-QPlatformIntegration* QTestLiteIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+QPlatformIntegration* QXlibIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
- if (system.toLower() == "testlite")
- return new QTestLiteIntegration;
+ if (system.toLower() == "xlib")
+ return new QXlibIntegration;
#ifndef QT_NO_OPENGL
- if (system.toLower() == "testlitegl")
- return new QTestLiteIntegration(true);
+ if (system.toLower() == "xlibgl")
+ return new QXlibIntegration(true);
#endif
return 0;
}
-Q_EXPORT_PLUGIN2(testlite, QTestLiteIntegrationPlugin)
+Q_EXPORT_PLUGIN2(xlib, QXlibIntegrationPlugin)
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp
index 8023014..80011d9 100644
--- a/src/plugins/platforms/testlite/qglxintegration.cpp
+++ b/src/plugins/platforms/xlib/qglxintegration.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -43,8 +43,9 @@
#include <QLibrary>
#include <QGLFormat>
-#include "qtestlitewindow.h"
-#include "qtestlitescreen.h"
+#include "qxlibwindow.h"
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
#include <X11/Xlib.h>
@@ -113,7 +114,7 @@ QVector<int> QGLXContext::buildSpec(const QPlatformWindowFormat &format)
return spec;
}
-GLXFBConfig QGLXContext::findConfig(const QTestLiteScreen *screen, const QPlatformWindowFormat &format)
+GLXFBConfig QGLXContext::findConfig(const QXlibScreen *screen, const QPlatformWindowFormat &format)
{
bool reduced = true;
GLXFBConfig chosenConfig = 0;
@@ -122,7 +123,7 @@ GLXFBConfig QGLXContext::findConfig(const QTestLiteScreen *screen, const QPlatfo
QVector<int> spec = buildSpec(reducedFormat);
int confcount = 0;
GLXFBConfig *configs;
- configs = glXChooseFBConfig(screen->display(),screen->xScreenNumber(),spec.constData(),&confcount);
+ configs = glXChooseFBConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),spec.constData(),&confcount);
if (confcount)
{
for (int i = 0; i < confcount; i++) {
@@ -130,7 +131,7 @@ GLXFBConfig QGLXContext::findConfig(const QTestLiteScreen *screen, const QPlatfo
// Make sure we try to get an ARGB visual if the format asked for an alpha:
if (reducedFormat.alpha()) {
int alphaSize;
- glXGetFBConfigAttrib(screen->display(),configs[i],GLX_ALPHA_SIZE,&alphaSize);
+ glXGetFBConfigAttrib(screen->display()->nativeDisplay(),configs[i],GLX_ALPHA_SIZE,&alphaSize);
if (alphaSize > 0)
break;
} else {
@@ -149,10 +150,10 @@ GLXFBConfig QGLXContext::findConfig(const QTestLiteScreen *screen, const QPlatfo
return chosenConfig;
}
-XVisualInfo *QGLXContext::findVisualInfo(const QTestLiteScreen *screen, const QPlatformWindowFormat &format)
+XVisualInfo *QGLXContext::findVisualInfo(const QXlibScreen *screen, const QPlatformWindowFormat &format)
{
GLXFBConfig config = QGLXContext::findConfig(screen,format);
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display(),config);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config);
return visualInfo;
}
@@ -237,7 +238,7 @@ QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWin
return retFormat;
}
-QGLXContext::QGLXContext(Window window, QTestLiteScreen *screen, const QPlatformWindowFormat &format)
+QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWindowFormat &format)
: QPlatformGLContext()
, m_screen(screen)
, m_drawable((Drawable)window)
@@ -264,15 +265,15 @@ QGLXContext::QGLXContext(Window window, QTestLiteScreen *screen, const QPlatform
shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
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);
+ m_context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE);
+ m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context);
#ifdef MYX11_DEBUG
qDebug() << "QGLXGLContext::create context" << m_context;
#endif
}
-QGLXContext::QGLXContext(QTestLiteScreen *screen, Drawable drawable, GLXContext context)
+QGLXContext::QGLXContext(QXlibScreen *screen, Drawable drawable, GLXContext context)
: QPlatformGLContext(), m_screen(screen), m_drawable(drawable), m_context(context)
{
@@ -282,11 +283,11 @@ QGLXContext::~QGLXContext()
{
if (m_context) {
qDebug("Destroying GLX context 0x%p", m_context);
- glXDestroyContext(m_screen->display(), m_context);
+ glXDestroyContext(m_screen->display()->nativeDisplay(), m_context);
}
}
-void QGLXContext::createDefaultSharedContex(QTestLiteScreen *screen)
+void QGLXContext::createDefaultSharedContex(QXlibScreen *screen)
{
int x = 0;
int y = 0;
@@ -297,15 +298,15 @@ void QGLXContext::createDefaultSharedContex(QTestLiteScreen *screen)
GLXContext context;
GLXFBConfig config = findConfig(screen,format);
if (config) {
- XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display(),config);
- Colormap cmap = XCreateColormap(screen->display(),screen->rootWindow(),visualInfo->visual,AllocNone);
+ XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config);
+ Colormap cmap = XCreateColormap(screen->display()->nativeDisplay(),screen->rootWindow(),visualInfo->visual,AllocNone);
XSetWindowAttributes a;
a.colormap = cmap;
- Window sharedWindow = XCreateWindow(screen->display(), screen->rootWindow(),x, y, w, h,
+ Window sharedWindow = XCreateWindow(screen->display()->nativeDisplay(), screen->rootWindow(),x, y, w, h,
0, visualInfo->depth, InputOutput, visualInfo->visual,
CWColormap, &a);
- context = glXCreateNewContext(screen->display(),config,GLX_RGBA_TYPE,0,TRUE);
+ context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,0,TRUE);
QPlatformGLContext *sharedContext = new QGLXContext(screen,sharedWindow,context);
QPlatformGLContext::setDefaultSharedContext(sharedContext);
} else {
@@ -319,18 +320,18 @@ void QGLXContext::makeCurrent()
#ifdef MYX11_DEBUG
qDebug("QGLXGLContext::makeCurrent(window=0x%x, ctx=0x%x)", m_drawable, m_context);
#endif
- glXMakeCurrent(m_screen->display(), m_drawable, m_context);
+ glXMakeCurrent(m_screen->display()->nativeDisplay(), m_drawable, m_context);
}
void QGLXContext::doneCurrent()
{
QPlatformGLContext::doneCurrent();
- glXMakeCurrent(m_screen->display(), 0, 0);
+ glXMakeCurrent(m_screen->display()->nativeDisplay(), 0, 0);
}
void QGLXContext::swapBuffers()
{
- glXSwapBuffers(m_screen->display(), m_drawable);
+ glXSwapBuffers(m_screen->display()->nativeDisplay(), m_drawable);
}
void* QGLXContext::getProcAddress(const QString& procName)
@@ -342,7 +343,7 @@ void* QGLXContext::getProcAddress(const QString& procName)
if (resolved && !glXGetProcAddressARB)
return 0;
if (!glXGetProcAddressARB) {
- QList<QByteArray> glxExt = QByteArray(glXGetClientString(m_screen->display(), GLX_EXTENSIONS)).split(' ');
+ QList<QByteArray> glxExt = QByteArray(glXGetClientString(m_screen->display()->nativeDisplay(), 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);
diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h
index abece45..dbb5c2e 100644
--- a/src/plugins/platforms/testlite/qglxintegration.h
+++ b/src/plugins/platforms/xlib/qglxintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -42,7 +42,7 @@
#ifndef Q_GLX_CONTEXT_H
#define Q_GLX_CONTEXT_H
-#include "qtestlitewindow.h"
+#include "qxlibwindow.h"
#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindowFormat>
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
class QGLXContext : public QPlatformGLContext
{
public:
- QGLXContext(Window window, QTestLiteScreen *xd, const QPlatformWindowFormat &format);
+ QGLXContext(Window window, QXlibScreen *xd, const QPlatformWindowFormat &format);
~QGLXContext();
virtual void makeCurrent();
@@ -69,22 +69,22 @@ public:
QPlatformWindowFormat platformWindowFormat() const;
- static XVisualInfo *findVisualInfo(const QTestLiteScreen *xd, const QPlatformWindowFormat &format);
+ static XVisualInfo *findVisualInfo(const QXlibScreen *xd, const QPlatformWindowFormat &format);
private:
- static GLXFBConfig findConfig(const QTestLiteScreen *xd,const QPlatformWindowFormat &format);
+ static GLXFBConfig findConfig(const QXlibScreen *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);
- QTestLiteScreen *m_screen;
+ QXlibScreen *m_screen;
Drawable m_drawable;
GLXContext m_context;
QPlatformWindowFormat m_windowFormat;
- QGLXContext (QTestLiteScreen *screen, Drawable drawable, GLXContext context);
+ QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context);
static QMutex m_defaultSharedContextMutex;
- static void createDefaultSharedContex(QTestLiteScreen *xd);
+ static void createDefaultSharedContex(QXlibScreen *xd);
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/testlite/qtestliteclipboard.cpp b/src/plugins/platforms/xlib/qxlibclipboard.cpp
index 9bab7f9..dfaf552 100644
--- a/src/plugins/platforms/testlite/qtestliteclipboard.cpp
+++ b/src/plugins/platforms/xlib/qxlibclipboard.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,21 +39,22 @@
**
****************************************************************************/
-#include "qtestliteclipboard.h"
+#include "qxlibclipboard.h"
-#include "qtestlitescreen.h"
-#include "qtestlitemime.h"
+#include "qxlibscreen.h"
+#include "qxlibmime.h"
+#include "qxlibdisplay.h"
#include <private/qapplication_p.h>
#include <QtCore/QDebug>
-class QTestLiteClipboardMime : public QTestLiteMime
+class QXlibClipboardMime : public QXlibMime
{
Q_OBJECT
public:
- QTestLiteClipboardMime(QClipboard::Mode mode, QTestLiteClipboard *clipboard)
- : QTestLiteMime()
+ QXlibClipboardMime(QClipboard::Mode mode, QXlibClipboard *clipboard)
+ : QXlibMime()
, m_clipboard(clipboard)
{
switch (mode) {
@@ -62,7 +63,7 @@ public:
break;
case QClipboard::Clipboard:
- modeAtom = QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD);
+ modeAtom = QXlibStatic::atom(QXlibStatic::CLIPBOARD);
break;
default:
@@ -78,11 +79,11 @@ protected:
return QStringList();
if (!formatList.count()) {
- QTestLiteClipboardMime *that = const_cast<QTestLiteClipboardMime *>(this);
+ QXlibClipboardMime *that = const_cast<QXlibClipboardMime *>(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));
+ that->format_atoms = m_clipboard->getDataInFormat(modeAtom,QXlibStatic::atom(QXlibStatic::TARGETS));
if (format_atoms.size() > 0) {
Atom *targets = (Atom *) format_atoms.data();
@@ -92,7 +93,7 @@ protected:
if (targets[i] == 0)
continue;
- QStringList formatsForAtom = mimeFormatsForAtom(m_clipboard->screen()->display(),targets[i]);
+ QStringList formatsForAtom = mimeFormatsForAtom(m_clipboard->screen()->display()->nativeDisplay(),targets[i]);
for (int j = 0; j < formatsForAtom.size(); ++j) {
if (!formatList.contains(formatsForAtom.at(j)))
that->formatList.append(formatsForAtom.at(j));
@@ -124,31 +125,31 @@ protected:
atoms.append(targets[i]);
QByteArray encoding;
- Atom fmtatom = mimeAtomForFormat(m_clipboard->screen()->display(),fmt, requestedType, atoms, &encoding);
+ Atom fmtatom = mimeAtomForFormat(m_clipboard->screen()->display()->nativeDisplay(),fmt, requestedType, atoms, &encoding);
if (fmtatom == 0)
return QVariant();
- return mimeConvertToFormat(m_clipboard->screen()->display(),fmtatom, m_clipboard->getDataInFormat(modeAtom,fmtatom), fmt, requestedType, encoding);
+ return mimeConvertToFormat(m_clipboard->screen()->display()->nativeDisplay(),fmtatom, m_clipboard->getDataInFormat(modeAtom,fmtatom), fmt, requestedType, encoding);
}
private:
bool empty() const
{
- Window win = XGetSelectionOwner(m_clipboard->screen()->display(), modeAtom);
+ Window win = XGetSelectionOwner(m_clipboard->screen()->display()->nativeDisplay(), modeAtom);
return win == XNone;
}
Atom modeAtom;
- QTestLiteClipboard *m_clipboard;
+ QXlibClipboard *m_clipboard;
QStringList formatList;
QByteArray format_atoms;
};
-const int QTestLiteClipboard::clipboard_timeout = 5000;
+const int QXlibClipboard::clipboard_timeout = 5000;
-QTestLiteClipboard::QTestLiteClipboard(QTestLiteScreen *screen)
+QXlibClipboard::QXlibClipboard(QXlibScreen *screen)
: QPlatformClipboard()
, m_screen(screen)
, m_xClipboard(0)
@@ -160,14 +161,14 @@ QTestLiteClipboard::QTestLiteClipboard(QTestLiteScreen *screen)
{
}
-const QMimeData * QTestLiteClipboard::mimeData(QClipboard::Mode mode) const
+const QMimeData * QXlibClipboard::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);
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ that->m_xClipboard = new QXlibClipboardMime(mode,that);
}
- Window clipboardOwner = XGetSelectionOwner(screen()->display(),QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD));
+ Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),QXlibStatic::atom(QXlibStatic::CLIPBOARD));
if (clipboardOwner == owner()) {
return m_clientClipboard;
} else {
@@ -175,10 +176,10 @@ const QMimeData * QTestLiteClipboard::mimeData(QClipboard::Mode mode) const
}
} else if (mode == QClipboard::Selection) {
if (!m_xSelection) {
- QTestLiteClipboard *that = const_cast<QTestLiteClipboard *>(this);
- that->m_xSelection = new QTestLiteClipboardMime(mode,that);
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ that->m_xSelection = new QXlibClipboardMime(mode,that);
}
- Window clipboardOwner = XGetSelectionOwner(screen()->display(),XA_PRIMARY);
+ Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),XA_PRIMARY);
if (clipboardOwner == owner()) {
return m_clientSelection;
} else {
@@ -188,7 +189,7 @@ const QMimeData * QTestLiteClipboard::mimeData(QClipboard::Mode mode) const
return 0;
}
-void QTestLiteClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+void QXlibClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
{
Atom modeAtom;
QMimeData **d;
@@ -199,7 +200,7 @@ void QTestLiteClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
break;
case QClipboard::Clipboard:
- modeAtom = QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD);
+ modeAtom = QXlibStatic::atom(QXlibStatic::CLIPBOARD);
d = &m_clientClipboard;
break;
@@ -218,15 +219,15 @@ void QTestLiteClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
*d = data;
}
- XSetSelectionOwner(m_screen->display(), modeAtom, newOwner, CurrentTime);
+ XSetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom, newOwner, CurrentTime);
- if (XGetSelectionOwner(m_screen->display(), modeAtom) != newOwner) {
+ if (XGetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom) != newOwner) {
qWarning("QClipboard::setData: Cannot set X11 selection owner");
}
}
-bool QTestLiteClipboard::supportsMode(QClipboard::Mode mode) const
+bool QXlibClipboard::supportsMode(QClipboard::Mode mode) const
{
if (mode == QClipboard::Clipboard || mode == QClipboard::Selection)
return true;
@@ -234,17 +235,17 @@ bool QTestLiteClipboard::supportsMode(QClipboard::Mode mode) const
}
-QTestLiteScreen * QTestLiteClipboard::screen() const
+QXlibScreen * QXlibClipboard::screen() const
{
return m_screen;
}
-Window QTestLiteClipboard::requestor() const
+Window QXlibClipboard::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(),
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
x, y, w, h, 0 /*border_width*/,
m_screen->blackPixel(), m_screen->whitePixel());
that->setRequestor(window);
@@ -252,20 +253,20 @@ Window QTestLiteClipboard::requestor() const
return m_requestor;
}
-void QTestLiteClipboard::setRequestor(Window window)
+void QXlibClipboard::setRequestor(Window window)
{
if (m_requestor != XNone) {
- XDestroyWindow(m_screen->display(),m_requestor);
+ XDestroyWindow(m_screen->display()->nativeDisplay(),m_requestor);
}
m_requestor = window;
}
-Window QTestLiteClipboard::owner() const
+Window QXlibClipboard::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(),
+ QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
+ Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
x, y, w, h, 0 /*border_width*/,
m_screen->blackPixel(), m_screen->whitePixel());
that->setOwner(window);
@@ -273,61 +274,61 @@ Window QTestLiteClipboard::owner() const
return m_owner;
}
-void QTestLiteClipboard::setOwner(Window window)
+void QXlibClipboard::setOwner(Window window)
{
if (m_owner != XNone){
- XDestroyWindow(m_screen->display(),m_owner);
+ XDestroyWindow(m_screen->display()->nativeDisplay(),m_owner);
}
m_owner = window;
}
-Atom QTestLiteClipboard::sendTargetsSelection(QMimeData *d, Window window, Atom property)
+Atom QXlibClipboard::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));
+ QList<Atom> atoms = QXlibMime::mimeAtomsForFormat(screen()->display()->nativeDisplay(),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));
+ types.append(QXlibStatic::atom(QXlibStatic::TARGETS));
+ types.append(QXlibStatic::atom(QXlibStatic::MULTIPLE));
+ types.append(QXlibStatic::atom(QXlibStatic::TIMESTAMP));
+ types.append(QXlibStatic::atom(QXlibStatic::SAVE_TARGETS));
- XChangeProperty(screen()->display(), window, property, XA_ATOM, 32,
+ XChangeProperty(screen()->display()->nativeDisplay(), 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 QXlibClipboard::sendSelection(QMimeData *d, Atom target, Window window, Atom property)
{
Atom atomFormat = target;
int dataFormat = 0;
QByteArray data;
- QString fmt = QTestLiteMime::mimeAtomToString(screen()->display(), target);
+ QString fmt = QXlibMime::mimeAtomToString(screen()->display()->nativeDisplay(), 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)) {
+ if (QXlibMime::mimeDataForAtom(screen()->display()->nativeDisplay(),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);
+ static Atom motif_clip_temporary = QXlibStatic::atom(QXlibStatic::CLIP_TEMPORARY);
bool allow_incr = property != motif_clip_temporary;
// X_ChangeProperty protocol request is 24 bytes
- const int increment = (XMaxRequestSize(screen()->display()) * 4) - 24;
+ const int increment = (XMaxRequestSize(screen()->display()->nativeDisplay()) * 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);
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property,
+ QXlibStatic::atom(QXlibStatic::INCR), 32, PropModeReplace, (uchar *) &bytes, 1);
// (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
qDebug() << "not implemented INCRT just YET!";
@@ -339,14 +340,14 @@ Atom QTestLiteClipboard::sendSelection(QMimeData *d, Atom target, Window window,
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,
+ XChangeProperty(screen()->display()->nativeDisplay(), window, property, atomFormat,
dataFormat, PropModeReplace, (uchar *) data.data(),
dataSize);
}
return property;
}
-void QTestLiteClipboard::handleSelectionRequest(XEvent *xevent)
+void QXlibClipboard::handleSelectionRequest(XEvent *xevent)
{
XSelectionRequestEvent *req = &xevent->xselectionrequest;
@@ -367,23 +368,23 @@ void QTestLiteClipboard::handleSelectionRequest(XEvent *xevent)
QMimeData *d;
if (req->selection == XA_PRIMARY) {
d = m_clientSelection;
- } else if (req->selection == QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD)) {
+ } else if (req->selection == QXlibStatic::atom(QXlibStatic::CLIPBOARD)) {
d = m_clientClipboard;
} else {
qWarning("QClipboard: Unknown selection '%lx'", req->selection);
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
return;
}
if (!d) {
qWarning("QClipboard: Cannot transfer data, no data available");
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), 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);
+ Atom xa_targets = QXlibStatic::atom(QXlibStatic::TARGETS);
+ Atom xa_multiple = QXlibStatic::atom(QXlibStatic::MULTIPLE);
+ Atom xa_timestamp = QXlibStatic::atom(QXlibStatic::TIMESTAMP);
struct AtomPair { Atom target; Atom property; } *multi = 0;
Atom multi_type = XNone;
@@ -399,7 +400,7 @@ void QTestLiteClipboard::handleSelectionRequest(XEvent *xevent)
0, &multi_type, &multi_format)
|| multi_format != 32) {
// MULTIPLE property not formatted correctly
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
return;
}
nmulti = multi_data.size()/sizeof(*multi);
@@ -427,7 +428,7 @@ void QTestLiteClipboard::handleSelectionRequest(XEvent *xevent)
;
} else if (target == xa_timestamp) {
// if (d->timestamp != CurrentTime) {
-// XChangeProperty(screen()->display(), req->requestor, property, XA_INTEGER, 32,
+// XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, property, XA_INTEGER, 32,
// PropModeReplace, CurrentTime, 1);
// ret = property;
// } else {
@@ -454,7 +455,7 @@ void QTestLiteClipboard::handleSelectionRequest(XEvent *xevent)
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,
+ XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, req->property, multi_type, 32,
PropModeReplace, (uchar *) multi, nmulti * 2);
}
@@ -463,15 +464,15 @@ void QTestLiteClipboard::handleSelectionRequest(XEvent *xevent)
}
// send selection notify to requestor
- XSendEvent(screen()->display(), req->requestor, False, NoEventMask, &event);
+ XSendEvent(screen()->display()->nativeDisplay(), 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
+bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const
{
- int maxsize = maxSelectionIncr(screen()->display());
+ int maxsize = maxSelectionIncr(screen()->display()->nativeDisplay());
ulong bytes_left; // bytes_after
ulong length; // nitems
uchar *data;
@@ -485,7 +486,7 @@ bool QTestLiteClipboard::clipboardReadProperty(Window win, Atom property, bool d
format = &dummy_format;
// Don't read anything, just get the size of the property data
- r = XGetWindowProperty(screen()->display(), win, property, 0, 0, False,
+ r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, 0, 0, False,
AnyPropertyType, type, format,
&length, &bytes_left, &data);
if (r != Success || (type && *type == XNone)) {
@@ -524,7 +525,7 @@ bool QTestLiteClipboard::clipboardReadProperty(Window win, Atom property, bool d
while (bytes_left) {
// more to read...
- r = XGetWindowProperty(screen()->display(), win, property, offset, maxsize/4,
+ r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, offset, maxsize/4,
False, AnyPropertyType, type, format,
&length, &bytes_left, &data);
if (r != Success || (type && *type == XNone))
@@ -549,7 +550,7 @@ bool QTestLiteClipboard::clipboardReadProperty(Window win, Atom property, bool d
XFree((char*)data);
}
- if (*format == 8 && *type == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT)) {
+ if (*format == 8 && *type == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT)) {
// convert COMPOUND_TEXT to a multibyte string
XTextProperty textprop;
textprop.encoding = *type;
@@ -559,7 +560,7 @@ bool QTestLiteClipboard::clipboardReadProperty(Window win, Atom property, bool d
char **list_ret = 0;
int count;
- if (XmbTextPropertyToTextList(screen()->display(), &textprop, &list_ret,
+ if (XmbTextPropertyToTextList(screen()->display()->nativeDisplay(), &textprop, &list_ret,
&count) == Success && count && list_ret) {
offset = buffer_offset = strlen(list_ret[0]);
buffer->resize(offset);
@@ -574,14 +575,14 @@ bool QTestLiteClipboard::clipboardReadProperty(Window win, Atom property, bool d
*size = buffer_offset;
if (deleteProperty)
- XDeleteProperty(screen()->display(), win, property);
+ XDeleteProperty(screen()->display()->nativeDisplay(), win, property);
- XFlush(screen()->display());
+ screen()->display()->flush();
return ok;
}
-QByteArray QTestLiteClipboard::clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm)
+QByteArray QXlibClipboard::clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm)
{
XEvent event;
@@ -600,7 +601,7 @@ QByteArray QTestLiteClipboard::clipboardReadIncrementalProperty(Window win, Atom
}
for (;;) {
- XFlush(screen()->display());
+ screen()->display()->flush();
if (!screen()->waitForClipboardEvent(win,PropertyNotify,&event,clipboard_timeout))
break;
if (event.xproperty.atom != property ||
@@ -639,17 +640,17 @@ QByteArray QTestLiteClipboard::clipboardReadIncrementalProperty(Window win, Atom
return QByteArray();
}
-QByteArray QTestLiteClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
+QByteArray QXlibClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
{
QByteArray buf;
Window win = requestor();
- XSelectInput(screen()->display(), win, NoEventMask); // don't listen for any events
+ XSelectInput(screen()->display()->nativeDisplay(), 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);
+ XDeleteProperty(screen()->display()->nativeDisplay(), win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION));
+ XConvertSelection(screen()->display()->nativeDisplay(), modeAtom, fmtatom, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), win, CurrentTime);
+ screen()->display()->sync();
XEvent xevent;
if (!screen()->waitForClipboardEvent(win,SelectionNotify,&xevent,clipboard_timeout) ||
@@ -658,19 +659,19 @@ QByteArray QTestLiteClipboard::getDataInFormat(Atom modeAtom, Atom fmtatom)
}
Atom type;
- XSelectInput(screen()->display(), win, PropertyChangeMask);
+ XSelectInput(screen()->display()->nativeDisplay(), win, PropertyChangeMask);
- if (clipboardReadProperty(win, QTestLiteStatic::atom(QTestLiteStatic::_QT_SELECTION), true, &buf, 0, &type, 0)) {
- if (type == QTestLiteStatic::atom(QTestLiteStatic::INCR)) {
+ if (clipboardReadProperty(win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), true, &buf, 0, &type, 0)) {
+ if (type == QXlibStatic::atom(QXlibStatic::INCR)) {
int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
- buf = clipboardReadIncrementalProperty(win, QTestLiteStatic::atom(QTestLiteStatic::_QT_SELECTION), nbytes, false);
+ buf = clipboardReadIncrementalProperty(win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), nbytes, false);
}
}
- XSelectInput(screen()->display(), win, NoEventMask);
+ XSelectInput(screen()->display()->nativeDisplay(), win, NoEventMask);
return buf;
}
-#include "qtestliteclipboard.moc"
+#include "qxlibclipboard.moc"
diff --git a/src/plugins/platforms/testlite/qtestliteclipboard.h b/src/plugins/platforms/xlib/qxlibclipboard.h
index 76065a2..15901b0 100644
--- a/src/plugins/platforms/testlite/qtestliteclipboard.h
+++ b/src/plugins/platforms/xlib/qxlibclipboard.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -43,20 +43,20 @@
#define QTESTLITECLIPBOARD_H
#include <QPlatformClipboard>
-#include "qtestlitestaticinfo.h"
+#include "qxlibstatic.h"
-class QTestLiteScreen;
-class QTestLiteClipboard : public QPlatformClipboard
+class QXlibScreen;
+class QXlibClipboard : public QPlatformClipboard
{
public:
- QTestLiteClipboard(QTestLiteScreen *screen);
+ QXlibClipboard(QXlibScreen *screen);
const QMimeData *mimeData(QClipboard::Mode mode) const;
void setMimeData(QMimeData *data, QClipboard::Mode mode);
bool supportsMode(QClipboard::Mode mode) const;
- QTestLiteScreen *screen() const;
+ QXlibScreen *screen() const;
Window requestor() const;
void setRequestor(Window window);
@@ -76,7 +76,7 @@ private:
Atom sendTargetsSelection(QMimeData *d, Window window, Atom property);
Atom sendSelection(QMimeData *d, Atom target, Window window, Atom property);
- QTestLiteScreen *m_screen;
+ QXlibScreen *m_screen;
QMimeData *m_xClipboard;
QMimeData *m_clientClipboard;
diff --git a/src/plugins/platforms/testlite/qtestlitecursor.cpp b/src/plugins/platforms/xlib/qxlibcursor.cpp
index e7ef673..042cbc9 100644
--- a/src/plugins/platforms/testlite/qtestlitecursor.cpp
+++ b/src/plugins/platforms/xlib/qxlibcursor.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,11 +39,12 @@
**
****************************************************************************/
-#include "qtestlitecursor.h"
+#include "qxlibcursor.h"
-#include "qtestliteintegration.h"
-#include "qtestlitescreen.h"
-#include "qtestlitewindow.h"
+#include "qxlibintegration.h"
+#include "qxlibscreen.h"
+#include "qxlibwindow.h"
+#include "qxlibdisplay.h"
#include <QtGui/QBitmap>
@@ -51,17 +52,17 @@
QT_BEGIN_NAMESPACE
-QTestLiteCursor::QTestLiteCursor(QTestLiteScreen *screen)
+QXlibCursor::QXlibCursor(QXlibScreen *screen)
: QPlatformCursor(screen)
{
}
-void QTestLiteCursor::changeCursor(QCursor *cursor, QWidget *widget)
+void QXlibCursor::changeCursor(QCursor *cursor, QWidget *widget)
{
- QTestLiteWindow *w = 0;
+ QXlibWindow *w = 0;
if (widget) {
QWidget *window = widget->window();
- w = static_cast<QTestLiteWindow*>(window->platformWindow());
+ w = static_cast<QXlibWindow*>(window->platformWindow());
} else {
// No X11 cursor control when there is no widget under the cursor
return;
@@ -89,7 +90,7 @@ void QTestLiteCursor::changeCursor(QCursor *cursor, QWidget *widget)
w->setCursor(c);
}
-Cursor QTestLiteCursor::createCursorBitmap(QCursor * cursor)
+Cursor QXlibCursor::createCursorBitmap(QCursor * cursor)
{
XColor bg, fg;
bg.red = 255 << 8;
@@ -121,18 +122,18 @@ Cursor QTestLiteCursor::createCursorBitmap(QCursor * cursor)
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);
+ Pixmap cp = XCreateBitmapFromData(testLiteScreen()->display()->nativeDisplay(), rootwin, mapBits, width, height);
+ Pixmap mp = XCreateBitmapFromData(testLiteScreen()->display()->nativeDisplay(), rootwin, maskBits, width, height);
+ Cursor c = XCreatePixmapCursor(testLiteScreen()->display()->nativeDisplay(), cp, mp, &fg, &bg, spot.x(), spot.y());
+ XFreePixmap(testLiteScreen()->display()->nativeDisplay(), cp);
+ XFreePixmap(testLiteScreen()->display()->nativeDisplay(), mp);
delete[] mapBits;
delete[] maskBits;
return c;
}
-Cursor QTestLiteCursor::createCursorShape(int cshape)
+Cursor QXlibCursor::createCursorShape(int cshape)
{
Cursor cursor = 0;
@@ -141,48 +142,48 @@ Cursor QTestLiteCursor::createCursorShape(int cshape)
switch (cshape) {
case Qt::ArrowCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_left_ptr);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_left_ptr);
break;
case Qt::UpArrowCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_center_ptr);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_center_ptr);
break;
case Qt::CrossCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_crosshair);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_crosshair);
break;
case Qt::WaitCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_watch);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_watch);
break;
case Qt::IBeamCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_xterm);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_xterm);
break;
case Qt::SizeAllCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_fleur);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_fleur);
break;
case Qt::PointingHandCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_hand2);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_hand2);
break;
case Qt::SizeBDiagCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_top_right_corner);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_top_right_corner);
break;
case Qt::SizeFDiagCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_bottom_right_corner);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_bottom_right_corner);
break;
case Qt::SizeVerCursor:
case Qt::SplitVCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_sb_v_double_arrow);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_sb_v_double_arrow);
break;
case Qt::SizeHorCursor:
case Qt::SplitHCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_sb_h_double_arrow);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_sb_h_double_arrow);
break;
case Qt::WhatsThisCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_question_arrow);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_question_arrow);
break;
case Qt::ForbiddenCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_circle);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_circle);
break;
case Qt::BusyCursor:
- cursor = XCreateFontCursor(testLiteScreen()->display(), XC_watch);
+ cursor = XCreateFontCursor(testLiteScreen()->display()->nativeDisplay(), XC_watch);
break;
default: //default cursor for all the rest
@@ -191,9 +192,9 @@ Cursor QTestLiteCursor::createCursorShape(int cshape)
return cursor;
}
-QTestLiteScreen * QTestLiteCursor::testLiteScreen() const
+QXlibScreen * QXlibCursor::testLiteScreen() const
{
- return static_cast<QTestLiteScreen *>(screen);
+ return static_cast<QXlibScreen *>(screen);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/testlite/qtestlitecursor.h b/src/plugins/platforms/xlib/qxlibcursor.h
index bb3549e..62b13eb 100644
--- a/src/plugins/platforms/testlite/qtestlitecursor.h
+++ b/src/plugins/platforms/xlib/qxlibcursor.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -44,14 +44,14 @@
#include <QtGui/QPlatformCursor>
-#include "qtestliteintegration.h"
+#include "qxlibintegration.h"
QT_BEGIN_NAMESPACE
-class QTestLiteCursor : QPlatformCursor
+class QXlibCursor : QPlatformCursor
{
public:
- QTestLiteCursor(QTestLiteScreen *screen);
+ QXlibCursor(QXlibScreen *screen);
void changeCursor(QCursor * cursor, QWidget * widget);
private:
@@ -59,7 +59,7 @@ private:
Cursor createCursorBitmap(QCursor * cursor);
Cursor createCursorShape(int cshape);
- QTestLiteScreen *testLiteScreen() const;
+ QXlibScreen *testLiteScreen() const;
QMap<int, Cursor> cursorMap;
};
diff --git a/src/plugins/platforms/xlib/qxlibdisplay.cpp b/src/plugins/platforms/xlib/qxlibdisplay.cpp
new file mode 100644
index 0000000..d8aa230
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibdisplay.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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 "qxlibdisplay.h"
+
+QXlibDisplay::QXlibDisplay(Display *display)
+ : mDisplay(display)
+{
+ if (!mDisplay) {
+ qFatal("Cannot connect to X server");
+ }
+ mDisplayName = QString::fromLocal8Bit(DisplayString(mDisplay));
+}
+
+QXlibDisplay::~QXlibDisplay()
+{
+ XCloseDisplay(mDisplay);
+}
+
+QString QXlibDisplay::displayName() const
+{
+ { return mDisplayName; }
+}
+
+
+
+Display * QXlibDisplay::nativeDisplay() const
+{
+ return mDisplay;
+}
+
+void QXlibDisplay::sync() const
+{
+ XSync(mDisplay, False);
+}
+
+void QXlibDisplay::flush() const
+{
+ XFlush(mDisplay);
+}
diff --git a/src/plugins/platforms/xlib/qxlibdisplay.h b/src/plugins/platforms/xlib/qxlibdisplay.h
new file mode 100644
index 0000000..557ab52
--- /dev/null
+++ b/src/plugins/platforms/xlib/qxlibdisplay.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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 QXLIBDISPLAY_H
+#define QXLIBDISPLAY_H
+
+#include "qxlibintegration.h"
+
+class QXlibDisplay
+{
+public:
+ QXlibDisplay(Display *display);
+ ~QXlibDisplay();
+ QString displayName() const;
+
+ Display *nativeDisplay() const;
+
+ void sync() const;
+ void flush() const;
+private:
+ Display *mDisplay;
+ QString mDisplayName;
+};
+
+#endif // QXLIBDISPLAY_H
diff --git a/src/plugins/platforms/testlite/qtestliteintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp
index 9b641d1..6733ed1 100644
--- a/src/plugins/platforms/testlite/qtestliteintegration.cpp
+++ b/src/plugins/platforms/xlib/qxlibintegration.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,15 +39,16 @@
**
****************************************************************************/
-#include "qtestliteintegration.h"
-#include "qtestlitewindowsurface.h"
+#include "qxlibintegration.h"
+#include "qxlibwindowsurface.h"
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtCore/qdebug.h>
-#include "qtestlitewindow.h"
+#include "qxlibwindow.h"
#include "qgenericunixfontdatabase.h"
-#include "qtestlitescreen.h"
-#include "qtestliteclipboard.h"
+#include "qxlibscreen.h"
+#include "qxlibclipboard.h"
+#include "qxlibdisplay.h"
#if !defined(QT_NO_OPENGL)
#if !defined(QT_OPENGL_ES_2)
@@ -61,16 +62,16 @@
QT_BEGIN_NAMESPACE
-QTestLiteIntegration::QTestLiteIntegration(bool useOpenGL)
+QXlibIntegration::QXlibIntegration(bool useOpenGL)
: mUseOpenGL(useOpenGL)
, mFontDb(new QGenericUnixFontDatabase())
, mClipboard(0)
{
- mPrimaryScreen = new QTestLiteScreen();
+ mPrimaryScreen = new QXlibScreen();
mScreens.append(mPrimaryScreen);
}
-QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type) const
+QPixmapData *QXlibIntegration::createPixmapData(QPixmapData::PixelType type) const
{
#ifndef QT_NO_OPENGL
if (mUseOpenGL)
@@ -79,33 +80,33 @@ QPixmapData *QTestLiteIntegration::createPixmapData(QPixmapData::PixelType type)
return new QRasterPixmapData(type);
}
-QWindowSurface *QTestLiteIntegration::createWindowSurface(QWidget *widget, WId) const
+QWindowSurface *QXlibIntegration::createWindowSurface(QWidget *widget, WId) const
{
#ifndef QT_NO_OPENGL
if (mUseOpenGL)
return new QGLWindowSurface(widget);
#endif
- return new QTestLiteWindowSurface(widget);
+ return new QXlibWindowSurface(widget);
}
-QPlatformWindow *QTestLiteIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
+QPlatformWindow *QXlibIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
{
- return new QTestLiteWindow(widget);
+ return new QXlibWindow(widget);
}
-QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, int height) const
+QPixmap QXlibIntegration::grabWindow(WId window, int x, int y, int width, int height) const
{
QImage image;
QWidget *widget = QWidget::find(window);
if (widget) {
- QTestLiteScreen *screen = QTestLiteScreen::testLiteScreenForWidget(widget);
+ QXlibScreen *screen = QXlibScreen::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]);
+ QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens[i]);
if (screen->rootWindow() == window) {
image = screen->grabWindow(window,x,y,width,height);
}
@@ -114,36 +115,36 @@ QPixmap QTestLiteIntegration::grabWindow(WId window, int x, int y, int width, in
return QPixmap::fromImage(image);
}
-QPlatformFontDatabase *QTestLiteIntegration::fontDatabase() const
+QPlatformFontDatabase *QXlibIntegration::fontDatabase() const
{
return mFontDb;
}
-QPlatformClipboard * QTestLiteIntegration::clipboard() const
+QPlatformClipboard * QXlibIntegration::clipboard() const
{
//Use lazy init since clipboard needs QTestliteScreen
if (!mClipboard) {
- QTestLiteIntegration *that = const_cast<QTestLiteIntegration *>(this);
- that->mClipboard = new QTestLiteClipboard(mPrimaryScreen);
+ QXlibIntegration *that = const_cast<QXlibIntegration *>(this);
+ that->mClipboard = new QXlibClipboard(mPrimaryScreen);
}
return mClipboard;
}
-bool QTestLiteIntegration::hasOpenGL() const
+bool QXlibIntegration::hasOpenGL() const
{
#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;
+ QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0));
+ return glXQueryExtension(screen->display()->nativeDisplay(), 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));
+ const QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0));
EGLint major, minor;
eglBindAPI(EGL_OPENGL_ES_API);
- EGLDisplay disp = eglGetDisplay(screen->display());
+ EGLDisplay disp = eglGetDisplay(screen->display()->nativeDisplay());
wasEglInitialized = eglInitialize(disp,&major,&minor);
}
return wasEglInitialized;
diff --git a/src/plugins/platforms/testlite/qtestliteintegration.h b/src/plugins/platforms/xlib/qxlibintegration.h
index 320cf00..3bbf897 100644
--- a/src/plugins/platforms/testlite/qtestliteintegration.h
+++ b/src/plugins/platforms/xlib/qxlibintegration.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -48,16 +48,16 @@
#include <QtGui/QPlatformIntegration>
#include <QtGui/QPlatformScreen>
-#include "qtestlitestaticinfo.h"
+#include "qxlibstatic.h"
QT_BEGIN_NAMESPACE
-class QTestLiteScreen;
+class QXlibScreen;
-class QTestLiteIntegration : public QPlatformIntegration
+class QXlibIntegration : public QPlatformIntegration
{
public:
- QTestLiteIntegration(bool useOpenGL = false);
+ QXlibIntegration(bool useOpenGL = false);
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
@@ -74,7 +74,7 @@ public:
private:
bool mUseOpenGL;
- QTestLiteScreen *mPrimaryScreen;
+ QXlibScreen *mPrimaryScreen;
QList<QPlatformScreen *> mScreens;
QPlatformFontDatabase *mFontDb;
QPlatformClipboard *mClipboard;
diff --git a/src/plugins/platforms/testlite/qtestlitekeyboard.cpp b/src/plugins/platforms/xlib/qxlibkeyboard.cpp
index 5b4ebd7..8d94157 100644
--- a/src/plugins/platforms/testlite/qtestlitekeyboard.cpp
+++ b/src/plugins/platforms/xlib/qxlibkeyboard.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,9 +39,10 @@
**
****************************************************************************/
-#include "qtestlitekeyboard.h"
+#include "qxlibkeyboard.h"
-#include "qtestlitescreen.h"
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
#include <QtGui/QWindowSystemInterface>
@@ -740,7 +741,7 @@ static QChar keysymToUnicode(unsigned char byte3, unsigned char byte4)
return QChar(0x0);
}
-Qt::KeyboardModifiers QTestLiteKeyboard::translateModifiers(int s)
+Qt::KeyboardModifiers QXlibKeyboard::translateModifiers(int s)
{
Qt::KeyboardModifiers ret = 0;
if (s & ShiftMask)
@@ -756,7 +757,7 @@ Qt::KeyboardModifiers QTestLiteKeyboard::translateModifiers(int s)
return ret;
}
-void QTestLiteKeyboard::setMask(KeySym sym, uint mask)
+void QXlibKeyboard::setMask(KeySym sym, uint mask)
{
if (m_alt_mask == 0
&& m_meta_mask != mask
@@ -800,7 +801,7 @@ void QTestLiteKeyboard::setMask(KeySym sym, uint mask)
}
}
-int QTestLiteKeyboard::translateKeySym(uint key) const
+int QXlibKeyboard::translateKeySym(uint key) const
{
int code = -1;
int i = 0; // any other keys
@@ -822,7 +823,7 @@ int QTestLiteKeyboard::translateKeySym(uint key) const
return code;
}
-QString QTestLiteKeyboard::translateKeySym(KeySym keysym, uint xmodifiers,
+QString QXlibKeyboard::translateKeySym(KeySym keysym, uint xmodifiers,
int &code, Qt::KeyboardModifiers &modifiers,
QByteArray &chars, int &count)
{
@@ -939,7 +940,7 @@ QString QTestLiteKeyboard::translateKeySym(KeySym keysym, uint xmodifiers,
return text;
}
-QTestLiteKeyboard::QTestLiteKeyboard(QTestLiteScreen *screen)
+QXlibKeyboard::QXlibKeyboard(QXlibScreen *screen)
: m_screen(screen)
, m_alt_mask(0)
, m_super_mask(0)
@@ -949,9 +950,9 @@ QTestLiteKeyboard::QTestLiteKeyboard(QTestLiteScreen *screen)
changeLayout();
}
-void QTestLiteKeyboard::changeLayout()
+void QXlibKeyboard::changeLayout()
{
- XkbDescPtr xkbDesc = XkbGetMap(m_screen->display(), XkbAllClientInfoMask, XkbUseCoreKbd);
+ XkbDescPtr xkbDesc = XkbGetMap(m_screen->display()->nativeDisplay(), 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) {
@@ -986,7 +987,7 @@ static Qt::KeyboardModifiers modifierFromKeyCode(int qtcode)
}
}
-void QTestLiteKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev)
+void QXlibKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyEvent *ev)
{
int qtcode = 0;
Qt::KeyboardModifiers modifiers = translateModifiers(ev->state);
@@ -996,5 +997,5 @@ void QTestLiteKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, XKeyE
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));
+ QWindowSystemInterface::handleExtendedKeyEvent(widget,ev->time,type,qtcode,modifiers,ev->keycode,0,ev->state,text.left(count));
}
diff --git a/src/plugins/platforms/testlite/qtestlitekeyboard.h b/src/plugins/platforms/xlib/qxlibkeyboard.h
index 6873a09..5e0135a 100644
--- a/src/plugins/platforms/testlite/qtestlitekeyboard.h
+++ b/src/plugins/platforms/xlib/qxlibkeyboard.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -42,12 +42,12 @@
#ifndef QTESTLITEKEYBOARD_H
#define QTESTLITEKEYBOARD_H
-#include "qtestliteintegration.h"
+#include "qxlibintegration.h"
-class QTestLiteKeyboard
+class QXlibKeyboard
{
public:
- QTestLiteKeyboard(QTestLiteScreen *screen);
+ QXlibKeyboard(QXlibScreen *screen);
void changeLayout();
@@ -63,7 +63,7 @@ private:
int &code, Qt::KeyboardModifiers &modifiers,
QByteArray &chars, int &count);
- QTestLiteScreen *m_screen;
+ QXlibScreen *m_screen;
uint m_alt_mask;
uint m_super_mask;
diff --git a/src/plugins/platforms/testlite/qtestlitemime.cpp b/src/plugins/platforms/xlib/qxlibmime.cpp
index c509991..e98983d 100644
--- a/src/plugins/platforms/testlite/qtestlitemime.cpp
+++ b/src/plugins/platforms/xlib/qxlibmime.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,31 +39,31 @@
**
****************************************************************************/
-#include "qtestlitemime.h"
+#include "qxlibmime.h"
-#include "qtestlitestaticinfo.h"
-#include "qtestlitescreen.h"
+#include "qxlibstatic.h"
+#include "qxlibscreen.h"
#include <QtCore/QTextCodec>
#include <QtGui/QImageWriter>
#include <QtCore/QBuffer>
-QTestLiteMime::QTestLiteMime()
+QXlibMime::QXlibMime()
: QInternalMimeData()
{ }
-QTestLiteMime::~QTestLiteMime()
+QXlibMime::~QXlibMime()
{}
-QString QTestLiteMime::mimeAtomToString(Display *display, Atom a)
+QString QXlibMime::mimeAtomToString(Display *display, Atom a)
{
if (!a) return 0;
- if (a == XA_STRING || a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)) {
+ if (a == XA_STRING || a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)) {
return "text/plain"; // some Xdnd clients are dumb
}
char *atom = XGetAtomName(display, a);
@@ -72,14 +72,14 @@ QString QTestLiteMime::mimeAtomToString(Display *display, Atom a)
return result;
}
-Atom QTestLiteMime::mimeStringToAtom(Display *display, const QString &mimeType)
+Atom QXlibMime::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 QXlibMime::mimeFormatsForAtom(Display *display, Atom a)
{
QStringList formats;
if (a) {
@@ -87,10 +87,10 @@ QStringList QTestLiteMime::mimeFormatsForAtom(Display *display, Atom a)
formats.append(atomName);
// special cases for string type
- if (a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)
+ if (a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)
|| a == XA_STRING
- || a == QTestLiteStatic::atom(QTestLiteStatic::TEXT)
- || a == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT))
+ || a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
formats.append(QLatin1String("text/plain"));
// special cases for uris
@@ -104,7 +104,7 @@ QStringList QTestLiteMime::mimeFormatsForAtom(Display *display, Atom a)
return formats;
}
-bool QTestLiteMime::mimeDataForAtom(Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
+bool QXlibMime::mimeDataForAtom(Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
{
bool ret = false;
*atomFormat = a;
@@ -116,27 +116,27 @@ bool QTestLiteMime::mimeDataForAtom(Display *display, Atom a, QMimeData *mimeDat
*dataFormat = 16;
ret = true;
} else {
- if ((a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)
+ if ((a == QXlibStatic::atom(QXlibStatic::UTF8_STRING)
|| a == XA_STRING
- || a == QTestLiteStatic::atom(QTestLiteStatic::TEXT)
- || a == QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT))
+ || a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
&& QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
- if (a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING)){
+ if (a == QXlibStatic::atom(QXlibStatic::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)) {
+ } else if (a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::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))
+ XICCEncodingStyle style = (a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
? XCompoundTextStyle : XStdICCTextStyle;
XTextProperty textprop;
if (list[0] != NULL
@@ -165,17 +165,17 @@ bool QTestLiteMime::mimeDataForAtom(Display *display, Atom a, QMimeData *mimeDat
return ret && data != 0;
}
-QList<Atom> QTestLiteMime::mimeAtomsForFormat(Display *display, const QString &format)
+QList<Atom> QXlibMime::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(QXlibStatic::atom(QXlibStatic::UTF8_STRING));
atoms.append(XA_STRING);
- atoms.append(QTestLiteStatic::atom(QTestLiteStatic::TEXT));
- atoms.append(QTestLiteStatic::atom(QTestLiteStatic::COMPOUND_TEXT));
+ atoms.append(QXlibStatic::atom(QXlibStatic::TEXT));
+ atoms.append(QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT));
}
// special cases for uris
@@ -192,7 +192,7 @@ QList<Atom> QTestLiteMime::mimeAtomsForFormat(Display *display, const QString &f
return atoms;
}
-QVariant QTestLiteMime::mimeConvertToFormat(Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
+QVariant QXlibMime::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)
@@ -212,12 +212,12 @@ QVariant QTestLiteMime::mimeConvertToFormat(Display *display, Atom a, const QByt
// special cases for string types
if (format == QLatin1String("text/plain")) {
- if (a == QTestLiteStatic::atom(QTestLiteStatic::UTF8_STRING))
+ if (a == QXlibStatic::atom(QXlibStatic::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))
+ if (a == QXlibStatic::atom(QXlibStatic::TEXT)
+ || a == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT))
// #### might be wrong for COMPUND_TEXT
return QString::fromLocal8Bit(data, data.size());
}
@@ -251,7 +251,7 @@ QVariant QTestLiteMime::mimeConvertToFormat(Display *display, Atom a, const QByt
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);
+ QImage qimg = QXlibStatic::qimageFromXImage(ximg);
XDestroyImage(ximg);
QImageWriter imageWriter;
@@ -266,18 +266,18 @@ QVariant QTestLiteMime::mimeConvertToFormat(Display *display, Atom a, const QByt
return QVariant();
}
-Atom QTestLiteMime::mimeAtomForFormat(Display *display, const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *requestedEncoding)
+Atom QXlibMime::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(QXlibStatic::atom(QXlibStatic::UTF8_STRING)))
+ return QXlibStatic::atom(QXlibStatic::UTF8_STRING);
+ if (atoms.contains(QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT)))
+ return QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT);
+ if (atoms.contains(QXlibStatic::atom(QXlibStatic::TEXT)))
+ return QXlibStatic::atom(QXlibStatic::TEXT);
if (atoms.contains(XA_STRING))
return XA_STRING;
}
diff --git a/src/plugins/platforms/testlite/qtestlitemime.h b/src/plugins/platforms/xlib/qxlibmime.h
index f11070f..a9bc265 100644
--- a/src/plugins/platforms/testlite/qtestlitemime.h
+++ b/src/plugins/platforms/xlib/qxlibmime.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -46,14 +46,14 @@
#include <QtGui/QClipboard>
-#include "qtestliteintegration.h"
-#include "qtestliteclipboard.h"
+#include "qxlibintegration.h"
+#include "qxlibclipboard.h"
-class QTestLiteMime : public QInternalMimeData {
+class QXlibMime : public QInternalMimeData {
Q_OBJECT
public:
- QTestLiteMime();
- ~QTestLiteMime();
+ QXlibMime();
+ ~QXlibMime();
static QList<Atom> mimeAtomsForFormat(Display *display, const QString &format);
static QString mimeAtomToString(Display *display, Atom a);
diff --git a/src/plugins/platforms/testlite/qtestlitescreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp
index c211ee6..23a2d07 100644
--- a/src/plugins/platforms/testlite/qtestlitescreen.cpp
+++ b/src/plugins/platforms/xlib/qxlibscreen.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -39,13 +39,14 @@
**
****************************************************************************/
-#include "qtestlitescreen.h"
+#include "qxlibscreen.h"
-#include "qtestlitecursor.h"
-#include "qtestlitewindow.h"
-#include "qtestlitekeyboard.h"
-#include "qtestlitestaticinfo.h"
-#include "qtestliteclipboard.h"
+#include "qxlibcursor.h"
+#include "qxlibwindow.h"
+#include "qxlibkeyboard.h"
+#include "qxlibstatic.h"
+#include "qxlibclipboard.h"
+#include "qxlibdisplay.h"
#include <QtCore/QDebug>
#include <QtCore/QSocketNotifier>
@@ -188,54 +189,65 @@ qDebug() << "qt_x_errhandler" << err->error_code;
return 0;
}
-QTestLiteScreen::QTestLiteScreen()
+QXlibScreen::QXlibScreen()
: 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);
- }
+ Display *display = XOpenDisplay(display_name);
+ mDisplay = new QXlibDisplay(display);
+
#ifndef DONT_USE_MIT_SHM
- Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay);
+ Status MIT_SHM_extension_supported = XShmQueryExtension (mDisplay->nativeDisplay());
Q_ASSERT(MIT_SHM_extension_supported == True);
#endif
original_x_errhandler = XSetErrorHandler(qt_x_errhandler);
if (qgetenv("DO_X_SYNCHRONIZE").toInt())
- XSynchronize(mDisplay, true);
+ XSynchronize(mDisplay->nativeDisplay(), true);
- mScreen = DefaultScreen(mDisplay);
- XSelectInput(mDisplay,rootWindow(), KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
- int width = DisplayWidth(mDisplay, mScreen);
- int height = DisplayHeight(mDisplay, mScreen);
+ mScreen = DefaultScreen(mDisplay->nativeDisplay());
+ XSelectInput(mDisplay->nativeDisplay(),rootWindow(), KeymapStateMask | EnterWindowMask | LeaveWindowMask | PropertyChangeMask);
+ int width = DisplayWidth(mDisplay->nativeDisplay(), mScreen);
+ int height = DisplayHeight(mDisplay->nativeDisplay(), mScreen);
mGeometry = QRect(0,0,width,height);
- int physicalWidth = DisplayWidthMM(mDisplay, mScreen);
- int physicalHeight = DisplayHeightMM(mDisplay, mScreen);
+ int physicalWidth = DisplayWidthMM(mDisplay->nativeDisplay(), mScreen);
+ int physicalHeight = DisplayHeightMM(mDisplay->nativeDisplay(), mScreen);
mPhysicalSize = QSize(physicalWidth,physicalHeight);
- int xSocketNumber = XConnectionNumber(mDisplay);
+ int xSocketNumber = XConnectionNumber(mDisplay->nativeDisplay());
- mDepth = DefaultDepth(mDisplay,mScreen);
+ mDepth = DefaultDepth(mDisplay->nativeDisplay(),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);
+ mCursor = new QXlibCursor(this);
+ mKeyboard = new QXlibKeyboard(this);
}
-QTestLiteScreen::~QTestLiteScreen()
+QXlibScreen::~QXlibScreen()
{
delete mCursor;
- XCloseDisplay(mDisplay);
+ delete mDisplay;
+}
+
+Window QXlibScreen::rootWindow()
+{
+ return RootWindow(mDisplay->nativeDisplay(), mScreen);
+}
+
+unsigned long QXlibScreen::blackPixel()
+{
+ return BlackPixel(mDisplay->nativeDisplay(), mScreen);
+}
+
+unsigned long QXlibScreen::whitePixel()
+{
+ return WhitePixel(mDisplay->nativeDisplay(), mScreen);
}
#ifdef KeyPress
@@ -245,17 +257,17 @@ QTestLiteScreen::~QTestLiteScreen()
#undef KeyRelease
#endif
-bool QTestLiteScreen::handleEvent(XEvent *xe)
+bool QXlibScreen::handleEvent(XEvent *xe)
{
int quit = false;
- QTestLiteWindow *platformWindow = 0;
+ QXlibWindow *platformWindow = 0;
QWidget *widget = QWidget::find(xe->xany.window);
if (widget) {
- platformWindow = static_cast<QTestLiteWindow *>(widget->platformWindow());
+ platformWindow = static_cast<QXlibWindow *>(widget->platformWindow());
}
- Atom wmProtocolsAtom = QTestLiteStatic::atom(QTestLiteStatic::WM_PROTOCOLS);
- Atom wmDeleteWindowAtom = QTestLiteStatic::atom(QTestLiteStatic::WM_DELETE_WINDOW);
+ Atom wmProtocolsAtom = QXlibStatic::atom(QXlibStatic::WM_PROTOCOLS);
+ Atom wmDeleteWindowAtom = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW);
switch (xe->type) {
case ClientMessage:
@@ -346,27 +358,27 @@ bool QTestLiteScreen::handleEvent(XEvent *xe)
static Bool checkForClipboardEvents(Display *, XEvent *e, XPointer)
{
- Atom clipboard = QTestLiteStatic::atom(QTestLiteStatic::CLIPBOARD);
+ Atom clipboard = QXlibStatic::atom(QXlibStatic::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)
+bool QXlibScreen::waitForClipboardEvent(Window win, int type, XEvent *event, int timeout)
{
QElapsedTimer timer;
timer.start();
do {
- if (XCheckTypedWindowEvent(mDisplay,win,type,event))
+ if (XCheckTypedWindowEvent(mDisplay->nativeDisplay(),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))
+ if (XCheckIfEvent(mDisplay->nativeDisplay(), &e, checkForClipboardEvents, 0))
handleEvent(&e);
- XFlush(mDisplay);
+ mDisplay->flush();
// sleep 50 ms, so we don't use up CPU cycles all the time.
struct timeval usleep_tv;
@@ -377,13 +389,13 @@ bool QTestLiteScreen::waitForClipboardEvent(Window win, int type, XEvent *event,
return false;
}
-void QTestLiteScreen::eventDispatcher()
+void QXlibScreen::eventDispatcher()
{
- ulong marker = XNextRequest(mDisplay);
+ ulong marker = XNextRequest(mDisplay->nativeDisplay());
// int i = 0;
- while (XPending(mDisplay)) {
+ while (XPending(mDisplay->nativeDisplay())) {
XEvent event;
- XNextEvent(mDisplay, &event);
+ XNextEvent(mDisplay->nativeDisplay(), &event);
/* done = */
handleEvent(&event);
@@ -392,7 +404,7 @@ void QTestLiteScreen::eventDispatcher()
qDebug() << "potential livelock averted";
#endif
#if 0
- if (XEventsQueued(mDisplay, QueuedAfterFlush)) {
+ if (XEventsQueued(mDisplay->nativeDisplay(), QueuedAfterFlush)) {
qDebug() << " with events queued";
QTimer::singleShot(0, this, SLOT(eventDispatcher()));
}
@@ -402,7 +414,7 @@ void QTestLiteScreen::eventDispatcher()
}
}
-QImage QTestLiteScreen::grabWindow(Window window, int x, int y, int w, int h)
+QImage QXlibScreen::grabWindow(Window window, int x, int y, int w, int h)
{
if (w == 0 || h ==0)
return QImage();
@@ -412,7 +424,7 @@ QImage QTestLiteScreen::grabWindow(Window window, int x, int y, int w, int h)
window = rootWindow();
XWindowAttributes window_attr;
- if (!XGetWindowAttributes(mDisplay, window, &window_attr))
+ if (!XGetWindowAttributes(mDisplay->nativeDisplay(), window, &window_attr))
return QImage();
if (w < 0)
@@ -424,7 +436,7 @@ QImage QTestLiteScreen::grabWindow(Window window, int x, int y, int w, int h)
// 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);
+ XImage *xi = XGetImage(mDisplay->nativeDisplay(), window, x, y, w, h, AllPlanes, ZPixmap);
if (!xi)
return QImage();
@@ -437,31 +449,36 @@ QImage QTestLiteScreen::grabWindow(Window window, int x, int y, int w, int h)
return result;
}
-QTestLiteScreen * QTestLiteScreen::testLiteScreenForWidget(QWidget *widget)
+QXlibScreen * QXlibScreen::testLiteScreenForWidget(QWidget *widget)
{
QPlatformScreen *platformScreen = platformScreenForWidget(widget);
- return static_cast<QTestLiteScreen *>(platformScreen);
+ return static_cast<QXlibScreen *>(platformScreen);
}
-Display * QTestLiteScreen::display() const
+QXlibDisplay * QXlibScreen::display() const
{
return mDisplay;
}
-int QTestLiteScreen::xScreenNumber() const
+int QXlibScreen::xScreenNumber() const
{
return mScreen;
}
-QTestLiteKeyboard * QTestLiteScreen::keyboard() const
+Visual * QXlibScreen::defaultVisual() const
+{
+ DefaultVisual(display()->nativeDisplay(), xScreenNumber());
+}
+
+QXlibKeyboard * QXlibScreen::keyboard() const
{
return mKeyboard;
}
-void QTestLiteScreen::handleSelectionRequest(XEvent *event)
+void QXlibScreen::handleSelectionRequest(XEvent *event)
{
QPlatformIntegration *integration = QApplicationPrivate::platformIntegration();
- QTestLiteClipboard *clipboard = static_cast<QTestLiteClipboard *>(integration->clipboard());
+ QXlibClipboard *clipboard = static_cast<QXlibClipboard *>(integration->clipboard());
clipboard->handleSelectionRequest(event);
}
diff --git a/src/plugins/platforms/testlite/qtestlitescreen.h b/src/plugins/platforms/xlib/qxlibscreen.h
index 860a67c..35c0141 100644
--- a/src/plugins/platforms/testlite/qtestlitescreen.h
+++ b/src/plugins/platforms/xlib/qxlibscreen.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -43,43 +43,44 @@
#define QTESTLITESCREEN_H
#include <QtGui/QPlatformScreen>
-#include "qtestliteintegration.h"
+#include "qxlibintegration.h"
QT_BEGIN_NAMESPACE
-class QTestLiteCursor;
-class QTestLiteKeyboard;
+class QXlibCursor;
+class QXlibKeyboard;
+class QXlibDisplay;
-class QTestLiteScreen : public QPlatformScreen
+class QXlibScreen : public QPlatformScreen
{
Q_OBJECT
public:
- QTestLiteScreen();
+ QXlibScreen();
- ~QTestLiteScreen();
-
- QString displayName() const { return mDisplayName; }
+ ~QXlibScreen();
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); }
+ Window rootWindow();
+ unsigned long blackPixel();
+ unsigned long whitePixel();
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);
+ static QXlibScreen *testLiteScreenForWidget(QWidget *widget);
- Display *display() const;
+ QXlibDisplay *display() const;
int xScreenNumber() const;
- QTestLiteKeyboard *keyboard() const;
+ Visual *defaultVisual() const;
+
+ QXlibKeyboard *keyboard() const;
public slots:
void eventDispatcher();
@@ -87,15 +88,14 @@ public slots:
private:
void handleSelectionRequest(XEvent *event);
- QString mDisplayName;
QRect mGeometry;
QSize mPhysicalSize;
int mDepth;
QImage::Format mFormat;
- QTestLiteCursor *mCursor;
- QTestLiteKeyboard *mKeyboard;
+ QXlibCursor *mCursor;
+ QXlibKeyboard *mKeyboard;
- Display * mDisplay;
+ QXlibDisplay * mDisplay;
int mScreen;
};
diff --git a/src/plugins/platforms/testlite/qtestlitestaticinfo.cpp b/src/plugins/platforms/xlib/qxlibstatic.cpp
index 2c6404d..6117781 100644
--- a/src/plugins/platforms/testlite/qtestlitestaticinfo.cpp
+++ b/src/plugins/platforms/xlib/qxlibstatic.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,8 +39,9 @@
**
****************************************************************************/
-#include "qtestlitestaticinfo.h"
-#include "qtestlitescreen.h"
+#include "qxlibstatic.h"
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
#include <qplatformdefs.h>
@@ -261,7 +262,7 @@ public:
, xfixes_eventbase(0)
, xfixes_errorbase(0)
{
- QTestLiteScreen *screen = qobject_cast<QTestLiteScreen *> (QApplicationPrivate::platformIntegration()->screens().at(0));
+ QXlibScreen *screen = qobject_cast<QXlibScreen *> (QApplicationPrivate::platformIntegration()->screens().at(0));
Q_ASSERT(screen);
initializeAllAtoms(screen);
@@ -287,7 +288,7 @@ public:
return supported;
}
- Atom atom(QTestLiteStatic::X11Atom atom)
+ Atom atom(QXlibStatic::X11Atom atom)
{
return m_allAtoms[atom];
}
@@ -351,8 +352,8 @@ public:
private:
- void initializeAllAtoms(QTestLiteScreen *screen) {
- const char *names[QTestLiteStatic::NAtoms];
+ void initializeAllAtoms(QXlibScreen *screen) {
+ const char *names[QXlibStatic::NAtoms];
const char *ptr = x11_atomnames;
int i = 0;
@@ -363,22 +364,22 @@ private:
++ptr;
}
- Q_ASSERT(i == QTestLiteStatic::NPredefinedAtoms);
+ Q_ASSERT(i == QXlibStatic::NPredefinedAtoms);
QByteArray settings_atom_name("_QT_SETTINGS_TIMESTAMP_");
- settings_atom_name += XDisplayName(qPrintable(screen->displayName()));
+ settings_atom_name += XDisplayName(qPrintable(screen->display()->displayName()));
names[i++] = settings_atom_name;
- Q_ASSERT(i == QTestLiteStatic::NAtoms);
+ Q_ASSERT(i == QXlibStatic::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);
+ for (i = 0; i < QXlibStatic::NAtoms; ++i)
+ m_allAtoms[i] = XInternAtom(screen->display()->nativeDisplay(), (char *)names[i], False);
#endif
}
- void initializeSupportedAtoms(QTestLiteScreen *screen)
+ void initializeSupportedAtoms(QXlibScreen *screen)
{
Atom type;
int format;
@@ -386,8 +387,8 @@ private:
unsigned long nitems, after;
unsigned char *data = 0;
- int e = XGetWindowProperty(screen->display(), screen->rootWindow(),
- this->atom(QTestLiteStatic::_NET_SUPPORTED), 0, 0,
+ int e = XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
+ this->atom(QXlibStatic::_NET_SUPPORTED), 0, 0,
False, XA_ATOM, &type, &format, &nitems, &after, &data);
if (data)
XFree(data);
@@ -397,8 +398,8 @@ private:
ts.open(QIODevice::WriteOnly);
while (after > 0) {
- XGetWindowProperty(screen->display(), screen->rootWindow(),
- this->atom(QTestLiteStatic::_NET_SUPPORTED), offset, 1024,
+ XGetWindowProperty(screen->display()->nativeDisplay(), screen->rootWindow(),
+ this->atom(QXlibStatic::_NET_SUPPORTED), offset, 1024,
False, XA_ATOM, &type, &format, &nitems, &after, &data);
if (type == XA_ATOM && format == 32) {
@@ -423,11 +424,11 @@ private:
}
}
- void resolveXFixes(QTestLiteScreen *screen)
+ void resolveXFixes(QXlibScreen *screen)
{
#ifndef QT_NO_XFIXES
// See if Xfixes is supported on the connected display
- if (XQueryExtension(screen->display(), "XFIXES", &xfixes_major,
+ if (XQueryExtension(screen->display()->nativeDisplay(), "XFIXES", &xfixes_major,
&xfixes_eventbase, &xfixes_errorbase)) {
ptrXFixesQueryExtension = XFIXES_LOAD_V1(XFixesQueryExtension);
ptrXFixesQueryVersion = XFIXES_LOAD_V1(XFixesQueryVersion);
@@ -435,7 +436,7 @@ private:
ptrXFixesSelectSelectionInput = XFIXES_LOAD_V2(XFixesSelectSelectionInput);
if(ptrXFixesQueryExtension && ptrXFixesQueryVersion
- && ptrXFixesQueryExtension(screen->display(), &xfixes_eventbase,
+ && ptrXFixesQueryExtension(screen->display()->nativeDisplay(), &xfixes_eventbase,
&xfixes_errorbase)) {
// Xfixes is supported.
// Note: the XFixes protocol version is negotiated using QueryVersion.
@@ -446,7 +447,7 @@ private:
// X server when it receives an XFixes request is undefined.
int major = 3;
int minor = 0;
- ptrXFixesQueryVersion(screen->display(), &major, &minor);
+ ptrXFixesQueryVersion(screen->display()->nativeDisplay(), &major, &minor);
use_xfixes = (major >= 1);
xfixes_major = major;
}
@@ -456,7 +457,7 @@ private:
}
Atom *m_supportedAtoms;
- Atom m_allAtoms[QTestLiteStatic::NAtoms];
+ Atom m_allAtoms[QXlibStatic::NAtoms];
#ifndef QT_NO_XFIXES
PtrXFixesQueryExtension ptrXFixesQueryExtension;
@@ -474,28 +475,28 @@ private:
Q_GLOBAL_STATIC(QTestLiteStaticInfoPrivate, qTestLiteStaticInfoPrivate);
-Atom QTestLiteStatic::atom(QTestLiteStatic::X11Atom atom)
+Atom QXlibStatic::atom(QXlibStatic::X11Atom atom)
{
return qTestLiteStaticInfoPrivate()->atom(atom);
}
-bool QTestLiteStatic::isSupportedByWM(Atom atom)
+bool QXlibStatic::isSupportedByWM(Atom atom)
{
return qTestLiteStaticInfoPrivate()->isSupportedByWM(atom);
}
-bool QTestLiteStatic::useXFixes()
+bool QXlibStatic::useXFixes()
{
return qTestLiteStaticInfoPrivate()->useXFixes();
}
-int QTestLiteStatic::xFixesEventBase()
+int QXlibStatic::xFixesEventBase()
{
return qTestLiteStaticInfoPrivate()->xFixesEventBase();
}
#ifndef QT_NO_XFIXES
-PtrXFixesSelectSelectionInput QTestLiteStatic::xFixesSelectSelectionInput()
+PtrXFixesSelectSelectionInput QXlibStatic::xFixesSelectSelectionInput()
{
qDebug() << qTestLiteStaticInfoPrivate()->useXFixes();
if (!qTestLiteStaticInfoPrivate()->useXFixes())
@@ -504,7 +505,7 @@ PtrXFixesSelectSelectionInput QTestLiteStatic::xFixesSelectSelectionInput()
return qTestLiteStaticInfoPrivate()->xFixesSelectSelectionInput();
}
-QImage QTestLiteStatic::qimageFromXImage(XImage *xi)
+QImage QXlibStatic::qimageFromXImage(XImage *xi)
{
return qTestLiteStaticInfoPrivate()->qimageFromXImage(xi);
}
diff --git a/src/plugins/platforms/testlite/qtestlitestaticinfo.h b/src/plugins/platforms/xlib/qxlibstatic.h
index 0876768..72cfaec 100644
--- a/src/plugins/platforms/testlite/qtestlitestaticinfo.h
+++ b/src/plugins/platforms/xlib/qxlibstatic.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -231,7 +231,7 @@ enum {
#endif
-class QTestLiteStatic
+class QXlibStatic
{
public:
enum X11Atom {
diff --git a/src/plugins/platforms/testlite/qtestlitewindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp
index d9c69e3..a7bc53c 100644
--- a/src/plugins/platforms/testlite/qtestlitewindow.cpp
+++ b/src/plugins/platforms/xlib/qxlibwindow.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,12 +39,13 @@
**
****************************************************************************/
-#include "qtestlitewindow.h"
+#include "qxlibwindow.h"
-#include "qtestliteintegration.h"
-#include "qtestlitescreen.h"
-#include "qtestlitekeyboard.h"
-#include "qtestlitestaticinfo.h"
+#include "qxlibintegration.h"
+#include "qxlibscreen.h"
+#include "qxlibkeyboard.h"
+#include "qxlibstatic.h"
+#include "qxlibdisplay.h"
#include <QtGui/QWindowSystemInterface>
#include <QSocketNotifier>
@@ -60,7 +61,7 @@
#else
#include "../eglconvenience/qeglconvenience.h"
#include "../eglconvenience/qeglplatformcontext.h"
-#include "qtestliteeglintegration.h"
+#include "../eglconvenience/qxlibeglintegration.h"
#endif //QT_OPENGL_ES_2
#endif //QT_NO_OPENGL
@@ -68,61 +69,61 @@
QT_BEGIN_NAMESPACE
-QTestLiteWindow::QTestLiteWindow(QWidget *window)
+QXlibWindow::QXlibWindow(QWidget *window)
: QPlatformWindow(window)
, mGLContext(0)
- , mScreen(QTestLiteScreen::testLiteScreenForWidget(window))
+ , mScreen(QXlibScreen::testLiteScreenForWidget(window))
{
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() ) {
- #if !defined(QT_NO_OPENGL)
+ if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
+ && QApplicationPrivate::platformIntegration()->hasOpenGL() ) {
+#if !defined(QT_NO_OPENGL)
#if !defined(QT_OPENGL_ES_2)
- XVisualInfo *visualInfo = QGLXContext::findVisualInfo(mScreen,window->platformWindowFormat());
+ XVisualInfo *visualInfo = QGLXContext::findVisualInfo(mScreen,window->platformWindowFormat());
#else
- QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());
+ QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat());
- EGLDisplay eglDisplay = eglGetDisplay(mScreen->display());
- EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat);
- VisualID id = QTestLiteEglIntegration::getCompatibleVisualId(mScreen->display(),eglConfig);
+ EGLDisplay eglDisplay = eglGetDisplay(mScreen->display()->nativeDisplay());
+ EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat);
+ VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(),eglConfig);
- XVisualInfo visualInfoTemplate;
- memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
- visualInfoTemplate.visualid = id;
+ XVisualInfo visualInfoTemplate;
+ memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
+ visualInfoTemplate.visualid = id;
- XVisualInfo *visualInfo;
- int matchingCount = 0;
- visualInfo = XGetVisualInfo(mScreen->display(), VisualIDMask, &visualInfoTemplate, &matchingCount);
+ XVisualInfo *visualInfo;
+ int matchingCount = 0;
+ visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), 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)
+ if (visualInfo) {
+ Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(),mScreen->rootWindow(),visualInfo->visual,AllocNone);
+
+ XSetWindowAttributes a;
+ a.colormap = cmap;
+ x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h,
+ 0, visualInfo->depth, InputOutput, visualInfo->visual,
+ CWColormap, &a);
} else {
- x_window = XCreateSimpleWindow(mScreen->display(), mScreen->rootWindow(),
- x, y, w, h, 0 /*border_width*/,
- mScreen->blackPixel(), mScreen->whitePixel());
+ qFatal("no window!");
}
+#endif //!defined(QT_NO_OPENGL)
+ } else {
+ x_window = XCreateSimpleWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),
+ x, y, w, h, 0 /*border_width*/,
+ mScreen->blackPixel(), mScreen->whitePixel());
+ }
#ifdef MYX11_DEBUG
- qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;
+ qDebug() << "QTestLiteWindow::QTestLiteWindow creating" << hex << x_window << window;
#endif
- XSetWindowBackgroundPixmap(mScreen->display(), x_window, XNone);
+ XSetWindowBackgroundPixmap(mScreen->display()->nativeDisplay(), x_window, XNone);
- XSelectInput(mScreen->display(), x_window,
+ XSelectInput(mScreen->display()->nativeDisplay(), x_window,
ExposureMask | KeyPressMask | KeyReleaseMask |
EnterWindowMask | LeaveWindowMask | FocusChangeMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
@@ -133,27 +134,27 @@ QTestLiteWindow::QTestLiteWindow(QWidget *window)
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
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW); // support del window protocol
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_TAKE_FOCUS); // support take focus window protocol
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::_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
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::_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);
+ protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_CONTEXT_HELP);
+ XSetWMProtocols(mScreen->display()->nativeDisplay(), x_window, protocols, n);
}
-QTestLiteWindow::~QTestLiteWindow()
+QXlibWindow::~QXlibWindow()
{
#ifdef MYX11_DEBUG
qDebug() << "~QTestLiteWindow" << hex << x_window;
#endif
delete mGLContext;
- XFreeGC(mScreen->display(), gc);
- XDestroyWindow(mScreen->display(), x_window);
+ XFreeGC(mScreen->display()->nativeDisplay(), gc);
+ XDestroyWindow(mScreen->display()->nativeDisplay(), x_window);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -172,7 +173,7 @@ static Qt::MouseButtons translateMouseButtons(int s)
-void QTestLiteWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
+void QXlibWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
{
static QPoint mousePoint;
@@ -215,68 +216,68 @@ void QTestLiteWindow::handleMouseEvent(QEvent::Type type, XButtonEvent *e)
mousePoint = QPoint(e->x_root, e->y_root);
}
-void QTestLiteWindow::handleCloseEvent()
+void QXlibWindow::handleCloseEvent()
{
QWindowSystemInterface::handleCloseEvent(widget());
}
-void QTestLiteWindow::handleEnterEvent()
+void QXlibWindow::handleEnterEvent()
{
QWindowSystemInterface::handleEnterEvent(widget());
}
-void QTestLiteWindow::handleLeaveEvent()
+void QXlibWindow::handleLeaveEvent()
{
QWindowSystemInterface::handleLeaveEvent(widget());
}
-void QTestLiteWindow::handleFocusInEvent()
+void QXlibWindow::handleFocusInEvent()
{
QWindowSystemInterface::handleWindowActivated(widget());
}
-void QTestLiteWindow::handleFocusOutEvent()
+void QXlibWindow::handleFocusOutEvent()
{
QWindowSystemInterface::handleWindowActivated(0);
}
-void QTestLiteWindow::setGeometry(const QRect &rect)
+void QXlibWindow::setGeometry(const QRect &rect)
{
- XMoveResizeWindow(mScreen->display(), x_window, rect.x(), rect.y(), rect.width(), rect.height());
+ XMoveResizeWindow(mScreen->display()->nativeDisplay(), x_window, rect.x(), rect.y(), rect.width(), rect.height());
QPlatformWindow::setGeometry(rect);
}
-Qt::WindowFlags QTestLiteWindow::windowFlags() const
+Qt::WindowFlags QXlibWindow::windowFlags() const
{
- return window_flags;
+ return mWindowFlags;
}
-WId QTestLiteWindow::winId() const
+WId QXlibWindow::winId() const
{
return x_window;
}
-void QTestLiteWindow::setParent(const QPlatformWindow *window)
+void QXlibWindow::setParent(const QPlatformWindow *window)
{
QPoint topLeft = geometry().topLeft();
- XReparentWindow(mScreen->display(),x_window,window->winId(),topLeft.x(),topLeft.y());
+ XReparentWindow(mScreen->display()->nativeDisplay(),x_window,window->winId(),topLeft.x(),topLeft.y());
}
-void QTestLiteWindow::raise()
+void QXlibWindow::raise()
{
- XRaiseWindow(mScreen->display(), x_window);
+ XRaiseWindow(mScreen->display()->nativeDisplay(), x_window);
}
-void QTestLiteWindow::lower()
+void QXlibWindow::lower()
{
- XLowerWindow(mScreen->display(), x_window);
+ XLowerWindow(mScreen->display()->nativeDisplay(), x_window);
}
-void QTestLiteWindow::setWindowTitle(const QString &title)
+void QXlibWindow::setWindowTitle(const QString &title)
{
QByteArray ba = title.toLatin1(); //We're not making a general solution here...
XTextProperty windowName;
@@ -285,21 +286,21 @@ void QTestLiteWindow::setWindowTitle(const QString &title)
windowName.format = 8;
windowName.nitems = ba.length();
- XSetWMName(mScreen->display(), x_window, &windowName);
+ XSetWMName(mScreen->display()->nativeDisplay(), x_window, &windowName);
}
-GC QTestLiteWindow::createGC()
+GC QXlibWindow::createGC()
{
GC gc;
- gc = XCreateGC(mScreen->display(), x_window, 0, 0);
+ gc = XCreateGC(mScreen->display()->nativeDisplay(), x_window, 0, 0);
if (gc < 0) {
qWarning("QTestLiteWindow::createGC() could not create GC");
}
return gc;
}
-void QTestLiteWindow::paintEvent()
+void QXlibWindow::paintEvent()
{
#ifdef MYX11_DEBUG
// qDebug() << "QTestLiteWindow::paintEvent" << shm_img.size() << painted;
@@ -309,12 +310,12 @@ void QTestLiteWindow::paintEvent()
surface->flush(widget(), widget()->geometry(), QPoint());
}
-void QTestLiteWindow::requestActivateWindow()
+void QXlibWindow::requestActivateWindow()
{
- XSetInputFocus(mScreen->display(), x_window, XRevertToParent, CurrentTime);
+ XSetInputFocus(mScreen->display()->nativeDisplay(), x_window, XRevertToParent, CurrentTime);
}
-void QTestLiteWindow::resizeEvent(XConfigureEvent *e)
+void QXlibWindow::resizeEvent(XConfigureEvent *e)
{
int xpos = geometry().x();
int ypos = geometry().y();
@@ -333,7 +334,7 @@ void QTestLiteWindow::resizeEvent(XConfigureEvent *e)
QWindowSystemInterface::handleGeometryChange(widget(), newRect);
}
-void QTestLiteWindow::mousePressEvent(XButtonEvent *e)
+void QXlibWindow::mousePressEvent(XButtonEvent *e)
{
static long prevTime = 0;
static Window prevWindow;
@@ -356,22 +357,22 @@ void QTestLiteWindow::mousePressEvent(XButtonEvent *e)
handleMouseEvent(type, e);
}
-QtMWMHints QTestLiteWindow::getMWMHints() const
+QXlibMWMHints QXlibWindow::getMWMHints() const
{
- QtMWMHints mwmhints;
+ QXlibMWMHints mwmhints;
Atom type;
int format;
ulong nitems, bytesLeft;
uchar *data = 0;
- Atom atomForMotifWmHints = QTestLiteStatic::atom(QTestLiteStatic::_MOTIF_WM_HINTS);
- if ((XGetWindowProperty(mScreen->display(), x_window, atomForMotifWmHints, 0, 5, false,
+ Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
+ if ((XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints, 0, 5, false,
atomForMotifWmHints, &type, &format, &nitems, &bytesLeft,
&data) == Success)
&& (type == atomForMotifWmHints
&& format == 32
&& nitems >= 5)) {
- mwmhints = *(reinterpret_cast<QtMWMHints *>(data));
+ mwmhints = *(reinterpret_cast<QXlibMWMHints *>(data));
} else {
mwmhints.flags = 0L;
mwmhints.functions = MWM_FUNC_ALL;
@@ -386,15 +387,15 @@ QtMWMHints QTestLiteWindow::getMWMHints() const
return mwmhints;
}
-void QTestLiteWindow::setMWMHints(const QtMWMHints &mwmhints)
+void QXlibWindow::setMWMHints(const QXlibMWMHints &mwmhints)
{
- Atom atomForMotifWmHints = QTestLiteStatic::atom(QTestLiteStatic::_MOTIF_WM_HINTS);
+ Atom atomForMotifWmHints = QXlibStatic::atom(QXlibStatic::_MOTIF_WM_HINTS);
if (mwmhints.flags != 0l) {
- XChangeProperty(mScreen->display(), x_window,
+ XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
atomForMotifWmHints, atomForMotifWmHints, 32,
PropModeReplace, (unsigned char *) &mwmhints, 5);
} else {
- XDeleteProperty(mScreen->display(), x_window, atomForMotifWmHints);
+ XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, atomForMotifWmHints);
}
}
@@ -411,10 +412,46 @@ static inline bool isTransient(const QWidget *w)
&& !w->testAttribute(Qt::WA_X11BypassTransientForHint));
}
-Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
+QVector<Atom> QXlibWindow::getNetWmState() const
+{
+ QVector<Atom> returnValue;
+
+ // Don't read anything, just get the size of the property data
+ Atom actualType;
+ int actualFormat;
+ ulong propertyLength;
+ ulong bytesLeft;
+ uchar *propertyData = 0;
+ if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0, 0,
+ False, XA_ATOM, &actualType, &actualFormat,
+ &propertyLength, &bytesLeft, &propertyData) == Success
+ && actualType == XA_ATOM && actualFormat == 32) {
+ returnValue.resize(bytesLeft / 4);
+ XFree((char*) propertyData);
+
+ // fetch all data
+ if (XGetWindowProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), 0,
+ returnValue.size(), False, XA_ATOM, &actualType, &actualFormat,
+ &propertyLength, &bytesLeft, &propertyData) != Success) {
+ returnValue.clear();
+ } else if (propertyLength != (ulong)returnValue.size()) {
+ returnValue.resize(propertyLength);
+ }
+
+ // put it into netWmState
+ if (!returnValue.isEmpty()) {
+ memcpy(returnValue.data(), propertyData, returnValue.size() * sizeof(Atom));
+ }
+ XFree((char*) propertyData);
+ }
+
+ return returnValue;
+}
+
+Qt::WindowFlags QXlibWindow::setWindowFlags(Qt::WindowFlags flags)
{
// Q_ASSERT(flags & Qt::Window);
- window_flags = flags;
+ mWindowFlags = flags;
#ifdef MYX11_DEBUG
qDebug() << "QTestLiteWindow::setWindowFlags" << hex << x_window << "flags" << flags;
@@ -442,7 +479,7 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
XSetWindowAttributes wsa;
- QtMWMHints mwmhints;
+ QXlibMWMHints mwmhints;
mwmhints.flags = 0L;
mwmhints.functions = 0L;
mwmhints.decorations = 0;
@@ -518,8 +555,50 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
mwmhints.decorations = 0;
}
+ if (widget()->windowModality() == Qt::WindowModal) {
+ mwmhints.input_mode = MWM_INPUT_PRIMARY_APPLICATION_MODAL;
+ } else if (widget()->windowModality() == Qt::ApplicationModal) {
+ mwmhints.input_mode = MWM_INPUT_FULL_APPLICATION_MODAL;
+ }
+
setMWMHints(mwmhints);
+ QVector<Atom> netWmState = getNetWmState();
+
+ if (flags & Qt::WindowStaysOnTopHint) {
+ if (flags & Qt::WindowStaysOnBottomHint)
+ qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_ABOVE));
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_STAYS_ON_TOP)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_STAYS_ON_TOP));
+ } else if (flags & Qt::WindowStaysOnBottomHint) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_BELOW));
+ }
+ if (widget()->isFullScreen()) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_FULLSCREEN));
+ }
+ if (widget()->isMaximized()) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_HORZ));
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MAXIMIZED_VERT));
+ }
+ if (widget()->windowModality() != Qt::NonModal) {
+ if (!netWmState.contains(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL)))
+ netWmState.append(QXlibStatic::atom(QXlibStatic::_NET_WM_STATE_MODAL));
+ }
+
+ if (!netWmState.isEmpty()) {
+ XChangeProperty(mScreen->display()->nativeDisplay(), x_window,
+ QXlibStatic::atom(QXlibStatic::_NET_WM_STATE), XA_ATOM, 32, PropModeReplace,
+ (unsigned char *) netWmState.data(), netWmState.size());
+ } else {
+ XDeleteProperty(mScreen->display()->nativeDisplay(), x_window, QXlibStatic::atom(QXlibStatic::_NET_WM_STATE));
+ }
+
//##### only if initializeWindow???
if (popup || tooltip) { // popup widget
@@ -531,7 +610,7 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
wsa.override_redirect = True;
wsa.save_under = True;
- XChangeWindowAttributes(mScreen->display(), x_window, CWOverrideRedirect | CWSaveUnder,
+ XChangeWindowAttributes(mScreen->display()->nativeDisplay(), x_window, CWOverrideRedirect | CWSaveUnder,
&wsa);
} else {
#ifdef MYX11_DEBUG
@@ -542,37 +621,49 @@ Qt::WindowFlags QTestLiteWindow::setWindowFlags(Qt::WindowFlags flags)
return flags;
}
-void QTestLiteWindow::setVisible(bool visible)
+void QXlibWindow::setVisible(bool visible)
{
#ifdef MYX11_DEBUG
qDebug() << "QTestLiteWindow::setVisible" << visible << hex << x_window;
#endif
+ if (isTransient(widget())) {
+ Window parentXWindow = x_window;
+ if (widget()->parentWidget()) {
+ QWidget *widgetParent = widget()->parentWidget()->window();
+ if (widgetParent && widgetParent->platformWindow()) {
+ QXlibWindow *parentWidnow = static_cast<QXlibWindow *>(widgetParent->platformWindow());
+ parentXWindow = parentWidnow->x_window;
+ }
+ }
+ XSetTransientForHint(mScreen->display()->nativeDisplay(),x_window,parentXWindow);
+ }
+
if (visible) {
//ensure that the window is viewed in correct position.
doSizeHints();
- XMapWindow(mScreen->display(), x_window);
+ XMapWindow(mScreen->display()->nativeDisplay(), x_window);
} else {
- XUnmapWindow(mScreen->display(), x_window);
+ XUnmapWindow(mScreen->display()->nativeDisplay(), x_window);
}
}
-void QTestLiteWindow::setCursor(const Cursor &cursor)
+void QXlibWindow::setCursor(const Cursor &cursor)
{
- XDefineCursor(mScreen->display(), x_window, cursor);
- XFlush(mScreen->display());
+ XDefineCursor(mScreen->display()->nativeDisplay(), x_window, cursor);
+ mScreen->display()->flush();
}
-QPlatformGLContext *QTestLiteWindow::glContext() const
+QPlatformGLContext *QXlibWindow::glContext() const
{
if (!QApplicationPrivate::platformIntegration()->hasOpenGL())
return 0;
if (!mGLContext) {
- QTestLiteWindow *that = const_cast<QTestLiteWindow *>(this);
+ QXlibWindow *that = const_cast<QXlibWindow *>(this);
#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());
+ EGLDisplay display = eglGetDisplay(mScreen->display()->nativeDisplay());
QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat());
@@ -590,17 +681,17 @@ QPlatformGLContext *QTestLiteWindow::glContext() const
return mGLContext;
}
-Window QTestLiteWindow::xWindow() const
+Window QXlibWindow::xWindow() const
{
return x_window;
}
-GC QTestLiteWindow::graphicsContext() const
+GC QXlibWindow::graphicsContext() const
{
return gc;
}
-void QTestLiteWindow::doSizeHints()
+void QXlibWindow::doSizeHints()
{
Q_ASSERT(widget()->testAttribute(Qt::WA_WState_Created));
XSizeHints s;
@@ -616,10 +707,10 @@ void QTestLiteWindow::doSizeHints()
s.flags |= PSize;
s.flags |= PWinGravity;
s.win_gravity = QApplication::isRightToLeft() ? NorthEastGravity : NorthWestGravity;
- XSetWMNormalHints(mScreen->display(), x_window, &s);
+ XSetWMNormalHints(mScreen->display()->nativeDisplay(), x_window, &s);
}
-QPlatformWindowFormat QTestLiteWindow::correctColorBuffers(const QPlatformWindowFormat &platformWindowFormat) const
+QPlatformWindowFormat QXlibWindow::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 :)
diff --git a/src/plugins/platforms/testlite/qtestlitewindow.h b/src/plugins/platforms/xlib/qxlibwindow.h
index e45c3fd..08694a5 100644
--- a/src/plugins/platforms/testlite/qtestlitewindow.h
+++ b/src/plugins/platforms/xlib/qxlibwindow.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -42,7 +42,7 @@
#ifndef QTESTLITEWINDOW_H
#define QTESTLITEWINDOW_H
-#include "qtestliteintegration.h"
+#include "qxlibintegration.h"
#include <QPlatformWindow>
#include <QEvent>
@@ -50,7 +50,7 @@
#include <QObject>
#include <QImage>
-struct QtMWMHints {
+struct QXlibMWMHints {
ulong flags, functions, decorations;
long input_mode;
ulong status;
@@ -83,11 +83,11 @@ enum {
MWM_INPUT_FULL_APPLICATION_MODAL = 3L
};
-class QTestLiteWindow : public QPlatformWindow
+class QXlibWindow : public QPlatformWindow
{
public:
- QTestLiteWindow(QWidget *window);
- ~QTestLiteWindow();
+ QXlibWindow(QWidget *window);
+ ~QXlibWindow();
void mousePressEvent(XButtonEvent*);
@@ -123,8 +123,9 @@ public:
GC graphicsContext() const;
protected:
- void setMWMHints(const QtMWMHints &mwmhints);
- QtMWMHints getMWMHints() const;
+ QVector<Atom> getNetWmState() const;
+ void setMWMHints(const QXlibMWMHints &mwmhints);
+ QXlibMWMHints getMWMHints() const;
void doSizeHints();
@@ -137,8 +138,8 @@ private:
GC createGC();
QPlatformGLContext *mGLContext;
- QTestLiteScreen *mScreen;
- Qt::WindowFlags window_flags;
+ QXlibScreen *mScreen;
+ Qt::WindowFlags mWindowFlags;
};
#endif
diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp
index ced964a..513f10d 100644
--- a/src/plugins/platforms/testlite/qtestlitewindowsurface.cpp
+++ b/src/plugins/platforms/xlib/qxlibwindowsurface.cpp
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,14 +39,15 @@
**
****************************************************************************/
-#include "qtestlitewindowsurface.h"
-#include "qtestliteintegration.h"
+#include "qxlibwindowsurface.h"
+#include "qxlibintegration.h"
#include <QtCore/qdebug.h>
#include <QWindowSystemInterface>
-#include "qtestlitewindow.h"
-#include "qtestlitescreen.h"
+#include "qxlibwindow.h"
+#include "qxlibscreen.h"
+#include "qxlibdisplay.h"
# include <sys/ipc.h>
# include <sys/shm.h>
@@ -55,9 +56,9 @@
QT_BEGIN_NAMESPACE
-struct MyShmImageInfo {
- MyShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {}
- ~MyShmImageInfo() { destroy(); }
+struct QXlibShmImageInfo {
+ QXlibShmImageInfo(Display *xdisplay) : image(0), display(xdisplay) {}
+ ~QXlibShmImageInfo() { destroy(); }
void destroy();
@@ -68,7 +69,7 @@ struct MyShmImageInfo {
#ifndef DONT_USE_MIT_SHM
-void MyShmImageInfo::destroy()
+void QXlibShmImageInfo::destroy()
{
XShmDetach (display, &shminfo);
XDestroyImage (image);
@@ -77,23 +78,22 @@ void MyShmImageInfo::destroy()
}
#endif
-void QTestLiteWindowSurface::resizeShmImage(int width, int height)
+void QXlibWindowSurface::resizeShmImage(int width, int height)
{
#ifdef DONT_USE_MIT_SHM
shm_img = QImage(width, height, QImage::Format_RGB32);
#else
- QTestLiteScreen *screen = QTestLiteScreen::testLiteScreenForWidget(window());
+ QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(window());
if (image_info)
image_info->destroy();
else
- image_info = new MyShmImageInfo(screen->display());
+ image_info = new QXlibShmImageInfo(screen->display()->nativeDisplay());
- Visual *visual = DefaultVisual(screen->display(), screen->xScreenNumber());
+ Visual *visual = screen->defaultVisual();
-
- XImage *image = XShmCreateImage (screen->display(), visual, 24, ZPixmap, 0,
+ XImage *image = XShmCreateImage (screen->display()->nativeDisplay(), 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(screen->display(), &image_info->shminfo);
+ Status shm_attach_status = XShmAttach(screen->display()->nativeDisplay(), &image_info->shminfo);
Q_ASSERT(shm_attach_status == True);
@@ -115,37 +115,37 @@ void QTestLiteWindowSurface::resizeShmImage(int width, int height)
}
-void QTestLiteWindowSurface::resizeBuffer(QSize s)
+void QXlibWindowSurface::resizeBuffer(QSize s)
{
if (shm_img.size() != s)
resizeShmImage(s.width(), s.height());
}
-QSize QTestLiteWindowSurface::bufferSize() const
+QSize QXlibWindowSurface::bufferSize() const
{
return shm_img.size();
}
-QTestLiteWindowSurface::QTestLiteWindowSurface (QWidget *window)
+QXlibWindowSurface::QXlibWindowSurface (QWidget *window)
: QWindowSurface(window),
painted(false), image_info(0)
{
- xw = static_cast<QTestLiteWindow*>(window->platformWindow());
+ xw = static_cast<QXlibWindow*>(window->platformWindow());
// qDebug() << "QTestLiteWindowSurface::QTestLiteWindowSurface:" << xw->window;
}
-QTestLiteWindowSurface::~QTestLiteWindowSurface()
+QXlibWindowSurface::~QXlibWindowSurface()
{
delete image_info;
}
-QPaintDevice *QTestLiteWindowSurface::paintDevice()
+QPaintDevice *QXlibWindowSurface::paintDevice()
{
return &shm_img;
}
-void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QXlibWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(widget);
Q_UNUSED(region);
@@ -154,7 +154,7 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion &region, const
if (!painted)
return;
- QTestLiteScreen *screen = QTestLiteScreen::testLiteScreenForWidget(widget);
+ QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(widget);
GC gc = xw->graphicsContext();
Window window = xw->xWindow();
#ifdef DONT_USE_MIT_SHM
@@ -185,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 (screen->display(), window, gc, image_info->image, 0, 0,
+ XShmPutImage (screen->display()->nativeDisplay(), window, gc, image_info->image, 0, 0,
x, y, image_info->image->width, image_info->image->height,
/*send_event*/ False);
- XSync(screen->display(), False);
+ screen->display()->sync();
}
#endif
}
@@ -197,7 +197,7 @@ void QTestLiteWindowSurface::flush(QWidget *widget, const QRegion &region, const
// from qwindowsurface.cpp
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
-bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy)
+bool QXlibWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
if (shm_img.isNull())
return false;
@@ -210,13 +210,13 @@ bool QTestLiteWindowSurface::scroll(const QRegion &area, int dx, int dy)
}
-void QTestLiteWindowSurface::beginPaint(const QRegion &region)
+void QXlibWindowSurface::beginPaint(const QRegion &region)
{
Q_UNUSED(region);
resizeBuffer(size());
}
-void QTestLiteWindowSurface::endPaint(const QRegion &region)
+void QXlibWindowSurface::endPaint(const QRegion &region)
{
Q_UNUSED(region);
painted = true; //there is content in the buffer
diff --git a/src/plugins/platforms/testlite/qtestlitewindowsurface.h b/src/plugins/platforms/xlib/qxlibwindowsurface.h
index ca900e5..d46b7b4 100644
--- a/src/plugins/platforms/testlite/qtestlitewindowsurface.h
+++ b/src/plugins/platforms/xlib/qxlibwindowsurface.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -47,21 +47,19 @@
QT_BEGIN_NAMESPACE
-class QTestLiteWindow;
-class QTestLiteIntegration;
-class QTestLiteScreen;
-class MyShmImageInfo;
+class QXlibWindow;
+class QXlibIntegration;
+class QXlibScreen;
+class QXlibShmImageInfo;
-class QTestLiteWindowSurface : public QWindowSurface
+class QXlibWindowSurface : public QWindowSurface
{
public:
- QTestLiteWindowSurface (QWidget *window);
- ~QTestLiteWindowSurface();
+ QXlibWindowSurface (QWidget *window);
+ ~QXlibWindowSurface();
QPaintDevice *paintDevice();
-// void flush();
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-// void resize(const QSize &size);
bool scroll(const QRegion &area, int dx, int dy);
void beginPaint(const QRegion &region);
@@ -76,9 +74,9 @@ private:
void resizeShmImage(int width, int height);
QImage shm_img;
- MyShmImageInfo *image_info;
+ QXlibShmImageInfo *image_info;
- QTestLiteWindow *xw;
+ QXlibWindow *xw;
};
diff --git a/src/plugins/platforms/testlite/testlite.pro b/src/plugins/platforms/xlib/xlib.pro
index 7fb3304..159fdbe 100644
--- a/src/plugins/platforms/testlite/testlite.pro
+++ b/src/plugins/platforms/xlib/xlib.pro
@@ -1,30 +1,32 @@
-TARGET = qtestlite
+TARGET = qxlib
include(../../qpluginbase.pri)
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
SOURCES = \
main.cpp \
- qtestliteintegration.cpp \
- qtestlitewindowsurface.cpp \
- qtestlitewindow.cpp \
- qtestlitecursor.cpp \
- qtestlitescreen.cpp \
- qtestlitekeyboard.cpp \
- qtestliteclipboard.cpp \
- qtestlitemime.cpp \
- qtestlitestaticinfo.cpp
+ qxlibintegration.cpp \
+ qxlibwindowsurface.cpp \
+ qxlibwindow.cpp \
+ qxlibcursor.cpp \
+ qxlibscreen.cpp \
+ qxlibkeyboard.cpp \
+ qxlibclipboard.cpp \
+ qxlibmime.cpp \
+ qxlibstatic.cpp \
+ qxlibdisplay.cpp
HEADERS = \
- qtestliteintegration.h \
- qtestlitewindowsurface.h \
- qtestlitewindow.h \
- qtestlitecursor.h \
- qtestlitescreen.h \
- qtestlitekeyboard.h \
- qtestliteclipboard.h \
- qtestlitemime.h \
- qtestlitestaticinfo.h
+ qxlibintegration.h \
+ qxlibwindowsurface.h \
+ qxlibwindow.h \
+ qxlibcursor.h \
+ qxlibscreen.h \
+ qxlibkeyboard.h \
+ qxlibclipboard.h \
+ qxlibmime.h \
+ qxlibstatic.h \
+ qxlibdisplay.h
LIBS += -lX11 -lXext
@@ -43,12 +45,12 @@ contains(QT_CONFIG, opengl) {
HEADERS += \
../eglconvenience/qeglplatformcontext.h \
../eglconvenience/qeglconvenience.h \
- qtestliteeglintegration.h
+ ../eglconvenience/qxlibeglintegration.h
SOURCES += \
../eglconvenience/qeglplatformcontext.cpp \
../eglconvenience/qeglconvenience.cpp \
- qtestliteeglintegration.cpp
+ ../eglconvenience/qxlibeglintegration.cpp
LIBS += -lEGL
}
}